@@ -2,6 +2,11 @@ import { oc } from "@orpc/contract";
22import { z } from "zod" ;
33import { CheckoutSchema } from "../schemas/checkout" ;
44import { CurrencySchema } from "../schemas/currency" ;
5+ import { CustomerSchema } from "../schemas/customer" ;
6+ import {
7+ PaginationInputSchema ,
8+ PaginationOutputSchema ,
9+ } from "../schemas/pagination" ;
510
611/**
712 * Helper to treat empty strings as undefined (not provided).
@@ -142,10 +147,74 @@ export const paymentReceivedContract = oc
142147 . input ( PaymentReceivedInputSchema )
143148 . output ( z . object ( { ok : z . boolean ( ) } ) ) ;
144149
150+ // List checkouts schemas
151+ const CheckoutStatusSchema = z . enum ( [
152+ "UNCONFIRMED" ,
153+ "CONFIRMED" ,
154+ "PENDING_PAYMENT" ,
155+ "PAYMENT_RECEIVED" ,
156+ "EXPIRED" ,
157+ ] ) ;
158+
159+ const ListCheckoutsInputSchema = PaginationInputSchema . extend ( {
160+ status : CheckoutStatusSchema . optional ( ) ,
161+ } ) ;
162+
163+ const ListCheckoutsOutputSchema = PaginationOutputSchema . extend ( {
164+ checkouts : z . array ( CheckoutSchema ) ,
165+ } ) ;
166+
167+ export const listCheckoutsContract = oc
168+ . input ( ListCheckoutsInputSchema )
169+ . output ( ListCheckoutsOutputSchema ) ;
170+
171+ // MCP-specific embedded customer schema
172+ const CheckoutCustomerSchema = CustomerSchema . nullable ( ) ;
173+
174+ // MCP-specific summary schema for list (simpler than full CheckoutSchema)
175+ const CheckoutListItemSchema = z . object ( {
176+ id : z . string ( ) ,
177+ status : CheckoutStatusSchema ,
178+ type : z . enum ( [ "PRODUCTS" , "AMOUNT" , "TOP_UP" ] ) ,
179+ currency : CurrencySchema ,
180+ totalAmount : z . number ( ) . nullable ( ) ,
181+ customerId : z . string ( ) . nullable ( ) ,
182+ customer : CheckoutCustomerSchema ,
183+ productId : z . string ( ) . nullable ( ) ,
184+ organizationId : z . string ( ) ,
185+ expiresAt : z . date ( ) ,
186+ createdAt : z . date ( ) ,
187+ modifiedAt : z . date ( ) . nullable ( ) ,
188+ } ) ;
189+
190+ // MCP-specific detailed schema for get (includes additional fields)
191+ const CheckoutDetailSchema = CheckoutListItemSchema . extend ( {
192+ userMetadata : z . record ( z . unknown ( ) ) . nullable ( ) ,
193+ successUrl : z . string ( ) . nullable ( ) ,
194+ discountAmount : z . number ( ) . nullable ( ) ,
195+ netAmount : z . number ( ) . nullable ( ) ,
196+ taxAmount : z . number ( ) . nullable ( ) ,
197+ } ) ;
198+
199+ const ListCheckoutsSummaryOutputSchema = PaginationOutputSchema . extend ( {
200+ checkouts : z . array ( CheckoutListItemSchema ) ,
201+ } ) ;
202+
203+ export const listCheckoutsSummaryContract = oc
204+ . input ( ListCheckoutsInputSchema )
205+ . output ( ListCheckoutsSummaryOutputSchema ) ;
206+
207+ export const getCheckoutSummaryContract = oc
208+ . input ( GetCheckoutInputSchema )
209+ . output ( CheckoutDetailSchema ) ;
210+
145211export const checkout = {
146212 get : getCheckoutContract ,
147213 create : createCheckoutContract ,
148214 confirm : confirmCheckoutContract ,
149215 registerInvoice : registerInvoiceContract ,
150216 paymentReceived : paymentReceivedContract ,
217+ list : listCheckoutsContract ,
218+ listSummary : listCheckoutsSummaryContract ,
219+ getSummary : getCheckoutSummaryContract ,
151220} ;
0 commit comments