@zkp2p/pay-shared 4.0.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PayCryptoTokenSymbol } from './crypto.js';
2
2
  import type { ProofMode } from './buyerTee.js';
3
3
  import type { OnboardingStepIdValue } from './onboarding.js';
4
+ import type { SarSupportedFiatRail } from './rails.js';
4
5
  export declare const PaymentPlatform: {
5
6
  readonly VENMO: "venmo";
6
7
  readonly CASHAPP: "cashapp";
@@ -62,6 +63,7 @@ export type CheckoutMethodType = typeof CheckoutMethod[keyof typeof CheckoutMeth
62
63
  export declare const FeePayer: {
63
64
  readonly MERCHANT: "MERCHANT";
64
65
  readonly PAYEE: "PAYEE";
66
+ readonly SPLIT: "SPLIT";
65
67
  };
66
68
  export type FeePayerType = typeof FeePayer[keyof typeof FeePayer];
67
69
  export declare const MerchantPaymentFlowMode: {
@@ -147,11 +149,95 @@ export type SettlementReferralFeeEntry = {
147
149
  recipient: string;
148
150
  feeUsdc: string;
149
151
  };
152
+ /** FIXED orders carry an amount from creation; OPEN orders get one when the buyer starts a payment. */
153
+ export declare const OrderAmountMode: {
154
+ readonly FIXED: "FIXED";
155
+ readonly OPEN: "OPEN";
156
+ };
157
+ export type OrderAmountModeType = typeof OrderAmountMode[keyof typeof OrderAmountMode];
158
+ /**
159
+ * Why the buyer can no longer change an open order's amount. Precedence when several apply:
160
+ * PAID, then PAYMENT_MAY_SETTLE, then PAYMENT_IN_PROGRESS.
161
+ */
162
+ export declare const AmountLockReason: {
163
+ /** Only CREATED non-Zcash payments lock the amount; cancelling them unlocks it. */
164
+ readonly PAYMENT_IN_PROGRESS: "PAYMENT_IN_PROGRESS";
165
+ /** An EXPIRED payment, a locking Zcash payment or a reopenable FAILED Relay payment can still settle; cancelling cannot unlock it. */
166
+ readonly PAYMENT_MAY_SETTLE: "PAYMENT_MAY_SETTLE";
167
+ /** A SETTLED payment exists. */
168
+ readonly PAID: "PAID";
169
+ };
170
+ export type AmountLockReasonType = typeof AmountLockReason[keyof typeof AmountLockReason];
171
+ export declare const OpenAmountErrorCode: {
172
+ readonly OPEN_AMOUNT_INVALID: "OPEN_AMOUNT_INVALID";
173
+ readonly OPEN_AMOUNT_DISABLED: "OPEN_AMOUNT_DISABLED";
174
+ readonly AMOUNT_REQUIRED: "AMOUNT_REQUIRED";
175
+ readonly AMOUNT_NOT_ALLOWED: "AMOUNT_NOT_ALLOWED";
176
+ readonly AMOUNT_OUT_OF_RANGE: "AMOUNT_OUT_OF_RANGE";
177
+ readonly AMOUNT_LOCKED: "AMOUNT_LOCKED";
178
+ readonly AMOUNT_CONFLICT: "AMOUNT_CONFLICT";
179
+ readonly RESIZE_NOT_SUPPORTED: "RESIZE_NOT_SUPPORTED";
180
+ };
181
+ export type OpenAmountErrorCodeType = typeof OpenAmountErrorCode[keyof typeof OpenAmountErrorCode];
182
+ /** Merchant request shape. Amounts are positive decimals in `currency` with at most 2 decimals. */
183
+ export type OpenAmountInput = {
184
+ currency: string;
185
+ minAmount?: string;
186
+ maxAmount?: string;
187
+ presets?: string[];
188
+ };
189
+ /** Stored + API shape (normalized: upper-case currency, 2-dp decimal strings, presets sorted asc, unique). */
190
+ export type OpenAmountConfig = {
191
+ currency: string;
192
+ minAmount: string | null;
193
+ maxAmount: string | null;
194
+ presets: string[];
195
+ };
196
+ /** The buyer's saved amount and the currency they typed it in (the checkout's selected currency, which may differ from `openAmount.currency`). */
197
+ export type OpenAmountSavedInput = {
198
+ amount: string;
199
+ currency: string;
200
+ };
201
+ /**
202
+ * Platform-quotes `openAmountDisplay` (amendment 2026-10-05): an unlocked open order's range and
203
+ * presets in the request's `fiatCurrency`. In the order's own currency the merchant's values are
204
+ * exact, cents kept; in any other currency they are whole units (minimum rounded up, maximum down,
205
+ * presets half-up and clamped into the range). The bounds and `currencyPerOrderUnit` are null, and
206
+ * `presets` is empty, when an exchange rate is unavailable.
207
+ */
208
+ export type OpenAmountDisplay = {
209
+ currency: string;
210
+ effectiveMin: string | null;
211
+ effectiveMax: string | null;
212
+ presets: string[];
213
+ /** Units of `currency` one unit of `openAmount.currency` buys at the rates used, as a decimal string; null when unavailable. */
214
+ currencyPerOrderUnit: string | null;
215
+ };
216
+ /** Hosted (checkout) only. */
217
+ export type HostedOpenAmount = OpenAmountConfig & {
218
+ /** In `currency`, 2 dp, rounded UP. Null while locked, once FULFILLED or CANCELLED, or when the live rate is unavailable. */
219
+ effectiveMin: string | null;
220
+ /** In `currency`, 2 dp, rounded DOWN. Null while locked, once FULFILLED or CANCELLED, or when the live rate is unavailable. */
221
+ effectiveMax: string | null;
222
+ /** The buyer's saved amount in the currency they typed it in, or null before the first payment start. */
223
+ savedInput: OpenAmountSavedInput | null;
224
+ };
225
+ /** `ORDER_AMOUNT_SET` webhook detail. */
226
+ export type OrderAmountChange = {
227
+ previousAmountUsdc: string | null;
228
+ newAmountUsdc: string;
229
+ /** The amount the buyer typed, in the currency they typed it in (the checkout's selected currency). */
230
+ fiat: OpenAmountSavedInput;
231
+ amountVersion: number;
232
+ };
150
233
  type CreateOrderRequestBase = {
234
+ idempotencyKey?: string;
151
235
  destinationAddress?: string;
152
236
  destinationToken?: string;
153
237
  destinationChainId?: number;
154
238
  feePayer?: FeePayerType;
239
+ /** SPLIT buyer share of total fees, in basis points (0–10000, steps of 1000). */
240
+ buyerFeeShareBps?: number;
155
241
  enabledRails?: string[];
156
242
  dynamicOrdersEnabled?: boolean;
157
243
  successUrl?: string | null;
@@ -162,13 +248,21 @@ type CreateOrderRequestWithUsdc = CreateOrderRequestBase & {
162
248
  requestedUsdcAmount: string;
163
249
  requestedFiatAmount?: never;
164
250
  requestedFiatCurrency?: never;
251
+ openAmount?: never;
165
252
  };
166
253
  type CreateOrderRequestWithFiat = CreateOrderRequestBase & {
167
254
  requestedUsdcAmount?: never;
168
255
  requestedFiatAmount: string;
169
256
  requestedFiatCurrency: string;
257
+ openAmount?: never;
170
258
  };
171
- export type CreateOrderRequest = CreateOrderRequestWithUsdc | CreateOrderRequestWithFiat;
259
+ type CreateOrderRequestWithOpenAmount = CreateOrderRequestBase & {
260
+ requestedUsdcAmount?: never;
261
+ requestedFiatAmount?: never;
262
+ requestedFiatCurrency?: never;
263
+ openAmount: OpenAmountInput;
264
+ };
265
+ export type CreateOrderRequest = CreateOrderRequestWithUsdc | CreateOrderRequestWithFiat | CreateOrderRequestWithOpenAmount;
172
266
  export type CheckoutRequest = CreateOrderRequest;
173
267
  export type MerchantCheckoutTheme = {
174
268
  presetName?: 'default' | 'dark' | 'light' | 'custom';
@@ -196,7 +290,7 @@ export type CheckoutMerchant = {
196
290
  /** Whether the merchant has been verified by ZKP2P. */
197
291
  verified: boolean;
198
292
  };
199
- export type CheckoutOrder = {
293
+ type CheckoutOrderBase = {
200
294
  id: string;
201
295
  merchantId: string;
202
296
  status: CheckoutOrderStatusType;
@@ -208,12 +302,18 @@ export type CheckoutOrder = {
208
302
  refundTransactionHash: string | null;
209
303
  refundMetadata: unknown | null;
210
304
  inPersonCheckout: boolean;
211
- requestedUsdcAmount: string;
212
- remainingUsdcAmount: string;
305
+ /**
306
+ * USDC the customer would be charged for the current outstanding balance if they
307
+ * paid by Apple Pay, grossed up by the merchant's Apple Pay fee when the payer
308
+ * owes it. Hosted aggregates only; null when Apple Pay is disabled or pricing
309
+ * cannot be resolved. Checkout hides Apple Pay when it is above the 2,500 USDC cap.
310
+ */
311
+ applePayChargeUsdcAmount?: string | null;
213
312
  destinationAddress: string;
214
313
  destinationToken: string;
215
314
  destinationChainId: string;
216
315
  feePayer: FeePayerType;
316
+ buyerFeeShareBps: number;
217
317
  enabledRails: string[];
218
318
  successUrl: string | null;
219
319
  cancelUrl: string | null;
@@ -231,7 +331,34 @@ export type CheckoutOrder = {
231
331
  createdAt: string;
232
332
  updatedAt: string | null;
233
333
  };
334
+ export type FixedAmountCheckoutOrder = CheckoutOrderBase & {
335
+ amountMode: typeof OrderAmountMode.FIXED;
336
+ requestedUsdcAmount: string;
337
+ remainingUsdcAmount: string;
338
+ };
339
+ /** Amounts stay null until the buyer starts the first payment; `amountVersion` is 0 until then. */
340
+ export type OpenAmountCheckoutOrder = CheckoutOrderBase & {
341
+ amountMode: typeof OrderAmountMode.OPEN;
342
+ requestedUsdcAmount: string | null;
343
+ remainingUsdcAmount: string | null;
344
+ openAmount: OpenAmountConfig;
345
+ amountVersion: number;
346
+ };
347
+ /** Narrow on `amountMode` before reading amounts. */
348
+ export type CheckoutOrder = FixedAmountCheckoutOrder | OpenAmountCheckoutOrder;
349
+ /** Hosted aggregate shape of an open order: effective range, saved input and lock state. */
350
+ export type HostedOpenAmountCheckoutOrder = Omit<OpenAmountCheckoutOrder, 'openAmount'> & {
351
+ openAmount: HostedOpenAmount;
352
+ /** Computed server-side from the order's payments; null means the buyer may change the amount. */
353
+ amountLock: AmountLockReasonType | null;
354
+ };
355
+ export type HostedCheckoutOrder = FixedAmountCheckoutOrder | HostedOpenAmountCheckoutOrder;
234
356
  export type CheckoutPaymentQuote = {
357
+ /** Full-size economics when Peer funds a smaller executable intent. */
358
+ amountAdjustment?: {
359
+ requestedSignalAmountRaw: string;
360
+ buyerFiatAmount: string;
361
+ };
235
362
  conversionRate?: string;
236
363
  signalIntent: {
237
364
  processorName: string;
@@ -266,6 +393,8 @@ export type CheckoutNearbySuggestion = {
266
393
  tokenAmount: string;
267
394
  percentDifference: string;
268
395
  rail: string;
396
+ /** Open-amount orders only: the suggestion in the quote's `fiatCurrency`, 2 dp, rounded down. */
397
+ inputAmount?: string;
269
398
  };
270
399
  export type CheckoutNearbySuggestions = {
271
400
  status: 'suggestions' | 'none' | 'ineligible' | 'unavailable';
@@ -308,6 +437,31 @@ export type CheckoutQuotes = {
308
437
  fiatCurrency: string;
309
438
  platforms: CheckoutQuoteEntry[];
310
439
  nearbySuggestions?: CheckoutNearbySuggestions;
440
+ /** Open order with no saved amount and no `amount` query parameter: `platforms` is empty. */
441
+ amountRequired?: true;
442
+ /** Open orders, when `amount` (in `fiatCurrency`) was sent: the draft converted to USDC. */
443
+ amountUsdc?: string;
444
+ /** Open orders, when `amount` was sent: Apple Pay pricing of the draft. */
445
+ applePay?: {
446
+ chargeUsdcAmount: string | null;
447
+ eligible: boolean;
448
+ };
449
+ /** Unlocked open orders that are not fulfilled or cancelled, with or without `amount`: the range and presets in `fiatCurrency`. */
450
+ openAmountDisplay?: OpenAmountDisplay;
451
+ };
452
+ export declare const PaymentPenaltyKind: {
453
+ readonly PURCHASE_PROTECTION: "PURCHASE_PROTECTION";
454
+ readonly CROSS_CURRENCY: "CROSS_CURRENCY";
455
+ };
456
+ export type PaymentPenaltyKindType = (typeof PaymentPenaltyKind)[keyof typeof PaymentPenaltyKind];
457
+ /** One attestation-applied reduction of the credited fiat amount. Amounts are in the payment's `currency`. */
458
+ export type PaymentPenalty = {
459
+ kind: PaymentPenaltyKindType;
460
+ penaltyBps: number;
461
+ /** Pre-penalty amount in `payment.currency`, 2-decimal string. */
462
+ originalAmount: string;
463
+ /** Post-penalty amount actually credited, same units. */
464
+ attestedAmount: string;
311
465
  };
312
466
  export type CheckoutPayment = {
313
467
  id: string;
@@ -315,6 +469,7 @@ export type CheckoutPayment = {
315
469
  status: CheckoutPaymentStatusType;
316
470
  chargebackStatus: PaymentChargebackStatusType;
317
471
  chargeback: PaymentChargebackFact | null;
472
+ penalties: PaymentPenalty[];
318
473
  rail: string;
319
474
  paymentMethodId: string | null;
320
475
  proofMode: ProofMode;
@@ -346,15 +501,25 @@ export type CheckoutAggregatePayment = Omit<CheckoutPayment, 'paymentMethodId'>
346
501
  paymentMethodId?: string | null;
347
502
  };
348
503
  export type CheckoutAggregate = {
349
- order: CheckoutOrder;
504
+ order: HostedCheckoutOrder;
350
505
  merchant: CheckoutMerchant;
351
506
  currentPayment: CheckoutAggregatePayment | null;
352
507
  };
508
+ /** Public GET /api/v1/orders/:orderId responseObject. */
509
+ export type HostedCheckoutResponse = CheckoutAggregate & {
510
+ paymentCreationPaused: boolean;
511
+ };
353
512
  export type CreateOrderResponse = {
354
513
  order: CheckoutOrder;
514
+ } & ({
355
515
  orderToken: string;
356
- };
357
- export type CreatePaymentRequest = {
516
+ idempotentReplay?: never;
517
+ } | {
518
+ orderToken: null;
519
+ idempotentReplay: true;
520
+ });
521
+ type CreatePaymentRequestBase = {
522
+ onrampProvider?: 'coinbase_apple_pay';
358
523
  rail: string;
359
524
  paymentMethodId?: string;
360
525
  fiatCurrency?: string;
@@ -364,6 +529,23 @@ export type CreatePaymentRequest = {
364
529
  excludedPayToValues?: string[];
365
530
  refundTo?: string;
366
531
  };
532
+ /**
533
+ * Open-amount orders: `amount`, the fiat `amountCurrency` it is typed in (the checkout's selected
534
+ * currency, sent on crypto and Apple Pay starts too) and the `amountVersion` the buyer loaded travel
535
+ * together, or not at all.
536
+ * On fiat rails, starts with `amount` require `fiatCurrency` to equal `amountCurrency`;
537
+ * omitted `fiatCurrency` means USD. A mismatch returns HTTP 400. Crypto and Apple Pay
538
+ * starts are exempt from this check.
539
+ */
540
+ export type CreatePaymentRequest = CreatePaymentRequestBase & ({
541
+ amount?: never;
542
+ amountCurrency?: never;
543
+ expectedAmountVersion?: never;
544
+ } | {
545
+ amount: string;
546
+ amountCurrency: string;
547
+ expectedAmountVersion: number;
548
+ });
367
549
  export type CheckoutPaymentCreationResponse = CheckoutPayment & {
368
550
  relayerTransactionId?: string;
369
551
  recipientRecovery?: 'matched' | 'missed' | 'not_applicable';
@@ -371,9 +553,9 @@ export type CheckoutPaymentCreationResponse = CheckoutPayment & {
371
553
  export type PaymentDeeplinkResponse = {
372
554
  paymentId: string;
373
555
  orderId: string;
374
- intentHash: string;
556
+ intentHash: string | null;
375
557
  url: string;
376
- proofSubmissionUrl: string;
558
+ proofSubmissionUrl: string | null;
377
559
  checkoutReturnUrl: string;
378
560
  linkKind?: 'app_clip' | 'deeplink';
379
561
  };
@@ -382,7 +564,9 @@ export type MerchantConfig = {
382
564
  id: string;
383
565
  merchantId: string;
384
566
  feePayer: FeePayerType;
567
+ buyerFeeShareBps: number;
385
568
  enabledRails: string[];
569
+ applePayAvailable: boolean;
386
570
  defaultPaymentCurrency: string | null;
387
571
  destinationChainId: string;
388
572
  destinationToken: string;
@@ -393,15 +577,27 @@ export type MerchantConfig = {
393
577
  platformReferralFeeConfig: ReferralFeeConfig | null;
394
578
  referralSplitConfig: ReferralSplitConfig | null;
395
579
  flatFeePricing: boolean;
580
+ /** Admin-managed: this merchant may create Master Merchant Account sub-merchants. */
581
+ masterMerchantEnabled: boolean;
582
+ /** Admin-managed cap, in bps, for the master merchant fee on this merchant's sub-merchants; null means no Master Merchant Account-specific cap. */
583
+ masterMerchantMaxFeeBps: number | null;
396
584
  createdAt: string;
397
585
  updatedAt: string | null;
398
586
  };
587
+ export declare const MerchantUserRole: {
588
+ readonly OWNER: "OWNER";
589
+ readonly MANAGER: "MANAGER";
590
+ readonly CASHIER: "CASHIER";
591
+ };
592
+ export type MerchantUserRoleType = typeof MerchantUserRole[keyof typeof MerchantUserRole];
399
593
  export type MerchantUser = {
400
594
  id: string;
401
595
  email: string | null;
402
596
  privyUserId: string | null;
403
597
  v1PrivyUserId: string | null;
404
- role: 'OWNER' | 'MANAGER' | 'CASHIER';
598
+ role: MerchantUserRoleType;
599
+ /** Master Merchant Account seat after an ownership transfer: it cannot be removed by merchant users, only by an admin. */
600
+ removalLocked: boolean;
405
601
  merchantId: string | null;
406
602
  createdAt: string;
407
603
  updatedAt: string | null;
@@ -417,6 +613,8 @@ export type MerchantProfile = {
417
613
  onboardingCompletedAt: string | null;
418
614
  onboardingSkippedAt: string | null;
419
615
  apiKey: string;
616
+ /** Canonical IPv4/IPv6 CIDR entries allowed to use the API key; empty means the allowlist is off. */
617
+ apiKeyIpAllowlist: string[];
420
618
  environment: MerchantEnvironmentType;
421
619
  sandboxMerchantId: string | null;
422
620
  inPersonCheckoutEnabled: boolean;
@@ -425,12 +623,16 @@ export type MerchantProfile = {
425
623
  v1EvmWalletAddress: string | null;
426
624
  v1SolanaWalletAddress: string | null;
427
625
  tier: MerchantTierName | null;
626
+ /** The Master Merchant Account merchant that created this sub-merchant; null for every other merchant. */
627
+ masterMerchantId: string | null;
428
628
  createdAt: string;
429
629
  updatedAt: string | null;
430
630
  merchantConfig: MerchantConfig | null;
431
631
  merchantUsers: MerchantUser[];
432
632
  };
633
+ export declare const PAYMENT_CREATION_PAUSED_MESSAGE = "Payments are temporarily paused. Please try again shortly.";
433
634
  export declare const OrderErrorCode: {
635
+ readonly PAYMENTS_PAUSED: "PAYMENTS_PAUSED";
434
636
  readonly PROOF_INVALID: "PROOF_INVALID";
435
637
  readonly PROOF_EXPIRED: "PROOF_EXPIRED";
436
638
  readonly PROOF_RECIPIENT_MISMATCH: "PROOF_RECIPIENT_MISMATCH";
@@ -443,6 +645,7 @@ export declare const OrderErrorCode: {
443
645
  readonly ATTESTATION_ERROR: "ATTESTATION_ERROR";
444
646
  readonly BRIDGE_TIMEOUT: "BRIDGE_TIMEOUT";
445
647
  readonly FEE_THRESHOLD_EXCEEDED: "FEE_THRESHOLD_EXCEEDED";
648
+ readonly INTENT_ABOVE_MAX: "INTENT_ABOVE_MAX";
446
649
  readonly SDK_ERROR: "SDK_ERROR";
447
650
  readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
448
651
  };
@@ -691,7 +894,14 @@ export type StartSessionRequest = {
691
894
  originToken: PayCryptoTokenSymbol;
692
895
  };
693
896
  export type RelayCryptoPaymentStatus = 'refund' | 'delayed' | 'waiting' | 'failure' | 'pending' | 'success';
897
+ export type NearIntentsPaymentDetails = {
898
+ status: 'PENDING_DEPOSIT' | 'KNOWN_DEPOSIT_TX' | 'INCOMPLETE_DEPOSIT' | 'PROCESSING' | 'SUCCESS' | 'REFUNDED' | 'FAILED';
899
+ deadline: string;
900
+ refundAddress: string;
901
+ refundedAmount?: string;
902
+ };
694
903
  export type CheckoutCryptoPayment = {
904
+ nearIntents?: NearIntentsPaymentDetails;
695
905
  requestId: string;
696
906
  status: RelayCryptoPaymentStatus;
697
907
  depositAddress: string;
@@ -788,6 +998,12 @@ export type OnboardingStepState = {
788
998
  status: OnboardingStepStatusValue;
789
999
  verifiedBy: OnboardingStepVerifiedByValue;
790
1000
  };
1001
+ /**
1002
+ * responseObject of GET /api/v1/merchants/dashboard/me/onboarding,
1003
+ * POST /api/v1/merchants/dashboard/me/onboarding/steps/:stepId/ack, and
1004
+ * POST /api/v1/merchants/dashboard/me/onboarding/skip.
1005
+ * For POST routes, this is the state after the write is applied.
1006
+ */
791
1007
  export type MerchantOnboardingResponse = {
792
1008
  path: MerchantIntegrationPathValue | null;
793
1009
  sandboxApiKey: string | null;
@@ -795,11 +1011,25 @@ export type MerchantOnboardingResponse = {
795
1011
  skippedAt: string | null;
796
1012
  steps: OnboardingStepState[];
797
1013
  };
1014
+ export declare const MERCHANT_REFERRAL_FEE_BPS_BY_TIER: Readonly<Record<MerchantTierName, number>>;
1015
+ export type MerchantReferralReferredMerchant = {
1016
+ id: string;
1017
+ name: string;
1018
+ createdAt: string;
1019
+ };
1020
+ export type MerchantReferralProgramResponse = {
1021
+ code: string;
1022
+ referralFeeBpsByTier: Readonly<Record<MerchantTierName, number>>;
1023
+ recipientAddress: string;
1024
+ totalReferred: number;
1025
+ referredMerchants: MerchantReferralReferredMerchant[];
1026
+ };
798
1027
  export declare const WebhookEventType: {
799
1028
  readonly ORDER_CREATED: "ORDER_CREATED";
800
1029
  readonly ORDER_FULFILLED: "ORDER_FULFILLED";
801
1030
  readonly ORDER_CANCELLED: "ORDER_CANCELLED";
802
1031
  readonly ORDER_RESIZED: "ORDER_RESIZED";
1032
+ readonly ORDER_AMOUNT_SET: "ORDER_AMOUNT_SET";
803
1033
  readonly PAYMENT_CREATED: "PAYMENT_CREATED";
804
1034
  readonly PAYMENT_SETTLED: "PAYMENT_SETTLED";
805
1035
  readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
@@ -814,8 +1044,21 @@ export declare const WebhookEventType: {
814
1044
  readonly PAYMENT_CHARGEBACKED: "PAYMENT_CHARGEBACKED";
815
1045
  readonly ORDER_PARTIALLY_CHARGEBACKED: "ORDER_PARTIALLY_CHARGEBACKED";
816
1046
  readonly ORDER_CHARGEBACKED: "ORDER_CHARGEBACKED";
1047
+ readonly CASHOUT_ORDER_CREATED: "CASHOUT_ORDER_CREATED";
1048
+ readonly CASHOUT_ORDER_CANCELLED: "CASHOUT_ORDER_CANCELLED";
1049
+ readonly CASHOUT_ORDER_PARTIALLY_FUNDED: "CASHOUT_ORDER_PARTIALLY_FUNDED";
1050
+ readonly CASHOUT_ORDER_FUNDED: "CASHOUT_ORDER_FUNDED";
1051
+ readonly CASHOUT_ORDER_MATCHED: "CASHOUT_ORDER_MATCHED";
1052
+ readonly CASHOUT_ORDER_PARTIALLY_PAID: "CASHOUT_ORDER_PARTIALLY_PAID";
1053
+ readonly CASHOUT_ORDER_SETTLED: "CASHOUT_ORDER_SETTLED";
1054
+ readonly CASHOUT_ORDER_EXPIRED: "CASHOUT_ORDER_EXPIRED";
817
1055
  };
818
1056
  export type WebhookEventTypeValue = typeof WebhookEventType[keyof typeof WebhookEventType];
1057
+ /** Cashout events carry a CashoutView, not the order envelope. */
1058
+ export declare const CASHOUT_WEBHOOK_EVENT_TYPES: readonly ["CASHOUT_ORDER_CREATED", "CASHOUT_ORDER_CANCELLED", "CASHOUT_ORDER_PARTIALLY_FUNDED", "CASHOUT_ORDER_FUNDED", "CASHOUT_ORDER_MATCHED", "CASHOUT_ORDER_PARTIALLY_PAID", "CASHOUT_ORDER_SETTLED", "CASHOUT_ORDER_EXPIRED"];
1059
+ export type CashoutWebhookEventTypeValue = typeof CASHOUT_WEBHOOK_EVENT_TYPES[number];
1060
+ export type OrderWebhookEventTypeValue = Exclude<WebhookEventTypeValue, CashoutWebhookEventTypeValue>;
1061
+ export declare function isCashoutWebhookEventType(type: string): type is CashoutWebhookEventTypeValue;
819
1062
  export declare const WebhookDeliveryStatus: {
820
1063
  readonly PENDING: "PENDING";
821
1064
  readonly DELIVERED: "DELIVERED";
@@ -848,9 +1091,9 @@ export type WebhookDelivery = {
848
1091
  responseCode?: number | null;
849
1092
  createdAt: string;
850
1093
  };
851
- export type WebhookPayload = {
1094
+ export type OrderWebhookPayload = {
852
1095
  id: string;
853
- type: WebhookEventTypeValue;
1096
+ type: OrderWebhookEventTypeValue;
854
1097
  timestamp: string;
855
1098
  data: {
856
1099
  order: CheckoutOrder | null;
@@ -868,8 +1111,49 @@ export type WebhookPayload = {
868
1111
  previousAmountUsdc: string;
869
1112
  newAmountUsdc: string;
870
1113
  };
1114
+ /** Only on `ORDER_AMOUNT_SET`. */
1115
+ amountChange?: OrderAmountChange;
1116
+ };
1117
+ };
1118
+ /** Bumped only on a breaking change to a cashout payload. */
1119
+ export declare const CASHOUT_WEBHOOK_VERSION = 1;
1120
+ /** One buyer payment that left part of the cashout unpaid; decimal USDC. */
1121
+ export interface CashoutPartialPayment {
1122
+ /** The cashout's depositAmount: what buyers can pay in total. */
1123
+ expectedAmount: string;
1124
+ /** What buyers have paid so far, this fill included. */
1125
+ paidAmount: string;
1126
+ /** expectedAmount − paidAmount. */
1127
+ remainingAmount: string;
1128
+ fill: {
1129
+ amount: string;
1130
+ txHash: string;
871
1131
  };
1132
+ }
1133
+ export type CashoutWebhookEventData = {
1134
+ readonly type: Exclude<CashoutWebhookEventTypeValue, typeof WebhookEventType.CASHOUT_ORDER_PARTIALLY_PAID>;
1135
+ readonly data: CashoutView;
1136
+ } | {
1137
+ readonly type: typeof WebhookEventType.CASHOUT_ORDER_PARTIALLY_PAID;
1138
+ readonly data: CashoutView;
1139
+ readonly partialPayment: CashoutPartialPayment;
1140
+ };
1141
+ export type CashoutWebhookPayload = {
1142
+ id: string;
1143
+ type: Exclude<CashoutWebhookEventTypeValue, typeof WebhookEventType.CASHOUT_ORDER_PARTIALLY_PAID>;
1144
+ timestamp: string;
1145
+ version: typeof CASHOUT_WEBHOOK_VERSION;
1146
+ data: CashoutView;
1147
+ } | {
1148
+ id: string;
1149
+ type: typeof WebhookEventType.CASHOUT_ORDER_PARTIALLY_PAID;
1150
+ timestamp: string;
1151
+ version: typeof CASHOUT_WEBHOOK_VERSION;
1152
+ data: CashoutView;
1153
+ partialPayment: CashoutPartialPayment;
872
1154
  };
1155
+ export type WebhookPayload = OrderWebhookPayload | CashoutWebhookPayload;
1156
+ export declare function isCashoutWebhook(payload: WebhookPayload): payload is CashoutWebhookPayload;
873
1157
  export type CreateWebhookRequest = {
874
1158
  url: string;
875
1159
  events?: WebhookEventTypeValue[];
@@ -897,4 +1181,687 @@ export type TestWebhookResponse = {
897
1181
  responseCode?: number | null;
898
1182
  error?: string | null;
899
1183
  };
1184
+ /**
1185
+ * Wallet-snapshot fence rejections (ownership-transfer era rule). PR 4-6 add keys to this object.
1186
+ * MERCHANT_OWNERSHIP_CHANGED is retryable: an order insert lost the era it read its wallet in.
1187
+ * ORDER_FROM_PREVIOUS_OWNER is final: the order belongs to an earlier owner's era.
1188
+ */
1189
+ export declare const MerchantOwnershipErrorCode: {
1190
+ readonly MERCHANT_OWNERSHIP_CHANGED: "MERCHANT_OWNERSHIP_CHANGED";
1191
+ readonly ORDER_FROM_PREVIOUS_OWNER: "ORDER_FROM_PREVIOUS_OWNER";
1192
+ readonly MEMBER_LOCKED: "MEMBER_LOCKED";
1193
+ /** 403: the current merchant is not an enabled, LIVE, eligible Master Merchant Account. */
1194
+ readonly MASTER_MERCHANT_NOT_ENABLED: "MASTER_MERCHANT_NOT_ENABLED";
1195
+ /** 422: the master merchant fee is above the Master Merchant Account's masterMerchantMaxFeeBps, only when the Master Merchant Account has a cap. */
1196
+ readonly MASTER_MERCHANT_FEE_EXCEEDS_CAP: "MASTER_MERCHANT_FEE_EXCEEDS_CAP";
1197
+ /** 422: a payment method's configured fees for some amount band would exceed the max fee. */
1198
+ readonly MASTER_MERCHANT_FEE_EXCEEDS_MAX_FEE: "MASTER_MERCHANT_FEE_EXCEEDS_MAX_FEE";
1199
+ /** 409: the Master Merchant Account can no longer change this sub merchant's fee (transferred, or a transfer is pending). */
1200
+ readonly MASTER_MERCHANT_FEE_LOCKED: "MASTER_MERCHANT_FEE_LOCKED";
1201
+ readonly TRANSFER_ALREADY_PENDING: "TRANSFER_ALREADY_PENDING";
1202
+ readonly WALLET_SETUP_REQUIRED: "WALLET_SETUP_REQUIRED";
1203
+ readonly TERMS_CHANGED: "TERMS_CHANGED";
1204
+ readonly TRANSFER_NOT_FOUND: "TRANSFER_NOT_FOUND";
1205
+ readonly TRANSFER_EMAIL_MISMATCH: "TRANSFER_EMAIL_MISMATCH";
1206
+ readonly TRANSFER_UNAVAILABLE: "TRANSFER_UNAVAILABLE";
1207
+ };
1208
+ export type MerchantOwnershipErrorCodeType = typeof MerchantOwnershipErrorCode[keyof typeof MerchantOwnershipErrorCode];
1209
+ export declare const MERCHANT_OWNERSHIP_CHANGED_MESSAGE = "The merchant account changed owners while this order was being created. Retry to create it for the new owner.";
1210
+ export declare const ORDER_FROM_PREVIOUS_OWNER_MESSAGE = "This order was created before the merchant account changed owners. Ask the merchant for a new payment link.";
1211
+ export declare const ORDER_FROM_PREVIOUS_OWNER_REFUND_MESSAGE = "This order was created before the merchant account changed owners, so it cannot be refunded from this account.";
1212
+ /** Response copy for MEMBER_LOCKED: the Master Merchant Account seat after an ownership transfer can only be removed by an admin. */
1213
+ export declare const MEMBER_LOCKED_MESSAGE = "Locked merchant member can only be removed by an admin";
1214
+ export type OwnershipTransferErrorCodeType = typeof MerchantOwnershipErrorCode.TRANSFER_ALREADY_PENDING | typeof MerchantOwnershipErrorCode.WALLET_SETUP_REQUIRED | typeof MerchantOwnershipErrorCode.TERMS_CHANGED | typeof MerchantOwnershipErrorCode.TRANSFER_NOT_FOUND | typeof MerchantOwnershipErrorCode.TRANSFER_EMAIL_MISMATCH | typeof MerchantOwnershipErrorCode.TRANSFER_UNAVAILABLE;
1215
+ /** One user-facing message per ownership-transfer error; the API and the CLI simulator both send these. */
1216
+ export declare const OWNERSHIP_TRANSFER_ERROR_MESSAGES: Readonly<Record<OwnershipTransferErrorCodeType, string>>;
1217
+ /**
1218
+ * Routing states POST /auth/login returns (HTTP 200, `merchant: null`) instead of auto-claiming an
1219
+ * invite or auto-creating a merchant, while an ownership transfer applies to a user with no merchant.
1220
+ */
1221
+ export declare const OwnershipTransferLoginState: {
1222
+ readonly PENDING_OWNERSHIP_TRANSFER: "PENDING_OWNERSHIP_TRANSFER";
1223
+ readonly OWNERSHIP_TRANSFER_EMAIL_MISMATCH: "OWNERSHIP_TRANSFER_EMAIL_MISMATCH";
1224
+ readonly OWNERSHIP_TRANSFER_UNAVAILABLE: "OWNERSHIP_TRANSFER_UNAVAILABLE";
1225
+ };
1226
+ export type OwnershipTransferLoginStateType = typeof OwnershipTransferLoginState[keyof typeof OwnershipTransferLoginState];
1227
+ /** Discriminator of POST /auth/ownership-transfers/preview. EMAIL_MISMATCH is the spec's `emailMatches: false`. */
1228
+ export declare const OwnershipTransferPreviewState: {
1229
+ readonly PENDING: "PENDING";
1230
+ readonly EMAIL_MISMATCH: "EMAIL_MISMATCH";
1231
+ readonly ACCEPTED: "ACCEPTED";
1232
+ };
1233
+ export type OwnershipTransferPreviewStateType = typeof OwnershipTransferPreviewState[keyof typeof OwnershipTransferPreviewState];
1234
+ /** Mirrors the Prisma enum MerchantOwnershipTransferStatus for pure (Prisma-free) wire schemas. */
1235
+ export declare const OwnershipTransferStatus: {
1236
+ readonly PENDING: "PENDING";
1237
+ readonly ACCEPTED: "ACCEPTED";
1238
+ readonly CANCELLED: "CANCELLED";
1239
+ readonly EXPIRED: "EXPIRED";
1240
+ };
1241
+ export type OwnershipTransferStatusType = typeof OwnershipTransferStatus[keyof typeof OwnershipTransferStatus];
1242
+ export declare const MerchantOwnershipTransferCancelReason: {
1243
+ readonly MASTER_MERCHANT_CANCELLED: "MASTER_MERCHANT_CANCELLED";
1244
+ readonly TERMS_CHANGED: "TERMS_CHANGED";
1245
+ readonly MASTER_MERCHANT_FLAG_REMOVED: "MASTER_MERCHANT_FLAG_REMOVED";
1246
+ };
1247
+ export type MerchantOwnershipTransferCancelReasonType = typeof MerchantOwnershipTransferCancelReason[keyof typeof MerchantOwnershipTransferCancelReason];
1248
+ export declare const OwnershipTransferMasterMerchantPermission: {
1249
+ readonly CHECKOUT_CONFIG: "CHECKOUT_CONFIG";
1250
+ readonly TEAM: "TEAM";
1251
+ };
1252
+ export type OwnershipTransferMasterMerchantPermissionType = typeof OwnershipTransferMasterMerchantPermission[keyof typeof OwnershipTransferMasterMerchantPermission];
1253
+ /** What the Master Merchant Account's locked MANAGER seat keeps after a transfer (spec decisions 2 and 9; refunds are OWNER-only); the accept page lists exactly these. */
1254
+ export declare const OWNERSHIP_TRANSFER_MASTER_MERCHANT_PERMISSIONS: readonly OwnershipTransferMasterMerchantPermissionType[];
1255
+ /** "alice@example.com" → "a•••@example.com". The input is a validated, lowercased address. */
1256
+ export declare function maskOwnershipTransferEmail(email: string): string;
1257
+ export declare const CashoutStatus: {
1258
+ readonly AWAITING_FUNDING: "AWAITING_FUNDING";
1259
+ readonly FUNDED: "FUNDED";
1260
+ readonly READY: "READY";
1261
+ readonly LISTING: "LISTING";
1262
+ readonly PAYING: "PAYING";
1263
+ readonly SETTLED: "SETTLED";
1264
+ readonly CANCELLING: "CANCELLING";
1265
+ readonly CANCELLED: "CANCELLED";
1266
+ readonly EXPIRED: "EXPIRED";
1267
+ };
1268
+ export type CashoutStatusType = typeof CashoutStatus[keyof typeof CashoutStatus];
1269
+ export declare const CashoutFundingStatus: {
1270
+ readonly AWAITING_FUNDING: "AWAITING_FUNDING";
1271
+ readonly PARTIALLY_FUNDED: "PARTIALLY_FUNDED";
1272
+ readonly FUNDED: "FUNDED";
1273
+ readonly FUNDING_EXPIRED: "FUNDING_EXPIRED";
1274
+ };
1275
+ export type CashoutFundingStatusType = typeof CashoutFundingStatus[keyof typeof CashoutFundingStatus];
1276
+ export declare const CashoutCancelSource: {
1277
+ readonly CHECKOUT: "CHECKOUT";
1278
+ readonly MERCHANT: "MERCHANT";
1279
+ readonly PEER_APP: "PEER_APP";
1280
+ };
1281
+ export type CashoutCancelSourceType = typeof CashoutCancelSource[keyof typeof CashoutCancelSource];
1282
+ export declare const CashoutPayoutKind: {
1283
+ readonly ESCROW: "ESCROW";
1284
+ readonly CRYPTO: "CRYPTO";
1285
+ };
1286
+ export type CashoutPayoutKindType = typeof CashoutPayoutKind[keyof typeof CashoutPayoutKind];
1287
+ export declare const CashoutAttemptStatus: {
1288
+ readonly ACTIVE: "ACTIVE";
1289
+ readonly CLOSED: "CLOSED";
1290
+ readonly SETTLED: "SETTLED";
1291
+ readonly FAILED: "FAILED";
1292
+ };
1293
+ export type CashoutAttemptStatusType = typeof CashoutAttemptStatus[keyof typeof CashoutAttemptStatus];
1294
+ /** Fiat payout methods, in the order players see them: SAR rails, then buyer-proof rails. */
1295
+ export declare const CashoutFiatRail: {
1296
+ readonly VENMO: "venmo";
1297
+ readonly CASHAPP: "cashapp";
1298
+ readonly PAYPAL: "paypal";
1299
+ readonly ZELLE: "zelle";
1300
+ readonly REVOLUT: "revolut";
1301
+ readonly CHIME: "chime";
1302
+ };
1303
+ export type CashoutFiatRailType = typeof CashoutFiatRail[keyof typeof CashoutFiatRail];
1304
+ /** One rail per crypto payout network, with checkout's rail ids (any-coin spec "Cashout rails"); the player sees them as one "Crypto" option. */
1305
+ export declare const CashoutCryptoRail: {
1306
+ readonly RELAY_1: "relay_1";
1307
+ readonly RELAY_10: "relay_10";
1308
+ readonly RELAY_56: "relay_56";
1309
+ readonly RELAY_137: "relay_137";
1310
+ readonly RELAY_480: "relay_480";
1311
+ readonly RELAY_999: "relay_999";
1312
+ readonly RELAY_5042: "relay_5042";
1313
+ readonly RELAY_8453: "relay_8453";
1314
+ readonly RELAY_42161: "relay_42161";
1315
+ readonly RELAY_8253038: "relay_8253038";
1316
+ readonly RELAY_728126428: "relay_728126428";
1317
+ readonly RELAY_792703809: "relay_792703809";
1318
+ /** ZEC on Zcash through NEAR Intents (Zcash spec "Catalog, route and address"); checkout's ZCASH_RAIL. */
1319
+ readonly NEAR_INTENTS_133701: "near_intents_133701";
1320
+ };
1321
+ export type CashoutCryptoRailType = typeof CashoutCryptoRail[keyof typeof CashoutCryptoRail];
1322
+ /** Every cashout rail, in rail order: fiat, then the crypto networks. */
1323
+ export declare const CashoutRail: {
1324
+ readonly RELAY_1: "relay_1";
1325
+ readonly RELAY_10: "relay_10";
1326
+ readonly RELAY_56: "relay_56";
1327
+ readonly RELAY_137: "relay_137";
1328
+ readonly RELAY_480: "relay_480";
1329
+ readonly RELAY_999: "relay_999";
1330
+ readonly RELAY_5042: "relay_5042";
1331
+ readonly RELAY_8453: "relay_8453";
1332
+ readonly RELAY_42161: "relay_42161";
1333
+ readonly RELAY_8253038: "relay_8253038";
1334
+ readonly RELAY_728126428: "relay_728126428";
1335
+ readonly RELAY_792703809: "relay_792703809";
1336
+ /** ZEC on Zcash through NEAR Intents (Zcash spec "Catalog, route and address"); checkout's ZCASH_RAIL. */
1337
+ readonly NEAR_INTENTS_133701: "near_intents_133701";
1338
+ readonly VENMO: "venmo";
1339
+ readonly CASHAPP: "cashapp";
1340
+ readonly PAYPAL: "paypal";
1341
+ readonly ZELLE: "zelle";
1342
+ readonly REVOLUT: "revolut";
1343
+ readonly CHIME: "chime";
1344
+ };
1345
+ export type CashoutRailType = CashoutFiatRailType | CashoutCryptoRailType;
1346
+ /** Fiat rails whose account the player connects so Peer can confirm buyer payments; derived from SAR_SUPPORTED_FIAT_RAILS. */
1347
+ export type CashoutSarRailType = Extract<CashoutFiatRailType, SarSupportedFiatRail>;
1348
+ /** Fiat rails with no connect step: the buyer proves the payment with the PeerAuth extension or the Peer app. */
1349
+ export type CashoutBuyerProofRailType = Exclude<CashoutFiatRailType, CashoutSarRailType>;
1350
+ export declare const CashoutPayoutProvider: {
1351
+ readonly RELAY: "RELAY";
1352
+ readonly NEAR_INTENTS: "NEAR_INTENTS";
1353
+ };
1354
+ export type CashoutPayoutProviderType = typeof CashoutPayoutProvider[keyof typeof CashoutPayoutProvider];
1355
+ export declare const CashoutPayoutBridgeStatus: {
1356
+ readonly QUOTED: "QUOTED";
1357
+ readonly NOT_SENT: "NOT_SENT";
1358
+ readonly BRIDGING: "BRIDGING";
1359
+ readonly DELIVERED: "DELIVERED";
1360
+ readonly REFUNDED: "REFUNDED";
1361
+ };
1362
+ export type CashoutPayoutBridgeStatusType = typeof CashoutPayoutBridgeStatus[keyof typeof CashoutPayoutBridgeStatus];
1363
+ /** A crypto payout's coin, network and the player's address there. */
1364
+ export interface CashoutCryptoDestination {
1365
+ chainId: number;
1366
+ /** The shared catalog's address for the token on chainId. */
1367
+ tokenAddress: string;
1368
+ symbol: PayCryptoTokenSymbol;
1369
+ decimals: number;
1370
+ /** Canonical: EVM checksummed, bech32 lower-case, base58 as entered. */
1371
+ address: string;
1372
+ }
1373
+ /** Body of the crypto payout-method, payout-quote and send-to-address requests. The rail names the network. */
1374
+ export interface CashoutPayoutDestinationRequest {
1375
+ rail: CashoutCryptoRailType;
1376
+ tokenAddress: string;
1377
+ address: string;
1378
+ }
1379
+ /** A crypto payout method: the network's rail and where on it the player takes the payout. */
1380
+ export interface CashoutCryptoMethod {
1381
+ rail: CashoutCryptoRailType;
1382
+ destination: CashoutCryptoDestination;
1383
+ }
1384
+ /** POST /api/v1/cashout-checkout/:id/payout-quote. Not a promise. */
1385
+ export interface CashoutPayoutQuote {
1386
+ destination: CashoutCryptoDestination;
1387
+ /** Decimal USDC that would leave the player's wallet. */
1388
+ usdcAmount: string;
1389
+ /** Decimal destination token; equals usdcAmount for USDC on Base. */
1390
+ estimatedAmount: string;
1391
+ quotedAt: string;
1392
+ }
1393
+ /** The player's bridged payout, newest attempt first; never NOT_SENT. */
1394
+ export interface CashoutPayoutBridgeView {
1395
+ provider: CashoutPayoutProviderType;
1396
+ status: Exclude<CashoutPayoutBridgeStatusType, typeof CashoutPayoutBridgeStatus.NOT_SENT>;
1397
+ destination: CashoutCryptoDestination;
1398
+ usdcAmount: string;
1399
+ /** The binding quote's output, decimal destination token. */
1400
+ estimatedAmount: string;
1401
+ deliveredAmount: string | null;
1402
+ destinationTxHash: string | null;
1403
+ /** Decimal USDC. */
1404
+ refundedAmount: string | null;
1405
+ refundTxHash: string | null;
1406
+ }
1407
+ export interface CashoutPartialFillView {
1408
+ /** Decimal USDC this buyer paid. */
1409
+ amount: string;
1410
+ txHash: string;
1411
+ paidAt: string;
1412
+ }
1413
+ /** Where a SETTLED cashout's USDC ended up; decimal USDC, "0.00" for a part that did not happen. */
1414
+ export interface CashoutSettlementBreakdown {
1415
+ /** Paid by buyers through the escrow, across every listing. */
1416
+ buyerPaidAmount: string;
1417
+ /** USDC that left the player's wallet for a crypto payout (direct or bridged) or a send-to-address remainder. */
1418
+ sentAmount: string;
1419
+ /** The player's recipient: EVM lower-case, Solana, Tron and Bitcoin canonical; never a deposit address. */
1420
+ sentTo: string | null;
1421
+ /** Left in, or returned to, the player's Peer wallet. */
1422
+ returnedAmount: string;
1423
+ /** Swept by the escrow as dust when it closed the deposit. */
1424
+ dustAmount: string;
1425
+ /** Σ refundLossUnits: USDC Relay kept on refunds; "0.00" when none. */
1426
+ refundFeeAmount: string;
1427
+ }
1428
+ /** Merchant-facing cashout. Never includes the Peer fee, the player's email, wallet or payee handle. */
1429
+ export interface CashoutView {
1430
+ cashoutId: string;
1431
+ merchantReference: string | null;
1432
+ status: CashoutStatusType;
1433
+ fundingStatus: CashoutFundingStatusType;
1434
+ payout: {
1435
+ amount: string;
1436
+ chainId: number;
1437
+ tokenAddress: string;
1438
+ decimals: number;
1439
+ };
1440
+ merchantFee: {
1441
+ bps: number;
1442
+ amount: string;
1443
+ };
1444
+ funding: {
1445
+ chainId: number;
1446
+ tokenAddress: string;
1447
+ decimals: number;
1448
+ /** Quoted amount to send, decimal funding token. */
1449
+ amount: string;
1450
+ /** Sent before the deadline, decimal funding token. */
1451
+ sentAmount: string;
1452
+ /** amount − sentAmount, never below zero; decimal funding token. */
1453
+ missingAmount: string;
1454
+ /** Payout plus buffer: the USDC the quote delivers, decimal USDC. */
1455
+ expectedAmount: string;
1456
+ /** Reached the player's wallet on Base, decimal USDC. */
1457
+ receivedAmount: string;
1458
+ /** Null once the cashout can no longer be funded. */
1459
+ depositAddress: string | null;
1460
+ /** Funding deadline; each on-time arrival moves it to at least the funding TTL (24 hours by default) after that check. */
1461
+ quoteExpiresAt: string;
1462
+ };
1463
+ depositAmount: string | null;
1464
+ /** What buyers have paid across every listing, partial fills included. */
1465
+ paidAmount: string;
1466
+ partialFills: CashoutPartialFillView[];
1467
+ /** Only when status is SETTLED. */
1468
+ settlement: CashoutSettlementBreakdown | null;
1469
+ attempt: {
1470
+ kind: CashoutPayoutKindType;
1471
+ rail: string | null;
1472
+ status: CashoutAttemptStatusType;
1473
+ } | null;
1474
+ /** Only when settled with a sent amount, including a send-to-address remainder. */
1475
+ payoutTransfer: {
1476
+ /** Where the player received it. */
1477
+ chainId: number;
1478
+ tokenAddress: string;
1479
+ decimals: number;
1480
+ address: string;
1481
+ /** Delivered, decimal destination token. */
1482
+ amount: string;
1483
+ /** The delivering transaction on chainId. */
1484
+ txHash: string;
1485
+ /** The USDC transfer on Base; settlement.sentAmount is its amount. */
1486
+ usdcTxHash: string;
1487
+ /** The bridge provider (RELAY or NEAR_INTENTS) when bridged; null for USDC on Base, where txHash = usdcTxHash. */
1488
+ provider: CashoutPayoutProviderType | null;
1489
+ } | null;
1490
+ cancelSource: CashoutCancelSourceType | null;
1491
+ returnUrl: string | null;
1492
+ expiresAt: string;
1493
+ fundedAt: string | null;
1494
+ settledAt: string | null;
1495
+ cancelledAt: string | null;
1496
+ createdAt: string;
1497
+ }
1498
+ export interface CreateCashoutRequest {
1499
+ merchantReference?: string;
1500
+ customerEmail: string;
1501
+ payout: {
1502
+ amount: string;
1503
+ chainId: number;
1504
+ tokenAddress: string;
1505
+ };
1506
+ funding: {
1507
+ chainId: number;
1508
+ tokenAddress: string;
1509
+ refundAddress?: string;
1510
+ };
1511
+ returnUrl?: string;
1512
+ /** Limits the cashout to these rails; never widens the merchant's (any-coin spec "Cashout rails"). */
1513
+ rails?: CashoutRailType[];
1514
+ }
1515
+ /** A replay with the same key and body returns the current checkout link, marked `idempotentReplay: true`. */
1516
+ export type CreateCashoutResponse = CashoutView & {
1517
+ checkoutUrl: string;
1518
+ idempotentReplay: boolean;
1519
+ };
1520
+ export interface ListCashoutsResponse {
1521
+ items: CashoutView[];
1522
+ page: number;
1523
+ limit: number;
1524
+ total: number;
1525
+ }
1526
+ /** A moment on a cashout's dashboard timeline. */
1527
+ export declare const CashoutTimelineEventType: {
1528
+ readonly CREATED: "CREATED";
1529
+ readonly PARTIALLY_FUNDED: "PARTIALLY_FUNDED";
1530
+ readonly FUNDED: "FUNDED";
1531
+ readonly FUNDING_EXPIRED: "FUNDING_EXPIRED";
1532
+ readonly SIGNED_IN: "SIGNED_IN";
1533
+ readonly METHOD_READY: "METHOD_READY";
1534
+ readonly LISTED: "LISTED";
1535
+ readonly TRANSFER_SENT: "TRANSFER_SENT";
1536
+ readonly MATCHED: "MATCHED";
1537
+ /** A buyer paid part of the listing; the rest is listed again or left for the player. */
1538
+ readonly PARTIALLY_PAID: "PARTIALLY_PAID";
1539
+ /** Pay set the deposit's intent range to what is left, so another buyer can take it. */
1540
+ readonly RELISTED: "RELISTED";
1541
+ readonly BUYER_DROPPED: "BUYER_DROPPED";
1542
+ readonly RECONNECT_NEEDED: "RECONNECT_NEEDED";
1543
+ readonly CANCEL_STARTED: "CANCEL_STARTED";
1544
+ /** The listing came back to the player's wallet so they can pick another payout method. */
1545
+ readonly LISTING_WITHDRAWN: "LISTING_WITHDRAWN";
1546
+ readonly SETTLED: "SETTLED";
1547
+ readonly CANCELLED: "CANCELLED";
1548
+ readonly FUNDING_ISSUE: "FUNDING_ISSUE";
1549
+ readonly PAYOUT_REFUNDED: "PAYOUT_REFUNDED";
1550
+ };
1551
+ export type CashoutTimelineEventTypeValue = typeof CashoutTimelineEventType[keyof typeof CashoutTimelineEventType];
1552
+ /** Largest merchant cashout payout step, in whole USDC. The smallest is the API's CASHOUT_MIN_USDC (10 in production). */
1553
+ export declare const CASHOUT_PAYOUT_STEP_MAX_USDC = 1000;
1554
+ /** Whole-USDC bounds for a merchant's cashout payout step in this environment. */
1555
+ export interface CashoutPayoutStepRange {
1556
+ min: number;
1557
+ max: number;
1558
+ }
1559
+ /** A merchant's cashout settings; the Peer fee is not the merchant's to see. */
1560
+ export interface CashoutSettings {
1561
+ rails: CashoutRailType[];
1562
+ /** Merchant fee in bps of the deposit, 0–1000. */
1563
+ feeBps: number;
1564
+ /** Whole USDC, within the environment's payout step range. */
1565
+ payoutStepUsdc: number;
1566
+ /** An https URL or a mailto: link; optional. Without it the player's checkout shows no contact line. */
1567
+ supportUrl: string | null;
1568
+ }
1569
+ export declare const CashoutFundingIssueKind: {
1570
+ readonly LATE_FUNDS: "LATE_FUNDS";
1571
+ readonly OVERPAYMENT: "OVERPAYMENT";
1572
+ readonly ROUTE_REFUND: "ROUTE_REFUND";
1573
+ };
1574
+ export type CashoutFundingIssueKindType = typeof CashoutFundingIssueKind[keyof typeof CashoutFundingIssueKind];
1575
+ export declare const CashoutFundingIssueResolution: {
1576
+ readonly RETURNED: "RETURNED";
1577
+ readonly CLAIMED: "CLAIMED";
1578
+ };
1579
+ export type CashoutFundingIssueResolutionType = typeof CashoutFundingIssueResolution[keyof typeof CashoutFundingIssueResolution];
1580
+ /** A funding token as offered to a merchant: `key` is "chainId:lowercaseAddress". */
1581
+ export interface CashoutFundingTokenOption {
1582
+ key: string;
1583
+ chainId: number;
1584
+ address: string;
1585
+ symbol: string;
1586
+ }
1587
+ /** GET /merchants/me/cashout-settings: the saved settings plus what Peer currently allows. */
1588
+ export interface CashoutSettingsView extends CashoutSettings {
1589
+ availableRails: CashoutRailType[];
1590
+ availableFundingTokens: CashoutFundingTokenOption[];
1591
+ payoutStepRange: CashoutPayoutStepRange;
1592
+ }
1593
+ /** Merchant-facing; never includes the admin's note or name. */
1594
+ export interface MerchantCashoutFundingIssue {
1595
+ kind: CashoutFundingIssueKindType;
1596
+ /** Decimal USDC; null for a route refund, which is paid back in the origin token. */
1597
+ amountUsdc: string | null;
1598
+ txHash: string | null;
1599
+ detectedAt: string;
1600
+ resolution: CashoutFundingIssueResolutionType | null;
1601
+ resolutionTxHash: string | null;
1602
+ resolvedAt: string | null;
1603
+ }
1604
+ export type CashoutPayoutMethodView = {
1605
+ rail: CashoutFiatRailType;
1606
+ handle: string;
1607
+ } | CashoutCryptoMethod;
1608
+ /** The dashboard's cashout: the API view plus what only the merchant's staff may see. */
1609
+ export interface MerchantCashoutView extends CashoutView {
1610
+ /** The player's email as given at create, stored lower-cased. */
1611
+ customerEmail: string;
1612
+ payoutMethod: CashoutPayoutMethodView | null;
1613
+ /** Null once the cashout is final. */
1614
+ checkoutUrl: string | null;
1615
+ }
1616
+ export interface CashoutTimelineEntry {
1617
+ type: CashoutTimelineEventTypeValue;
1618
+ text: string;
1619
+ txHash: string | null;
1620
+ /** The chain txHash is on; null when txHash isn't linked. */
1621
+ txChainId: number | null;
1622
+ occurredAt: string;
1623
+ }
1624
+ export interface CashoutWebhookDeliveryView {
1625
+ eventType: string;
1626
+ status: string;
1627
+ attempts: number;
1628
+ responseCode: number | null;
1629
+ lastAttemptAt: string | null;
1630
+ createdAt: string;
1631
+ }
1632
+ export interface MerchantCashoutDetail {
1633
+ cashout: MerchantCashoutView;
1634
+ timeline: CashoutTimelineEntry[];
1635
+ /** Not stored: what happens next from the current status, or null when final. */
1636
+ nextStep: string | null;
1637
+ webhooks: CashoutWebhookDeliveryView[];
1638
+ fundingIssues: MerchantCashoutFundingIssue[];
1639
+ }
1640
+ /** The dashboard's create form result; a replay returns the same cashout and its current link. */
1641
+ export type CreateMerchantCashoutResponse = MerchantCashoutView & {
1642
+ idempotentReplay: boolean;
1643
+ };
1644
+ export interface ListMerchantCashoutsResponse {
1645
+ items: MerchantCashoutView[];
1646
+ page: number;
1647
+ limit: number;
1648
+ total: number;
1649
+ }
1650
+ export interface AdminCashoutSettings {
1651
+ disabledRails: CashoutRailType[];
1652
+ disabledFundingTokens: string[];
1653
+ peerFeeRecipient: string;
1654
+ supportedFundingTokens: CashoutFundingTokenOption[];
1655
+ updatedAt: string;
1656
+ }
1657
+ export interface AdminCashoutMerchantConfig {
1658
+ merchantId: string;
1659
+ peerFeeBps: number;
1660
+ payoutStepUsdc: number;
1661
+ payoutStepRange: CashoutPayoutStepRange;
1662
+ fundingTokens: string[];
1663
+ /** Merchant cashout rails, edited by the merchant and Peer admins, in rail order. */
1664
+ rails: CashoutRailType[];
1665
+ /** Player support link; optional. */
1666
+ supportUrl: string | null;
1667
+ /** Merchant rails minus Peer's global disables and the fiat rails `DISABLED_RAILS` turns off, in rail order. */
1668
+ effectiveRails: CashoutRailType[];
1669
+ merchantFeeBps: number;
1670
+ merchantFeeRecipient: string | null;
1671
+ }
1672
+ export interface AdminCashoutFundingIssue extends MerchantCashoutFundingIssue {
1673
+ id: string;
1674
+ cashoutId: string;
1675
+ merchantId: string;
1676
+ merchantName: string;
1677
+ relayRequestId: string | null;
1678
+ resolutionNote: string | null;
1679
+ resolvedBy: string | null;
1680
+ }
1681
+ export interface AdminCashoutSupport {
1682
+ fundingIssues: AdminCashoutFundingIssue[];
1683
+ }
1684
+ export interface AdminCashoutChange {
1685
+ id: string;
1686
+ merchantId: string | null;
1687
+ cashoutFundingIssueId: string | null;
1688
+ actor: string;
1689
+ changes: Record<string, {
1690
+ before: unknown;
1691
+ after: unknown;
1692
+ }>;
1693
+ createdAt: string;
1694
+ }
1695
+ /** What the player can do next; drives every checkout button and every 409. */
1696
+ export declare const CashoutPlayerAction: {
1697
+ readonly SET_METHOD: "SET_METHOD";
1698
+ readonly CONNECT_RAIL: "CONNECT_RAIL";
1699
+ readonly SKIP_CONNECT: "SKIP_CONNECT";
1700
+ readonly CONFIRM: "CONFIRM";
1701
+ readonly CANCEL: "CANCEL";
1702
+ readonly FINISH_CANCEL: "FINISH_CANCEL";
1703
+ readonly CHANGE_METHOD: "CHANGE_METHOD";
1704
+ readonly SEND_TO_ADDRESS: "SEND_TO_ADDRESS";
1705
+ readonly RELIST: "RELIST";
1706
+ };
1707
+ export type CashoutPlayerActionType = typeof CashoutPlayerAction[keyof typeof CashoutPlayerAction];
1708
+ /** What Pay is sending from the player's wallet. */
1709
+ export declare const CashoutSending: {
1710
+ readonly LISTING: "LISTING";
1711
+ readonly TRANSFER: "TRANSFER";
1712
+ readonly WITHDRAW: "WITHDRAW";
1713
+ readonly RELISTING: "RELISTING";
1714
+ };
1715
+ export type CashoutSendingType = typeof CashoutSending[keyof typeof CashoutSending];
1716
+ export declare const CashoutCredentialStatus: {
1717
+ readonly ACTIVE: "active";
1718
+ readonly INACTIVE: "inactive";
1719
+ readonly MISSING: "missing";
1720
+ };
1721
+ export type CashoutCredentialStatusType = typeof CashoutCredentialStatus[keyof typeof CashoutCredentialStatus];
1722
+ export interface CashoutRailOption {
1723
+ rail: CashoutRailType;
1724
+ /** Smallest single buyer payment, USDC decimal; null for crypto rails. */
1725
+ minAmount: string | null;
1726
+ /** Largest single buyer payment, USDC decimal; null for crypto rails. */
1727
+ maxAmount: string | null;
1728
+ }
1729
+ /** A SAR method supports seller-side confirmation; when connecting is skipped, each buyer proves payment. */
1730
+ export interface CashoutSarMethod {
1731
+ rail: CashoutSarRailType;
1732
+ payeeHandle: string;
1733
+ credentialStatus: CashoutCredentialStatusType;
1734
+ /** The player chose to list without connecting this method. */
1735
+ connectSkipped: boolean;
1736
+ payeeHash: string;
1737
+ /** The email of the PayPal account; null on every other rail. Only the player's own checkout sees it. */
1738
+ paypalEmail: string | null;
1739
+ }
1740
+ /** A buyer-proof method has no connect step or credential; each buyer proves their payment. */
1741
+ export interface CashoutBuyerProofMethod {
1742
+ rail: CashoutBuyerProofRailType;
1743
+ payeeHandle: string;
1744
+ payeeHash: string;
1745
+ }
1746
+ /** GET /api/v1/cashout-checkout/:id (link token only). */
1747
+ export interface CashoutCheckoutSummary {
1748
+ cashoutId: string;
1749
+ merchant: {
1750
+ name: string;
1751
+ logoUrl: string | null;
1752
+ supportUrl: string | null;
1753
+ disableBranding: boolean;
1754
+ checkoutTheme: MerchantCheckoutTheme | null;
1755
+ };
1756
+ email: string;
1757
+ maskedEmail: string;
1758
+ payoutAmount: string;
1759
+ status: CashoutStatusType;
1760
+ rails: CashoutRailOption[];
1761
+ returnUrl: string | null;
1762
+ }
1763
+ /** GET /api/v1/cashout-checkout/:id/state (link token + Peer app login). */
1764
+ export interface CashoutCheckoutState {
1765
+ cashoutId: string;
1766
+ status: CashoutStatusType;
1767
+ walletAddress: string;
1768
+ depositAmount: string | null;
1769
+ /** Live from the escrow deposit; null before listing and once the listing is closed. */
1770
+ remainingAmount: string | null;
1771
+ buyerPaymentActive: boolean;
1772
+ method: CashoutSarMethod | CashoutBuyerProofMethod | CashoutCryptoMethod | null;
1773
+ /** Prefill from this player's last cashout on an available rail; never a deposit address. */
1774
+ lastPayoutTarget: CashoutPayoutMethodView | null;
1775
+ attempt: {
1776
+ attemptId: string;
1777
+ status: CashoutAttemptStatusType;
1778
+ depositId: string | null;
1779
+ } | null;
1780
+ signer: {
1781
+ signerId: string;
1782
+ policyId: string;
1783
+ attached: boolean;
1784
+ };
1785
+ /** What Pay is sending from the player's wallet right now; null when nothing is in flight. */
1786
+ sending: CashoutSendingType | null;
1787
+ /**
1788
+ * The newest send of the current attempt (or of the last closed attempt while the cashout is back in FUNDED/READY) failed; a failed relist counts only while the cashout is listed.
1789
+ * Also true when a Venmo or PayPal listing's Peer Pay group send failed and its listing was withdrawn (the cashout is back in FUNDED/READY).
1790
+ */
1791
+ lastSendFailed: boolean;
1792
+ /** Set when the Peer wallet no longer covers this cashout (newest first, like the wallet job): what it needs and what is left for it after the player's older cashouts, in decimal USDC. Only CANCEL is offered then. */
1793
+ walletShortfall: {
1794
+ requiredAmount: string;
1795
+ availableAmount: string;
1796
+ } | null;
1797
+ /** PARTIALLY_FUNDED means the merchant still owes a top-up; receivedAmount is the USDC that reached the player's wallet. */
1798
+ funding: {
1799
+ status: CashoutFundingStatusType;
1800
+ receivedAmount: string | null;
1801
+ };
1802
+ /** Who cancelled; PEER_APP when the player took the cashout back in the Peer app. */
1803
+ cancelSource: CashoutCancelSourceType | null;
1804
+ merchantReference: string | null;
1805
+ /** Once settled: the delivering transaction and its chain. */
1806
+ settleTx: {
1807
+ chainId: number;
1808
+ txHash: string;
1809
+ } | null;
1810
+ /** The newest attempt's newest bridge unless it is NOT_SENT. */
1811
+ payoutBridge: CashoutPayoutBridgeView | null;
1812
+ /** While a buyer pays, when that buyer was matched (ISO time). */
1813
+ buyerMatchedAt: string | null;
1814
+ /** Set once a buyer paid part of the cashout; decimal USDC. totalAmount is depositAmount. */
1815
+ partialPayment: {
1816
+ paidAmount: string;
1817
+ unpaidAmount: string;
1818
+ totalAmount: string;
1819
+ /** What the live listing's deposit holds (cashoutDepositRemainingUnits); null when nothing is listed. Relist, withdraw and send amounts. */
1820
+ listedAmount: string | null;
1821
+ /**
1822
+ * The listed deposit still takes new buyers (EscrowV2 `acceptingIntents`). False when nothing is listed, and when a
1823
+ * withdraw landed while a buyer held the deposit (a send-to-address or change-method exit, or a Peer-app withdraw): the
1824
+ * escrow then takes no new buyer, so the rest is never relisted and only an exit moves it.
1825
+ */
1826
+ acceptingBuyers: boolean;
1827
+ } | null;
1828
+ /** Only when status is SETTLED. */
1829
+ settlement: CashoutSettlementBreakdown | null;
1830
+ actions: CashoutPlayerActionType[];
1831
+ }
1832
+ export type SetCashoutPayoutMethodRequest = {
1833
+ rail: typeof CashoutRail.VENMO | typeof CashoutRail.CASHAPP;
1834
+ payeeHandle: string;
1835
+ }
1836
+ /** The App Clip checks the connected PayPal account against this email. */
1837
+ | {
1838
+ rail: typeof CashoutRail.PAYPAL;
1839
+ payeeHandle: string;
1840
+ paypalEmail: string;
1841
+ }
1842
+ /** Buyer-proof rails need only the payout account; there is no connect step. */
1843
+ | {
1844
+ rail: CashoutBuyerProofRailType;
1845
+ payeeHandle: string;
1846
+ } | CashoutPayoutDestinationRequest;
1847
+ /** POST /api/v1/cashout-checkout/:id/send-to-address. The checkout requires the network tick box before sending. */
1848
+ export type SendCashoutToAddressRequest = CashoutPayoutDestinationRequest;
1849
+ export interface CashoutActivityItem {
1850
+ cashoutId: string;
1851
+ /** Only the player passing linkAuth and loginAuth may see this link to open their cashout. */
1852
+ checkoutUrl: string;
1853
+ payoutAmount: string;
1854
+ /** The chosen payout app, or null before the player picks one. */
1855
+ payoutRail: CashoutRailType | null;
1856
+ status: CashoutStatusType;
1857
+ createdAt: string;
1858
+ }
1859
+ export interface ListCashoutActivityResponse {
1860
+ /** Only the player passing linkAuth and loginAuth may see the full recipient email identifying this list. */
1861
+ email: string;
1862
+ items: CashoutActivityItem[];
1863
+ page: number;
1864
+ limit: number;
1865
+ total: number;
1866
+ }
900
1867
  export {};