@moonpay/platform-protocol 0.0.0 → 0.2.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/index.cjs +96 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1081 -0
- package/dist/index.d.ts +1081 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -5
- package/README.md +0 -3
- package/index.js +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fiat currency or crypto token
|
|
3
|
+
*/
|
|
4
|
+
type Asset = {
|
|
5
|
+
/**
|
|
6
|
+
* A fiat or crypto currency code.
|
|
7
|
+
*
|
|
8
|
+
* **Fiat**
|
|
9
|
+
* Fiat codes are represented as [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes.
|
|
10
|
+
*
|
|
11
|
+
* Currently only `USD` is supported.
|
|
12
|
+
*
|
|
13
|
+
* **Crypto**
|
|
14
|
+
* For crypto currency codes, see [supported currencies](https://dev.moonpay.com/docs/list-of-supported-cryptocurrencies).
|
|
15
|
+
*
|
|
16
|
+
* Examples: `BTC` `SOL` `ETH` `USDC_BASE` `USDC_SOL`
|
|
17
|
+
*/
|
|
18
|
+
code: string;
|
|
19
|
+
/**
|
|
20
|
+
* The human-readable name
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The number of supported decimal places
|
|
25
|
+
*/
|
|
26
|
+
precision?: number;
|
|
27
|
+
};
|
|
28
|
+
type AssetBase = {
|
|
29
|
+
/**
|
|
30
|
+
* A fiat or crypto currency code.
|
|
31
|
+
*
|
|
32
|
+
* **Fiat**
|
|
33
|
+
* Fiat codes are represented as [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes.
|
|
34
|
+
*
|
|
35
|
+
* Currently only `USD` is supported.
|
|
36
|
+
*
|
|
37
|
+
* **Crypto**
|
|
38
|
+
* For crypto currency codes, see [supported currencies](https://dev.moonpay.com/docs/list-of-supported-cryptocurrencies).
|
|
39
|
+
*
|
|
40
|
+
* Examples: `BTC` `SOL` `ETH` `USDC_BASE` `USDC_SOL`
|
|
41
|
+
*/
|
|
42
|
+
code: string;
|
|
43
|
+
};
|
|
44
|
+
type CreateSessionTokenRequestBody = {
|
|
45
|
+
/**
|
|
46
|
+
* A unique identifier for the customer from your system.
|
|
47
|
+
*/
|
|
48
|
+
externalCustomerId: string;
|
|
49
|
+
/**
|
|
50
|
+
* The IP address of the user's device to ensure the integrity of the session. Both IPv4 and IPv6 values are supported.
|
|
51
|
+
*/
|
|
52
|
+
deviceIp: IPv4Address | IPv6Address;
|
|
53
|
+
/**
|
|
54
|
+
* The customer's email address. Must be a valid email. If provided, `phoneNumber` must also be provided.
|
|
55
|
+
*/
|
|
56
|
+
email?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The customer's phone number in E.164 format. If provided, `email` must also be provided.
|
|
59
|
+
*/
|
|
60
|
+
phoneNumber?: string;
|
|
61
|
+
};
|
|
62
|
+
type CreateSessionTokenResponse = {
|
|
63
|
+
/**
|
|
64
|
+
* An opaque session token used to set up a connection on your frontend. This token is single-use and must be generated each time the customer visits your app.
|
|
65
|
+
*
|
|
66
|
+
* Token expires 24 hours after issuance.
|
|
67
|
+
*/
|
|
68
|
+
sessionToken: string;
|
|
69
|
+
};
|
|
70
|
+
type Fees = {
|
|
71
|
+
/**
|
|
72
|
+
* Network fees (in fiat) for the transaction.
|
|
73
|
+
*/
|
|
74
|
+
network?: MonetaryFeeAmount;
|
|
75
|
+
/**
|
|
76
|
+
* MoonPay fees (in fiat) for the transaction.
|
|
77
|
+
*/
|
|
78
|
+
moonpay?: MonetaryFeeAmount;
|
|
79
|
+
/**
|
|
80
|
+
* Ecosystem fees (in fiat) for the transaction, if applicable.
|
|
81
|
+
*/
|
|
82
|
+
ecosystem?: MonetaryFeeAmount;
|
|
83
|
+
/**
|
|
84
|
+
* Partner fees (in fiat) for the transaction, if applicable. Deprecated: use `fees.ecosystem` instead. This field will be removed in a future release.
|
|
85
|
+
* @deprecated
|
|
86
|
+
*/
|
|
87
|
+
partner?: MonetaryFeeAmount;
|
|
88
|
+
};
|
|
89
|
+
type GetQuoteBody = {
|
|
90
|
+
/**
|
|
91
|
+
* Source asset in fiat. Amount can be set in `source` or `destination`.
|
|
92
|
+
*/
|
|
93
|
+
source: {
|
|
94
|
+
/**
|
|
95
|
+
* The currency or token being spent
|
|
96
|
+
*/
|
|
97
|
+
asset: AssetBase;
|
|
98
|
+
/**
|
|
99
|
+
* A stringified amount, which can include decimals.
|
|
100
|
+
*/
|
|
101
|
+
amount?: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Destination asset in crypto. Amount can be set in `destination` or `source`.
|
|
105
|
+
*/
|
|
106
|
+
destination: {
|
|
107
|
+
asset: AssetBase;
|
|
108
|
+
/**
|
|
109
|
+
* The amount being received, if known
|
|
110
|
+
*/
|
|
111
|
+
amount?: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Wallet address and optional tag where the crypto will be sent. Required for the quote to be executable.
|
|
115
|
+
*/
|
|
116
|
+
wallet?: Wallet;
|
|
117
|
+
/**
|
|
118
|
+
* Payment method for the transaction. Required for the quote to be executable.
|
|
119
|
+
*/
|
|
120
|
+
paymentMethod?: QuotePaymentMethod;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Quote for a fiat-to-crypto buy. Contains locked rate, fees, expiry, and signature for payment execution.
|
|
124
|
+
*/
|
|
125
|
+
type GetQuoteResponse = {
|
|
126
|
+
/**
|
|
127
|
+
* Source side of the quote: amount and asset (fiat currency) you send.
|
|
128
|
+
*/
|
|
129
|
+
source: {
|
|
130
|
+
/**
|
|
131
|
+
* A stringified amount, which can include decimals.
|
|
132
|
+
*/
|
|
133
|
+
amount: string;
|
|
134
|
+
/**
|
|
135
|
+
* The currency or token being spent
|
|
136
|
+
*/
|
|
137
|
+
asset: Asset;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Destination side of the quote: amount and asset (cryptocurrency) the customer receives.
|
|
141
|
+
*/
|
|
142
|
+
destination: {
|
|
143
|
+
/**
|
|
144
|
+
* A stringified amount, which can include decimals.
|
|
145
|
+
*/
|
|
146
|
+
amount: string;
|
|
147
|
+
asset: Asset;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Breakdown of network, MoonPay, and ecosystem fees.
|
|
151
|
+
*/
|
|
152
|
+
fees: Fees;
|
|
153
|
+
/**
|
|
154
|
+
* Wallet address and optional tag where the crypto will be sent. Null when not provided.
|
|
155
|
+
*/
|
|
156
|
+
wallet: Wallet | null;
|
|
157
|
+
/**
|
|
158
|
+
* The payment method used for the quote.
|
|
159
|
+
*/
|
|
160
|
+
paymentMethod: QuotePaymentMethod | null;
|
|
161
|
+
limits: QuoteLimits | null;
|
|
162
|
+
/**
|
|
163
|
+
* An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the quote expires.
|
|
164
|
+
*/
|
|
165
|
+
expiresAt: string;
|
|
166
|
+
/**
|
|
167
|
+
* Whether the quote can be executed. Only `executable` quotes can be used to initiate payment frames.
|
|
168
|
+
*/
|
|
169
|
+
executable: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* The rate used to convert fiat <-> crypto, expressed as the crypto value of one unit of fiat.
|
|
172
|
+
*/
|
|
173
|
+
exchangeRate: string;
|
|
174
|
+
/**
|
|
175
|
+
* An opaque token representing the quote to initiate payment frames.
|
|
176
|
+
*/
|
|
177
|
+
signature: string;
|
|
178
|
+
};
|
|
179
|
+
type IPv4Address = string;
|
|
180
|
+
type IPv6Address = string;
|
|
181
|
+
type LimitWithAsset = {
|
|
182
|
+
/**
|
|
183
|
+
* A stringified amount, which can include decimals.
|
|
184
|
+
*/
|
|
185
|
+
amount: string;
|
|
186
|
+
asset: AssetBase;
|
|
187
|
+
};
|
|
188
|
+
type MonetaryFeeAmount = {
|
|
189
|
+
/**
|
|
190
|
+
* The amount of fees in fiat.
|
|
191
|
+
*/
|
|
192
|
+
amount: string;
|
|
193
|
+
/**
|
|
194
|
+
* The fiat currency used to pay the fees.
|
|
195
|
+
*/
|
|
196
|
+
asset: AssetBase;
|
|
197
|
+
};
|
|
198
|
+
type MoonPayCorePaginationInfo = {
|
|
199
|
+
/**
|
|
200
|
+
* The cursor to use as the starting point for the next page of results.
|
|
201
|
+
*/
|
|
202
|
+
nextCursor: string | null;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* The card network brand.
|
|
206
|
+
*/
|
|
207
|
+
type MoonPayPaymentsCardBrand = 'visa' | 'mastercard' | 'maestro' | 'american_express' | 'other';
|
|
208
|
+
/**
|
|
209
|
+
* The type of card: credit, debit, or unknown.
|
|
210
|
+
*/
|
|
211
|
+
type MoonPayPaymentsCardType = 'credit' | 'debit' | 'unknown';
|
|
212
|
+
type MoonPayPaymentsListPaymentMethodsResponse = {
|
|
213
|
+
/**
|
|
214
|
+
* List of available payment method configurations
|
|
215
|
+
*/
|
|
216
|
+
paymentMethodConfigs?: Array<MoonPayPaymentsPaymentMethod>;
|
|
217
|
+
/**
|
|
218
|
+
* List of stored payment methods available for the customer
|
|
219
|
+
*/
|
|
220
|
+
paymentMethods?: Array<MoonPayPaymentsStoredPaymentMethod>;
|
|
221
|
+
};
|
|
222
|
+
type MoonPayPaymentsPaymentMethod = {
|
|
223
|
+
type: PaymentMethodType;
|
|
224
|
+
/**
|
|
225
|
+
* Details of how the payment method can be used.
|
|
226
|
+
*/
|
|
227
|
+
capabilities: MoonPayPaymentsPaymentMethodCapabilities;
|
|
228
|
+
availability: MoonPayPaymentsPaymentMethodAvailability;
|
|
229
|
+
};
|
|
230
|
+
type MoonPayPaymentsPaymentMethodAvailability = {
|
|
231
|
+
/**
|
|
232
|
+
* Whether the payment method is available
|
|
233
|
+
*/
|
|
234
|
+
active: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* If the payment method is not available, reasons explaining why.
|
|
237
|
+
*/
|
|
238
|
+
reasons?: Array<string>;
|
|
239
|
+
};
|
|
240
|
+
type MoonPayPaymentsPaymentMethodCapabilities = {
|
|
241
|
+
/**
|
|
242
|
+
* [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes of fiat currencies supported by this payment method.
|
|
243
|
+
*/
|
|
244
|
+
supportedCurrencies: Array<string>;
|
|
245
|
+
/**
|
|
246
|
+
* Transaction types supported by this payment method.
|
|
247
|
+
*/
|
|
248
|
+
supportedTransactionTypes: Array<string>;
|
|
249
|
+
/**
|
|
250
|
+
* Whether this payment method can be deleted.
|
|
251
|
+
*/
|
|
252
|
+
allowsDeletion: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Whether this payment method requires the MoonPay widget to complete the payment flow.
|
|
255
|
+
*/
|
|
256
|
+
requiresWidget: boolean;
|
|
257
|
+
};
|
|
258
|
+
type MoonPayPaymentsStoredCardPaymentMethod = MoonPayPaymentsStoredPaymentMethodBase & {
|
|
259
|
+
cardType: MoonPayPaymentsCardType;
|
|
260
|
+
/**
|
|
261
|
+
* The card network brand
|
|
262
|
+
*/
|
|
263
|
+
brand: MoonPayPaymentsCardBrand;
|
|
264
|
+
/**
|
|
265
|
+
* Last 4 digits of the card number
|
|
266
|
+
*/
|
|
267
|
+
last4: string;
|
|
268
|
+
/**
|
|
269
|
+
* Expiration month as 2-digit string
|
|
270
|
+
*/
|
|
271
|
+
expirationMonth: string;
|
|
272
|
+
/**
|
|
273
|
+
* Expiration year as 4-digit string
|
|
274
|
+
*/
|
|
275
|
+
expirationYear: string;
|
|
276
|
+
/**
|
|
277
|
+
* Current availability of this stored card
|
|
278
|
+
*/
|
|
279
|
+
availability: MoonPayPaymentsPaymentMethodAvailability;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* A stored payment method.
|
|
283
|
+
*/
|
|
284
|
+
type MoonPayPaymentsStoredPaymentMethod = MoonPayPaymentsStoredPaymentMethodBase | MoonPayPaymentsStoredCardPaymentMethod;
|
|
285
|
+
type MoonPayPaymentsStoredPaymentMethodBase = {
|
|
286
|
+
/**
|
|
287
|
+
* Unique identifier for the stored payment method
|
|
288
|
+
*/
|
|
289
|
+
id: string;
|
|
290
|
+
type: PaymentMethodType;
|
|
291
|
+
};
|
|
292
|
+
type PaymentMethodType = 'apple_pay' | 'card' | 'ach' | 'fps' | 'fps_open_banking' | 'google_pay' | 'sepa' | 'sepa_open_banking' | 'pix' | 'paypal' | 'venmo' | 'revolut_pay' | 'moonpay_balance' | 'interac';
|
|
293
|
+
type QuoteLimitEntry = {
|
|
294
|
+
/**
|
|
295
|
+
* The maximum amount.
|
|
296
|
+
*/
|
|
297
|
+
limit: LimitWithAsset;
|
|
298
|
+
/**
|
|
299
|
+
* The remaining amount.
|
|
300
|
+
*/
|
|
301
|
+
remaining: LimitWithAsset;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Limits applicable to the quote.
|
|
305
|
+
*/
|
|
306
|
+
type QuoteLimits = {
|
|
307
|
+
/**
|
|
308
|
+
* The daily limit.
|
|
309
|
+
*/
|
|
310
|
+
daily?: QuoteLimitEntry;
|
|
311
|
+
/**
|
|
312
|
+
* The monthly limit.
|
|
313
|
+
*/
|
|
314
|
+
monthly?: QuoteLimitEntry;
|
|
315
|
+
/**
|
|
316
|
+
* The yearly limit.
|
|
317
|
+
*/
|
|
318
|
+
yearly?: QuoteLimitEntry;
|
|
319
|
+
};
|
|
320
|
+
type QuotePaymentMethod = {
|
|
321
|
+
type: PaymentMethodType;
|
|
322
|
+
/**
|
|
323
|
+
* Unique identifier of the payment method. Used to identify the specific card when type is card.
|
|
324
|
+
*/
|
|
325
|
+
id?: string;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* A stage in the transaction lifecycle
|
|
329
|
+
*/
|
|
330
|
+
type Stage = {
|
|
331
|
+
kind?: StageKind;
|
|
332
|
+
/**
|
|
333
|
+
* The human-readable name of the stage.
|
|
334
|
+
*/
|
|
335
|
+
name?: string;
|
|
336
|
+
status?: StageStatus;
|
|
337
|
+
/**
|
|
338
|
+
* A developer-friendly message if the status is `failed`
|
|
339
|
+
*/
|
|
340
|
+
failureReason?: string | null;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* The stages in a transaction lifecycle.
|
|
344
|
+
*/
|
|
345
|
+
type StageKind = 'ordering' | 'waiting_payment' | 'waiting_authentication' | 'verification' | 'processing' | 'delivery' | 'crypto_hold';
|
|
346
|
+
/**
|
|
347
|
+
* The status of a transaction stage.
|
|
348
|
+
*/
|
|
349
|
+
type StageStatus = 'not_started' | 'in_progress' | 'success' | 'failed';
|
|
350
|
+
type TermsAttestation = {
|
|
351
|
+
/**
|
|
352
|
+
* The MoonPay ID of the terms attestation.
|
|
353
|
+
*/
|
|
354
|
+
id: string;
|
|
355
|
+
/**
|
|
356
|
+
* Your identifier for the end customer who accepted MoonPay's terms.
|
|
357
|
+
*/
|
|
358
|
+
externalCustomerId: string;
|
|
359
|
+
/**
|
|
360
|
+
* An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string indicating when the attestation was recorded.
|
|
361
|
+
*/
|
|
362
|
+
attestedAt: string;
|
|
363
|
+
};
|
|
364
|
+
type Transaction = {
|
|
365
|
+
/**
|
|
366
|
+
* The MoonPay ID of the transaction.
|
|
367
|
+
*/
|
|
368
|
+
id: string;
|
|
369
|
+
/**
|
|
370
|
+
* An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the transaction was created.
|
|
371
|
+
*/
|
|
372
|
+
createdAt: string;
|
|
373
|
+
/**
|
|
374
|
+
* An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the transaction was last updated.
|
|
375
|
+
*/
|
|
376
|
+
updatedAt: string;
|
|
377
|
+
status: TransactionStatus;
|
|
378
|
+
/**
|
|
379
|
+
* Source amount and asset (fiat currency) the customer paid.
|
|
380
|
+
*/
|
|
381
|
+
source: {
|
|
382
|
+
/**
|
|
383
|
+
* A stringified amount, which can include decimals.
|
|
384
|
+
*/
|
|
385
|
+
amount: string;
|
|
386
|
+
/**
|
|
387
|
+
* The currency or token being spent
|
|
388
|
+
*/
|
|
389
|
+
asset: AssetBase;
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Destination amount and asset (cryptocurrency) the customer receives.
|
|
393
|
+
*/
|
|
394
|
+
destination: {
|
|
395
|
+
/**
|
|
396
|
+
* A stringified amount, which can include decimals.
|
|
397
|
+
*/
|
|
398
|
+
amount: string;
|
|
399
|
+
asset: AssetBase;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Details of fees for the transaction.
|
|
403
|
+
*/
|
|
404
|
+
fees: Fees;
|
|
405
|
+
/**
|
|
406
|
+
* The wallet used for the transaction.
|
|
407
|
+
*/
|
|
408
|
+
wallet: Wallet;
|
|
409
|
+
customer: TransactionCustomer;
|
|
410
|
+
paymentMethod?: TransactionPaymentMethod;
|
|
411
|
+
};
|
|
412
|
+
type TransactionCustomer = {
|
|
413
|
+
/**
|
|
414
|
+
* The MoonPay ID of the customer associated with the transaction.
|
|
415
|
+
*/
|
|
416
|
+
id: string;
|
|
417
|
+
};
|
|
418
|
+
type TransactionPaymentMethod = {
|
|
419
|
+
type: PaymentMethodType;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* The status of a transaction.
|
|
423
|
+
*
|
|
424
|
+
* - `completed`: The transaction is finalized and assets were delivered.
|
|
425
|
+
* - `failed`: The transaction failed. No payment was executed and funds were not transferred.
|
|
426
|
+
* - `pending`: The transaction was created and payment is accepted. The transfer is in progress.
|
|
427
|
+
*/
|
|
428
|
+
type TransactionStatus = 'completed' | 'failed' | 'pending';
|
|
429
|
+
/**
|
|
430
|
+
* Transaction with lifecycle stages showing step-by-step progress.
|
|
431
|
+
*/
|
|
432
|
+
type TransactionWithStages = Transaction & {
|
|
433
|
+
/**
|
|
434
|
+
* Details of the stages in the transaction lifecycle.
|
|
435
|
+
*/
|
|
436
|
+
stages?: Array<Stage>;
|
|
437
|
+
};
|
|
438
|
+
type Wallet = {
|
|
439
|
+
/**
|
|
440
|
+
* The wallet address used for the transaction.
|
|
441
|
+
*/
|
|
442
|
+
address: string;
|
|
443
|
+
/**
|
|
444
|
+
* An optional memo or destination tag (used by some blockchains such as XRP or XLM).
|
|
445
|
+
*/
|
|
446
|
+
tag?: string;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
declare enum ConnectionStatus {
|
|
450
|
+
/**
|
|
451
|
+
* New or expired user — needs the full connect flow.
|
|
452
|
+
*/
|
|
453
|
+
connectionRequired = "connectionRequired",
|
|
454
|
+
/**
|
|
455
|
+
* Valid connection — encrypted credentials are included.
|
|
456
|
+
*/
|
|
457
|
+
active = "active",
|
|
458
|
+
/**
|
|
459
|
+
* Restricted location — connection cannot be used.
|
|
460
|
+
*/
|
|
461
|
+
unavailable = "unavailable",
|
|
462
|
+
/**
|
|
463
|
+
* KYC decision delayed — may resolve on a subsequent visit.
|
|
464
|
+
*/
|
|
465
|
+
pending = "pending",
|
|
466
|
+
/**
|
|
467
|
+
* Terminal failure — KYC fail, rejection, etc.
|
|
468
|
+
*/
|
|
469
|
+
failed = "failed",
|
|
470
|
+
/**
|
|
471
|
+
* Customer has no valid Terms of Use attestation on file (headless/Identity API partners).
|
|
472
|
+
* Display Terms of Use in your own UI, capture acceptance, call
|
|
473
|
+
* `POST /platform/v1/terms/attestations`, then retry the connection.
|
|
474
|
+
*/
|
|
475
|
+
termsAcceptanceRequired = "termsAcceptanceRequired"
|
|
476
|
+
}
|
|
477
|
+
interface ConnectionRequired {
|
|
478
|
+
status: ConnectionStatus.connectionRequired;
|
|
479
|
+
/**
|
|
480
|
+
* Base64-encoded, X25519+AES-GCM encrypted anonymous token payload.
|
|
481
|
+
* These are frame-internal tokens used by the connect frame — they cannot be
|
|
482
|
+
* used to call MoonPay APIs directly. Decrypt via `decryptCredentials()` only
|
|
483
|
+
* if you need the `clientToken` to bootstrap the connect frame manually.
|
|
484
|
+
*/
|
|
485
|
+
credentials: string;
|
|
486
|
+
/**
|
|
487
|
+
* Capabilities and regulatory requirements available before authentication, if any.
|
|
488
|
+
* Present when Apple Pay 1TAP is enabled for the partner.
|
|
489
|
+
*/
|
|
490
|
+
capabilities?: CustomerCapabilities;
|
|
491
|
+
}
|
|
492
|
+
interface ActiveConnection {
|
|
493
|
+
status: ConnectionStatus.active;
|
|
494
|
+
/** The authenticated MoonPay customer. */
|
|
495
|
+
customer: {
|
|
496
|
+
id: string;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* Base64-encoded, X25519+AES-GCM encrypted JSON containing:
|
|
500
|
+
* ```json
|
|
501
|
+
* {
|
|
502
|
+
* "accessToken": "<token>",
|
|
503
|
+
* "clientToken": "<token>",
|
|
504
|
+
* "expiresAt": "<iso8601>"
|
|
505
|
+
* }
|
|
506
|
+
* ```
|
|
507
|
+
*
|
|
508
|
+
* - `accessToken`: A token that can be used to make API requests from the client.
|
|
509
|
+
* - `clientToken`: A token that can be used to initialize sensitive frames such as Apple Pay.
|
|
510
|
+
* - `expiresAt`: An ISO 8601 formatted string indicating when the tokens expire.
|
|
511
|
+
*/
|
|
512
|
+
credentials: string;
|
|
513
|
+
/**
|
|
514
|
+
* Capabilities and regulatory requirements for the authenticated customer.
|
|
515
|
+
*/
|
|
516
|
+
capabilities: CustomerCapabilities;
|
|
517
|
+
}
|
|
518
|
+
interface UnavailableConnection {
|
|
519
|
+
status: ConnectionStatus.unavailable;
|
|
520
|
+
}
|
|
521
|
+
interface PendingConnection {
|
|
522
|
+
status: ConnectionStatus.pending;
|
|
523
|
+
}
|
|
524
|
+
interface FailedConnection {
|
|
525
|
+
status: ConnectionStatus.failed;
|
|
526
|
+
reason: string;
|
|
527
|
+
}
|
|
528
|
+
interface TermsAcceptanceRequiredConnection {
|
|
529
|
+
status: ConnectionStatus.termsAcceptanceRequired;
|
|
530
|
+
}
|
|
531
|
+
/** Discriminated union of all connection result statuses. */
|
|
532
|
+
type Connection = ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
|
|
533
|
+
interface DecryptedCredentials {
|
|
534
|
+
accessToken: string;
|
|
535
|
+
clientToken: string;
|
|
536
|
+
expiresAt: string;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Capabilities and regulatory requirements for the authenticated customer.
|
|
540
|
+
*/
|
|
541
|
+
interface CustomerCapabilities {
|
|
542
|
+
/** Capabilities for the ramps (buy and sell) product. */
|
|
543
|
+
ramps?: RampsCapability;
|
|
544
|
+
/** Capabilities for the Apple Pay 1TAP flow. Present when 1TAP is enabled for the partner and the customer matches. */
|
|
545
|
+
oneTapApplePay?: RampsCapability;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Capabilities and requirements for the ramps (buy and sell) product.
|
|
549
|
+
*/
|
|
550
|
+
interface RampsCapability {
|
|
551
|
+
/** Regulatory requirements for ramps operations in the customer's jurisdiction. */
|
|
552
|
+
requirements: RampsRequirements;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Regulatory requirements that apply to ramps operations for the customer.
|
|
556
|
+
*/
|
|
557
|
+
interface RampsRequirements {
|
|
558
|
+
/**
|
|
559
|
+
* Present when the customer's jurisdiction requires payment disclosures
|
|
560
|
+
* before a ramps transaction. Omitted when no disclosures are required.
|
|
561
|
+
*/
|
|
562
|
+
paymentDisclosures?: PaymentDisclosuresRequirement;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* A jurisdiction that requires payment disclosures before a ramps transaction.
|
|
566
|
+
*/
|
|
567
|
+
interface PaymentDisclosuresRequirement {
|
|
568
|
+
/** The ISO 3166-1 alpha-3 country code for the jurisdiction. */
|
|
569
|
+
country: string;
|
|
570
|
+
/** The state or province code within the country. */
|
|
571
|
+
administrativeArea: string;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
declare enum ConnectionErrorCode {
|
|
575
|
+
validationError = "validationError",
|
|
576
|
+
/** Wire value is `'generic'`. */
|
|
577
|
+
connectionFailedGeneric = "generic"
|
|
578
|
+
}
|
|
579
|
+
interface ConfigValidationFieldError {
|
|
580
|
+
code: 'invalidSessionToken' | 'invalidClientToken' | 'invalidPublicKey';
|
|
581
|
+
message: string;
|
|
582
|
+
}
|
|
583
|
+
type ConnectionError = {
|
|
584
|
+
code: ConnectionErrorCode.validationError;
|
|
585
|
+
errors: ConfigValidationFieldError[];
|
|
586
|
+
} | {
|
|
587
|
+
code: ConnectionErrorCode.connectionFailedGeneric;
|
|
588
|
+
message?: string;
|
|
589
|
+
};
|
|
590
|
+
declare const DevPlatformApiErrorCodes: {
|
|
591
|
+
readonly unknownError: "unknown_error";
|
|
592
|
+
readonly unauthorized: "unauthorized";
|
|
593
|
+
readonly forbidden: "forbidden";
|
|
594
|
+
readonly notFound: "not_found";
|
|
595
|
+
readonly invalidRequest: "invalid_request";
|
|
596
|
+
readonly notImplemented: "not_implemented";
|
|
597
|
+
readonly tooManyRequests: "too_many_requests";
|
|
598
|
+
readonly notAllowed: "not_allowed";
|
|
599
|
+
readonly conflict: "conflict";
|
|
600
|
+
readonly unprocessableEntity: "unprocessable_entity";
|
|
601
|
+
readonly sseTimeout: "sse_timeout";
|
|
602
|
+
readonly sseError: "sse_error";
|
|
603
|
+
readonly connectionRequired: "connection_required";
|
|
604
|
+
readonly connectionPending: "connection_pending";
|
|
605
|
+
readonly connectionUnavailable: "connection_unavailable";
|
|
606
|
+
readonly serviceUnavailable: "service_unavailable";
|
|
607
|
+
readonly requirementsIncomplete: "requirements_incomplete";
|
|
608
|
+
readonly verificationRejected: "verification_rejected";
|
|
609
|
+
readonly countryMismatch: "country_mismatch";
|
|
610
|
+
readonly unsupportedCountry: "unsupported_country";
|
|
611
|
+
};
|
|
612
|
+
type DevPlatformApiErrorCode = (typeof DevPlatformApiErrorCodes)[keyof typeof DevPlatformApiErrorCodes];
|
|
613
|
+
interface DevPlatformApiErrorDetail {
|
|
614
|
+
field?: string;
|
|
615
|
+
message: string;
|
|
616
|
+
}
|
|
617
|
+
/** Shape returned by the MoonPay Platform API on error responses. */
|
|
618
|
+
interface DevPlatformApiError {
|
|
619
|
+
code: DevPlatformApiErrorCode;
|
|
620
|
+
message: string;
|
|
621
|
+
errors?: DevPlatformApiErrorDetail[];
|
|
622
|
+
}
|
|
623
|
+
interface GetConnectionError {
|
|
624
|
+
message: string;
|
|
625
|
+
}
|
|
626
|
+
interface ConnectError {
|
|
627
|
+
message: string;
|
|
628
|
+
}
|
|
629
|
+
interface SetupWidgetError {
|
|
630
|
+
kind: 'configurationError' | 'apiError' | 'genericError';
|
|
631
|
+
message: string;
|
|
632
|
+
}
|
|
633
|
+
interface SetupApplePayError {
|
|
634
|
+
kind: 'invalidQuote' | 'quoteExpired' | 'applePayUnavailable' | 'oneTapApplePaySecondFactorRequired' | 'genericError';
|
|
635
|
+
message: string;
|
|
636
|
+
}
|
|
637
|
+
interface SetupGooglePayError {
|
|
638
|
+
kind: 'invalidQuote' | 'quoteExpired' | 'googlePayUnavailable' | 'genericError';
|
|
639
|
+
message: string;
|
|
640
|
+
}
|
|
641
|
+
type GetQuoteError = DevPlatformApiError;
|
|
642
|
+
type GetPaymentMethodsError = DevPlatformApiError;
|
|
643
|
+
type GetTransactionsError = DevPlatformApiError;
|
|
644
|
+
type CreateSessionError = DevPlatformApiError;
|
|
645
|
+
type RevokeSessionError = DevPlatformApiError;
|
|
646
|
+
interface SetupBuyError {
|
|
647
|
+
kind: 'configurationError' | 'genericError';
|
|
648
|
+
message: string;
|
|
649
|
+
}
|
|
650
|
+
interface SetupBuyButtonError {
|
|
651
|
+
kind: 'configurationError' | 'genericError';
|
|
652
|
+
message: string;
|
|
653
|
+
}
|
|
654
|
+
interface SetupChallengeError {
|
|
655
|
+
kind: 'configurationError' | 'genericError';
|
|
656
|
+
message: string;
|
|
657
|
+
}
|
|
658
|
+
interface SetupAddCardError {
|
|
659
|
+
kind: 'configurationError' | 'genericError';
|
|
660
|
+
message: string;
|
|
661
|
+
}
|
|
662
|
+
interface ResetConnectionError {
|
|
663
|
+
message: string;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** The V2 protocol envelope sent over postMessage between frames and SDK. */
|
|
667
|
+
interface ProtocolMessage<K extends string = string, P = unknown> {
|
|
668
|
+
version: 2;
|
|
669
|
+
meta: {
|
|
670
|
+
channelId: string;
|
|
671
|
+
};
|
|
672
|
+
kind: K;
|
|
673
|
+
payload?: P;
|
|
674
|
+
}
|
|
675
|
+
declare const HANDSHAKE_REQUEST_KIND: "handshake";
|
|
676
|
+
declare const HANDSHAKE_ACK_KIND: "ack";
|
|
677
|
+
type HandshakeRequest = ProtocolMessage<typeof HANDSHAKE_REQUEST_KIND>;
|
|
678
|
+
type HandshakeAck = ProtocolMessage<typeof HANDSHAKE_ACK_KIND>;
|
|
679
|
+
/**
|
|
680
|
+
* Maps message `kind` to its payload type for the widget frame.
|
|
681
|
+
* Frames use this to type-check what they send; SDK uses it to type-check
|
|
682
|
+
* what it receives.
|
|
683
|
+
*/
|
|
684
|
+
interface WidgetMessageMap {
|
|
685
|
+
ready: void;
|
|
686
|
+
error: {
|
|
687
|
+
code: 'configurationError' | 'apiError' | 'generic';
|
|
688
|
+
message: string;
|
|
689
|
+
};
|
|
690
|
+
transactionCreated: {
|
|
691
|
+
transaction: {
|
|
692
|
+
id: string;
|
|
693
|
+
status: string;
|
|
694
|
+
};
|
|
695
|
+
};
|
|
696
|
+
complete: {
|
|
697
|
+
transaction: FrameTransaction;
|
|
698
|
+
};
|
|
699
|
+
close: void;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Maps message `kind` to its payload type for the Apple Pay frame
|
|
703
|
+
* (child → parent direction).
|
|
704
|
+
*/
|
|
705
|
+
interface ApplePayInboundMessageMap {
|
|
706
|
+
ready: void;
|
|
707
|
+
error: {
|
|
708
|
+
code: 'configurationError' | 'quoteExpired' | 'invalidQuote' | 'applePayUnavailable' | 'generic' | 'oneTapApplePaySecondFactorRequired';
|
|
709
|
+
message: string;
|
|
710
|
+
};
|
|
711
|
+
complete: {
|
|
712
|
+
transaction: FrameTransaction;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Maps message `kind` to its payload type for the Apple Pay frame
|
|
717
|
+
* (parent → child direction).
|
|
718
|
+
*/
|
|
719
|
+
interface ApplePayOutboundMessageMap {
|
|
720
|
+
setQuote: {
|
|
721
|
+
quote: {
|
|
722
|
+
signature: string;
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Maps message `kind` to its payload type for the Google Pay frame
|
|
728
|
+
* (child → parent direction).
|
|
729
|
+
*/
|
|
730
|
+
interface GooglePayInboundMessageMap {
|
|
731
|
+
ready: void;
|
|
732
|
+
error: {
|
|
733
|
+
code: 'configurationError' | 'quoteExpired' | 'invalidQuote' | 'googlePayUnavailable' | 'generic';
|
|
734
|
+
message: string;
|
|
735
|
+
};
|
|
736
|
+
/** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
|
|
737
|
+
challenge: {
|
|
738
|
+
kind: 'frame';
|
|
739
|
+
url: string;
|
|
740
|
+
};
|
|
741
|
+
complete: {
|
|
742
|
+
transaction: FrameTransaction;
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Maps message `kind` to its payload type for the Google Pay frame
|
|
747
|
+
* (parent → child direction).
|
|
748
|
+
*/
|
|
749
|
+
interface GooglePayOutboundMessageMap {
|
|
750
|
+
setQuote: {
|
|
751
|
+
quote: {
|
|
752
|
+
signature: string;
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Maps message `kind` to its payload type for the connect/check-connection
|
|
758
|
+
* frame (child → parent direction).
|
|
759
|
+
*/
|
|
760
|
+
interface ConnectMessageMap {
|
|
761
|
+
ready: void;
|
|
762
|
+
error: ConnectionError;
|
|
763
|
+
complete: ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Maps message `kind` to its payload type for the buy frame
|
|
767
|
+
* (child → parent direction).
|
|
768
|
+
*
|
|
769
|
+
* The buy frame executes the full buy pipeline (pre-check → create →
|
|
770
|
+
* post-check) headlessly. It may escalate to a challenge frame mid-pipeline.
|
|
771
|
+
*/
|
|
772
|
+
interface BuyMessageMap {
|
|
773
|
+
ready: void;
|
|
774
|
+
complete: {
|
|
775
|
+
transaction: FrameTransaction;
|
|
776
|
+
};
|
|
777
|
+
/** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
|
|
778
|
+
challenge: {
|
|
779
|
+
kind: string;
|
|
780
|
+
url: string;
|
|
781
|
+
};
|
|
782
|
+
error: {
|
|
783
|
+
code: string;
|
|
784
|
+
message: string;
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Maps message `kind` to its payload type for the buy frame
|
|
789
|
+
* (parent → child direction).
|
|
790
|
+
*/
|
|
791
|
+
interface BuyOutboundMessageMap {
|
|
792
|
+
setQuote: {
|
|
793
|
+
quote: {
|
|
794
|
+
signature: string;
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Maps message `kind` to its payload type for the buy-button frame
|
|
800
|
+
* (child → parent direction).
|
|
801
|
+
*
|
|
802
|
+
* The buy-button frame renders a payment button (card, Apple Pay, Google Pay)
|
|
803
|
+
* and runs the buy pipeline on tap. It may escalate to a challenge frame.
|
|
804
|
+
*/
|
|
805
|
+
interface BuyButtonMessageMap {
|
|
806
|
+
complete: {
|
|
807
|
+
transaction: FrameTransaction;
|
|
808
|
+
};
|
|
809
|
+
/** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
|
|
810
|
+
challenge: {
|
|
811
|
+
kind: string;
|
|
812
|
+
url: string;
|
|
813
|
+
};
|
|
814
|
+
error: {
|
|
815
|
+
code: string;
|
|
816
|
+
message: string;
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Maps message `kind` to its payload type for the buy-button frame
|
|
821
|
+
* (parent → child direction).
|
|
822
|
+
*/
|
|
823
|
+
interface BuyButtonOutboundMessageMap {
|
|
824
|
+
setQuote: {
|
|
825
|
+
quote: {
|
|
826
|
+
signature: string;
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
type ChallengeCompleteResult = {
|
|
831
|
+
flow: 'buy';
|
|
832
|
+
transaction: FrameTransaction;
|
|
833
|
+
} | {
|
|
834
|
+
flow: 'identity';
|
|
835
|
+
identityId: string;
|
|
836
|
+
};
|
|
837
|
+
type ChallengeCancellation = {
|
|
838
|
+
flow: 'buy';
|
|
839
|
+
transactionId?: string;
|
|
840
|
+
challengeToken?: string;
|
|
841
|
+
} | {
|
|
842
|
+
flow: 'identity';
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* Maps message `kind` to its payload type for the challenge frame
|
|
846
|
+
* (child → parent direction).
|
|
847
|
+
*
|
|
848
|
+
* The challenge frame is fully self-contained — it is driven by the
|
|
849
|
+
* `challengeToken` URL param. There is no parent → child message map.
|
|
850
|
+
*/
|
|
851
|
+
interface ChallengeMessageMap {
|
|
852
|
+
ready: void;
|
|
853
|
+
complete: ChallengeCompleteResult;
|
|
854
|
+
/** User dismissed the challenge. Carry `transactionId` / `challengeToken` to resume. */
|
|
855
|
+
cancelled: ChallengeCancellation;
|
|
856
|
+
error: {
|
|
857
|
+
code: string;
|
|
858
|
+
message: string;
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Maps message `kind` to its payload type for the reset frame
|
|
863
|
+
* (child → parent direction).
|
|
864
|
+
*
|
|
865
|
+
* The reset frame clears the customer's MoonPay connection for the partner.
|
|
866
|
+
* It is fully driven by the `sessionToken` URL param. There is no
|
|
867
|
+
* parent → child message map.
|
|
868
|
+
*/
|
|
869
|
+
interface ResetMessageMap {
|
|
870
|
+
complete: void;
|
|
871
|
+
error: {
|
|
872
|
+
code: string;
|
|
873
|
+
message: string;
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
/** Card returned by the add-card frame on successful creation. */
|
|
877
|
+
interface CardResponse {
|
|
878
|
+
id: string;
|
|
879
|
+
/** Payment method type, e.g. `'card'`. */
|
|
880
|
+
type: string;
|
|
881
|
+
/** Card sub-type, e.g. `'credit'` or `'debit'`. */
|
|
882
|
+
cardType: string;
|
|
883
|
+
/** Card network brand, e.g. `'visa'` or `'mastercard'`. */
|
|
884
|
+
brand: string;
|
|
885
|
+
last4: string;
|
|
886
|
+
expirationMonth: string;
|
|
887
|
+
expirationYear: string;
|
|
888
|
+
availability: {
|
|
889
|
+
active: true;
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Maps message `kind` to its payload type for the add-card frame
|
|
894
|
+
* (child → parent direction).
|
|
895
|
+
*
|
|
896
|
+
* There is no parent → child message map for the add-card frame.
|
|
897
|
+
*/
|
|
898
|
+
interface AddCardMessageMap {
|
|
899
|
+
complete: {
|
|
900
|
+
card: CardResponse;
|
|
901
|
+
};
|
|
902
|
+
error: {
|
|
903
|
+
code: 'generic' | 'configurationError';
|
|
904
|
+
message: string;
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** Transaction shape as sent within frame postMessage payloads. */
|
|
909
|
+
type FrameTransaction = {
|
|
910
|
+
id: string;
|
|
911
|
+
status: string;
|
|
912
|
+
} | {
|
|
913
|
+
id?: string;
|
|
914
|
+
status: 'failed';
|
|
915
|
+
failureReason: string;
|
|
916
|
+
};
|
|
917
|
+
/** A ProtocolMessage typed to a specific message map entry. */
|
|
918
|
+
type TypedMessage<Map extends Record<string, unknown>, K extends keyof Map & string> = Map[K] extends void ? ProtocolMessage<K, undefined> : ProtocolMessage<K, Map[K]>;
|
|
919
|
+
/** Union of all typed messages for a given message map. */
|
|
920
|
+
type MessageUnion<Map extends Record<string, unknown>> = {
|
|
921
|
+
[K in keyof Map & string]: TypedMessage<Map, K>;
|
|
922
|
+
}[keyof Map & string];
|
|
923
|
+
|
|
924
|
+
/** A parent→child message to update the quote in the Apple Pay frame. */
|
|
925
|
+
type SetQuoteCommand = ProtocolMessage<'setQuote', ApplePayOutboundMessageMap['setQuote']>;
|
|
926
|
+
/** A parent→child message to update the quote in the Google Pay frame. */
|
|
927
|
+
type SetGooglePayQuoteCommand = ProtocolMessage<'setQuote', GooglePayOutboundMessageMap['setQuote']>;
|
|
928
|
+
/** A parent→child message to update the quote in the buy frame. */
|
|
929
|
+
type SetBuyQuoteCommand = ProtocolMessage<'setQuote', BuyOutboundMessageMap['setQuote']>;
|
|
930
|
+
/** A parent→child message to update the quote in the buy-button frame. */
|
|
931
|
+
type SetBuyButtonQuoteCommand = ProtocolMessage<'setQuote', BuyButtonOutboundMessageMap['setQuote']>;
|
|
932
|
+
|
|
933
|
+
type WidgetEvent = {
|
|
934
|
+
kind: 'ready';
|
|
935
|
+
} | {
|
|
936
|
+
kind: 'error';
|
|
937
|
+
payload: WidgetMessageMap['error'];
|
|
938
|
+
} | {
|
|
939
|
+
kind: 'transactionCreated';
|
|
940
|
+
payload: WidgetMessageMap['transactionCreated'];
|
|
941
|
+
} | {
|
|
942
|
+
kind: 'complete';
|
|
943
|
+
payload: {
|
|
944
|
+
transaction: FrameTransaction;
|
|
945
|
+
};
|
|
946
|
+
} | {
|
|
947
|
+
kind: 'close';
|
|
948
|
+
};
|
|
949
|
+
type ApplePayEventError = {
|
|
950
|
+
kind: 'configurationError' | 'invalidQuote' | 'quoteExpired' | 'oneTapApplePaySecondFactorRequired' | 'genericError';
|
|
951
|
+
message: string;
|
|
952
|
+
};
|
|
953
|
+
type ApplePayEvent = {
|
|
954
|
+
kind: 'ready';
|
|
955
|
+
} | {
|
|
956
|
+
kind: 'complete';
|
|
957
|
+
payload: {
|
|
958
|
+
transaction: FrameTransaction;
|
|
959
|
+
};
|
|
960
|
+
} | {
|
|
961
|
+
kind: 'quoteExpired';
|
|
962
|
+
payload: {
|
|
963
|
+
setQuote: (signature: string) => void;
|
|
964
|
+
};
|
|
965
|
+
} | {
|
|
966
|
+
kind: 'error';
|
|
967
|
+
payload: ApplePayEventError;
|
|
968
|
+
} | {
|
|
969
|
+
kind: 'unsupported';
|
|
970
|
+
};
|
|
971
|
+
type GooglePayEventError = {
|
|
972
|
+
kind: 'configurationError' | 'invalidQuote' | 'quoteExpired' | 'genericError';
|
|
973
|
+
message: string;
|
|
974
|
+
};
|
|
975
|
+
type GooglePayEvent = {
|
|
976
|
+
kind: 'ready';
|
|
977
|
+
} | {
|
|
978
|
+
kind: 'complete';
|
|
979
|
+
payload: {
|
|
980
|
+
transaction: FrameTransaction;
|
|
981
|
+
};
|
|
982
|
+
} | {
|
|
983
|
+
kind: 'challenge';
|
|
984
|
+
payload: GooglePayInboundMessageMap['challenge'];
|
|
985
|
+
} | {
|
|
986
|
+
kind: 'quoteExpired';
|
|
987
|
+
payload: {
|
|
988
|
+
setQuote: (signature: string) => void;
|
|
989
|
+
};
|
|
990
|
+
} | {
|
|
991
|
+
kind: 'error';
|
|
992
|
+
payload: GooglePayEventError;
|
|
993
|
+
} | {
|
|
994
|
+
kind: 'unsupported';
|
|
995
|
+
};
|
|
996
|
+
type ConnectEvent = {
|
|
997
|
+
kind: 'ready';
|
|
998
|
+
} | {
|
|
999
|
+
kind: 'error';
|
|
1000
|
+
payload: ConnectMessageMap['error'];
|
|
1001
|
+
} | {
|
|
1002
|
+
kind: 'complete';
|
|
1003
|
+
payload: ConnectMessageMap['complete'];
|
|
1004
|
+
};
|
|
1005
|
+
type BuyEvent = {
|
|
1006
|
+
kind: 'ready';
|
|
1007
|
+
} | {
|
|
1008
|
+
kind: 'complete';
|
|
1009
|
+
payload: BuyMessageMap['complete'];
|
|
1010
|
+
} | {
|
|
1011
|
+
kind: 'challenge';
|
|
1012
|
+
payload: BuyMessageMap['challenge'];
|
|
1013
|
+
} | {
|
|
1014
|
+
kind: 'error';
|
|
1015
|
+
payload: BuyMessageMap['error'];
|
|
1016
|
+
};
|
|
1017
|
+
type BuyButtonEvent = {
|
|
1018
|
+
kind: 'complete';
|
|
1019
|
+
payload: BuyButtonMessageMap['complete'];
|
|
1020
|
+
} | {
|
|
1021
|
+
kind: 'challenge';
|
|
1022
|
+
payload: BuyButtonMessageMap['challenge'];
|
|
1023
|
+
} | {
|
|
1024
|
+
kind: 'error';
|
|
1025
|
+
payload: BuyButtonMessageMap['error'];
|
|
1026
|
+
};
|
|
1027
|
+
type ChallengeEvent = {
|
|
1028
|
+
kind: 'ready';
|
|
1029
|
+
} | {
|
|
1030
|
+
kind: 'complete';
|
|
1031
|
+
payload: ChallengeCompleteResult;
|
|
1032
|
+
} | {
|
|
1033
|
+
kind: 'cancelled';
|
|
1034
|
+
payload: ChallengeCancellation;
|
|
1035
|
+
} | {
|
|
1036
|
+
kind: 'error';
|
|
1037
|
+
payload: {
|
|
1038
|
+
code: string;
|
|
1039
|
+
message: string;
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
type AddCardEvent = {
|
|
1043
|
+
kind: 'complete';
|
|
1044
|
+
payload: {
|
|
1045
|
+
card: CardResponse;
|
|
1046
|
+
};
|
|
1047
|
+
} | {
|
|
1048
|
+
kind: 'error';
|
|
1049
|
+
payload: AddCardMessageMap['error'];
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* A discriminated union representing either a successful value or an error.
|
|
1054
|
+
* SDK methods return this type instead of throwing exceptions.
|
|
1055
|
+
*/
|
|
1056
|
+
type Result<T, E> = {
|
|
1057
|
+
ok: true;
|
|
1058
|
+
value: T;
|
|
1059
|
+
} | {
|
|
1060
|
+
ok: false;
|
|
1061
|
+
error: E;
|
|
1062
|
+
};
|
|
1063
|
+
/** A Result variant for operations that produce no value on success. */
|
|
1064
|
+
type EmptyResult<E> = {
|
|
1065
|
+
ok: true;
|
|
1066
|
+
} | {
|
|
1067
|
+
ok: false;
|
|
1068
|
+
error: E;
|
|
1069
|
+
};
|
|
1070
|
+
/** Construct a successful Result. */
|
|
1071
|
+
declare const ok: <T>(value: T) => {
|
|
1072
|
+
ok: true;
|
|
1073
|
+
value: T;
|
|
1074
|
+
};
|
|
1075
|
+
/** Construct a failed Result. */
|
|
1076
|
+
declare const err: <E>(error: E) => {
|
|
1077
|
+
ok: false;
|
|
1078
|
+
error: E;
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
export { type ActiveConnection, type AddCardEvent, type AddCardMessageMap, type ApplePayEvent, type ApplePayEventError, type ApplePayInboundMessageMap, type ApplePayOutboundMessageMap, type Asset, type AssetBase, type BuyButtonEvent, type BuyButtonMessageMap, type BuyButtonOutboundMessageMap, type BuyEvent, type BuyMessageMap, type BuyOutboundMessageMap, type CardResponse, type ChallengeCancellation, type ChallengeCompleteResult, type ChallengeEvent, type ChallengeMessageMap, type ConfigValidationFieldError, type ConnectError, type ConnectEvent, type ConnectMessageMap, type Connection, type ConnectionError, ConnectionErrorCode, type ConnectionRequired, ConnectionStatus, type CreateSessionError, type CreateSessionTokenRequestBody, type CreateSessionTokenResponse as CreateSessionTokenReturnType, type CustomerCapabilities, type DecryptedCredentials, type DevPlatformApiError, type DevPlatformApiErrorCode, DevPlatformApiErrorCodes, type DevPlatformApiErrorDetail, type EmptyResult, type FailedConnection, type Fees, type FrameTransaction, type GetConnectionError, type GetPaymentMethodsError, type GetQuoteError, type GetQuoteBody as GetQuoteParams, type GetTransactionsError, type GooglePayEvent, type GooglePayEventError, type GooglePayInboundMessageMap, type GooglePayOutboundMessageMap, HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND, type HandshakeAck, type HandshakeRequest, type LimitWithAsset, type MoonPayPaymentsListPaymentMethodsResponse as ListPaymentMethodsResponse, type MessageUnion, type MonetaryFeeAmount, type MoonPayCorePaginationInfo as PaginationInfo, type PaymentDisclosuresRequirement, type MoonPayPaymentsPaymentMethodAvailability as PaymentMethodAvailability, type MoonPayPaymentsPaymentMethodCapabilities as PaymentMethodCapabilities, type MoonPayPaymentsPaymentMethod as PaymentMethodConfig, type PaymentMethodType, type PendingConnection, type ProtocolMessage, type GetQuoteResponse as Quote, type QuoteLimitEntry, type QuoteLimits, type QuotePaymentMethod, type RampsCapability, type RampsRequirements, type ResetConnectionError, type ResetMessageMap, type Result, type RevokeSessionError, type SetBuyButtonQuoteCommand, type SetBuyQuoteCommand, type SetGooglePayQuoteCommand, type SetQuoteCommand, type SetupAddCardError, type SetupApplePayError, type SetupBuyButtonError, type SetupBuyError, type SetupChallengeError, type SetupGooglePayError, type SetupWidgetError, type Stage, type StageKind, type StageStatus, type MoonPayPaymentsStoredCardPaymentMethod as StoredCardPaymentMethod, type MoonPayPaymentsStoredPaymentMethod as StoredPaymentMethod, type TermsAcceptanceRequiredConnection, type TermsAttestation, type Transaction, type TransactionCustomer, type TransactionPaymentMethod, type TransactionStatus, type TransactionWithStages, type TypedMessage, type UnavailableConnection, type Wallet, type WidgetEvent, type WidgetMessageMap, err, ok };
|