Migration guides
Upgrade @zkp2p/pay-sdk and @zkp2p/pay-shared together, to the same version, then run your type checker: it flags most places that need a change. @zkp2p/pay-sdk@9.1.0 depends on @zkp2p/pay-shared@^9.1.0.
npm install @zkp2p/pay-sdk@^9.1.0 @zkp2p/pay-shared@^9.1.0
From an older major, apply the sections below oldest first, moving both packages to each major before starting the next. Each section uses the export names of its own version.
v9.0 to v9.1
Upgrade both packages to 9.1.0 and @zkp2p/peer-pay-cli to 0.11.0. Nothing existing changes shape or behaviour.
- Per-checkout expiry.
CreateOrderRequesttakes an optionalexpiresInMinutes(30 to 10080), and orders carryexpiresAt(nullwhen the order never expires). See checkout expiry. - Checkout grants. New:
createCheckoutGrant,buildCheckoutGrantUrland, on theembeddedsubpath,listenForCheckoutGrantEvents. See the guide. checkoutGrantId.PayoutViewandCheckoutOrderhave a new required field,checkoutGrantId: string | null, in API reads and webhooks. It isnullunless the payout or order was made from a grant. Add it to fixtures you build by hand.- Embed events.
EmbedCheckoutEventTypeadds'grant.created'and'grant.funding'. Add them to exhaustive switches over the event type. - CLI.
grants createmints a grant, and the local simulator serves the grant routes. See CLI commands.
v8 to v9
9.0.0 and @zkp2p/peer-pay-cli 0.10.0 were never published to npm. From 8.x, upgrade both packages straight to 9.1.0 and the CLI to 0.11.0, then apply this section and the next. SDK functions and the embedded helpers are unchanged.
- X Money.
PaymentPlatformaddsX_MONEY('xmoney'). Payments can haverail: 'xmoney', andpreselectedMethodaccepts it. Add it to exhaustive switches overPaymentPlatformType. - Deferred payout state.
CheckoutPaymenthas a new required field,payout: { status, releaseEligibleAt, releasedAt }.statusis aCheckoutPaymentPayoutStatus(PAID,HELD,RELEASEDorDISPUTED) ornull. Add the field to payment fixtures you build. See deferred payouts. PAYMENT_PAYOUT_RELEASED.WebhookEventTypeadds this event, sent when a held payout is released to you. Only webhooks subscribed to it receive it. Add it to exhaustive switches over the event type.- No payout maximum.
PAYOUT_ABOVE_MAXis no longer returned. A payout must still be a whole multiple of your payout step. - CLI local payouts.
payouts resolve-sendreturnsPAYOUT_SIGNATURE_REQUIREDuntil the customer's signatures are submitted. See test payouts locally.
v7 to v8
Upgrade both packages to 8.0.0 and @zkp2p/peer-pay-cli to 0.8.0. A Master Merchant Account now sets two fees per sub merchant: a pay-in fee, which is the former master merchant fee, and a new payout fee. See how the fees work.
Payouts. PayoutView, in payout responses and PAYOUT_* webhooks, adds masterMerchantPayoutFee: { bps, amount }. It is { "bps": 0, "amount": "0.00" } unless you are a sub merchant whose Master Merchant Account charges a payout fee. PAYOUT_WEBHOOK_VERSION stays 2. Creating a payout can return 403 PAYOUT_MASTER_MERCHANT_WALLET_MISSING. See money rules.
Renamed in @zkp2p/pay-shared, for code that manages sub merchants:
| v7 | v8 |
|---|---|
MASTER_MERCHANT_FEE_MAX_BPS | MASTER_MERCHANT_PAYIN_FEE_MAX_BPS |
SubMerchantSummary.masterMerchantFeeBps | masterMerchantPayinFeeBps, plus masterMerchantPayoutFeeBps |
CreateSubMerchantRequest.masterMerchantFeeBps | masterMerchantPayinFeeBps, plus a required masterMerchantPayoutFeeBps |
SetMasterMerchantFeeRequest | SetMasterMerchantFeesRequest, with both fees required |
MasterMerchantFeeResult | MasterMerchantFeesResult, with both fees |
MasterMerchantFeePreviewResponse.masterMerchantFeeBps, .masterMerchantMaxFeeBps | masterMerchantPayinFeeBps, masterMerchantMaxPayinFeeBps |
formatMasterMerchantFeeExceedsCapMessage | formatMasterMerchantPayinFeeExceedsCapMessage |
MerchantConfig.masterMerchantMaxFeeBps | masterMerchantMaxPayinFeeBps, plus masterMerchantMaxPayoutFeeBps |
MerchantOwnershipErrorCode.MASTER_MERCHANT_FEE_EXCEEDS_CAP | MASTER_MERCHANT_PAYIN_FEE_EXCEEDS_CAP, plus MASTER_MERCHANT_PAYOUT_FEE_EXCEEDS_CAP |
New exports: MASTER_MERCHANT_PAYOUT_FEE_MAX_BPS (1000) and formatMasterMerchantPayoutFeeExceedsCapMessage.
CLI. sub-merchants set-fee is now sub-merchants set-fees, and --master-merchant-fee-bps is now --payin-fee-bps. sub-merchants create and set-fees also require --payout-fee-bps. See sub merchants.
v7.0 to v7.1
Upgrade both packages to 7.1.0 and @zkp2p/peer-pay-cli to 0.7.0. WebhookEventType adds DISPUTE_OPENED, DISPUTE_PAID and DISPUTE_ESCALATED for seller disputes, which you pay. They are separate from chargebacks, which are paid from stake.
Existing LIVE webhook endpoints are auto-subscribed to the three DISPUTE_* events from the 7.1.0 release. Webhooks created afterwards, and all sandbox webhooks, must list them explicitly.
Order and payout payloads are unchanged, but the automatic subscription is a breaking integration change for handlers that assume every delivery has data.order. Dispute deliveries carry DisputeWebhookData and no data.order. Branch on the event type, or use isDisputeWebhook and isPayoutWebhook, before reading order data, and handle the three new members in any switch over WebhookPayload['type'].
The SDK exports DisputeWebhookPayload, DisputeWebhookData, DisputeStatus, isDisputeWebhook and DISPUTE_WEBHOOK_VERSION (1).
CLI 0.7.0 adds disputes list, disputes get DISPUTE_ID and simulate ORDER_ID --event DISPUTE_OPENED (or DISPUTE_ESCALATED, DISPUTE_PAID). Simulation needs a settled local fiat payment. See seller disputes.
v6 to v7
Upgrade both packages to 7.0.0 and @zkp2p/peer-pay-cli to 0.6.0. Version 6.1.0 was never published; its multi-currency changes ship in 7.0.0. This is a hard cutover from "cashout" to "payout" naming with no aliases, so update callers, webhook subscriptions, validators and iframe listeners together.
SDK functions, types and constants
Every merchant export with Cashout, CASHOUT or cashout in its name now uses Payout, PAYOUT or payout, and a doubled prefix collapses to one. For example, createCashout is now createPayout, CashoutView is PayoutView, isCashoutWebhook is isPayoutWebhook, CashoutPayoutKind is PayoutKind, and CASHOUT_PAYOUT_STEP_MAX_USDC is PAYOUT_STEP_MAX_USDC. Each export stays in the package it came from, and your type checker lists every old name. Types for the customer's hosted payout page, such as CashoutCheckoutState, keep their names.
Routes and JSON fields
| Old | New |
|---|---|
POST, GET /api/v1/cashouts | /api/v1/payouts |
GET /api/v1/cashouts/:id | /api/v1/payouts/:id |
POST /api/v1/cashouts/:id/cancel | /api/v1/payouts/:id/cancel |
Dashboard pages /cashouts, /cashouts/:cashoutId, /settings/cashout | /payouts, /payouts/:payoutId, /settings/payout |
Response and webhook identifiers change from cashoutId to payoutId. The nested PayoutView.payout object (amount, chain and token) keeps its name. Request fields, authentication and the Idempotency-Key header are unchanged.
For iframe checkout.success and checkout.failed events, the id moved from payload.cashoutId to payload.payoutId; an iframe host reads event.data.payload.payoutId. The event names are unchanged. checkout.success with status: "LISTING" means the payout is listed, not paid; confirm settlement from the API or a signed webhook.
Webhook version 2
Rename subscriptions and exhaustive event switches:
| v1 | v2 |
|---|---|
CASHOUT_ORDER_CREATED | PAYOUT_ORDER_CREATED |
CASHOUT_ORDER_CANCELLED | PAYOUT_ORDER_CANCELLED |
CASHOUT_ORDER_PARTIALLY_FUNDED | PAYOUT_ORDER_PARTIALLY_FUNDED |
CASHOUT_ORDER_FUNDED | PAYOUT_ORDER_FUNDED |
CASHOUT_ORDER_MATCHED | PAYOUT_ORDER_MATCHED |
CASHOUT_ORDER_PARTIALLY_PAID | PAYOUT_ORDER_PARTIALLY_PAID |
CASHOUT_ORDER_SETTLED | PAYOUT_ORDER_SETTLED |
CASHOUT_ORDER_EXPIRED | PAYOUT_ORDER_EXPIRED |
New payout deliveries have version: 2 and data.payoutId. Use PAYOUT_WEBHOOK_VERSION and isPayoutWebhook; order webhooks keep their unversioned envelope.
Deliveries queued before the 7.0.0 deploy keep their stored v1 payloads, with the old CASHOUT_ORDER_* types and data.cashoutId, even on retry. Route such a delivery by its old event type before passing it to v7 handling. See payout events.
Merchant error codes
Generic codes such as INVALID_IDEMPOTENCY_KEY are unchanged.
| Old | New |
|---|---|
CASHOUTS_DISABLED | PAYOUTS_DISABLED |
CASHOUT_FUNDING_AMOUNT_TOO_LOW | PAYOUT_FUNDING_AMOUNT_TOO_LOW |
CASHOUT_FUNDING_DETECTED | PAYOUT_FUNDING_DETECTED |
CASHOUT_FUNDING_TOKEN_UNSUPPORTED | PAYOUT_FUNDING_TOKEN_UNSUPPORTED |
CASHOUT_MERCHANT_WALLET_MISSING | PAYOUT_MERCHANT_WALLET_MISSING |
CASHOUT_NOT_CANCELLABLE | PAYOUT_NOT_CANCELLABLE |
CASHOUT_NOT_FOUND | PAYOUT_NOT_FOUND |
CASHOUT_NO_RAILS_AVAILABLE | PAYOUT_NO_RAILS_AVAILABLE |
CASHOUT_PAYOUT_ABOVE_MAX | PAYOUT_ABOVE_MAX |
CASHOUT_PAYOUT_NOT_STEP_MULTIPLE | PAYOUT_NOT_STEP_MULTIPLE |
CASHOUT_PAYOUT_TOKEN_UNSUPPORTED | PAYOUT_TOKEN_UNSUPPORTED |
CASHOUT_PRIVY_WALLET_FAILED | PAYOUT_PRIVY_WALLET_FAILED |
CASHOUT_RELAY_QUOTE_FAILED | PAYOUT_RELAY_QUOTE_FAILED |
CASHOUT_RELAY_STATUS_FAILED | PAYOUT_RELAY_STATUS_FAILED |
CASHOUT_REQUESTED_RAILS_UNAVAILABLE | PAYOUT_REQUESTED_RAILS_UNAVAILABLE |
CASHOUT_ROUTE_UNQUOTABLE | PAYOUT_ROUTE_UNQUOTABLE |
CASHOUT_SANDBOX_UNSUPPORTED | PAYOUT_SANDBOX_UNSUPPORTED |
CLI 0.6.0
Every cashouts command is now a payouts command with the same subcommand, for example cashouts create becomes payouts create. Commands that take a payout id show it as PAYOUT_ID. The old names are rejected, so update your scripts.
Local state files with old event names or v1 deliveries are rejected, and there is no conversion. To start over, stop the server and run peer-pay-cli local reset --state PATH (local reset). It renames the file to PATH.backup-<uuid> without reading it. Then restart peer-pay-cli serve with the same --state. Hosted data is unchanged. Local-control errors use PAYOUT_* codes.
Names that keep cashout
- Webhook delivery ids such as
cashout_<id>_CASHOUT_ORDER_SETTLEDkeep their spelling. Treat them as opaque deduplication keys: don't parse them, rewrite them, or reset your deduplication records. - The customer's payout page stays at
/c/:idon the checkout host.
Multi-currency payouts
Customers can receive any catalog currency on PayPal and Revolut. Your requests, funding, fees, limits, refunds and accounting stay in USD and USDC.
Payout responses add payoutCurrency, partialFills[].fiat and settlement.buyerPaidFiat, and the partial-payment webhook adds partialPayment.fill.fiat. Fiat values are informational, at each buyer's rate, and null when unknown; settlement.buyerPaidFiat is [] when no buyer paid. Update fixtures and strict response validators. The SDK exports PayoutCurrency, PayoutCurrencyType and PayoutFiatValue. These fields ship in payout webhook version 2; order webhooks are unchanged.
Customers can no longer cancel a payout from checkout: the CANCELLING status, the CHECKOUT cancel source and the CANCEL_STARTED timeline event are removed. cancelPayout still cancels an unfunded payout.
v5 to v6
v6 adds the payout client, then called cashouts, and versioned payout webhooks.
WebhookPayloadisOrderWebhookPayload | CashoutWebhookPayload. Narrow withisCashoutWebhook, exported by both packages, before readingdata.order. Cashout events carry aCashoutViewindata, andCASHOUT_ORDER_PARTIALLY_PAIDalso carriespartialPayment.WebhookEventTypeValueadds eight events:CASHOUT_ORDER_CREATED,CASHOUT_ORDER_CANCELLED,CASHOUT_ORDER_PARTIALLY_FUNDED,CASHOUT_ORDER_FUNDED,CASHOUT_ORDER_MATCHED,CASHOUT_ORDER_PARTIALLY_PAID,CASHOUT_ORDER_SETTLEDandCASHOUT_ORDER_EXPIRED. Update exhaustive switches, or useOrderWebhookEventTypeValuefrom@zkp2p/pay-sharedin order-only handlers.
New: createCashout, getCashout, listCashouts and cancelCashout, renamed in v7 to the payout functions.
v4 to v5
v5 adds open-amount orders, where the customer chooses the amount at checkout. Every order now has amountMode.
CheckoutOrderis a union onamountMode. Narrow it before reading amounts: an open-amount order hasrequestedUsdcAmount: nulluntil the customer starts a payment.createCheckoutthrows when fields from more than one amount mode are set, even if one is an empty string. The message isProvide exactly one of requestedUsdcAmount, requestedFiatAmount + requestedFiatCurrency, or openAmount.- An idempotent replay (
idempotentReplay: true) returnscheckoutUrl: null. Keep the URL from the first call. feePayercan be'SPLIT', withbuyerFeeShareBps. Handle it wherever you switch onFeePayerType.- New required fields matter only for objects you build yourself, such as test fixtures:
CheckoutPayment.penalties;buyerFeeShareBpsonCheckoutOrderandMerchantConfig;MerchantConfig.applePayAvailable,masterMerchantEnabledandmasterMerchantMaxFeeBps;MerchantProfile.apiKeyIpAllowlistandmasterMerchantId; andMerchantUser.removalLocked. - Hosted-checkout types changed too:
CheckoutAggregate.orderis aHostedCheckoutOrder,PaymentDeeplinkResponse.intentHashandproofSubmissionUrlcan benull, andCreatePaymentRequesttakesamount,amountCurrencyandexpectedAmountVersiontogether or not at all.
New: the ORDER_AMOUNT_SET webhook, with data.amountChange. Subscribe to it explicitly, and keep crediting the customer on ORDER_FULFILLED.
v3 to v4
The API reports merchant plans as BASE, PRO or CONCIERGE instead of FREE or PRO, so v3 types are wrong for current responses.
MerchantProfile.tierisMerchantTierName | null, whereMerchantTierNameis'BASE' | 'PRO' | 'CONCIERGE'.nullmeans no plan is set; accounts now start onPRO, not yet activated. The oldFREEmaps tonulland the oldPROtoCONCIERGE, so replacetier === 'FREE'checks withtier === null. To tell whether live orders are allowed, checkMerchantProfile.planActivatedAt(added later) instead: live order creation returns403 MERCHANT_TIER_FORBIDDENuntil the plan is activated, and a tier alone is not enough.- API failures throw
PayApiError, a subclass ofError, fromcreateCheckout,getMerchantandcheckQuoteAvailability. It carriesstatusCode,errorCode,fieldErrors,formErrorsandresponseObject, and its message now includes field detail, so branch onerrorCodeorfieldErrorsinstead of the message. See error handling. ChainConfig.usdcAddressisstring | null, because Tron payouts settle in USDT. UseresolveDestinationTokenAddressfor a chain's payout token.- Narrowed unions.
OrderBridgeInfo.statusisPaymentBridgeStatusType(PENDING,SUBMITTED,COMPLETED,FAILED);BridgeStatusResponse.statuskeeps its lowercase values.OnboardingStepState.idisOnboardingStepIdValue, which addsPLAN. - Chargeback events.
WebhookEventTypeaddsPAYMENT_CHARGEBACKED,ORDER_PARTIALLY_CHARGEBACKEDandORDER_CHARGEBACKED. Live webhooks that existed at the v4 release were subscribed automatically; webhooks created since, and all sandbox webhooks, must list them.
Also new: plan definitions (SELF_SERVE_TIERS, TIER_DEFINITIONS, formatTierMonthlyLimitsCopy), TRON_CHAIN_ID with Tron USDT payouts, and types for the /api/v1/integration endpoints.
v2 to v3
Every break in v3 is caught at compile time.
EmbedCheckoutEventTypeaddscheckout.closed. Add an arm to exhaustive switches, and close the iframe on it: it is a dismissal, not a failure. A non-exhaustiveifchain still compiles but leaves the customer stuck behind a Go Back button that does nothing. See dismissing the iframe.getMerchanttakes one argument:getMerchant(options). The API key identifies the merchant; the old first argument was ignored.- Aliases removed. Replace
CheckoutCreateResponsefrom@zkp2p/pay-sdkwithCreateCheckoutResult, andCheckoutCreateResponseorCreateCheckoutResponsefrom@zkp2p/pay-sharedwithCreateOrderResponse. - The SDK requires the
{ success, message, responseObject, statusCode }envelope and throwsMalformed API response envelopeotherwise. This matters only if you point the SDK at a mock or a proxy. MerchantProfiledropsmigrationStatusand adds the required fieldsintegrationPath,onboardingCompletedAtandonboardingSkippedAt.CreateWebhookResponseis nested. Readresponse.webhook.id,.urland.events;response.secretstays at the top level.WebhookWithSecretis removed: useCreateWebhookResponse.- Removed exports:
DashboardPrivyApp,DashboardPrivyAppType,MerchantMigrationStatusandMerchantMigrationStatusType. Delete any references.
New: CheckoutNearbySuggestion and CheckoutNearbySuggestions are re-exported from the SDK, and @zkp2p/pay-shared adds address validators such as isValidSolanaAddress and isValidTronAddress.
v1 to v2
Zelle uses a single rail. payment.rail is always zelle for Zelle payments, in API responses and webhooks, and the customer's bank moves to the new payment.paymentMethodId: zelle-chase, zelle-bofa, zelle-citi or zelle-capitalone, and null on other rails. enabledRails and preselectedMethod already used zelle.
- Match
payment.rail === 'zelle'instead ofzelle-chase,zelle-bofaorzelle-citi, and read the bank frompaymentMethodId. Payments stored before the change keep their old rail values. - Removed from
@zkp2p/pay-shared:ZELLE_QUOTE_PLATFORMS,expandZelleQuotePlatforms,zelleCompatibleMethods,SUPPORTED_ZELLE_RAIL_VARIANTSandisSupportedZelleRailVariant. Check a bank id withZELLE_PAYMENT_METHOD_IDS. - Renamed:
ZELLE_VARIANT_ACTION_SUFFIXis nowZELLE_METHOD_ACTION_SUFFIX, keyed bypaymentMethodId.
If you only create orders and handle webhooks by order status, nothing changes.
v0 to v1
v1 replaces the session-first integration with orders: payments attach to an order, and createCheckout creates it.
| v0 | v1 |
|---|---|
createCheckoutSession(params, opts) | createCheckout(params, opts) |
createSessionAndRedirect(params, opts) | createCheckoutAndRedirect(params, opts) |
getMerchant(merchantId, opts) | getMerchant(opts) |
getCheckoutUrl(sessionId, opts, sessionToken) | getCheckoutUrl(orderId, orderToken, opts) |
redirectToCheckout(sessionId, sessionToken, opts) | redirectToCheckout(orderId, orderToken, opts) |
POST /api/checkout/sessions | POST /api/v1/orders |
GET /api/merchants/{merchantId} | GET /api/v1/merchants/me |
URL /checkout?session=...&token=... | URL /?order=...&token=... |
Request fields:
| v0 | v1 |
|---|---|
merchantId | Removed: the API key identifies the merchant |
amountUsdc | requestedUsdcAmount |
fiatAmount + fiatCurrency | requestedFiatAmount + requestedFiatCurrency, instead of requestedUsdcAmount |
recipientAddress | destinationAddress, optional |
enabledPaymentPlatforms | enabledRails |
metadata | notes (Record<string, unknown>) |
checkoutMode, maxFeePercentage | Removed; set the fee cap in the dashboard |
destinationChainId, destinationToken, successUrl, cancelUrl | Unchanged |
In responses, session.id becomes order.id and sessionToken becomes orderToken; checkoutUrl is still returned. Default currency moves to the merchant setting defaultPaymentCurrency.
Webhook events:
| v0 | v1 |
|---|---|
order.created, session.started | ORDER_CREATED |
order.payment_sent | No equivalent; PAYMENT_CREATED is the closest |
order.fulfilled, session.completed | ORDER_FULFILLED, with PAYMENT_SETTLED for each payment |
order.failed | PAYMENT_FAILED |
order.expired | PAYMENT_EXPIRED. The order stays open and can still be paid. |
session.abandoned | No equivalent: orders never expire |
payout.submitted, payout.completed, payout.failed | PAYMENT_BRIDGE_SUBMITTED, PAYMENT_BRIDGE_COMPLETED, PAYMENT_BRIDGE_FAILED |
Payload paths:
| v0 | v1 |
|---|---|
data.session.id | data.order.id |
data.session.status | data.order.status and data.payment.status |
data.order.paymentPlatform | data.payment.rail |
data.order.fiatCurrency | data.payment.currency |
data.order.fulfillTx | data.payment.fulfillTransaction |
data.order.errorCode, data.order.errorMessage | data.payment.errorMessage, set on PAYMENT_FAILED |
| Payout info on the order or session | data.paymentBridge on PAYMENT_BRIDGE_* events |
An order can now be paid in several payments: it stays PARTIALLY_FULFILLED until it reaches FULFILLED. Fulfill on ORDER_FULFILLED, and don't cancel an order because a payment expired; see the payment window.