UNPKG

@paykit-sdk/core

Version:

The Payment Toolkit for Typescript

99 lines (96 loc) 3.05 kB
import { CreateCheckoutSchema, Checkout, UpdateCheckoutSchema } from '../resources/checkout.mjs'; import { CreateCustomerParams, Customer, UpdateCustomerParams } from '../resources/customer.mjs'; import { CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema } from '../resources/subscription.mjs'; import { CreatePaymentSchema, Payment, UpdatePaymentSchema, CapturePaymentSchema } from '../resources/payment.mjs'; import { CreateRefundSchema, Refund } from '../resources/refund.mjs'; import 'zod'; import '../resources/billing.mjs'; import '../resources/metadata.mjs'; import '../types.mjs'; interface PayKitEndpoints { '/customer/create': { args: [params: CreateCustomerParams]; return: Customer; }; '/customer/retrieve': { args: [id: string]; return: Customer | null; }; '/customer/update': { args: [id: string, params: UpdateCustomerParams]; return: Customer; }; '/customer/delete': { args: [id: string]; return: null; }; '/checkout/create': { args: [params: CreateCheckoutSchema]; return: Checkout; }; '/checkout/retrieve': { args: [id: string]; return: Checkout | null; }; '/checkout/update': { args: [id: string, params: UpdateCheckoutSchema]; return: Checkout; }; '/checkout/delete': { args: [id: string]; return: null; }; '/subscription/create': { args: [params: CreateSubscriptionSchema]; return: Subscription; }; '/subscription/retrieve': { args: [id: string]; return: Subscription | null; }; '/subscription/update': { args: [id: string, params: UpdateSubscriptionSchema]; return: Subscription; }; '/subscription/cancel': { args: [id: string]; return: Subscription; }; '/subscription/delete': { args: [id: string]; return: null; }; '/payment/create': { args: [params: CreatePaymentSchema]; return: Payment; }; '/payment/retrieve': { args: [id: string]; return: Payment | null; }; '/payment/update': { args: [id: string, params: UpdatePaymentSchema]; return: Payment; }; '/payment/capture': { args: [id: string, params: CapturePaymentSchema]; return: Payment; }; '/payment/cancel': { args: [id: string]; return: Payment; }; '/payment/delete': { args: [id: string]; return: null; }; '/refund/create': { args: [params: CreateRefundSchema]; return: Refund; }; } type EndpointPath = keyof PayKitEndpoints; type EndpointArgs<T extends EndpointPath> = PayKitEndpoints[T]['args']; type EndpointReturn<T extends EndpointPath> = PayKitEndpoints[T]['return']; type EndpointHandler<T extends EndpointPath> = (...args: EndpointArgs<T>) => Promise<EndpointReturn<T>>; export type { EndpointArgs, EndpointHandler, EndpointPath, EndpointReturn, PayKitEndpoints };