@zkp2p/pay-shared 0.0.2 → 2.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 +30 -26
- package/dist/bitcoin.d.ts +1 -0
- package/dist/bitcoin.js +13 -0
- package/dist/buyerTee.d.ts +4 -0
- package/dist/buyerTee.js +3 -0
- package/dist/chains.d.ts +18 -4
- package/dist/chains.js +65 -3
- package/dist/crypto.d.ts +65 -0
- package/dist/crypto.js +291 -0
- package/dist/fees.d.ts +27 -0
- package/dist/fees.js +195 -0
- package/dist/fiatAmount.d.ts +19 -0
- package/dist/fiatAmount.js +58 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +8 -0
- package/dist/paypalSarPhase.d.ts +5 -0
- package/dist/paypalSarPhase.js +8 -0
- package/dist/paypalSarVerify.d.ts +41 -0
- package/dist/paypalSarVerify.js +31 -0
- package/dist/rails.d.ts +137 -0
- package/dist/rails.js +320 -0
- package/dist/types.d.ts +427 -39
- package/dist/types.js +78 -13
- package/package.json +31 -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/src/types.d.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
export declare const PaymentPlatform: {
|
|
2
|
-
readonly VENMO: "venmo";
|
|
3
|
-
readonly CASHAPP: "cashapp";
|
|
4
|
-
readonly REVOLUT: "revolut";
|
|
5
|
-
readonly WISE: "wise";
|
|
6
|
-
readonly ZELLE: "zelle";
|
|
7
|
-
readonly PAYPAL: "paypal";
|
|
8
|
-
readonly MONZO: "monzo";
|
|
9
|
-
readonly N26: "n26";
|
|
10
|
-
};
|
|
11
|
-
export type PaymentPlatformType = typeof PaymentPlatform[keyof typeof PaymentPlatform];
|
|
12
|
-
export declare const OrderStatus: {
|
|
13
|
-
readonly SESSION_CREATED: "SESSION_CREATED";
|
|
14
|
-
readonly SIGNAL_SENT: "SIGNAL_SENT";
|
|
15
|
-
readonly SIGNAL_MINED: "SIGNAL_MINED";
|
|
16
|
-
readonly PAYMENT_SENT: "PAYMENT_SENT";
|
|
17
|
-
readonly PROOF_SUBMITTED: "PROOF_SUBMITTED";
|
|
18
|
-
readonly FULFILL_SUBMITTED: "FULFILL_SUBMITTED";
|
|
19
|
-
readonly FULFILLED: "FULFILLED";
|
|
20
|
-
readonly CANCELLED: "CANCELLED";
|
|
21
|
-
readonly EXPIRED: "EXPIRED";
|
|
22
|
-
readonly FAILED: "FAILED";
|
|
23
|
-
};
|
|
24
|
-
export type OrderStatusType = typeof OrderStatus[keyof typeof OrderStatus];
|
|
25
|
-
export declare const SessionStatus: {
|
|
26
|
-
readonly CREATED: "CREATED";
|
|
27
|
-
readonly ACTIVE: "ACTIVE";
|
|
28
|
-
readonly COMPLETED: "COMPLETED";
|
|
29
|
-
readonly EXPIRED: "EXPIRED";
|
|
30
|
-
readonly CANCELLED: "CANCELLED";
|
|
31
|
-
};
|
|
32
|
-
export type SessionStatusType = typeof SessionStatus[keyof typeof SessionStatus];
|
|
33
|
-
export type Merchant = {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
apiKey: string;
|
|
37
|
-
createdAt: string;
|
|
38
|
-
};
|
|
39
|
-
export type CheckoutSession = {
|
|
40
|
-
id: string;
|
|
41
|
-
merchantId: string;
|
|
42
|
-
amountUsdc: string;
|
|
43
|
-
destinationChainId: number;
|
|
44
|
-
destinationToken: string;
|
|
45
|
-
recipientAddress: string;
|
|
46
|
-
status: SessionStatusType;
|
|
47
|
-
paymentPlatforms: PaymentPlatformType[];
|
|
48
|
-
fiatCurrency: string;
|
|
49
|
-
successUrl?: string | null;
|
|
50
|
-
cancelUrl?: string | null;
|
|
51
|
-
metadata?: Record<string, string> | null;
|
|
52
|
-
createdAt: string;
|
|
53
|
-
updatedAt: string;
|
|
54
|
-
};
|
|
55
|
-
export type QuoteIntent = {
|
|
56
|
-
depositId: string;
|
|
57
|
-
processorName: string;
|
|
58
|
-
amount: string;
|
|
59
|
-
toAddress: string;
|
|
60
|
-
payeeDetails: string;
|
|
61
|
-
processorIntentData: Record<string, unknown>;
|
|
62
|
-
fiatCurrencyCode: string;
|
|
63
|
-
chainId: string;
|
|
64
|
-
};
|
|
65
|
-
export type Quote = {
|
|
66
|
-
fiatAmount: string;
|
|
67
|
-
fiatAmountFormatted: string;
|
|
68
|
-
tokenAmount: string;
|
|
69
|
-
tokenAmountFormatted: string;
|
|
70
|
-
paymentMethod: string;
|
|
71
|
-
payeeAddress: string;
|
|
72
|
-
conversionRate: string;
|
|
73
|
-
intent: QuoteIntent;
|
|
74
|
-
payeeData?: Record<string, string>;
|
|
75
|
-
};
|
|
76
|
-
export type Order = {
|
|
77
|
-
id: string;
|
|
78
|
-
sessionId: string;
|
|
79
|
-
merchantId: string;
|
|
80
|
-
status: OrderStatusType;
|
|
81
|
-
intentHash?: string | null;
|
|
82
|
-
signalTx?: string | null;
|
|
83
|
-
fulfillTx?: string | null;
|
|
84
|
-
paymentPlatform?: PaymentPlatformType | null;
|
|
85
|
-
fiatCurrency?: string | null;
|
|
86
|
-
amountUsdc?: string | null;
|
|
87
|
-
netAmountUsdc?: string | null;
|
|
88
|
-
conversionRate?: string | null;
|
|
89
|
-
recipient?: string | null;
|
|
90
|
-
quote?: Quote | null;
|
|
91
|
-
createdAt: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
};
|
|
94
|
-
export type CreateSessionRequest = {
|
|
95
|
-
merchantId: string;
|
|
96
|
-
amountUsdc: string;
|
|
97
|
-
destinationChainId: number;
|
|
98
|
-
destinationToken: string;
|
|
99
|
-
recipientAddress: string;
|
|
100
|
-
paymentPlatforms?: PaymentPlatformType[];
|
|
101
|
-
fiatCurrency?: string;
|
|
102
|
-
successUrl?: string;
|
|
103
|
-
cancelUrl?: string;
|
|
104
|
-
metadata?: Record<string, string>;
|
|
105
|
-
};
|
|
106
|
-
export type CreateSessionResponse = {
|
|
107
|
-
session: CheckoutSession;
|
|
108
|
-
checkoutUrl: string;
|
|
109
|
-
};
|
|
110
|
-
export type StartSessionRequest = {
|
|
111
|
-
paymentPlatform?: PaymentPlatformType;
|
|
112
|
-
fiatCurrency?: string;
|
|
113
|
-
};
|
|
114
|
-
export type StartSessionResponse = {
|
|
115
|
-
session: CheckoutSession;
|
|
116
|
-
order: Order;
|
|
117
|
-
quote: Quote;
|
|
118
|
-
intentHash: string;
|
|
119
|
-
expiresAt?: string | null;
|
|
120
|
-
};
|
|
121
|
-
export type MarkPaymentSentResponse = {
|
|
122
|
-
order: Order;
|
|
123
|
-
};
|
|
124
|
-
export type FulfillIntentRequest = {
|
|
125
|
-
intentHash: string;
|
|
126
|
-
proof: Record<string, unknown> | string;
|
|
127
|
-
};
|
|
128
|
-
export type FulfillIntentResponse = {
|
|
129
|
-
order: Order;
|
|
130
|
-
txHash: string;
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;CAUlB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEvF,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE3E,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,OAAO,aA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nB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/src/types.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const PaymentPlatform = {
|
|
2
|
-
VENMO: 'venmo',
|
|
3
|
-
CASHAPP: 'cashapp',
|
|
4
|
-
REVOLUT: 'revolut',
|
|
5
|
-
WISE: 'wise',
|
|
6
|
-
ZELLE: 'zelle',
|
|
7
|
-
PAYPAL: 'paypal',
|
|
8
|
-
MONZO: 'monzo',
|
|
9
|
-
N26: 'n26',
|
|
10
|
-
};
|
|
11
|
-
export const OrderStatus = {
|
|
12
|
-
SESSION_CREATED: 'SESSION_CREATED',
|
|
13
|
-
SIGNAL_SENT: 'SIGNAL_SENT',
|
|
14
|
-
SIGNAL_MINED: 'SIGNAL_MINED',
|
|
15
|
-
PAYMENT_SENT: 'PAYMENT_SENT',
|
|
16
|
-
PROOF_SUBMITTED: 'PROOF_SUBMITTED',
|
|
17
|
-
FULFILL_SUBMITTED: 'FULFILL_SUBMITTED',
|
|
18
|
-
FULFILLED: 'FULFILLED',
|
|
19
|
-
CANCELLED: 'CANCELLED',
|
|
20
|
-
EXPIRED: 'EXPIRED',
|
|
21
|
-
FAILED: 'FAILED',
|
|
22
|
-
};
|
|
23
|
-
export const SessionStatus = {
|
|
24
|
-
CREATED: 'CREATED',
|
|
25
|
-
ACTIVE: 'ACTIVE',
|
|
26
|
-
COMPLETED: 'COMPLETED',
|
|
27
|
-
EXPIRED: 'EXPIRED',
|
|
28
|
-
CANCELLED: 'CANCELLED',
|
|
29
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
export const PaymentPlatform = {
|
|
2
|
-
VENMO: 'venmo',
|
|
3
|
-
CASHAPP: 'cashapp',
|
|
4
|
-
REVOLUT: 'revolut',
|
|
5
|
-
WISE: 'wise',
|
|
6
|
-
ZELLE: 'zelle',
|
|
7
|
-
PAYPAL: 'paypal',
|
|
8
|
-
MONZO: 'monzo',
|
|
9
|
-
N26: 'n26',
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
|
-
export type PaymentPlatformType = typeof PaymentPlatform[keyof typeof PaymentPlatform];
|
|
13
|
-
|
|
14
|
-
// Supported chains for USDC destination
|
|
15
|
-
// Re-exported from chains.ts for backward compatibility
|
|
16
|
-
import { SupportedChainsMap } from './chains.js';
|
|
17
|
-
export const SupportedChains = SupportedChainsMap;
|
|
18
|
-
|
|
19
|
-
export type SupportedChainId = keyof typeof SupportedChains;
|
|
20
|
-
|
|
21
|
-
// Checkout mode determines how amounts are specified
|
|
22
|
-
export const CheckoutMode = {
|
|
23
|
-
EXACT_TOKEN: 'exact-token', // Merchant specifies USDC amount, customer pays variable fiat
|
|
24
|
-
EXACT_FIAT: 'exact-fiat', // Merchant specifies fiat amount, customer pays fixed fiat, merchant receives variable USDC
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
export type CheckoutModeType = typeof CheckoutMode[keyof typeof CheckoutMode];
|
|
28
|
-
|
|
29
|
-
export const OrderStatus = {
|
|
30
|
-
SIGNAL_SUBMITTED: 'SIGNAL_SUBMITTED', // Intent tx submitted, awaiting confirmation
|
|
31
|
-
SIGNAL_MINED: 'SIGNAL_MINED', // Intent tx confirmed, intentHash available
|
|
32
|
-
PAYMENT_SENT: 'PAYMENT_SENT', // User marked fiat payment as sent
|
|
33
|
-
PROOF_VERIFIED: 'PROOF_VERIFIED', // ZKP proof verified by attestation service
|
|
34
|
-
FULFILL_SUBMITTED: 'FULFILL_SUBMITTED', // Fulfill tx submitted, awaiting confirmation
|
|
35
|
-
FULFILLED: 'FULFILLED', // Fulfill tx confirmed, payment complete
|
|
36
|
-
CANCELLED: 'CANCELLED', // Order cancelled
|
|
37
|
-
EXPIRED: 'EXPIRED', // Order expired
|
|
38
|
-
FAILED: 'FAILED', // Order failed due to error
|
|
39
|
-
} as const;
|
|
40
|
-
|
|
41
|
-
export type OrderStatusType = typeof OrderStatus[keyof typeof OrderStatus];
|
|
42
|
-
|
|
43
|
-
export const ProofAttemptStatus = {
|
|
44
|
-
PENDING: 'PENDING', // Proof received, awaiting verification
|
|
45
|
-
VERIFYING: 'VERIFYING', // Being verified by attestation service
|
|
46
|
-
VERIFIED: 'VERIFIED', // Proof valid, fulfillment can proceed (Order tracks tx status)
|
|
47
|
-
REJECTED: 'REJECTED', // Proof failed verification (can retry with new proof)
|
|
48
|
-
} as const;
|
|
49
|
-
|
|
50
|
-
export type ProofAttemptStatusType = typeof ProofAttemptStatus[keyof typeof ProofAttemptStatus];
|
|
51
|
-
|
|
52
|
-
export const SessionStatus = {
|
|
53
|
-
CREATED: 'CREATED',
|
|
54
|
-
ACTIVE: 'ACTIVE',
|
|
55
|
-
COMPLETED: 'COMPLETED',
|
|
56
|
-
EXPIRED: 'EXPIRED',
|
|
57
|
-
CANCELLED: 'CANCELLED',
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
export type SessionStatusType = typeof SessionStatus[keyof typeof SessionStatus];
|
|
61
|
-
|
|
62
|
-
// Structured error codes for Order failures
|
|
63
|
-
export const OrderErrorCode = {
|
|
64
|
-
// Proof verification errors
|
|
65
|
-
PROOF_INVALID: 'PROOF_INVALID', // Proof data failed attestation verification
|
|
66
|
-
PROOF_EXPIRED: 'PROOF_EXPIRED', // Proof timestamp too old
|
|
67
|
-
PROOF_AMOUNT_MISMATCH: 'PROOF_AMOUNT_MISMATCH', // Payment amount doesn't match intent
|
|
68
|
-
PROOF_RECIPIENT_MISMATCH: 'PROOF_RECIPIENT_MISMATCH', // Payment recipient doesn't match
|
|
69
|
-
|
|
70
|
-
// Transaction errors
|
|
71
|
-
FULFILL_TIMEOUT: 'FULFILL_TIMEOUT', // On-chain tx timed out
|
|
72
|
-
FULFILL_REVERTED: 'FULFILL_REVERTED', // On-chain tx reverted
|
|
73
|
-
SIGNAL_TIMEOUT: 'SIGNAL_TIMEOUT', // Signal intent tx timed out
|
|
74
|
-
SIGNAL_REVERTED: 'SIGNAL_REVERTED', // Signal intent tx reverted
|
|
75
|
-
|
|
76
|
-
// Infrastructure errors
|
|
77
|
-
RPC_ERROR: 'RPC_ERROR', // RPC node connection/timeout
|
|
78
|
-
RELAYER_ERROR: 'RELAYER_ERROR', // Relayer submission failed
|
|
79
|
-
ATTESTATION_ERROR: 'ATTESTATION_ERROR', // Attestation service unavailable
|
|
80
|
-
|
|
81
|
-
// Bridge errors (cross-chain)
|
|
82
|
-
BRIDGE_QUOTE_ERROR: 'BRIDGE_QUOTE_ERROR', // Failed to get bridge quote
|
|
83
|
-
BRIDGE_TIMEOUT: 'BRIDGE_TIMEOUT', // Bridge fill timed out
|
|
84
|
-
|
|
85
|
-
// Fee threshold errors (exact-fiat mode)
|
|
86
|
-
FEE_THRESHOLD_EXCEEDED: 'FEE_THRESHOLD_EXCEEDED', // Quote fee exceeds merchant's max
|
|
87
|
-
|
|
88
|
-
// Generic
|
|
89
|
-
SDK_ERROR: 'SDK_ERROR', // Unknown SDK error
|
|
90
|
-
UNKNOWN_ERROR: 'UNKNOWN_ERROR', // Uncategorized error
|
|
91
|
-
} as const;
|
|
92
|
-
|
|
93
|
-
export type OrderErrorCodeType = typeof OrderErrorCode[keyof typeof OrderErrorCode];
|
|
94
|
-
|
|
95
|
-
export const MerchantEnvironment = {
|
|
96
|
-
LIVE: 'LIVE',
|
|
97
|
-
SANDBOX: 'SANDBOX',
|
|
98
|
-
} as const;
|
|
99
|
-
|
|
100
|
-
export type MerchantEnvironmentType = typeof MerchantEnvironment[keyof typeof MerchantEnvironment];
|
|
101
|
-
|
|
102
|
-
export type Merchant = {
|
|
103
|
-
id: string;
|
|
104
|
-
name: string;
|
|
105
|
-
logoUrl?: string | null;
|
|
106
|
-
disableBranding?: boolean;
|
|
107
|
-
apiKey: string;
|
|
108
|
-
environment?: MerchantEnvironmentType;
|
|
109
|
-
sandboxMerchantId?: string | null;
|
|
110
|
-
createdAt: string;
|
|
111
|
-
updatedAt: string;
|
|
112
|
-
// Checkout defaults
|
|
113
|
-
defaultChainId?: number | null;
|
|
114
|
-
defaultCheckoutMode?: 'exact-token' | 'exact-fiat' | null;
|
|
115
|
-
defaultFiatCurrency?: string | null;
|
|
116
|
-
defaultMaxFeePercentage?: number | null;
|
|
117
|
-
// Payment platform configuration (empty array = all platforms enabled)
|
|
118
|
-
enabledPaymentPlatforms?: PaymentPlatformType[] | null;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export type CreateMerchantRequest = {
|
|
122
|
-
name: string;
|
|
123
|
-
logoUrl?: string;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type CheckoutSession = {
|
|
127
|
-
id: string;
|
|
128
|
-
merchantId: string;
|
|
129
|
-
amountUsdc: string;
|
|
130
|
-
netAmountUsdc?: string | null;
|
|
131
|
-
destinationChainId: number;
|
|
132
|
-
destinationToken: string;
|
|
133
|
-
recipientAddress: string;
|
|
134
|
-
status: SessionStatusType;
|
|
135
|
-
selectedPaymentPlatform?: PaymentPlatformType | null;
|
|
136
|
-
selectedFiatCurrency?: string | null;
|
|
137
|
-
successUrl?: string | null;
|
|
138
|
-
cancelUrl?: string | null;
|
|
139
|
-
metadata?: Record<string, string> | null;
|
|
140
|
-
expiresAt?: string | null; // Session expiry time (default: 1 hour from creation)
|
|
141
|
-
activeOrderId?: string | null;
|
|
142
|
-
// Checkout mode (exact-token or exact-fiat)
|
|
143
|
-
checkoutMode?: CheckoutModeType;
|
|
144
|
-
// Exact-fiat mode fields
|
|
145
|
-
fiatAmount?: string | null; // Customer's fixed fiat payment (exact-fiat mode)
|
|
146
|
-
fiatCurrency?: string | null; // e.g., "USD" (exact-fiat mode)
|
|
147
|
-
maxFeePercentage?: number | null; // Merchant's max acceptable fee % (exact-fiat mode)
|
|
148
|
-
// Bridge fields (populated when destinationChainId != Base)
|
|
149
|
-
requiresBridge?: boolean;
|
|
150
|
-
// Payment platform configuration (empty array = all platforms enabled)
|
|
151
|
-
enabledPaymentPlatforms?: PaymentPlatformType[] | null;
|
|
152
|
-
createdAt: string;
|
|
153
|
-
updatedAt: string;
|
|
154
|
-
// Included merchant relation (when fetched with include)
|
|
155
|
-
merchant?: {
|
|
156
|
-
id: string;
|
|
157
|
-
name: string;
|
|
158
|
-
logoUrl?: string | null;
|
|
159
|
-
environment?: MerchantEnvironmentType;
|
|
160
|
-
disableBranding?: boolean;
|
|
161
|
-
} | null;
|
|
162
|
-
// Included active order relation (when fetched with include)
|
|
163
|
-
activeOrder?: Order | null;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export type QuoteIntent = {
|
|
167
|
-
depositId: string;
|
|
168
|
-
processorName: string;
|
|
169
|
-
amount: string;
|
|
170
|
-
toAddress: string;
|
|
171
|
-
payeeDetails: string;
|
|
172
|
-
processorIntentData: Record<string, unknown>;
|
|
173
|
-
fiatCurrencyCode: string;
|
|
174
|
-
chainId: string;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
export type Quote = {
|
|
178
|
-
fiatAmount: string;
|
|
179
|
-
fiatAmountFormatted: string;
|
|
180
|
-
tokenAmount: string;
|
|
181
|
-
tokenAmountFormatted: string;
|
|
182
|
-
paymentMethod: string;
|
|
183
|
-
payeeAddress: string;
|
|
184
|
-
conversionRate: string;
|
|
185
|
-
intent: QuoteIntent;
|
|
186
|
-
payeeData?: Record<string, string>;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export type Order = {
|
|
190
|
-
id: string;
|
|
191
|
-
sessionId: string;
|
|
192
|
-
merchantId: string;
|
|
193
|
-
status: OrderStatusType;
|
|
194
|
-
intentHash?: string | null;
|
|
195
|
-
signalTx?: string | null;
|
|
196
|
-
fulfillTx?: string | null;
|
|
197
|
-
paymentPlatform?: PaymentPlatformType | null;
|
|
198
|
-
fiatCurrency?: string | null;
|
|
199
|
-
amountUsdc?: string | null;
|
|
200
|
-
netAmountUsdc?: string | null;
|
|
201
|
-
conversionRate?: string | null;
|
|
202
|
-
recipient?: string | null;
|
|
203
|
-
quote?: Quote | null;
|
|
204
|
-
expiresAt?: string | null;
|
|
205
|
-
// Bridge execution data (populated for cross-chain orders)
|
|
206
|
-
bridgeCommitmentData?: string | null; // Encoded BridgeCommitment (stored at signal)
|
|
207
|
-
bridgeFulfillData?: string | null; // Encoded AcrossFulfillData (stored at fulfill)
|
|
208
|
-
bridgeDepositTxHash?: string | null; // Across deposit tx hash
|
|
209
|
-
// Bridge status tracking
|
|
210
|
-
bridgeStatus?: 'pending' | 'filled' | 'expired' | null;
|
|
211
|
-
bridgeFilledAt?: string | null;
|
|
212
|
-
bridgeFilledTxHash?: string | null; // Fill tx on destination chain
|
|
213
|
-
// Bridge info (populated when fetched with bridge data)
|
|
214
|
-
bridgeInfo?: OrderBridgeInfo | null;
|
|
215
|
-
// Proof tracking
|
|
216
|
-
currentProofId?: string | null;
|
|
217
|
-
// Cancellation tracking
|
|
218
|
-
cancelTx?: string | null;
|
|
219
|
-
cancelledAt?: string | null;
|
|
220
|
-
cancelReason?: string | null;
|
|
221
|
-
// Error tracking
|
|
222
|
-
errorCode?: string | null;
|
|
223
|
-
errorMessage?: string | null;
|
|
224
|
-
errorDetails?: Record<string, unknown> | null;
|
|
225
|
-
failedAt?: string | null;
|
|
226
|
-
createdAt: string;
|
|
227
|
-
updatedAt: string;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export type ProofAttempt = {
|
|
231
|
-
id: string;
|
|
232
|
-
orderId: string;
|
|
233
|
-
intentHash: string;
|
|
234
|
-
proof: Record<string, unknown>;
|
|
235
|
-
submittedAt: string;
|
|
236
|
-
status: ProofAttemptStatusType;
|
|
237
|
-
verifiedAt?: string | null;
|
|
238
|
-
attestationResponse?: Record<string, unknown> | null;
|
|
239
|
-
verificationError?: string | null;
|
|
240
|
-
verificationMessage?: string | null;
|
|
241
|
-
txHash?: string | null;
|
|
242
|
-
txSubmittedAt?: string | null;
|
|
243
|
-
txConfirmedAt?: string | null;
|
|
244
|
-
txError?: string | null;
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// Base fields common to both checkout modes
|
|
248
|
-
type CreateSessionBaseRequest = {
|
|
249
|
-
merchantId: string;
|
|
250
|
-
destinationChainId: number;
|
|
251
|
-
destinationToken: string; // Destination token alias (USDC/USDT) or token address
|
|
252
|
-
recipientAddress: string;
|
|
253
|
-
successUrl?: string;
|
|
254
|
-
cancelUrl?: string;
|
|
255
|
-
metadata?: Record<string, string>;
|
|
256
|
-
// Optional: Override merchant's enabled platforms for this session
|
|
257
|
-
enabledPaymentPlatforms?: PaymentPlatformType[];
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
// Exact-token mode: merchant specifies USDC amount, customer pays variable fiat
|
|
261
|
-
type CreateSessionExactTokenRequest = CreateSessionBaseRequest & {
|
|
262
|
-
checkoutMode?: 'exact-token';
|
|
263
|
-
amountUsdc: string;
|
|
264
|
-
fiatAmount?: never;
|
|
265
|
-
fiatCurrency?: never;
|
|
266
|
-
maxFeePercentage?: never;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// Exact-fiat mode: merchant specifies fiat amount, customer pays fixed fiat
|
|
270
|
-
type CreateSessionExactFiatRequest = CreateSessionBaseRequest & {
|
|
271
|
-
checkoutMode: 'exact-fiat';
|
|
272
|
-
amountUsdc?: never;
|
|
273
|
-
fiatAmount: string; // Fixed fiat amount customer pays
|
|
274
|
-
fiatCurrency?: string; // e.g., "USD" (optional: falls back to merchant defaultFiatCurrency)
|
|
275
|
-
maxFeePercentage?: number; // Max acceptable fee % (optional, default 10%)
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export type CreateSessionRequest = CreateSessionExactTokenRequest | CreateSessionExactFiatRequest;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Bridge information returned when session requires cross-chain bridging.
|
|
282
|
-
* Amounts are in raw units (6 decimals for USDC).
|
|
283
|
-
*/
|
|
284
|
-
export type BridgeInfo = {
|
|
285
|
-
required: boolean;
|
|
286
|
-
inputAmount?: string | null; // Amount on Base (includes fees)
|
|
287
|
-
outputAmount?: string | null; // Expected output after fees
|
|
288
|
-
feeAmount?: string | null; // Total bridge fee
|
|
289
|
-
minOutputAmount?: string | null; // Merchant's requested amount
|
|
290
|
-
estimatedTimeSeconds?: number | null;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export type CreateSessionResponse = {
|
|
294
|
-
session: CheckoutSession;
|
|
295
|
-
sessionToken: string; // Plain-text token for checkout authentication (only returned at creation)
|
|
296
|
-
checkoutUrl: string; // Includes session ID and token
|
|
297
|
-
bridge?: BridgeInfo;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
export type StartSessionRequest = {
|
|
301
|
-
paymentPlatform?: PaymentPlatformType;
|
|
302
|
-
fiatCurrency?: string;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export type StartSessionResponse = {
|
|
306
|
-
session: CheckoutSession;
|
|
307
|
-
order: Order;
|
|
308
|
-
quote: Quote;
|
|
309
|
-
intentHash: string;
|
|
310
|
-
expiresAt?: string | null;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
export type MarkPaymentSentResponse = {
|
|
314
|
-
order: Order;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
export type FulfillIntentRequest = {
|
|
318
|
-
intentHash: string;
|
|
319
|
-
proof: Record<string, unknown> | string;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export type FulfillIntentResponse = {
|
|
323
|
-
order: Order;
|
|
324
|
-
proofAttemptId: string;
|
|
325
|
-
txHash: string;
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
// Error response when proof verification fails
|
|
329
|
-
// canRetry: true means user can submit new proof for the same maker
|
|
330
|
-
export type FulfillIntentError = {
|
|
331
|
-
proofAttemptId: string;
|
|
332
|
-
errorCode?: string;
|
|
333
|
-
errorMessage: string;
|
|
334
|
-
canRetry: boolean;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
// Response type for GET /api/orders/:id/proof-attempts
|
|
338
|
-
export type ProofAttemptsResponse = {
|
|
339
|
-
proofAttempts: ProofAttempt[];
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
// Response type for GET /api/orders/:orderId/bridge-status
|
|
343
|
-
export interface BridgeStatusResponse {
|
|
344
|
-
status: 'pending' | 'filled' | 'expired' | 'not_applicable';
|
|
345
|
-
destinationChainId?: string; // bigint as string
|
|
346
|
-
outputAmountUsdc?: string; // Estimated now, may be exact for filled status
|
|
347
|
-
fillTxHash?: string; // Transaction on destination chain
|
|
348
|
-
depositTxHash?: string; // Transaction on Base (fulfillTx)
|
|
349
|
-
acrossTrackingUrl?: string; // URL to track on Across website
|
|
350
|
-
estimatedFillTime?: number; // Seconds remaining (estimated)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Bridge information included in order responses.
|
|
355
|
-
* Tracks the status of cross-chain bridging via Across Protocol.
|
|
356
|
-
*/
|
|
357
|
-
export interface OrderBridgeInfo {
|
|
358
|
-
status: 'PENDING' | 'DEPOSITED' | 'FILLED' | 'EXPIRED';
|
|
359
|
-
destinationChainId: string; // bigint as string
|
|
360
|
-
outputAmountUsdc?: string; // Net amount after bridge fees (legacy: estimate/minimum)
|
|
361
|
-
estimatedOutputAmountUsdc?: string; // Real Across-estimated output before fulfillment slippage buffer
|
|
362
|
-
minOutputAmountUsdc?: string; // Buffered minimum output currently enforced at fulfill
|
|
363
|
-
fillTxHash?: string | null; // Transaction on destination chain
|
|
364
|
-
estimatedFillTime?: number | null; // Seconds (estimated)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// ============ Webhook Types ============
|
|
368
|
-
|
|
369
|
-
export const WebhookEventType = {
|
|
370
|
-
// Order lifecycle events
|
|
371
|
-
ORDER_CREATED: 'order.created',
|
|
372
|
-
ORDER_PAYMENT_SENT: 'order.payment_sent',
|
|
373
|
-
ORDER_FULFILLED: 'order.fulfilled',
|
|
374
|
-
ORDER_FAILED: 'order.failed',
|
|
375
|
-
ORDER_EXPIRED: 'order.expired',
|
|
376
|
-
|
|
377
|
-
// Session lifecycle events
|
|
378
|
-
SESSION_STARTED: 'session.started',
|
|
379
|
-
SESSION_COMPLETED: 'session.completed',
|
|
380
|
-
SESSION_ABANDONED: 'session.abandoned',
|
|
381
|
-
} as const;
|
|
382
|
-
|
|
383
|
-
export type WebhookEventTypeValue = typeof WebhookEventType[keyof typeof WebhookEventType];
|
|
384
|
-
|
|
385
|
-
export const WebhookDeliveryStatus = {
|
|
386
|
-
PENDING: 'PENDING',
|
|
387
|
-
DELIVERED: 'DELIVERED',
|
|
388
|
-
FAILED: 'FAILED',
|
|
389
|
-
} as const;
|
|
390
|
-
|
|
391
|
-
export type WebhookDeliveryStatusType = typeof WebhookDeliveryStatus[keyof typeof WebhookDeliveryStatus];
|
|
392
|
-
|
|
393
|
-
export type Webhook = {
|
|
394
|
-
id: string;
|
|
395
|
-
merchantId: string;
|
|
396
|
-
url: string;
|
|
397
|
-
events: WebhookEventTypeValue[];
|
|
398
|
-
active: boolean;
|
|
399
|
-
createdAt: string;
|
|
400
|
-
updatedAt: string;
|
|
401
|
-
// Note: secret is only returned on creation
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
export type WebhookWithSecret = Webhook & {
|
|
405
|
-
secret: string;
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
export type WebhookDelivery = {
|
|
409
|
-
id: string;
|
|
410
|
-
webhookId: string;
|
|
411
|
-
eventType: WebhookEventTypeValue;
|
|
412
|
-
eventId: string;
|
|
413
|
-
status: WebhookDeliveryStatusType;
|
|
414
|
-
attempts: number;
|
|
415
|
-
lastAttemptAt?: string | null;
|
|
416
|
-
nextRetryAt?: string | null;
|
|
417
|
-
responseCode?: number | null;
|
|
418
|
-
createdAt: string;
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
export type WebhookPayload = {
|
|
422
|
-
id: string;
|
|
423
|
-
type: WebhookEventTypeValue;
|
|
424
|
-
timestamp: string;
|
|
425
|
-
environment: MerchantEnvironmentType;
|
|
426
|
-
data: {
|
|
427
|
-
session: CheckoutSession;
|
|
428
|
-
order?: Order | null;
|
|
429
|
-
txHash?: string | null;
|
|
430
|
-
error?: {
|
|
431
|
-
code: string;
|
|
432
|
-
message: string;
|
|
433
|
-
} | null;
|
|
434
|
-
};
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
// Webhook management API types
|
|
438
|
-
export type CreateWebhookRequest = {
|
|
439
|
-
url: string;
|
|
440
|
-
events?: WebhookEventTypeValue[];
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
export type CreateWebhookResponse = WebhookWithSecret;
|
|
444
|
-
|
|
445
|
-
export type UpdateWebhookRequest = {
|
|
446
|
-
url?: string;
|
|
447
|
-
events?: WebhookEventTypeValue[];
|
|
448
|
-
active?: boolean;
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
export type ListWebhooksResponse = {
|
|
452
|
-
webhooks: Webhook[];
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
export type ListWebhookDeliveriesResponse = {
|
|
456
|
-
deliveries: WebhookDelivery[];
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
export type TestWebhookResponse = {
|
|
460
|
-
success: boolean;
|
|
461
|
-
deliveryId: string;
|
|
462
|
-
responseCode?: number | null;
|
|
463
|
-
error?: string | null;
|
|
464
|
-
};
|