Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ack-pay-service-callback-did-uri.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@agentcommercekit/ack-pay": patch
---

Allow `paymentRequest.serviceCallback` to accept DID URIs in addition to URLs, matching the documented field contract and the existing `paymentService` / `receiptService` schemas.
19 changes: 19 additions & 0 deletions packages/ack-pay/src/schemas/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,23 @@ describe("paymentRequestSchema", () => {
expect(zod.success && zod.data.expiresAt).toBe(expected)
}
})

it("accepts URL and DID URI serviceCallback values", () => {
for (const serviceCallback of [
"https://service.example.com/webhook/payment-complete",
"did:web:merchant.example",
]) {
const input = { ...paymentRequest, serviceCallback }

expect(v.safeParse(valibotPaymentRequestSchema, input).success).toBe(true)
expect(zodPaymentRequestSchema.safeParse(input).success).toBe(true)
}
})

it("rejects invalid serviceCallback values", () => {
const input = { ...paymentRequest, serviceCallback: "not-a-url-or-did" }

expect(v.safeParse(valibotPaymentRequestSchema, input).success).toBe(false)
expect(zodPaymentRequestSchema.safeParse(input).success).toBe(false)
})
})
2 changes: 1 addition & 1 deletion packages/ack-pay/src/schemas/valibot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const paymentOptionSchema = v.object({
export const paymentRequestSchema = v.object({
id: v.string(),
description: v.optional(v.string()),
serviceCallback: v.optional(v.pipe(v.string(), v.url())),
serviceCallback: v.optional(urlOrDidUri),
expiresAt: v.optional(timestampSchema),
paymentOptions: v.pipe(
v.tupleWithRest([paymentOptionSchema], paymentOptionSchema),
Expand Down
2 changes: 1 addition & 1 deletion packages/ack-pay/src/schemas/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const paymentOptionSchema = z.object({
export const paymentRequestSchema = z.object({
id: z.string(),
description: z.string().optional(),
serviceCallback: z.url().optional(),
serviceCallback: urlOrDidUri.optional(),
expiresAt: timestampSchema.optional(),
paymentOptions: z.array(paymentOptionSchema).nonempty(),
})
Expand Down