@paykit-sdk/core
Version:
The Payment Toolkit for Typescript
59 lines (56 loc) • 2.48 kB
text/typescript
import './checkout.mjs';
import { Customer } from './customer.mjs';
import { Subscription } from './subscription.mjs';
import { Invoice } from './invoice.mjs';
import { Payment } from './payment.mjs';
import { Refund } from './refund.mjs';
import './metadata.mjs';
import './billing.mjs';
import 'zod';
import '../types.mjs';
interface WebhookEvent<T = any> {
/**
* The ID of the webhook event.
*/
id: string;
/**
* The type of the webhook event (Standard or Raw)
*/
type: string;
/**
* The created timestamp of the webhook event.
*/
created: number;
/**
* The data of the webhook event.
*/
data: T;
/**
* Whether the webhook event is raw from the provider.
*/
is_raw?: boolean;
}
type CustomerCreated = WebhookEvent<Customer>;
type CustomerUpdated = WebhookEvent<Customer | null>;
type CustomerDeleted = WebhookEvent<Customer | null>;
type SubscriptionCreated = WebhookEvent<Subscription>;
type SubscriptionUpdated = WebhookEvent<Subscription | null>;
type SubscriptionCanceled = WebhookEvent<Subscription | null>;
type PaymentCreated = WebhookEvent<Payment>;
type PaymentUpdated = WebhookEvent<Payment | null>;
type PaymentSucceeded = WebhookEvent<Payment>;
type PaymentFailed = WebhookEvent<Payment | null>;
type RefundCreated = WebhookEvent<Refund>;
type InvoiceGenerated = WebhookEvent<Invoice>;
/**
* Raw Provider-Specific Event Escape Hatch
*/
interface RawWebhookEvent<TProvider extends string = string, TData = any> extends WebhookEvent<TData> {
type: `${TProvider}.${string}`;
is_raw: true;
}
type WebhookEventPayload<TRawMap extends Record<string, any> = Record<string, any>> = CustomerCreated | CustomerUpdated | CustomerDeleted | SubscriptionCreated | SubscriptionUpdated | SubscriptionCanceled | PaymentCreated | PaymentUpdated | PaymentSucceeded | PaymentFailed | RefundCreated | InvoiceGenerated | {
[K in keyof TRawMap]: WebhookEvent<TRawMap[K]>;
}[keyof TRawMap];
declare const paykitEvent$InboundSchema: <Resource>(event: WebhookEvent<Resource>) => WebhookEvent<Resource>;
export { type CustomerCreated, type CustomerDeleted, type CustomerUpdated, type InvoiceGenerated, type PaymentCreated, type PaymentFailed, type PaymentSucceeded, type PaymentUpdated, type RawWebhookEvent, type RefundCreated, type SubscriptionCanceled, type SubscriptionCreated, type SubscriptionUpdated, type WebhookEvent, type WebhookEventPayload, paykitEvent$InboundSchema };