Skip to content
Closed
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
16 changes: 16 additions & 0 deletions src/contracts/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ export const GetCheckoutInputSchema = z.object({
});
export type GetCheckoutInput = z.infer<typeof GetCheckoutInputSchema>;

export const RedeemL402InputSchema = z.object({
paymentHash: z.string().describe("The payment hash from the L402 credential"),
});
export type RedeemL402Input = z.infer<typeof RedeemL402InputSchema>;

export const RedeemL402OutputSchema = z.object({
redeemed: z.boolean(),
reason: z.string().optional(),
});
export type RedeemL402Output = z.infer<typeof RedeemL402OutputSchema>;

export type CreateCheckout = z.infer<typeof CreateCheckoutInputSchema>;
export type ConfirmCheckout = z.infer<typeof ConfirmCheckoutInputSchema>;
export type RegisterInvoice = z.infer<typeof RegisterInvoiceInputSchema>;
Expand Down Expand Up @@ -190,12 +201,17 @@ export const getCheckoutDetailContract = oc
.input(GetCheckoutInputSchema)
.output(CheckoutDetailSchema);

export const redeemL402Contract = oc
.input(RedeemL402InputSchema)
.output(RedeemL402OutputSchema);

export const checkout = {
get: getCheckoutContract,
create: createCheckoutContract,
confirm: confirmCheckoutContract,
registerInvoice: registerInvoiceContract,
paymentReceived: paymentReceivedContract,
redeemL402: redeemL402Contract,
list: listCheckoutsContract,
listPaginated: listCheckoutsPaginatedContract,
// Original names preserved
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type {
CreateCheckout,
PaymentReceived,
RegisterInvoice,
RedeemL402Input,
RedeemL402Output,
} from "./contracts/checkout";
export {
CheckoutStatusSchema,
Expand Down Expand Up @@ -182,6 +184,7 @@ export const sdkContract = {
confirm: checkout.confirm,
registerInvoice: checkout.registerInvoice,
paymentReceived: checkout.paymentReceived,
redeemL402: checkout.redeemL402,
},
onboarding,
products: {
Expand Down