UNPKG

@paykit-sdk/stripe

Version:
58 lines (55 loc) 3.26 kB
import { PaykitProviderOptions, AbstractPayKitProvider, PayKitProvider, ProviderMetadataRegistry, CreateCheckoutSchema, Checkout, UpdateCheckoutSchema, CreateCustomerParams, Customer, UpdateCustomerParams, CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema, CreatePaymentSchema, Payment, UpdatePaymentSchema, CapturePaymentSchema, CreateRefundSchema, Refund, WebhookHandlerConfig, WebhookEventPayload } from '@paykit-sdk/core'; import Stripe from 'stripe'; interface StripeMetadata extends ProviderMetadataRegistry { customer: Stripe.CustomerCreateParams; checkout: Stripe.Checkout.SessionCreateParams; payment: Stripe.PaymentIntentCreateParams; subscription: Stripe.SubscriptionCreateParams; refund: Stripe.RefundCreateParams; } interface StripeOptions extends PaykitProviderOptions, Stripe.StripeConfig { /** Stripe secret key (sk_test_... or sk_live_...) */ apiKey: string; } type StripeRawEvents = { [K in Stripe.Event.Type as `stripe.${K}`]: Extract<Stripe.Event, { type: K; }>; }; declare class StripeProvider extends AbstractPayKitProvider implements PayKitProvider<StripeMetadata, Stripe, StripeRawEvents> { private stripe; private opts; readonly isSandbox: boolean; constructor(opts: StripeOptions); readonly providerName = "stripe"; get _native(): Stripe; private _resolvePaymentIntentId; createCheckout: (params: CreateCheckoutSchema<StripeMetadata["checkout"]>) => Promise<Checkout>; retrieveCheckout: (id: string) => Promise<Checkout>; updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>; deleteCheckout: (id: string) => Promise<null>; /** * Customer management */ createCustomer: (params: CreateCustomerParams<StripeMetadata["customer"]>) => Promise<Customer>; updateCustomer: (id: string, params: UpdateCustomerParams<StripeMetadata["customer"]>) => Promise<Customer>; deleteCustomer: (id: string) => Promise<null>; retrieveCustomer: (id: string) => Promise<Customer | null>; createSubscription: (params: CreateSubscriptionSchema<StripeMetadata["subscription"]>) => Promise<Subscription>; cancelSubscription: (id: string) => Promise<Subscription>; updateSubscription: (id: string, params: UpdateSubscriptionSchema<StripeMetadata["subscription"]>) => Promise<Subscription>; retrieveSubscription: (id: string) => Promise<Subscription>; deleteSubscription: (id: string) => Promise<null>; createPayment: (params: CreatePaymentSchema<StripeMetadata["payment"]>) => Promise<Payment>; updatePayment: (id: string, params: UpdatePaymentSchema<StripeMetadata["payment"]>) => Promise<Payment>; retrievePayment: (id: string) => Promise<Payment | null>; deletePayment: (id: string) => Promise<null>; capturePayment: (id: string, params: CapturePaymentSchema) => Promise<Payment>; cancelPayment: (id: string) => Promise<Payment>; /** * Refund management */ createRefund: (params: CreateRefundSchema<StripeMetadata["refund"]>) => Promise<Refund>; handleWebhook: (params: WebhookHandlerConfig, webhookSecret: string | null) => Promise<Array<WebhookEventPayload<StripeRawEvents>>>; } export { type StripeOptions, StripeProvider };