Skip to content
Merged
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/real-bugs-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Add fundWalletLink prop to x402 responses
2 changes: 2 additions & 0 deletions packages/thirdweb/src/x402/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export type RequestedPaymentRequirements = z.infer<
const FacilitatorSettleResponseSchema = SettleResponseSchema.extend({
network: FacilitatorNetworkSchema,
errorMessage: z.string().optional(),
fundWalletLink: z.string().optional(),
});
export type FacilitatorSettleResponse = z.infer<
typeof FacilitatorSettleResponseSchema
>;

const FacilitatorVerifyResponseSchema = VerifyResponseSchema.extend({
errorMessage: z.string().optional(),
fundWalletLink: z.string().optional(),
});

export type FacilitatorVerifyResponse = z.infer<
Expand Down
1 change: 1 addition & 0 deletions packages/thirdweb/src/x402/settle-payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export async function settlePayment(
error,
errorMessage:
errorMessages?.settlementFailed || settlement.errorMessage,
fundWalletLink: settlement.fundWalletLink,
accepts: paymentRequirements,
},
};
Expand Down
2 changes: 2 additions & 0 deletions packages/thirdweb/src/x402/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export type PaymentRequiredResult = {
accepts: RequestedPaymentRequirements[];
/** Optional payer address if verification partially succeeded */
payer?: string;
/** Optional link to a wallet to fund the wallet of the payer */
fundWalletLink?: string;
};
/** Response headers for the error response */
responseHeaders: Record<string, string>;
Expand Down
1 change: 1 addition & 0 deletions packages/thirdweb/src/x402/verify-payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export async function verifyPayment(
error: error,
errorMessage:
errorMessages?.verificationFailed || verification.errorMessage,
fundWalletLink: verification.fundWalletLink,
accepts: paymentRequirements,
},
};
Expand Down
Loading