Skip to main content

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. CreateOrderRequest takes an optional expiresInMinutes (30 to 10080), and orders carry expiresAt (null when the order never expires). See checkout expiry.
  • Checkout grants. New: createCheckoutGrant, buildCheckoutGrantUrl and, on the embedded subpath, listenForCheckoutGrantEvents. See the guide.
  • checkoutGrantId. PayoutView and CheckoutOrder have a new required field, checkoutGrantId: string | null, in API reads and webhooks. It is null unless the payout or order was made from a grant. Add it to fixtures you build by hand.
  • Embed events. EmbedCheckoutEventType adds 'grant.created' and 'grant.funding'. Add them to exhaustive switches over the event type.
  • CLI. grants create mints 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. PaymentPlatform adds X_MONEY ('xmoney'). Payments can have rail: 'xmoney', and preselectedMethod accepts it. Add it to exhaustive switches over PaymentPlatformType.
  • Deferred payout state. CheckoutPayment has a new required field, payout: { status, releaseEligibleAt, releasedAt }. status is a CheckoutPaymentPayoutStatus (PAID, HELD, RELEASED or DISPUTED) or null. Add the field to payment fixtures you build. See deferred payouts.
  • PAYMENT_PAYOUT_RELEASED. WebhookEventType adds 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_MAX is no longer returned. A payout must still be a whole multiple of your payout step.
  • CLI local payouts. payouts resolve-send returns PAYOUT_SIGNATURE_REQUIRED until 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:

v7v8
MASTER_MERCHANT_FEE_MAX_BPSMASTER_MERCHANT_PAYIN_FEE_MAX_BPS
SubMerchantSummary.masterMerchantFeeBpsmasterMerchantPayinFeeBps, plus masterMerchantPayoutFeeBps
CreateSubMerchantRequest.masterMerchantFeeBpsmasterMerchantPayinFeeBps, plus a required masterMerchantPayoutFeeBps
SetMasterMerchantFeeRequestSetMasterMerchantFeesRequest, with both fees required
MasterMerchantFeeResultMasterMerchantFeesResult, with both fees
MasterMerchantFeePreviewResponse.masterMerchantFeeBps, .masterMerchantMaxFeeBpsmasterMerchantPayinFeeBps, masterMerchantMaxPayinFeeBps
formatMasterMerchantFeeExceedsCapMessageformatMasterMerchantPayinFeeExceedsCapMessage
MerchantConfig.masterMerchantMaxFeeBpsmasterMerchantMaxPayinFeeBps, plus masterMerchantMaxPayoutFeeBps
MerchantOwnershipErrorCode.MASTER_MERCHANT_FEE_EXCEEDS_CAPMASTER_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​

OldNew
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:

v1v2
CASHOUT_ORDER_CREATEDPAYOUT_ORDER_CREATED
CASHOUT_ORDER_CANCELLEDPAYOUT_ORDER_CANCELLED
CASHOUT_ORDER_PARTIALLY_FUNDEDPAYOUT_ORDER_PARTIALLY_FUNDED
CASHOUT_ORDER_FUNDEDPAYOUT_ORDER_FUNDED
CASHOUT_ORDER_MATCHEDPAYOUT_ORDER_MATCHED
CASHOUT_ORDER_PARTIALLY_PAIDPAYOUT_ORDER_PARTIALLY_PAID
CASHOUT_ORDER_SETTLEDPAYOUT_ORDER_SETTLED
CASHOUT_ORDER_EXPIREDPAYOUT_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.

OldNew
CASHOUTS_DISABLEDPAYOUTS_DISABLED
CASHOUT_FUNDING_AMOUNT_TOO_LOWPAYOUT_FUNDING_AMOUNT_TOO_LOW
CASHOUT_FUNDING_DETECTEDPAYOUT_FUNDING_DETECTED
CASHOUT_FUNDING_TOKEN_UNSUPPORTEDPAYOUT_FUNDING_TOKEN_UNSUPPORTED
CASHOUT_MERCHANT_WALLET_MISSINGPAYOUT_MERCHANT_WALLET_MISSING
CASHOUT_NOT_CANCELLABLEPAYOUT_NOT_CANCELLABLE
CASHOUT_NOT_FOUNDPAYOUT_NOT_FOUND
CASHOUT_NO_RAILS_AVAILABLEPAYOUT_NO_RAILS_AVAILABLE
CASHOUT_PAYOUT_ABOVE_MAXPAYOUT_ABOVE_MAX
CASHOUT_PAYOUT_NOT_STEP_MULTIPLEPAYOUT_NOT_STEP_MULTIPLE
CASHOUT_PAYOUT_TOKEN_UNSUPPORTEDPAYOUT_TOKEN_UNSUPPORTED
CASHOUT_PRIVY_WALLET_FAILEDPAYOUT_PRIVY_WALLET_FAILED
CASHOUT_RELAY_QUOTE_FAILEDPAYOUT_RELAY_QUOTE_FAILED
CASHOUT_RELAY_STATUS_FAILEDPAYOUT_RELAY_STATUS_FAILED
CASHOUT_REQUESTED_RAILS_UNAVAILABLEPAYOUT_REQUESTED_RAILS_UNAVAILABLE
CASHOUT_ROUTE_UNQUOTABLEPAYOUT_ROUTE_UNQUOTABLE
CASHOUT_SANDBOX_UNSUPPORTEDPAYOUT_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_SETTLED keep 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/:id on 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.

  • WebhookPayload is OrderWebhookPayload | CashoutWebhookPayload. Narrow with isCashoutWebhook, exported by both packages, before reading data.order. Cashout events carry a CashoutView in data, and CASHOUT_ORDER_PARTIALLY_PAID also carries partialPayment.
  • WebhookEventTypeValue adds eight events: CASHOUT_ORDER_CREATED, CASHOUT_ORDER_CANCELLED, CASHOUT_ORDER_PARTIALLY_FUNDED, CASHOUT_ORDER_FUNDED, CASHOUT_ORDER_MATCHED, CASHOUT_ORDER_PARTIALLY_PAID, CASHOUT_ORDER_SETTLED and CASHOUT_ORDER_EXPIRED. Update exhaustive switches, or use OrderWebhookEventTypeValue from @zkp2p/pay-shared in 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.

  • CheckoutOrder is a union on amountMode. Narrow it before reading amounts: an open-amount order has requestedUsdcAmount: null until the customer starts a payment.
  • createCheckout throws when fields from more than one amount mode are set, even if one is an empty string. The message is Provide exactly one of requestedUsdcAmount, requestedFiatAmount + requestedFiatCurrency, or openAmount.
  • An idempotent replay (idempotentReplay: true) returns checkoutUrl: null. Keep the URL from the first call.
  • feePayer can be 'SPLIT', with buyerFeeShareBps. Handle it wherever you switch on FeePayerType.
  • New required fields matter only for objects you build yourself, such as test fixtures: CheckoutPayment.penalties; buyerFeeShareBps on CheckoutOrder and MerchantConfig; MerchantConfig.applePayAvailable, masterMerchantEnabled and masterMerchantMaxFeeBps; MerchantProfile.apiKeyIpAllowlist and masterMerchantId; and MerchantUser.removalLocked.
  • Hosted-checkout types changed too: CheckoutAggregate.order is a HostedCheckoutOrder, PaymentDeeplinkResponse.intentHash and proofSubmissionUrl can be null, and CreatePaymentRequest takes amount, amountCurrency and expectedAmountVersion together 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.tier is MerchantTierName | null, where MerchantTierName is 'BASE' | 'PRO' | 'CONCIERGE'. null means no plan is set; accounts now start on PRO, not yet activated. The old FREE maps to null and the old PRO to CONCIERGE, so replace tier === 'FREE' checks with tier === null. To tell whether live orders are allowed, check MerchantProfile.planActivatedAt (added later) instead: live order creation returns 403 MERCHANT_TIER_FORBIDDEN until the plan is activated, and a tier alone is not enough.
  • API failures throw PayApiError, a subclass of Error, from createCheckout, getMerchant and checkQuoteAvailability. It carries statusCode, errorCode, fieldErrors, formErrors and responseObject, and its message now includes field detail, so branch on errorCode or fieldErrors instead of the message. See error handling.
  • ChainConfig.usdcAddress is string | null, because Tron payouts settle in USDT. Use resolveDestinationTokenAddress for a chain's payout token.
  • Narrowed unions. OrderBridgeInfo.status is PaymentBridgeStatusType (PENDING, SUBMITTED, COMPLETED, FAILED); BridgeStatusResponse.status keeps its lowercase values. OnboardingStepState.id is OnboardingStepIdValue, which adds PLAN.
  • Chargeback events. WebhookEventType adds PAYMENT_CHARGEBACKED, ORDER_PARTIALLY_CHARGEBACKED and ORDER_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.

  • EmbedCheckoutEventType adds checkout.closed. Add an arm to exhaustive switches, and close the iframe on it: it is a dismissal, not a failure. A non-exhaustive if chain still compiles but leaves the customer stuck behind a Go Back button that does nothing. See dismissing the iframe.
  • getMerchant takes one argument: getMerchant(options). The API key identifies the merchant; the old first argument was ignored.
  • Aliases removed. Replace CheckoutCreateResponse from @zkp2p/pay-sdk with CreateCheckoutResult, and CheckoutCreateResponse or CreateCheckoutResponse from @zkp2p/pay-shared with CreateOrderResponse.
  • The SDK requires the { success, message, responseObject, statusCode } envelope and throws Malformed API response envelope otherwise. This matters only if you point the SDK at a mock or a proxy.
  • MerchantProfile drops migrationStatus and adds the required fields integrationPath, onboardingCompletedAt and onboardingSkippedAt.
  • CreateWebhookResponse is nested. Read response.webhook.id, .url and .events; response.secret stays at the top level. WebhookWithSecret is removed: use CreateWebhookResponse.
  • Removed exports: DashboardPrivyApp, DashboardPrivyAppType, MerchantMigrationStatus and MerchantMigrationStatusType. 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 of zelle-chase, zelle-bofa or zelle-citi, and read the bank from paymentMethodId. Payments stored before the change keep their old rail values.
  • Removed from @zkp2p/pay-shared: ZELLE_QUOTE_PLATFORMS, expandZelleQuotePlatforms, zelleCompatibleMethods, SUPPORTED_ZELLE_RAIL_VARIANTS and isSupportedZelleRailVariant. Check a bank id with ZELLE_PAYMENT_METHOD_IDS.
  • Renamed: ZELLE_VARIANT_ACTION_SUFFIX is now ZELLE_METHOD_ACTION_SUFFIX, keyed by paymentMethodId.

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.

v0v1
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/sessionsPOST /api/v1/orders
GET /api/merchants/{merchantId}GET /api/v1/merchants/me
URL /checkout?session=...&token=...URL /?order=...&token=...

Request fields:

v0v1
merchantIdRemoved: the API key identifies the merchant
amountUsdcrequestedUsdcAmount
fiatAmount + fiatCurrencyrequestedFiatAmount + requestedFiatCurrency, instead of requestedUsdcAmount
recipientAddressdestinationAddress, optional
enabledPaymentPlatformsenabledRails
metadatanotes (Record<string, unknown>)
checkoutMode, maxFeePercentageRemoved; set the fee cap in the dashboard
destinationChainId, destinationToken, successUrl, cancelUrlUnchanged

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:

v0v1
order.created, session.startedORDER_CREATED
order.payment_sentNo equivalent; PAYMENT_CREATED is the closest
order.fulfilled, session.completedORDER_FULFILLED, with PAYMENT_SETTLED for each payment
order.failedPAYMENT_FAILED
order.expiredPAYMENT_EXPIRED. The order stays open and can still be paid.
session.abandonedNo equivalent: orders never expire
payout.submitted, payout.completed, payout.failedPAYMENT_BRIDGE_SUBMITTED, PAYMENT_BRIDGE_COMPLETED, PAYMENT_BRIDGE_FAILED

Payload paths:

v0v1
data.session.iddata.order.id
data.session.statusdata.order.status and data.payment.status
data.order.paymentPlatformdata.payment.rail
data.order.fiatCurrencydata.payment.currency
data.order.fulfillTxdata.payment.fulfillTransaction
data.order.errorCode, data.order.errorMessagedata.payment.errorMessage, set on PAYMENT_FAILED
Payout info on the order or sessiondata.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.