xendit-components-web 0.0.8 → 0.0.10

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.
@@ -0,0 +1,820 @@
1
+ /**
2
+ * @public
3
+ * Channel properties for a payment method or payment token.
4
+ */
5
+ export declare interface ChannelProperties {
6
+ [key: string]: ChannelPropertyPrimative | ChannelPropertyPrimative[] | ChannelProperties;
7
+ }
8
+
9
+ /**
10
+ * @public
11
+ */
12
+ export declare type ChannelPropertyPrimative = string | number | boolean | undefined;
13
+
14
+ /**
15
+ * @public
16
+ */
17
+ export declare type IframeAppearanceOptions = {
18
+ /**
19
+ * Limited styles applied to iframe inputs.
20
+ */
21
+ inputStyles?: {
22
+ fontFamily?: string;
23
+ fontSize?: string;
24
+ fontWeight?: string;
25
+ lineHeight?: string;
26
+ letterSpacing?: string;
27
+ color?: string;
28
+ backgroundColor?: string;
29
+ };
30
+ /**
31
+ * Limited styles applied to iframe input placeholders.
32
+ */
33
+ placeholderStyles?: {
34
+ color?: string;
35
+ };
36
+ /**
37
+ * Custom font face to load within iframe fields.
38
+ * If you use this, you don't need to specify fontFamily or fontWeight.
39
+ */
40
+ fontFace?: {
41
+ /**
42
+ * CSS font-face source descriptor (e.g. `url(...) format(...)`)
43
+ */
44
+ source: string;
45
+ /**
46
+ * Font face options. Font family and weight are set automatically.
47
+ */
48
+ descriptors?: Pick<FontFaceDescriptors, "display" | "style" | "stretch">;
49
+ };
50
+ };
51
+
52
+ /**
53
+ * @public
54
+ * Event sometimes fired after submission, if an action is required.
55
+ */
56
+ export declare class XenditActionBeginEvent extends Event {
57
+ static type: "action-begin";
58
+ constructor();
59
+ }
60
+
61
+ /**
62
+ * @public
63
+ * Event fired when an action ends, success or fail.
64
+ */
65
+ export declare class XenditActionEndEvent extends Event {
66
+ static type: "action-end";
67
+ constructor();
68
+ }
69
+
70
+ /**
71
+ * @public
72
+ */
73
+ export declare class XenditComponents extends EventTarget {
74
+ /**
75
+ * @public
76
+ * Initialize the SDK for a given session.
77
+ *
78
+ * You can get the components sdk key from the components_sdk_key field of the
79
+ * `POST /sessions` or `GET /session` endpoints.
80
+ *
81
+ * This creates an object that can be used to create UI components, that allow
82
+ * users to make payment or save tokens, using a variety of channels, depending on
83
+ * the session configuration.
84
+ *
85
+ * @example
86
+ * ```
87
+ * // initialize
88
+ * const components = new XenditComponents({
89
+ * componentsSdkKey: "your-session-client-key",
90
+ * });
91
+ * ```
92
+ */
93
+ constructor(options: XenditSdkOptions);
94
+ /**
95
+ * @public
96
+ * Retrieve the xendit session object.
97
+ */
98
+ getSession(): XenditSession;
99
+ /**
100
+ * @public
101
+ * Retrieve the customer ascociated with the session.
102
+ */
103
+ getCustomer(): XenditCustomer | null;
104
+ /**
105
+ * @public
106
+ * Retrieve the list of payment channels available for this session.
107
+ *
108
+ * The channels are organized in a way that is appropriate to show to users.
109
+ * You can use this to render your channel picker UI.
110
+ *
111
+ * You can pass `{filter: "CHANNEL_CODE"}` to filter channels by string or regexp.
112
+ */
113
+ getActiveChannelGroups(options?: XenditGetChannelsOptions): XenditPaymentChannelGroup[];
114
+ /**
115
+ * @public
116
+ * Retrieve an unorganized list of payment channels available for this session.
117
+ *
118
+ * Use this when you need to search for specific channels. When rendering your UI,
119
+ * consider using `getActiveChannelGroups` if you support many channels.
120
+ *
121
+ * You can pass `{filter: "CHANNEL_CODE"}` to filter channels by string or regexp.
122
+ */
123
+ getActiveChannels(options?: XenditGetChannelsOptions): XenditPaymentChannel[];
124
+ /**
125
+ * @public
126
+ * Creates a drop-in UI component for selecting a channel and making payments.
127
+ *
128
+ * This returns a div immediately. The component will be populated after
129
+ * initialization is complete. You should insert this div into the DOM.
130
+ *
131
+ * Calling this again will destroy it and return a new element. Manually
132
+ * destroying the component is not necessary, removing it from the DOM is sufficient.
133
+ *
134
+ * @example
135
+ * ```
136
+ * const channelPickerDiv = components.createChannelPickerComponent();
137
+ * document.querySelector(".payment-container").appendChild(channelPickerDiv);
138
+ * ```
139
+ */
140
+ createChannelPickerComponent(): HTMLElement;
141
+ /**
142
+ * @public
143
+ * Creates a UI component for making payments with a specific channel. It will
144
+ * contain form fields, and/or instructions for the user.
145
+ *
146
+ * This also makes the provided channel "current", the `submit` method
147
+ * will use that channel.
148
+ *
149
+ * This returns a div. You should insert this div into the DOM. Creating a new
150
+ * component multiple times for the same channel will return the same component instance.
151
+ *
152
+ * Destroying the component manually is not necessary, removing it from the DOM is sufficient,
153
+ * but if you want to clear the form state, you can do so with the `destroyComponent` method.
154
+ *
155
+ * @example
156
+ * ```
157
+ * const cardsChannel = components.getActiveChannels({ filter: "CARDS" })[0];
158
+ * const paymentComponent = components.createChannelComponent(cardsChannel);
159
+ * document.querySelector(".payment-container").appendChild(paymentComponent);
160
+ * ```
161
+ */
162
+ createChannelComponent(channel: XenditPaymentChannel, active?: boolean): HTMLElement;
163
+ /**
164
+ * @public
165
+ * Returns the current payment channel.
166
+ */
167
+ getCurrentChannel(): XenditPaymentChannel | null;
168
+ /**
169
+ * @public
170
+ * Makes the given channel the current channel for submission.
171
+ *
172
+ * The current channel:
173
+ * - Is interactive if it has a form (other channel components are non-interactive)
174
+ * - Is used when `submit()` is called.
175
+ *
176
+ * Set to null to clear the current channel.
177
+ */
178
+ setCurrentChannel(channel: XenditPaymentChannel | null): void;
179
+ /**
180
+ * @public
181
+ *
182
+ * Reveals any hidden validation errors in the current channel's form. Does nothing if
183
+ * there are no validation errors to show.
184
+ *
185
+ * Normally, validation errors on required fields are not shown if the user did not touch them.
186
+ */
187
+ showValidationErrors(): void;
188
+ /**
189
+ * @public
190
+ * Creates a container element for rendering action UIs.
191
+ *
192
+ * For example, 3DS or QR codes.
193
+ *
194
+ * Create an action container before or during the action-begin event, and
195
+ * the action UI will be rendered inside it.
196
+ * Creating an action container during an action will throw an error.
197
+ *
198
+ * If no action container is created (or if the created container is removed from the DOM or is too small),
199
+ * the SDK will create an action container (in a modal dialog) for you.
200
+ */
201
+ createActionContainerComponent(): HTMLElement;
202
+ /**
203
+ * @public
204
+ * Destroys a component of any type created by the SDK. Removes it from the DOM if necessary.
205
+ * Throws if the element is not a xendit component or if it was already destroyed.
206
+ */
207
+ destroyComponent(component: HTMLElement): void;
208
+ /**
209
+ * @public
210
+ * Submit, makes a payment or saves a payment method for the current payment channel.
211
+ *
212
+ * Call this when your submit button is clicked. Listen to the events to know the status:
213
+ * - `submission-begin` and `submission-end` to know when submission is in progress (you should disable your UI during this time). Submission-end also provides a reason.
214
+ * - `action-begin` and `action-end` to know when user action is in progress
215
+ * - `will-redirect` when the user will be redirected to another page
216
+ * - `payment-[request|token]-[created|discarded]` informs you of the ID of the resource we create on the backend, and if/when it is discarded
217
+ * - `session-complete` when the payment request or token is successfully created (you should redirect the user to your confirmation page)
218
+ * - `session-expired-or-canceled` can happen at any time, but it's likely to happen on submission if the session expired or was cancelled during checkout
219
+ * - `submission-not-ready` fires before `submission-begin` to indicate that you cannot submit while a submission is in progress
220
+ *
221
+ * When a submission fails, you can try again by calling `submit()` again.
222
+ * (The `session-expired-or-canceled` and `fatal-error` events are fatal, submission failure is normal and recoverable)
223
+ *
224
+ * This corresponds to the endpoints:
225
+ * - `POST /v3/payment_requests` for PAY sessions
226
+ * - `POST /v3/payment_tokens` for SAVE sessions
227
+ */
228
+ submit(): void;
229
+ /**
230
+ * @public
231
+ * Cancels a submission.
232
+ *
233
+ * If a submission is in-flight, the request is cancelled. If an action is in progress,
234
+ * the action is aborted. Any active PaymentRequest or PaymentToken is abandoned.
235
+ *
236
+ * Does nothing if there is no active submission.
237
+ */
238
+ abortSubmission(): void;
239
+ /**
240
+ * @public
241
+ * Completes a payment in test mode.
242
+ *
243
+ * The session must be in test mode, and the session type must be PAY, and
244
+ * the sdk must have an in-progress action, and the channel must be a QR, VA, or OTC channel.
245
+ *
246
+ * @example
247
+ * ```
248
+ * components.addEventListener("action-begin", () => {
249
+ * components.simulatePayment();
250
+ * });
251
+ * ```
252
+ */
253
+ simulatePayment(): void;
254
+ /**
255
+ * @public
256
+ * The `init` event lets you know when the session data has been loaded.
257
+ *
258
+ * The `createChannelPickerComponent` method can be called before this event, but
259
+ * most other functionaility needs to wait for this event.
260
+ *
261
+ * @example
262
+ * ```
263
+ * components.addEventListener("init", () => {
264
+ * components.getSession();
265
+ * });
266
+ * ```
267
+ */
268
+ addEventListener(name: "init", listener: XenditEventListener<XenditInitEvent>, options?: boolean | AddEventListenerOptions): void;
269
+ /**
270
+ * @public
271
+ * The `submission-ready` and `submission-not-ready` events let you know when submission should be available.
272
+ * If ready, you can call `submit()` to begin the payment or token creation process.
273
+ *
274
+ * "submission-ready" means a channel has been selected, and all required fields are populated,
275
+ * and all fields are valid.
276
+ *
277
+ * Use this to enable/disable your submit button.
278
+ *
279
+ * @example
280
+ * ```
281
+ * components.addEventListener("submission-ready", () => {
282
+ * submitButton.disabled = false;
283
+ * });
284
+ * components.addEventListener("submission-not-ready", () => {
285
+ * submitButton.disabled = true;
286
+ * });
287
+ * ```
288
+ */
289
+ addEventListener(name: "submission-ready", listener: XenditEventListener<XenditReadyEvent>, options?: boolean | AddEventListenerOptions): void;
290
+ addEventListener(name: "submission-not-ready", listener: XenditEventListener<XenditReadyEvent>, options?: boolean | AddEventListenerOptions): void;
291
+ /**
292
+ * @public
293
+ * The `submission-begin` and `submission-end` events let you know when a submission is in progress.
294
+ *
295
+ * Use this to disable your UI while submission is in progress.
296
+ *
297
+ * In the case of successful submission, `submission-end` will be followed by `session-complete`.
298
+ * In the case of failed submission, the SDK will return to the ready state and you can try submitting again.
299
+ */
300
+ addEventListener(name: "submission-begin", listener: XenditEventListener<XenditSubmissionBeginEvent>, options?: boolean | AddEventListenerOptions): void;
301
+ addEventListener(name: "submission-end", listener: XenditEventListener<XenditSubmissionEndEvent>, options?: boolean | AddEventListenerOptions): void;
302
+ /**
303
+ * @public
304
+ * The events `payment-request-created`, `payment-token-created`, `payment-request-discarded`, and `payment-token-discarded`
305
+ * let you know when a payment request or payment token has been created (as part of a submission) or
306
+ * discarded (by cancelling or failing a submission).
307
+ */
308
+ addEventListener(name: "payment-request-created", listener: XenditEventListener<XenditPaymentRequestCreatedEvent>, options?: boolean | AddEventListenerOptions): void;
309
+ addEventListener(name: "payment-token-created", listener: XenditEventListener<XenditPaymentTokenCreatedEvent>, options?: boolean | AddEventListenerOptions): void;
310
+ addEventListener(name: "payment-request-discarded", listener: XenditEventListener<XenditPaymentRequestDiscardedEvent>, options?: boolean | AddEventListenerOptions): void;
311
+ addEventListener(name: "payment-token-discarded", listener: XenditEventListener<XenditPaymentTokenDiscardedEvent>, options?: boolean | AddEventListenerOptions): void;
312
+ /**
313
+ * @public
314
+ * The `action-begin` and `action-end` events let you know when a user action is in progress.
315
+ *
316
+ * After submission, an action may be required (e.g. 3DS, redirect, QR code, etc.).
317
+ * The SDK will control the UI for actions, you don't need to do anything.
318
+ *
319
+ * Avoid changing any application state while an action is in progress as it may be
320
+ * confusing for the user or interrupt their payment attempt.
321
+ *
322
+ * `action-end` is fired after the action is done, successfully or not. Note that users can
323
+ * voluntarily dismiss actions.
324
+ */
325
+ addEventListener(name: "action-begin", listener: XenditEventListener<XenditActionBeginEvent>, options?: boolean | AddEventListenerOptions): void;
326
+ addEventListener(name: "action-end", listener: XenditEventListener<XenditActionEndEvent>, options?: boolean | AddEventListenerOptions): void;
327
+ /**
328
+ * @public
329
+ * Event handler called just before the user is redirected to a third party site to
330
+ * complete the payment.
331
+ *
332
+ * Since redirects are actions, this will always be preceded by an `action-begin` event.
333
+ */
334
+ addEventListener(name: "will-redirect", listener: XenditEventListener<XenditWillRedirectEvent>, options?: boolean | AddEventListenerOptions): void;
335
+ /**
336
+ * @public
337
+ * Event handler called on success.
338
+ * The payment has been made and/or the token has been created.
339
+ */
340
+ addEventListener(name: "session-complete", listener: XenditEventListener<XenditSessionCompleteEvent>, options?: boolean | AddEventListenerOptions): void;
341
+ /**
342
+ * @public
343
+ * Event handler called when the session has expired or been cancelled.
344
+ */
345
+ addEventListener(name: "session-expired-or-canceled", listener: XenditEventListener<XenditSessionExpiredOrCanceledEvent>, options?: boolean | AddEventListenerOptions): void;
346
+ /**
347
+ * @public
348
+ * Event handler called when something unrecoverable has happened. You should create a new
349
+ * session and a new SDK instance.
350
+ */
351
+ addEventListener(name: "fatal-error", listener: XenditEventListener<XenditFatalErrorEvent>, options?: boolean | AddEventListenerOptions): void;
352
+ /**
353
+ * @public
354
+ * Fallback overload.
355
+ */
356
+ addEventListener<K extends keyof XenditEventMap>(type: K, listener: (this: XenditComponents, ev: XenditEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
357
+ /**
358
+ * @public
359
+ * Fallback overload.
360
+ */
361
+ removeEventListener<K extends keyof XenditEventMap>(type: K, listener: (this: XenditComponents, ev: XenditEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
362
+ static amountFormat(amount: number, currency: string): string;
363
+ }
364
+
365
+ /**
366
+ * @public
367
+ * Test version of XenditComponents that uses mock data instead of API calls.
368
+ * Use this class for testing and development purposes.
369
+ *
370
+ * The componentsSdkKey option is ignored.
371
+ *
372
+ * @example
373
+ * ```
374
+ * const testSdk = new XenditComponentsTest({});
375
+ * ```
376
+ */
377
+ export declare class XenditComponentsTest extends XenditComponents {
378
+ /**
379
+ * @public
380
+ * Test SDK ignores componentsSdkKey and uses a mock key.
381
+ */
382
+ constructor(options: Omit<XenditSdkOptions, "componentsSdkKey"> & {
383
+ componentsSdkKey?: string;
384
+ });
385
+ }
386
+
387
+ /**
388
+ * @public
389
+ */
390
+ export declare interface XenditCustomer {
391
+ id: string;
392
+ type: "INDIVIDUAL";
393
+ /**
394
+ * E-mail address of customer.
395
+ */
396
+ email?: string;
397
+ /**
398
+ * Mobile number of customer in E.164 format +(country code)(subscriber number)
399
+ */
400
+ mobileNumber?: string;
401
+ individualDetail: {
402
+ /**
403
+ * Primary or first name(s) of customer.
404
+ */
405
+ givenNames: string;
406
+ /**
407
+ * Last or family name of customer.
408
+ */
409
+ surname?: string;
410
+ };
411
+ }
412
+
413
+ /**
414
+ * @public
415
+ */
416
+ export declare type XenditEventListener<T extends Event | XenditEventMap[keyof XenditEventMap]> = ((event: T) => void) | null;
417
+
418
+ /**
419
+ * @public
420
+ */
421
+ export declare type XenditEventMap = {
422
+ init: XenditInitEvent;
423
+ "submission-ready": XenditReadyEvent;
424
+ "submission-not-ready": XenditReadyEvent;
425
+ "action-begin": XenditActionBeginEvent;
426
+ "action-end": XenditActionEndEvent;
427
+ "will-redirect": XenditWillRedirectEvent;
428
+ "session-complete": XenditSessionCompleteEvent;
429
+ "session-expired-or-canceled": XenditSessionExpiredOrCanceledEvent;
430
+ "payment-request-created": XenditPaymentRequestCreatedEvent;
431
+ "payment-request-discarded": XenditPaymentRequestDiscardedEvent;
432
+ "payment-token-created": XenditPaymentTokenCreatedEvent;
433
+ "payment-token-discarded": XenditPaymentTokenDiscardedEvent;
434
+ "fatal-error": XenditFatalErrorEvent;
435
+ };
436
+
437
+ /**
438
+ * @public
439
+ * Event fired when the SDK fails in an unrecoverable way.
440
+ */
441
+ export declare class XenditFatalErrorEvent extends Event {
442
+ /**
443
+ * A detailed error message for developers. Don't show this to users.
444
+ */
445
+ message: string;
446
+ static type: "fatal-error";
447
+ constructor(
448
+ /**
449
+ * A detailed error message for developers. Don't show this to users.
450
+ */
451
+ message: string);
452
+ }
453
+
454
+ /**
455
+ * @public
456
+ * Options for retrieving payment channels.
457
+ */
458
+ export declare interface XenditGetChannelsOptions {
459
+ /**
460
+ * Filter channels by their channel codes.
461
+ * (If using a RegExp, do not use the `g` flag.)
462
+ */
463
+ filter: string | string[] | RegExp;
464
+ /**
465
+ * If true, channels that do not satisfy the session's min/max amount will be filtered out.
466
+ * Default true.
467
+ */
468
+ filterMinMax?: boolean;
469
+ }
470
+
471
+ /**
472
+ * @public
473
+ * Event fired when the Session is loaded.
474
+ */
475
+ export declare class XenditInitEvent extends Event {
476
+ static type: "init";
477
+ constructor();
478
+ }
479
+
480
+ /**
481
+ * @public
482
+ * Event fired when the SDK is not ready to submit.
483
+ */
484
+ export declare class XenditNotReadyEvent extends Event {
485
+ static type: "submission-not-ready";
486
+ constructor();
487
+ }
488
+
489
+ /**
490
+ * @public
491
+ */
492
+ export declare interface XenditPaymentChannel {
493
+ /**
494
+ * The channel_code used to refer to this payment channel.
495
+ *
496
+ * This is either a string or an array of strings.
497
+ *
498
+ * In some cases (e.g. GOPAY), channels that are semantically the same have different channel codes depending
499
+ * on whether they're being used for pay or pay and save. In that case this will be an array of two channel codes.
500
+ */
501
+ channelCode: string | string[];
502
+ /**
503
+ * The display name of the payment channel.
504
+ */
505
+ brandName: string;
506
+ /**
507
+ * The theme color associated with the payment channel, in hex format.
508
+ *
509
+ * This will always be suitable for use as a background color with white text.
510
+ */
511
+ brandColor: string;
512
+ /**
513
+ * The logo URL of the payment channel.
514
+ */
515
+ brandLogoUrl: string;
516
+ /**
517
+ * UI group to which this channel belongs.
518
+ *
519
+ * This is a suggestion for how to organize channels in your UI.
520
+ */
521
+ uiGroup: XenditPaymentChannelGroup;
522
+ /**
523
+ * The minimum amount for which this channel can be used.
524
+ */
525
+ minAmount?: number;
526
+ /**
527
+ * The maximum amount for which this channel can be used.
528
+ */
529
+ maxAmount?: number;
530
+ /**
531
+ * If this is a cards channel, the supported card brands.
532
+ */
533
+ cardBrands?: {
534
+ name: string;
535
+ logoUrl: string;
536
+ }[];
537
+ }
538
+
539
+ /**
540
+ * @public
541
+ */
542
+ export declare interface XenditPaymentChannelGroup {
543
+ /**
544
+ * An arbitrary identifier.
545
+ */
546
+ groupId: string;
547
+ /**
548
+ * The display name of the group.
549
+ */
550
+ label: string;
551
+ /**
552
+ * The sort priority of the group.
553
+ */
554
+ channels: readonly XenditPaymentChannel[];
555
+ }
556
+
557
+ /**
558
+ * @public
559
+ */
560
+ export declare class XenditPaymentRequestCreatedEvent extends Event {
561
+ paymentRequestId: string;
562
+ static type: "payment-request-created";
563
+ constructor(paymentRequestId: string);
564
+ }
565
+
566
+ /**
567
+ * @public
568
+ */
569
+ export declare class XenditPaymentRequestDiscardedEvent extends Event {
570
+ paymentRequestId: string;
571
+ static type: "payment-request-discarded";
572
+ constructor(paymentRequestId: string);
573
+ }
574
+
575
+ /**
576
+ * @public
577
+ */
578
+ export declare class XenditPaymentTokenCreatedEvent extends Event {
579
+ paymentTokenId: string;
580
+ static type: "payment-token-created";
581
+ constructor(paymentTokenId: string);
582
+ }
583
+
584
+ /**
585
+ * @public
586
+ */
587
+ export declare class XenditPaymentTokenDiscardedEvent extends Event {
588
+ paymentTokenId: string;
589
+ static type: "payment-token-discarded";
590
+ constructor(paymentTokenId: string);
591
+ }
592
+
593
+ /**
594
+ * @public
595
+ * Event fired when the SDK is ready to submit.
596
+ */
597
+ export declare class XenditReadyEvent extends Event {
598
+ channelCode: string;
599
+ static type: "submission-ready";
600
+ constructor(channelCode: string);
601
+ }
602
+
603
+ /**
604
+ * @public
605
+ */
606
+ export declare interface XenditSdkOptions {
607
+ /**
608
+ * The client key from your session.
609
+ * Your server should retrieve this from the Xendit API and pass it directly to the
610
+ * client without saving or logging it anywhere.
611
+ */
612
+ componentsSdkKey: string;
613
+ iframeFieldAppearance?: IframeAppearanceOptions;
614
+ }
615
+
616
+ /**
617
+ * @public
618
+ */
619
+ export declare interface XenditSession {
620
+ /**
621
+ * Session ID with prefix `ps-`.
622
+ */
623
+ id: string;
624
+ /**
625
+ * Description of the transaction provided by merchant on session creation.
626
+ * The SDK does not use this, but you may show it to your users.
627
+ */
628
+ description?: string;
629
+ /**
630
+ * The type of session.
631
+ *
632
+ * PAY sessions create a payment request, calling /v3/payment_requests
633
+ * SAVE sessions create a saved payment token, calling /v3/payment_tokens
634
+ */
635
+ sessionType: "PAY" | "SAVE";
636
+ /**
637
+ * The kind of session, only COMPONENT sessions can be used with the components SDK.
638
+ */
639
+ mode: "COMPONENTS";
640
+ /**
641
+ * Merchant provided identifier for the session.
642
+ */
643
+ referenceId: string;
644
+ /**
645
+ * ISO 3166-1 alpha-2 two-letter country code for the country of transaction.
646
+ */
647
+ country: string;
648
+ /**
649
+ * ISO 4217 three-letter currency code for the payment.
650
+ */
651
+ currency: string;
652
+ /**
653
+ * For mode=PAY, the amount to be collected.
654
+ * For mode=SAVE, this will always be 0.
655
+ */
656
+ amount: number;
657
+ /**
658
+ * A map of channels to channel properties provided by merchant on session creation.
659
+ *
660
+ * Keys are channel codes in lowercase.
661
+ */
662
+ channelProperties?: Record<string, ChannelProperties>;
663
+ /**
664
+ * When the session will expire. After this, it cannot be used, you'll need to create a new session.
665
+ */
666
+ expiresAt: Date;
667
+ /**
668
+ * Locale code for the session.
669
+ */
670
+ locale: string;
671
+ /**
672
+ * Status of the session.
673
+ */
674
+ status: "ACTIVE" | "CANCELED" | "EXPIRED" | "COMPLETED";
675
+ /**
676
+ * Indicates whether the customer is allowed to save their payment method during this session.
677
+ *
678
+ * DISABLED means users do not have the option to save a payment method.
679
+ * OPTIONAL means users are given a checkbox to choose whether to save their payment method.
680
+ * FORCED means users must save their payment method and only channels that support saving will be shown.
681
+ * undefined means the merchant has not specified this preference or this is not a PAY session.
682
+ *
683
+ * If the user wishes to save a payment method, `/v3/payment_requests` will be called with type="PAY_AND_SAVE".
684
+ */
685
+ allowSavePaymentMethod?: "DISABLED" | "OPTIONAL" | "FORCED";
686
+ /**
687
+ * Indicates whether the payment will be captured automatically or manually.
688
+ */
689
+ captureMethod?: "AUTOMATIC" | "MANUAL";
690
+ /**
691
+ * Line items. The components SDK does not use this, but you may show it to your users.
692
+ */
693
+ items?: {
694
+ /**
695
+ * The type of item
696
+ */
697
+ type: "DIGITAL_PRODUCT" | "PHYSICAL_PRODUCT" | "DIGITAL_SERVICE" | "PHYSICAL_SERVICE" | "FEE";
698
+ /**
699
+ * Your reference ID for the item.
700
+ */
701
+ referenceId?: string;
702
+ /**
703
+ * Name of the item.
704
+ */
705
+ name: string;
706
+ /**
707
+ * Price per item. Can be negative for discounts. Total line item amount is net_unit_amount * quantity.
708
+ */
709
+ netUnitAmount: number;
710
+ /**
711
+ * Number of items in this line item.
712
+ */
713
+ quantity: number;
714
+ url?: string;
715
+ imageUrl?: string;
716
+ category?: string;
717
+ subcategory?: string;
718
+ description?: string;
719
+ metadata?: Record<string, string>;
720
+ }[];
721
+ }
722
+
723
+ /**
724
+ * @public
725
+ * Event fired when the session is complete, meaning the payment has been processed
726
+ * or the token has been created.
727
+ */
728
+ export declare class XenditSessionCompleteEvent extends Event {
729
+ static type: "session-complete";
730
+ constructor();
731
+ }
732
+
733
+ /**
734
+ * @public
735
+ * Event fired when the session has failed, meaning expired or cancelled.
736
+ */
737
+ export declare class XenditSessionExpiredOrCanceledEvent extends Event {
738
+ static type: "session-expired-or-canceled";
739
+ constructor();
740
+ }
741
+
742
+ /**
743
+ * @public
744
+ * Event fired after submission begins.
745
+ */
746
+ export declare class XenditSubmissionBeginEvent extends Event {
747
+ static type: "submission-begin";
748
+ constructor();
749
+ }
750
+
751
+ /**
752
+ * @public
753
+ * Event fired when a submission is complete or fails. Submission encompasses creation of a
754
+ * payment request or payment token, and any actions the user needs to complete.
755
+ *
756
+ * Includes details about why the submission ended, and error messages if applicable.
757
+ */
758
+ export declare class XenditSubmissionEndEvent extends Event {
759
+ /**
760
+ * The reason why the submission ended.
761
+ */
762
+ reason: string;
763
+ /**
764
+ * An error message to show to the user. A title and 1-2 lines of localized text.
765
+ */
766
+ userErrorMessage?: string[] | undefined;
767
+ /**
768
+ * A detailed error message for developers.
769
+ */
770
+ developerErrorMessage?: {
771
+ /**
772
+ * The type of error.
773
+ * - NETWORK_ERROR: A network error occurred while creating the payment request or payment token.
774
+ * - ERROR: Failed to created a payment request or payment token.
775
+ * - FAILURE: A payment request or payment token transitioned to a failure state.
776
+ */
777
+ type: "NETWORK_ERROR" | "ERROR" | "FAILURE";
778
+ /**
779
+ * The code associated with the error.
780
+ */
781
+ code: string;
782
+ } | undefined;
783
+ static type: "submission-end";
784
+ constructor(
785
+ /**
786
+ * The reason why the submission ended.
787
+ */
788
+ reason: string,
789
+ /**
790
+ * An error message to show to the user. A title and 1-2 lines of localized text.
791
+ */
792
+ userErrorMessage?: string[] | undefined,
793
+ /**
794
+ * A detailed error message for developers.
795
+ */
796
+ developerErrorMessage?: {
797
+ /**
798
+ * The type of error.
799
+ * - NETWORK_ERROR: A network error occurred while creating the payment request or payment token.
800
+ * - ERROR: Failed to created a payment request or payment token.
801
+ * - FAILURE: A payment request or payment token transitioned to a failure state.
802
+ */
803
+ type: "NETWORK_ERROR" | "ERROR" | "FAILURE";
804
+ /**
805
+ * The code associated with the error.
806
+ */
807
+ code: string;
808
+ } | undefined);
809
+ }
810
+
811
+ /**
812
+ * @public
813
+ * Event fired when the a redirect action is about to happen.
814
+ */
815
+ export declare class XenditWillRedirectEvent extends Event {
816
+ static type: "will-redirect";
817
+ constructor();
818
+ }
819
+
820
+ export { }