@zkp2p/pay-shared 0.0.1 → 1.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/LICENSE +6 -0
- package/README.md +116 -0
- package/dist/bitcoin.d.ts +1 -0
- package/dist/bitcoin.js +13 -0
- package/dist/chains.d.ts +17 -4
- package/dist/chains.js +60 -3
- package/dist/crypto.d.ts +34 -0
- package/dist/crypto.js +226 -0
- package/dist/fees.d.ts +27 -0
- package/dist/fees.js +195 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -0
- package/dist/rails.d.ts +61 -0
- package/dist/rails.js +144 -0
- package/dist/types.d.ts +352 -39
- package/dist/types.js +42 -13
- package/package.json +27 -5
- package/dist/chains.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/src/chains.ts +0 -417
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.ts +0 -132
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -29
- package/src/types.ts +0 -464
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PayCryptoTokenSymbol } from './crypto.js';
|
|
1
2
|
export declare const PaymentPlatform: {
|
|
2
3
|
readonly VENMO: "venmo";
|
|
3
4
|
readonly CASHAPP: "cashapp";
|
|
@@ -7,6 +8,7 @@ export declare const PaymentPlatform: {
|
|
|
7
8
|
readonly PAYPAL: "paypal";
|
|
8
9
|
readonly MONZO: "monzo";
|
|
9
10
|
readonly N26: "n26";
|
|
11
|
+
readonly CHIME: "chime";
|
|
10
12
|
};
|
|
11
13
|
export type PaymentPlatformType = typeof PaymentPlatform[keyof typeof PaymentPlatform];
|
|
12
14
|
export declare const SupportedChains: Record<number, string>;
|
|
@@ -39,14 +41,238 @@ export declare const SessionStatus: {
|
|
|
39
41
|
readonly CREATED: "CREATED";
|
|
40
42
|
readonly ACTIVE: "ACTIVE";
|
|
41
43
|
readonly COMPLETED: "COMPLETED";
|
|
44
|
+
readonly FAILED: "FAILED";
|
|
45
|
+
readonly REFUNDED: "REFUNDED";
|
|
42
46
|
readonly EXPIRED: "EXPIRED";
|
|
43
47
|
readonly CANCELLED: "CANCELLED";
|
|
44
48
|
};
|
|
45
49
|
export type SessionStatusType = typeof SessionStatus[keyof typeof SessionStatus];
|
|
50
|
+
export declare const CheckoutMethod: {
|
|
51
|
+
readonly FIAT: "fiat";
|
|
52
|
+
readonly CRYPTO: "crypto";
|
|
53
|
+
};
|
|
54
|
+
export type CheckoutMethodType = typeof CheckoutMethod[keyof typeof CheckoutMethod];
|
|
55
|
+
export declare const FeePayer: {
|
|
56
|
+
readonly MERCHANT: "MERCHANT";
|
|
57
|
+
readonly PAYEE: "PAYEE";
|
|
58
|
+
};
|
|
59
|
+
export type FeePayerType = typeof FeePayer[keyof typeof FeePayer];
|
|
60
|
+
export declare const CheckoutOrderStatus: {
|
|
61
|
+
readonly CREATED: "CREATED";
|
|
62
|
+
readonly PARTIALLY_FULFILLED: "PARTIALLY_FULFILLED";
|
|
63
|
+
readonly FULFILLED: "FULFILLED";
|
|
64
|
+
readonly CANCELLED: "CANCELLED";
|
|
65
|
+
};
|
|
66
|
+
export type CheckoutOrderStatusType = typeof CheckoutOrderStatus[keyof typeof CheckoutOrderStatus];
|
|
67
|
+
export declare const CheckoutPaymentStatus: {
|
|
68
|
+
readonly CREATED: "CREATED";
|
|
69
|
+
readonly SETTLED: "SETTLED";
|
|
70
|
+
readonly CANCELLED: "CANCELLED";
|
|
71
|
+
readonly EXPIRED: "EXPIRED";
|
|
72
|
+
readonly FAILED: "FAILED";
|
|
73
|
+
};
|
|
74
|
+
export type CheckoutPaymentStatusType = typeof CheckoutPaymentStatus[keyof typeof CheckoutPaymentStatus];
|
|
75
|
+
export type ReferralFeeEntry = {
|
|
76
|
+
recipient: string;
|
|
77
|
+
feeBps: number;
|
|
78
|
+
};
|
|
79
|
+
export type ReferralSplitConfig = ReferralFeeEntry[];
|
|
80
|
+
export type SettlementReferralFeeEntry = {
|
|
81
|
+
recipient: string;
|
|
82
|
+
feeUsdc: string;
|
|
83
|
+
};
|
|
84
|
+
type CreateOrderRequestBase = {
|
|
85
|
+
destinationAddress?: string;
|
|
86
|
+
destinationToken?: string;
|
|
87
|
+
destinationChainId?: number;
|
|
88
|
+
feePayer?: FeePayerType;
|
|
89
|
+
enabledRails?: string[];
|
|
90
|
+
successUrl?: string | null;
|
|
91
|
+
cancelUrl?: string | null;
|
|
92
|
+
notes?: Record<string, unknown> | null;
|
|
93
|
+
};
|
|
94
|
+
type CreateOrderRequestWithUsdc = CreateOrderRequestBase & {
|
|
95
|
+
requestedUsdcAmount: string;
|
|
96
|
+
requestedFiatAmount?: never;
|
|
97
|
+
requestedFiatCurrency?: never;
|
|
98
|
+
};
|
|
99
|
+
type CreateOrderRequestWithFiat = CreateOrderRequestBase & {
|
|
100
|
+
requestedUsdcAmount?: never;
|
|
101
|
+
requestedFiatAmount: string;
|
|
102
|
+
requestedFiatCurrency: string;
|
|
103
|
+
};
|
|
104
|
+
export type CreateOrderRequest = CreateOrderRequestWithUsdc | CreateOrderRequestWithFiat;
|
|
105
|
+
export type CheckoutRequest = CreateOrderRequest;
|
|
106
|
+
export type MerchantCheckoutTheme = {
|
|
107
|
+
presetName?: 'default' | 'dark' | 'light' | 'custom';
|
|
108
|
+
pageBackgroundColor?: string | null;
|
|
109
|
+
panelBackgroundColor?: string | null;
|
|
110
|
+
panelTextColor?: string | null;
|
|
111
|
+
panelTextMutedColor?: string | null;
|
|
112
|
+
panelAccentColor?: string | null;
|
|
113
|
+
panelBorderColor?: string | null;
|
|
114
|
+
buttonBackgroundColor?: string | null;
|
|
115
|
+
buttonTextColor?: string | null;
|
|
116
|
+
defaultMaxFeePercentage?: number;
|
|
117
|
+
payWithCryptoEnabled?: boolean;
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
export type CheckoutMerchant = {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
logoUrl: string | null;
|
|
124
|
+
environment: MerchantEnvironmentType;
|
|
125
|
+
disableBranding: boolean;
|
|
126
|
+
checkoutTheme: MerchantCheckoutTheme | null;
|
|
127
|
+
defaultPaymentCurrency?: string | null;
|
|
128
|
+
};
|
|
129
|
+
export type CheckoutOrder = {
|
|
130
|
+
id: string;
|
|
131
|
+
merchantId: string;
|
|
132
|
+
status: CheckoutOrderStatusType;
|
|
133
|
+
requestedUsdcAmount: string;
|
|
134
|
+
remainingUsdcAmount: string;
|
|
135
|
+
destinationAddress: string;
|
|
136
|
+
destinationToken: string;
|
|
137
|
+
destinationChainId: string;
|
|
138
|
+
feePayer: FeePayerType;
|
|
139
|
+
enabledRails: string[];
|
|
140
|
+
successUrl: string | null;
|
|
141
|
+
cancelUrl: string | null;
|
|
142
|
+
notes: unknown | null;
|
|
143
|
+
metadata: unknown | null;
|
|
144
|
+
bridgeInfo?: OrderBridgeInfo | null;
|
|
145
|
+
referralSplitConfig: ReferralSplitConfig | null;
|
|
146
|
+
cancelledAt: string | null;
|
|
147
|
+
completedAt: string | null;
|
|
148
|
+
createdAt: string;
|
|
149
|
+
updatedAt: string | null;
|
|
150
|
+
};
|
|
151
|
+
export type CheckoutPaymentQuote = {
|
|
152
|
+
conversionRate?: string;
|
|
153
|
+
signalIntent: {
|
|
154
|
+
processorName: string;
|
|
155
|
+
depositId: string;
|
|
156
|
+
amount: string;
|
|
157
|
+
toAddress: string;
|
|
158
|
+
escrowAddress?: string;
|
|
159
|
+
fiatCurrencyCode?: string;
|
|
160
|
+
payeeDetails: string;
|
|
161
|
+
};
|
|
162
|
+
maker?: {
|
|
163
|
+
depositData: Record<string, string>;
|
|
164
|
+
};
|
|
165
|
+
intentHash?: string;
|
|
166
|
+
};
|
|
167
|
+
export type CheckoutQuote = {
|
|
168
|
+
displayAmount: string;
|
|
169
|
+
spreadPercentage: number;
|
|
170
|
+
};
|
|
171
|
+
export type CheckoutQuoteEntry = {
|
|
172
|
+
platform: string;
|
|
173
|
+
displayAmount: string;
|
|
174
|
+
spreadPercentage: number;
|
|
175
|
+
};
|
|
176
|
+
export type CheckoutQuotes = {
|
|
177
|
+
orderId: string;
|
|
178
|
+
fiatCurrency: string;
|
|
179
|
+
platforms: CheckoutQuoteEntry[];
|
|
180
|
+
};
|
|
181
|
+
export type CheckoutPayment = {
|
|
182
|
+
id: string;
|
|
183
|
+
orderId: string;
|
|
184
|
+
status: CheckoutPaymentStatusType;
|
|
185
|
+
rail: string;
|
|
186
|
+
currency: string;
|
|
187
|
+
payTo: string;
|
|
188
|
+
quote: CheckoutPaymentQuote;
|
|
189
|
+
quoteExpiresAt: string;
|
|
190
|
+
paymentAmount: string;
|
|
191
|
+
currencyPerUsdRate: string;
|
|
192
|
+
netSettledUsdcAmount: string | null;
|
|
193
|
+
totalUsdcFeeAmount: string;
|
|
194
|
+
referralFees: SettlementReferralFeeEntry[] | null;
|
|
195
|
+
railIdentifier: string | null;
|
|
196
|
+
fulfillTransaction: string | null;
|
|
197
|
+
completedAt: string | null;
|
|
198
|
+
createdAt: string;
|
|
199
|
+
updatedAt: string | null;
|
|
200
|
+
};
|
|
201
|
+
export type CheckoutAggregate = {
|
|
202
|
+
order: CheckoutOrder;
|
|
203
|
+
merchant: CheckoutMerchant;
|
|
204
|
+
currentPayment: CheckoutPayment | null;
|
|
205
|
+
};
|
|
206
|
+
export type CreateOrderResponse = {
|
|
207
|
+
order: CheckoutOrder;
|
|
208
|
+
orderToken: string;
|
|
209
|
+
};
|
|
210
|
+
export type CreateCheckoutResponse = CreateOrderResponse;
|
|
211
|
+
export type CheckoutCreateResponse = CreateOrderResponse;
|
|
212
|
+
export type CreatePaymentRequest = {
|
|
213
|
+
rail: string;
|
|
214
|
+
fiatCurrency?: string;
|
|
215
|
+
currency?: string;
|
|
216
|
+
replacementPaymentId?: string;
|
|
217
|
+
quoteLimit?: number;
|
|
218
|
+
excludedPayToValues?: string[];
|
|
219
|
+
};
|
|
220
|
+
export type CheckoutPaymentCreationResponse = CheckoutPayment & {
|
|
221
|
+
relayerTransactionId?: string;
|
|
222
|
+
};
|
|
223
|
+
export type PaymentDeeplinkResponse = {
|
|
224
|
+
paymentId: string;
|
|
225
|
+
orderId: string;
|
|
226
|
+
intentHash: string;
|
|
227
|
+
url: string;
|
|
228
|
+
proofSubmissionUrl: string;
|
|
229
|
+
checkoutReturnUrl: string;
|
|
230
|
+
};
|
|
231
|
+
export type CheckoutDeeplinkResponse = PaymentDeeplinkResponse;
|
|
232
|
+
export type MerchantConfig = {
|
|
233
|
+
id: string;
|
|
234
|
+
merchantId: string;
|
|
235
|
+
feePayer: FeePayerType;
|
|
236
|
+
enabledRails: string[];
|
|
237
|
+
defaultPaymentCurrency: string | null;
|
|
238
|
+
destinationChainId: string;
|
|
239
|
+
destinationToken: string;
|
|
240
|
+
sweepEnabled: boolean;
|
|
241
|
+
recipientOverrideEnabled: boolean;
|
|
242
|
+
disableBranding: boolean;
|
|
243
|
+
merchantCheckoutTheme: MerchantCheckoutTheme;
|
|
244
|
+
platformReferralFeeConfig: ReferralFeeConfig | null;
|
|
245
|
+
referralSplitConfig: ReferralSplitConfig | null;
|
|
246
|
+
createdAt: string;
|
|
247
|
+
updatedAt: string | null;
|
|
248
|
+
};
|
|
249
|
+
export type MerchantUser = {
|
|
250
|
+
id: string;
|
|
251
|
+
email: string | null;
|
|
252
|
+
privyUserId: string;
|
|
253
|
+
role: 'OWNER' | 'MANAGER';
|
|
254
|
+
merchantId: string | null;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
updatedAt: string | null;
|
|
257
|
+
};
|
|
258
|
+
export type MerchantProfile = {
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
logoUrl: string | null;
|
|
262
|
+
apiKey: string;
|
|
263
|
+
environment: MerchantEnvironmentType;
|
|
264
|
+
sandboxMerchantId: string | null;
|
|
265
|
+
evmWalletAddress: string | null;
|
|
266
|
+
solanaWalletAddress: string | null;
|
|
267
|
+
tier: 'FREE' | 'PRO';
|
|
268
|
+
createdAt: string;
|
|
269
|
+
updatedAt: string | null;
|
|
270
|
+
merchantConfig: MerchantConfig | null;
|
|
271
|
+
merchantUsers: MerchantUser[];
|
|
272
|
+
};
|
|
46
273
|
export declare const OrderErrorCode: {
|
|
47
274
|
readonly PROOF_INVALID: "PROOF_INVALID";
|
|
48
275
|
readonly PROOF_EXPIRED: "PROOF_EXPIRED";
|
|
49
|
-
readonly PROOF_AMOUNT_MISMATCH: "PROOF_AMOUNT_MISMATCH";
|
|
50
276
|
readonly PROOF_RECIPIENT_MISMATCH: "PROOF_RECIPIENT_MISMATCH";
|
|
51
277
|
readonly FULFILL_TIMEOUT: "FULFILL_TIMEOUT";
|
|
52
278
|
readonly FULFILL_REVERTED: "FULFILL_REVERTED";
|
|
@@ -55,7 +281,6 @@ export declare const OrderErrorCode: {
|
|
|
55
281
|
readonly RPC_ERROR: "RPC_ERROR";
|
|
56
282
|
readonly RELAYER_ERROR: "RELAYER_ERROR";
|
|
57
283
|
readonly ATTESTATION_ERROR: "ATTESTATION_ERROR";
|
|
58
|
-
readonly BRIDGE_QUOTE_ERROR: "BRIDGE_QUOTE_ERROR";
|
|
59
284
|
readonly BRIDGE_TIMEOUT: "BRIDGE_TIMEOUT";
|
|
60
285
|
readonly FEE_THRESHOLD_EXCEEDED: "FEE_THRESHOLD_EXCEEDED";
|
|
61
286
|
readonly SDK_ERROR: "SDK_ERROR";
|
|
@@ -67,6 +292,38 @@ export declare const MerchantEnvironment: {
|
|
|
67
292
|
readonly SANDBOX: "SANDBOX";
|
|
68
293
|
};
|
|
69
294
|
export type MerchantEnvironmentType = typeof MerchantEnvironment[keyof typeof MerchantEnvironment];
|
|
295
|
+
export declare const TrancheCurrency: {
|
|
296
|
+
readonly USD: "USD";
|
|
297
|
+
readonly USDC: "USDC";
|
|
298
|
+
};
|
|
299
|
+
export type TrancheCurrencyType = typeof TrancheCurrency[keyof typeof TrancheCurrency];
|
|
300
|
+
export type FeeTranche = {
|
|
301
|
+
min: number;
|
|
302
|
+
max: number | null;
|
|
303
|
+
value: number;
|
|
304
|
+
};
|
|
305
|
+
export type ReferralFeeConfig = {
|
|
306
|
+
mode: 'default';
|
|
307
|
+
} | {
|
|
308
|
+
mode: 'exempt';
|
|
309
|
+
} | {
|
|
310
|
+
mode: 'flat';
|
|
311
|
+
currency: 'USDC';
|
|
312
|
+
valueBps: number;
|
|
313
|
+
} | {
|
|
314
|
+
mode: 'tranches';
|
|
315
|
+
currency: 'USDC';
|
|
316
|
+
tranches: FeeTranche[];
|
|
317
|
+
};
|
|
318
|
+
export type MaxFeeConfig = {
|
|
319
|
+
mode: 'flat';
|
|
320
|
+
currency: 'USD';
|
|
321
|
+
valuePercentage: number;
|
|
322
|
+
} | {
|
|
323
|
+
mode: 'tranches';
|
|
324
|
+
currency: 'USD';
|
|
325
|
+
tranches: FeeTranche[];
|
|
326
|
+
};
|
|
70
327
|
export type Merchant = {
|
|
71
328
|
id: string;
|
|
72
329
|
name: string;
|
|
@@ -75,13 +332,18 @@ export type Merchant = {
|
|
|
75
332
|
apiKey: string;
|
|
76
333
|
environment?: MerchantEnvironmentType;
|
|
77
334
|
sandboxMerchantId?: string | null;
|
|
335
|
+
privyWalletAddress?: string | null;
|
|
336
|
+
privySolanaAddress?: string | null;
|
|
78
337
|
createdAt: string;
|
|
79
338
|
updatedAt: string;
|
|
80
339
|
defaultChainId?: number | null;
|
|
81
|
-
|
|
82
|
-
defaultFiatCurrency?: string | null;
|
|
340
|
+
defaultDestinationToken?: 'USDC' | 'USDT' | null;
|
|
83
341
|
defaultMaxFeePercentage?: number | null;
|
|
342
|
+
defaultMaxFeeConfig?: MaxFeeConfig | null;
|
|
343
|
+
referralFeeConfig?: ReferralFeeConfig | null;
|
|
84
344
|
enabledPaymentPlatforms?: PaymentPlatformType[] | null;
|
|
345
|
+
payWithCryptoEnabled: boolean;
|
|
346
|
+
relayPayoutsEnabled: boolean;
|
|
85
347
|
};
|
|
86
348
|
export type CreateMerchantRequest = {
|
|
87
349
|
name: string;
|
|
@@ -96,8 +358,15 @@ export type CheckoutSession = {
|
|
|
96
358
|
destinationToken: string;
|
|
97
359
|
recipientAddress: string;
|
|
98
360
|
status: SessionStatusType;
|
|
361
|
+
selectedCheckoutMethod?: CheckoutMethodType | null;
|
|
99
362
|
selectedPaymentPlatform?: PaymentPlatformType | null;
|
|
100
363
|
selectedFiatCurrency?: string | null;
|
|
364
|
+
paymentSentAt?: string | null;
|
|
365
|
+
cryptoRequestId?: string | null;
|
|
366
|
+
cryptoDepositAddress?: string | null;
|
|
367
|
+
cryptoOriginChainId?: number | null;
|
|
368
|
+
cryptoOriginToken?: PayCryptoTokenSymbol | null;
|
|
369
|
+
cryptoOriginAmount?: string | null;
|
|
101
370
|
successUrl?: string | null;
|
|
102
371
|
cancelUrl?: string | null;
|
|
103
372
|
metadata?: Record<string, string> | null;
|
|
@@ -107,8 +376,12 @@ export type CheckoutSession = {
|
|
|
107
376
|
fiatAmount?: string | null;
|
|
108
377
|
fiatCurrency?: string | null;
|
|
109
378
|
maxFeePercentage?: number | null;
|
|
379
|
+
maxFeeConfigSnapshot?: MaxFeeConfig | null;
|
|
380
|
+
requestedNetAmountUsdc?: string | null;
|
|
110
381
|
requiresBridge?: boolean;
|
|
111
382
|
enabledPaymentPlatforms?: PaymentPlatformType[] | null;
|
|
383
|
+
payWithCryptoEnabled: boolean;
|
|
384
|
+
cryptoPayment?: CheckoutCryptoPayment | null;
|
|
112
385
|
createdAt: string;
|
|
113
386
|
updatedAt: string;
|
|
114
387
|
merchant?: {
|
|
@@ -125,6 +398,7 @@ export type QuoteIntent = {
|
|
|
125
398
|
processorName: string;
|
|
126
399
|
amount: string;
|
|
127
400
|
toAddress: string;
|
|
401
|
+
escrowAddress?: string;
|
|
128
402
|
payeeDetails: string;
|
|
129
403
|
processorIntentData: Record<string, unknown>;
|
|
130
404
|
fiatCurrencyCode: string;
|
|
@@ -152,6 +426,7 @@ export type Order = {
|
|
|
152
426
|
paymentPlatform?: PaymentPlatformType | null;
|
|
153
427
|
fiatCurrency?: string | null;
|
|
154
428
|
amountUsdc?: string | null;
|
|
429
|
+
grossAmountUsdc?: string | null;
|
|
155
430
|
netAmountUsdc?: string | null;
|
|
156
431
|
conversionRate?: string | null;
|
|
157
432
|
recipient?: string | null;
|
|
@@ -160,7 +435,7 @@ export type Order = {
|
|
|
160
435
|
bridgeCommitmentData?: string | null;
|
|
161
436
|
bridgeFulfillData?: string | null;
|
|
162
437
|
bridgeDepositTxHash?: string | null;
|
|
163
|
-
bridgeStatus?: 'pending' | '
|
|
438
|
+
bridgeStatus?: 'pending' | 'completed' | 'failed' | null;
|
|
164
439
|
bridgeFilledAt?: string | null;
|
|
165
440
|
bridgeFilledTxHash?: string | null;
|
|
166
441
|
bridgeInfo?: OrderBridgeInfo | null;
|
|
@@ -216,10 +491,6 @@ type CreateSessionExactFiatRequest = CreateSessionBaseRequest & {
|
|
|
216
491
|
maxFeePercentage?: number;
|
|
217
492
|
};
|
|
218
493
|
export type CreateSessionRequest = CreateSessionExactTokenRequest | CreateSessionExactFiatRequest;
|
|
219
|
-
/**
|
|
220
|
-
* Bridge information returned when session requires cross-chain bridging.
|
|
221
|
-
* Amounts are in raw units (6 decimals for USDC).
|
|
222
|
-
*/
|
|
223
494
|
export type BridgeInfo = {
|
|
224
495
|
required: boolean;
|
|
225
496
|
inputAmount?: string | null;
|
|
@@ -234,17 +505,53 @@ export type CreateSessionResponse = {
|
|
|
234
505
|
checkoutUrl: string;
|
|
235
506
|
bridge?: BridgeInfo;
|
|
236
507
|
};
|
|
508
|
+
export type SelectPlatformRequest = {
|
|
509
|
+
checkoutMethod: 'fiat';
|
|
510
|
+
paymentPlatform: PaymentPlatformType;
|
|
511
|
+
fiatCurrency: string;
|
|
512
|
+
} | {
|
|
513
|
+
checkoutMethod: 'crypto';
|
|
514
|
+
};
|
|
237
515
|
export type StartSessionRequest = {
|
|
516
|
+
checkoutMethod: 'fiat';
|
|
238
517
|
paymentPlatform?: PaymentPlatformType;
|
|
239
518
|
fiatCurrency?: string;
|
|
519
|
+
} | {
|
|
520
|
+
checkoutMethod: 'crypto';
|
|
521
|
+
originChainId: number;
|
|
522
|
+
originToken: PayCryptoTokenSymbol;
|
|
523
|
+
};
|
|
524
|
+
export type RelayCryptoPaymentStatus = 'refund' | 'delayed' | 'waiting' | 'failure' | 'pending' | 'success';
|
|
525
|
+
export type CheckoutCryptoPayment = {
|
|
526
|
+
requestId: string;
|
|
527
|
+
status: RelayCryptoPaymentStatus;
|
|
528
|
+
depositAddress: string;
|
|
529
|
+
originChainId: number;
|
|
530
|
+
originToken: PayCryptoTokenSymbol;
|
|
531
|
+
originAmount: string;
|
|
532
|
+
expectedDestinationAmount?: string | null;
|
|
533
|
+
actualDestinationAmount?: string | null;
|
|
534
|
+
sourceTxHash?: string | null;
|
|
535
|
+
destinationTxHash?: string | null;
|
|
536
|
+
errorMessage?: string | null;
|
|
537
|
+
completedAt?: string | null;
|
|
240
538
|
};
|
|
241
|
-
export type
|
|
539
|
+
export type StartFiatSessionResponse = {
|
|
540
|
+
resultType: 'fiat_order';
|
|
242
541
|
session: CheckoutSession;
|
|
243
542
|
order: Order;
|
|
244
543
|
quote: Quote;
|
|
245
|
-
intentHash: string;
|
|
544
|
+
intentHash: string | null;
|
|
246
545
|
expiresAt?: string | null;
|
|
546
|
+
status?: string | null;
|
|
547
|
+
relayerTransactionId?: string | null;
|
|
247
548
|
};
|
|
549
|
+
export type StartCryptoSessionResponse = {
|
|
550
|
+
resultType: 'crypto_quote';
|
|
551
|
+
session: CheckoutSession;
|
|
552
|
+
cryptoPayment: CheckoutCryptoPayment;
|
|
553
|
+
};
|
|
554
|
+
export type StartSessionResponse = StartFiatSessionResponse | StartCryptoSessionResponse;
|
|
248
555
|
export type MarkPaymentSentResponse = {
|
|
249
556
|
order: Order;
|
|
250
557
|
};
|
|
@@ -267,36 +574,41 @@ export type ProofAttemptsResponse = {
|
|
|
267
574
|
proofAttempts: ProofAttempt[];
|
|
268
575
|
};
|
|
269
576
|
export interface BridgeStatusResponse {
|
|
270
|
-
status: 'pending' | '
|
|
577
|
+
status: 'pending' | 'completed' | 'failed' | 'not_applicable';
|
|
271
578
|
destinationChainId?: string;
|
|
272
|
-
|
|
579
|
+
outputAmount?: string;
|
|
580
|
+
estimatedOutputAmount?: string;
|
|
581
|
+
minimumOutputAmount?: string;
|
|
273
582
|
fillTxHash?: string;
|
|
274
583
|
depositTxHash?: string;
|
|
275
|
-
acrossTrackingUrl?: string;
|
|
276
584
|
estimatedFillTime?: number;
|
|
585
|
+
fallbackToOrigin?: boolean;
|
|
586
|
+
failureMessage?: string;
|
|
277
587
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Bridge information included in order responses.
|
|
280
|
-
* Tracks the status of cross-chain bridging via Across Protocol.
|
|
281
|
-
*/
|
|
282
588
|
export interface OrderBridgeInfo {
|
|
283
|
-
status: 'PENDING' | '
|
|
589
|
+
status: 'PENDING' | 'SUBMITTED' | 'COMPLETED' | 'FAILED';
|
|
284
590
|
destinationChainId: string;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
591
|
+
outputAmount?: string;
|
|
592
|
+
estimatedOutputAmount?: string;
|
|
593
|
+
minimumOutputAmount?: string;
|
|
288
594
|
fillTxHash?: string | null;
|
|
289
595
|
estimatedFillTime?: number | null;
|
|
596
|
+
fallbackToOrigin?: boolean;
|
|
597
|
+
failureMessage?: string | null;
|
|
290
598
|
}
|
|
291
599
|
export declare const WebhookEventType: {
|
|
292
|
-
readonly ORDER_CREATED: "
|
|
293
|
-
readonly
|
|
294
|
-
readonly
|
|
295
|
-
readonly
|
|
296
|
-
readonly
|
|
297
|
-
readonly
|
|
298
|
-
readonly
|
|
299
|
-
readonly
|
|
600
|
+
readonly ORDER_CREATED: "ORDER_CREATED";
|
|
601
|
+
readonly ORDER_FULFILLED: "ORDER_FULFILLED";
|
|
602
|
+
readonly ORDER_CANCELLED: "ORDER_CANCELLED";
|
|
603
|
+
readonly PAYMENT_CREATED: "PAYMENT_CREATED";
|
|
604
|
+
readonly PAYMENT_SETTLED: "PAYMENT_SETTLED";
|
|
605
|
+
readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
|
|
606
|
+
readonly PAYMENT_EXPIRED: "PAYMENT_EXPIRED";
|
|
607
|
+
readonly PAYMENT_FAILED: "PAYMENT_FAILED";
|
|
608
|
+
readonly PAYMENT_BRIDGE_PENDING: "PAYMENT_BRIDGE_PENDING";
|
|
609
|
+
readonly PAYMENT_BRIDGE_SUBMITTED: "PAYMENT_BRIDGE_SUBMITTED";
|
|
610
|
+
readonly PAYMENT_BRIDGE_COMPLETED: "PAYMENT_BRIDGE_COMPLETED";
|
|
611
|
+
readonly PAYMENT_BRIDGE_FAILED: "PAYMENT_BRIDGE_FAILED";
|
|
300
612
|
};
|
|
301
613
|
export type WebhookEventTypeValue = typeof WebhookEventType[keyof typeof WebhookEventType];
|
|
302
614
|
export declare const WebhookDeliveryStatus: {
|
|
@@ -305,12 +617,17 @@ export declare const WebhookDeliveryStatus: {
|
|
|
305
617
|
readonly FAILED: "FAILED";
|
|
306
618
|
};
|
|
307
619
|
export type WebhookDeliveryStatusType = typeof WebhookDeliveryStatus[keyof typeof WebhookDeliveryStatus];
|
|
620
|
+
export type WebhookHeader = {
|
|
621
|
+
key: string;
|
|
622
|
+
value: string;
|
|
623
|
+
};
|
|
308
624
|
export type Webhook = {
|
|
309
625
|
id: string;
|
|
310
626
|
merchantId: string;
|
|
311
627
|
url: string;
|
|
312
628
|
events: WebhookEventTypeValue[];
|
|
313
629
|
active: boolean;
|
|
630
|
+
customHeaders: WebhookHeader[];
|
|
314
631
|
createdAt: string;
|
|
315
632
|
updatedAt: string;
|
|
316
633
|
};
|
|
@@ -333,26 +650,23 @@ export type WebhookPayload = {
|
|
|
333
650
|
id: string;
|
|
334
651
|
type: WebhookEventTypeValue;
|
|
335
652
|
timestamp: string;
|
|
336
|
-
environment: MerchantEnvironmentType;
|
|
337
653
|
data: {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
error?: {
|
|
342
|
-
code: string;
|
|
343
|
-
message: string;
|
|
344
|
-
} | null;
|
|
654
|
+
order: CheckoutOrder | null;
|
|
655
|
+
payment: CheckoutPayment | null;
|
|
656
|
+
paymentBridge: Record<string, unknown> | null;
|
|
345
657
|
};
|
|
346
658
|
};
|
|
347
659
|
export type CreateWebhookRequest = {
|
|
348
660
|
url: string;
|
|
349
661
|
events?: WebhookEventTypeValue[];
|
|
662
|
+
customHeaders?: WebhookHeader[];
|
|
350
663
|
};
|
|
351
664
|
export type CreateWebhookResponse = WebhookWithSecret;
|
|
352
665
|
export type UpdateWebhookRequest = {
|
|
353
666
|
url?: string;
|
|
354
667
|
events?: WebhookEventTypeValue[];
|
|
355
668
|
active?: boolean;
|
|
669
|
+
customHeaders?: WebhookHeader[];
|
|
356
670
|
};
|
|
357
671
|
export type ListWebhooksResponse = {
|
|
358
672
|
webhooks: Webhook[];
|
|
@@ -367,4 +681,3 @@ export type TestWebhookResponse = {
|
|
|
367
681
|
error?: string | null;
|
|
368
682
|
};
|
|
369
683
|
export {};
|
|
370
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SupportedChainsMap } from './chains.js';
|
|
1
2
|
export const PaymentPlatform = {
|
|
2
3
|
VENMO: 'venmo',
|
|
3
4
|
CASHAPP: 'cashapp',
|
|
@@ -7,10 +8,10 @@ export const PaymentPlatform = {
|
|
|
7
8
|
PAYPAL: 'paypal',
|
|
8
9
|
MONZO: 'monzo',
|
|
9
10
|
N26: 'n26',
|
|
11
|
+
CHIME: 'chime',
|
|
10
12
|
};
|
|
11
13
|
// Supported chains for USDC destination
|
|
12
14
|
// Re-exported from chains.ts for backward compatibility
|
|
13
|
-
import { SupportedChainsMap } from './chains.js';
|
|
14
15
|
export const SupportedChains = SupportedChainsMap;
|
|
15
16
|
// Checkout mode determines how amounts are specified
|
|
16
17
|
export const CheckoutMode = {
|
|
@@ -38,15 +39,38 @@ export const SessionStatus = {
|
|
|
38
39
|
CREATED: 'CREATED',
|
|
39
40
|
ACTIVE: 'ACTIVE',
|
|
40
41
|
COMPLETED: 'COMPLETED',
|
|
42
|
+
FAILED: 'FAILED',
|
|
43
|
+
REFUNDED: 'REFUNDED',
|
|
41
44
|
EXPIRED: 'EXPIRED',
|
|
42
45
|
CANCELLED: 'CANCELLED',
|
|
43
46
|
};
|
|
47
|
+
export const CheckoutMethod = {
|
|
48
|
+
FIAT: 'fiat',
|
|
49
|
+
CRYPTO: 'crypto',
|
|
50
|
+
};
|
|
51
|
+
// ============ Canonical Checkout API ============
|
|
52
|
+
export const FeePayer = {
|
|
53
|
+
MERCHANT: 'MERCHANT',
|
|
54
|
+
PAYEE: 'PAYEE',
|
|
55
|
+
};
|
|
56
|
+
export const CheckoutOrderStatus = {
|
|
57
|
+
CREATED: 'CREATED',
|
|
58
|
+
PARTIALLY_FULFILLED: 'PARTIALLY_FULFILLED',
|
|
59
|
+
FULFILLED: 'FULFILLED',
|
|
60
|
+
CANCELLED: 'CANCELLED',
|
|
61
|
+
};
|
|
62
|
+
export const CheckoutPaymentStatus = {
|
|
63
|
+
CREATED: 'CREATED',
|
|
64
|
+
SETTLED: 'SETTLED',
|
|
65
|
+
CANCELLED: 'CANCELLED',
|
|
66
|
+
EXPIRED: 'EXPIRED',
|
|
67
|
+
FAILED: 'FAILED',
|
|
68
|
+
};
|
|
44
69
|
// Structured error codes for Order failures
|
|
45
70
|
export const OrderErrorCode = {
|
|
46
71
|
// Proof verification errors
|
|
47
72
|
PROOF_INVALID: 'PROOF_INVALID', // Proof data failed attestation verification
|
|
48
73
|
PROOF_EXPIRED: 'PROOF_EXPIRED', // Proof timestamp too old
|
|
49
|
-
PROOF_AMOUNT_MISMATCH: 'PROOF_AMOUNT_MISMATCH', // Payment amount doesn't match intent
|
|
50
74
|
PROOF_RECIPIENT_MISMATCH: 'PROOF_RECIPIENT_MISMATCH', // Payment recipient doesn't match
|
|
51
75
|
// Transaction errors
|
|
52
76
|
FULFILL_TIMEOUT: 'FULFILL_TIMEOUT', // On-chain tx timed out
|
|
@@ -58,7 +82,6 @@ export const OrderErrorCode = {
|
|
|
58
82
|
RELAYER_ERROR: 'RELAYER_ERROR', // Relayer submission failed
|
|
59
83
|
ATTESTATION_ERROR: 'ATTESTATION_ERROR', // Attestation service unavailable
|
|
60
84
|
// Bridge errors (cross-chain)
|
|
61
|
-
BRIDGE_QUOTE_ERROR: 'BRIDGE_QUOTE_ERROR', // Failed to get bridge quote
|
|
62
85
|
BRIDGE_TIMEOUT: 'BRIDGE_TIMEOUT', // Bridge fill timed out
|
|
63
86
|
// Fee threshold errors (exact-fiat mode)
|
|
64
87
|
FEE_THRESHOLD_EXCEEDED: 'FEE_THRESHOLD_EXCEEDED', // Quote fee exceeds merchant's max
|
|
@@ -70,18 +93,24 @@ export const MerchantEnvironment = {
|
|
|
70
93
|
LIVE: 'LIVE',
|
|
71
94
|
SANDBOX: 'SANDBOX',
|
|
72
95
|
};
|
|
96
|
+
export const TrancheCurrency = {
|
|
97
|
+
USD: 'USD',
|
|
98
|
+
USDC: 'USDC',
|
|
99
|
+
};
|
|
73
100
|
// ============ Webhook Types ============
|
|
74
101
|
export const WebhookEventType = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
ORDER_CREATED: 'ORDER_CREATED',
|
|
103
|
+
ORDER_FULFILLED: 'ORDER_FULFILLED',
|
|
104
|
+
ORDER_CANCELLED: 'ORDER_CANCELLED',
|
|
105
|
+
PAYMENT_CREATED: 'PAYMENT_CREATED',
|
|
106
|
+
PAYMENT_SETTLED: 'PAYMENT_SETTLED',
|
|
107
|
+
PAYMENT_CANCELLED: 'PAYMENT_CANCELLED',
|
|
108
|
+
PAYMENT_EXPIRED: 'PAYMENT_EXPIRED',
|
|
109
|
+
PAYMENT_FAILED: 'PAYMENT_FAILED',
|
|
110
|
+
PAYMENT_BRIDGE_PENDING: 'PAYMENT_BRIDGE_PENDING',
|
|
111
|
+
PAYMENT_BRIDGE_SUBMITTED: 'PAYMENT_BRIDGE_SUBMITTED',
|
|
112
|
+
PAYMENT_BRIDGE_COMPLETED: 'PAYMENT_BRIDGE_COMPLETED',
|
|
113
|
+
PAYMENT_BRIDGE_FAILED: 'PAYMENT_BRIDGE_FAILED',
|
|
85
114
|
};
|
|
86
115
|
export const WebhookDeliveryStatus = {
|
|
87
116
|
PENDING: 'PENDING',
|
package/package.json
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkp2p/pay-shared",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/zkp2p/pay.git",
|
|
12
|
+
"directory": "packages/shared"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/zkp2p/pay/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/zkp2p/pay/tree/main/packages/shared#readme",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"zkp2p",
|
|
20
|
+
"pay",
|
|
21
|
+
"shared",
|
|
22
|
+
"types",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
7
28
|
"exports": {
|
|
8
29
|
".": {
|
|
9
30
|
"types": "./dist/index.d.ts",
|
|
@@ -11,11 +32,12 @@
|
|
|
11
32
|
}
|
|
12
33
|
},
|
|
13
34
|
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
"src"
|
|
35
|
+
"dist"
|
|
16
36
|
],
|
|
17
37
|
"scripts": {
|
|
18
|
-
"build": "tsc -p tsconfig.json",
|
|
19
|
-
"lint": "eslint . --ext .ts,.tsx"
|
|
38
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
39
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
40
|
+
"prepack": "npm run build",
|
|
41
|
+
"prepublishOnly": "npm pack --dry-run"
|
|
20
42
|
}
|
|
21
43
|
}
|