Skip to main content

TypeScript Types

Import from either @zkp2p/pay-sdk (re-exported) or @zkp2p/pay-shared.

import type {
CreateOrderRequest,
CreateOrderResponse,
CheckoutOrder,
CheckoutPayment,
MerchantProfile,
ReferralSplitConfig,
WebhookPayload,
} from '@zkp2p/pay-sdk';

Create Order Request

type CreateOrderRequest = (
| {
requestedUsdcAmount: string;
requestedFiatAmount?: never;
requestedFiatCurrency?: never;
}
| {
requestedUsdcAmount?: never;
requestedFiatAmount: string;
requestedFiatCurrency: string;
}
) & {
destinationAddress?: string;
destinationToken?: string;
destinationChainId?: number;
feePayer?: FeePayerType;
enabledRails?: string[];
successUrl?: string | null;
cancelUrl?: string | null;
notes?: Record<string, unknown> | null;
};

Create Order Response

type CreateOrderResponse = {
order: CheckoutOrder;
orderToken: string;
};

Checkout Result (SDK helper)

type CreateCheckoutResult = {
order: CheckoutOrder;
orderToken: string;
checkoutUrl: string;
};

Checkout Order

type CheckoutOrder = {
id: string;
merchantId: string;
status: CheckoutOrderStatusType;
requestedUsdcAmount: string;
remainingUsdcAmount: string;
destinationAddress: string;
destinationToken: string;
destinationChainId: string;
feePayer: FeePayerType;
enabledRails: string[];
successUrl: string | null;
cancelUrl: string | null;
notes: unknown | null;
metadata: unknown | null;
referralSplitConfig: ReferralSplitConfig | null;
cancelledAt: string | null;
completedAt: string | null;
createdAt: string;
updatedAt: string | null;
};

Payment

type CheckoutPayment = {
id: string;
orderId: string;
status: CheckoutPaymentStatusType;
rail: string;
currency: string;
payTo: string;
paymentAmount: string;
netSettledUsdcAmount: string | null;
totalUsdcFeeAmount: string;
fulfillTransaction: string | null;
createdAt: string;
updatedAt: string | null;
};

Merchant Types

type MerchantProfile = {
id: string;
name: string;
logoUrl: string | null;
apiKey: string;
environment: MerchantEnvironmentType;
evmWalletAddress: string | null;
solanaWalletAddress: string | null;
merchantConfig: MerchantConfig | null;
merchantUsers: MerchantUser[];
};

Webhook Types

type WebhookPayload = {
id: string;
type: WebhookEventTypeValue;
timestamp: string;
environment: MerchantEnvironmentType;
data: {
order?: CheckoutOrder | null;
payment?: CheckoutPayment | null;
paymentBridge?: unknown | null;
txHash?: string | null;
error?: {
code: string;
message: string;
} | null;
};
};

Constants

const FeePayer = {
MERCHANT: 'MERCHANT',
PAYEE: 'PAYEE',
} as const;

const CheckoutOrderStatus = {
CREATED: 'CREATED',
PARTIALLY_FULFILLED: 'PARTIALLY_FULFILLED',
FULFILLED: 'FULFILLED',
CANCELLED: 'CANCELLED',
} as const;

const CheckoutPaymentStatus = {
CREATED: 'CREATED',
SETTLED: 'SETTLED',
CANCELLED: 'CANCELLED',
EXPIRED: 'EXPIRED',
FAILED: 'FAILED',
} as const;