-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rpc): add optional paymentIdentifier to RpcSubmitPaymentArgsSchema for V2 parity #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||
| import { describe, expect, it } from "vitest"; | ||||||||||||||
| import { | ||||||||||||||
| RpcCheckPaymentResultSchema, | ||||||||||||||
| RpcSubmitPaymentRequestSchema, | ||||||||||||||
| RpcSubmitPaymentResultSchema, | ||||||||||||||
| } from "../src/index.js"; | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -140,4 +141,60 @@ describe("rpc schemas", () => { | |||||||||||||
| "https://example.com/payment/pay_01JMVP9QE8XA3BDGM5RN7KWTZ4", | ||||||||||||||
| ); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| describe("paymentIdentifier — x402 V2 idempotency parity", () => { | ||||||||||||||
| const STUB_TX_HEX = "0x" + "ab".repeat(32); | ||||||||||||||
|
|
||||||||||||||
| it("accepts a submit request with an optional paymentIdentifier", () => { | ||||||||||||||
| const req = RpcSubmitPaymentRequestSchema.parse({ | ||||||||||||||
| txHex: STUB_TX_HEX, | ||||||||||||||
| paymentIdentifier: "pay_01JMVP9QE8XA3BDGM5", | ||||||||||||||
| }); | ||||||||||||||
| expect(req.paymentIdentifier).toBe("pay_01JMVP9QE8XA3BDGM5"); | ||||||||||||||
|
Comment on lines
+151
to
+153
|
||||||||||||||
| paymentIdentifier: "pay_01JMVP9QE8XA3BDGM5", | |
| }); | |
| expect(req.paymentIdentifier).toBe("pay_01JMVP9QE8XA3BDGM5"); | |
| paymentIdentifier: "client_01JMVP9QE8XA3BDGM5", | |
| }); | |
| expect(req.paymentIdentifier).toBe("client_01JMVP9QE8XA3BDGM5"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching HttpPaymentIdentifierExtensionSchema.info.id from PaymentIdSchema to PaymentIdentifierSchema is a stricter validation change for some previously-accepted inputs (e.g., "pay_123" would have parsed before but now fails due to the 16+ length requirement). That makes the PR not purely additive as described; either (a) update the backward-compatibility notes/versioning to reflect the tightened HTTP validation, or (b) consider accepting both schemas here (e.g., union) if you need to preserve old callers while migrating.