@tonder.io/ionic-lite-sdk 0.0.68 → 0.0.69-beta.TEC-146.1

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/README.md CHANGED
@@ -71,8 +71,10 @@ const cards = await liteCheckout.getCustomerCards();
71
71
  ```
72
72
 
73
73
  ```javascript
74
- // Save a new card
75
- const newCard = await liteCheckout.saveCustomerCard(cardData);
74
+ // Mount Skyflow Elements for card fields, then save
75
+ await liteCheckout.mountCardFields({ fields: ['cardholder_name', 'card_number', 'expiration_month', 'expiration_year', 'cvv'] });
76
+ // After user fills in the fields:
77
+ const newCard = await liteCheckout.saveCustomerCard();
76
78
  ```
77
79
 
78
80
  ```javascript
@@ -86,8 +88,10 @@ const paymentMethods = await liteCheckout.getCustomerPaymentMethods();
86
88
  ```
87
89
 
88
90
  ```javascript
89
- // Process a payment
90
- const paymentResponse = await liteCheckout.payment(paymentData);
91
+ // New card payment: mount fields first, then pay
92
+ await liteCheckout.mountCardFields({ fields: ['cardholder_name', 'card_number', 'expiration_month', 'expiration_year', 'cvv'] });
93
+ // After user fills in the fields:
94
+ const paymentResponse = await liteCheckout.payment(paymentData); // no card field needed
91
95
  ```
92
96
 
93
97
  ## Configuration Options
@@ -162,11 +166,7 @@ When calling the `payment` method, use the following data structure:
162
166
 
163
167
  - **metadata**: Object for including any additional information about the transaction. This can be used for internal references or tracking.
164
168
 
165
- - **card**: (for LiteCheckout) Object containing card information. This is used differently depending on whether it's a new card or a saved card:
166
-
167
- - For a new card: Include `card_number`, `cvv`, `expiration_month`, `expiration_year`, and `cardholder_name`.
168
- - For a saved card: Include only the `skyflow_id` of the saved card.
169
- - This is only used when not paying with a payment_method.
169
+ - **card**: (for LiteCheckout) Used only when paying with a **saved card** pass the `skyflow_id` string of the saved card. For a **new card**, omit this field and use `mountCardFields()` to collect card data via Skyflow Elements before calling `payment()`. This field is not used when paying with `payment_method`.
170
170
 
171
171
  - **payment_method**: (for LiteCheckout) String indicating the alternative payment method to be used (e.g., "Spei"). This is only used when not paying with a card.
172
172
  - **order_reference**: Unique order reference from the merchant. Used to visually identify/filter the order in dashboard.
@@ -260,14 +260,7 @@ const paymentData = {
260
260
  metadata: {
261
261
  order_id: "ORDER123",
262
262
  },
263
- // For a new card:
264
- card: {
265
- card_number: "4111111111111111",
266
- cvv: "123",
267
- expiration_month: "12",
268
- expiration_year: "25",
269
- cardholder_name: "John Doe",
270
- },
263
+ // For a new card: omit `card` — use mountCardFields() before calling payment().
271
264
  // card: "skyflow_id" // for a selected saved card.
272
265
  // payment_method: "Spei", // For the selected payment method.
273
266
  // apm_config: {} // Optional, only for APMs like Mercado Pago, Oxxo Pay
@@ -320,44 +313,171 @@ if (
320
313
  - `configureCheckout(data)`: Set initial checkout data
321
314
  - `injectCheckout()`: Initialize the checkout
322
315
  - `getCustomerCards()`: Retrieve saved cards
323
- - `saveCustomerCard(cardData)`: Save a new card
316
+ - `saveCustomerCard()`: Save a new card (requires `mountCardFields()` called first)
324
317
  - `removeCustomerCard(cardId)`: Remove a saved card
325
318
  - `getCustomerPaymentMethods()`: Get available payment methods
326
319
  - `payment(data)`: Process a payment
327
320
  - `verify3dsTransaction()`: Verify a 3DS transaction
328
- - `mountCardFields({ fields, card_id })`: Mounts card input fields (e.g., CVV) for a saved card. Useful for requesting CVV when listing saved cards.
321
+ - `mountCardFields({ fields, card_id })`: Mount Skyflow Elements (secure iframes) into developer-provided `<div>` containers. Used for both **new card enrollment** and **saved-card CVV collection**.
329
322
 
330
323
  #### mountCardFields
331
324
 
332
- Mounts card input fields (currently CVV) for a saved card. When a `card_id` is provided, the CVV input will be associated with that specific card, allowing you to update its CVV. This is useful for workflows where you need to request CVV for saved cards before payment.
325
+ Mounts Skyflow Elements (secure iframes) into developer-provided `<div>` containers. This is the secure way to collect card data card values never pass through your application.
333
326
 
334
327
  **Parameters:**
335
328
 
336
- | Name | Type | Required | Description |
337
- |---------|----------|----------|---------------------------------------------------------------------|
338
- | fields | string[] | Yes | Array of fields to mount (currently supports `["cvv"]`). |
339
- | card_id | string | No | Card ID of the saved card. Associates the CVV input with this card. |
329
+ | Name | Type | Required | Description |
330
+ |------------------|--------------------------------------------------|----------|------------------------------------------------------------------------------------------|
331
+ | fields | `CardField[]` or `{ field, container_id? }[]` | Yes | Fields to mount. Use string names or objects with an optional custom `container_id`. |
332
+ | card_id | string | No | Skyflow ID of a saved card. When provided, elements update that card (e.g. CVV only). |
333
+ | unmount_context | string | No | Which context to unmount before mounting: `'all'` (default), `'current'`, or `'none'`. |
334
+
335
+ **Default container IDs** (used when no custom `container_id` is provided):
336
+
337
+ | Field | Default div ID |
338
+ |--------------------|-----------------------------------------|
339
+ | `cardholder_name` | `#collect_cardholder_name` |
340
+ | `card_number` | `#collect_card_number` |
341
+ | `expiration_month` | `#collect_expiration_month` |
342
+ | `expiration_year` | `#collect_expiration_year` |
343
+ | `cvv` (new card) | `#collect_cvv` |
344
+ | `cvv` (saved card) | `#collect_cvv_<card_id>` |
345
+
346
+ **Use case 1 — New card enrollment / payment:**
347
+ ```html
348
+ <!-- Place these divs where you want the fields to appear -->
349
+ <div id="collect_cardholder_name"></div>
350
+ <div id="collect_card_number"></div>
351
+ <div id="collect_expiration_month"></div>
352
+ <div id="collect_expiration_year"></div>
353
+ <div id="collect_cvv"></div>
354
+ ```
355
+ ```ts
356
+ // Mount all 5 fields (call once during setup, before payment or save)
357
+ await liteCheckout.mountCardFields({
358
+ fields: ['cardholder_name', 'card_number', 'expiration_month', 'expiration_year', 'cvv']
359
+ });
360
+
361
+ // New card payment — no `card` field needed
362
+ await liteCheckout.payment({ customer, cart, currency });
363
+
364
+ // Or save the new card
365
+ await liteCheckout.saveCustomerCard();
366
+ ```
367
+
368
+ **Use case 2 — Saved-card CVV collection:**
369
+ ```html
370
+ <div id="collect_cvv_saved-card-id"></div>
371
+ ```
372
+ ```ts
373
+ // Mount only the CVV field for the selected saved card
374
+ liteCheckout.mountCardFields({ fields: ['cvv'], card_id: 'saved-card-id' });
375
+
376
+ // Then pay with the saved card
377
+ await liteCheckout.payment({ customer, cart, card: 'saved-card-id' });
378
+ ```
379
+
380
+ **Custom container IDs:**
381
+ ```ts
382
+ await liteCheckout.mountCardFields({
383
+ fields: [
384
+ { field: 'card_number', container_id: '#my-card-number' },
385
+ { field: 'cvv', container_id: '#my-cvv' },
386
+ { field: 'cardholder_name', container_id: '#my-name' },
387
+ { field: 'expiration_month', container_id: '#my-month' },
388
+ { field: 'expiration_year', container_id: '#my-year' },
389
+ ]
390
+ });
391
+ ```
340
392
 
341
393
  **Important Notes:**
342
- 1. **Single Card Selection Only:** The CVV input for a saved card must only be displayed when a specific card is selected.
343
- 2. **One CVV Input at a Time:** You cannot display multiple CVV inputs for different cards simultaneously. Only one CVV update operation should be active at any given time.
344
- 3. **Mutually Exclusive with Card Form:** The CVV input for a saved card cannot be shown at the same time as the full card enrollment form. These are two separate workflows:
345
- - **Save New Card:** Use the complete card form without `card_id`.
346
- - **Update CVV for Saved Card:** Use CVV input with `card_id` only.
394
+ 1. **New card vs saved card are mutually exclusive:** Do not show the full card form and a saved-card CVV input simultaneously.
395
+ 2. **Single saved card at a time:** Only one saved-card CVV input should be active at once.
396
+ 3. **Call before submitting:** Always call `mountCardFields()` and let the user fill in the fields before calling `payment()` or `saveCustomerCard()`.
347
397
 
348
- **Example:**
349
- ```tsx
350
- // Update CVV for a saved card
398
+ ---
399
+
400
+ #### revealCardFields
351
401
 
352
- // 1. Place the div in your component where the CVV field will be mounted
353
- <div id={`collect_cvv_saved-card-id`}></div>
402
+ Reveals card data collected in the last `saveCustomerCard()` or `payment()` (with a new card) using Skyflow Reveal Elements — secure iframes that render the actual or masked values in your `<div>` containers without ever exposing raw card data to the application.
354
403
 
355
- // 2. Call mountCardFields and pass the card_id of the selected card
356
- liteCheckout.mountCardFields({ fields: ["cvv"], card_id: "saved-card-id" });
404
+ > **When to call:** After a successful `saveCustomerCard()` or `payment()` that processed a new card (not a saved card).
357
405
 
406
+ **Parameters:**
407
+
408
+ | Name | Type | Required | Description |
409
+ |--------|----------------------------------------|----------|--------------------------------------------------------------------|
410
+ | fields | `(CardField \| IRevealCardField)[]` | Yes | Fields to reveal. Use string shorthand or objects for custom config. |
411
+ | styles | `IRevealElementStyles` | No | Global styles applied to all reveal elements. |
412
+
413
+ **Default container IDs** (used when no custom `container_id` is provided):
414
+
415
+ | Field | Default div ID | Default Redaction |
416
+ |--------------------|---------------------------------|-------------------|
417
+ | `cardholder_name` | `#reveal_cardholder_name` | `PLAIN_TEXT` |
418
+ | `card_number` | `#reveal_card_number` | `MASKED` |
419
+ | `expiration_month` | `#reveal_expiration_month` | `PLAIN_TEXT` |
420
+ | `expiration_year` | `#reveal_expiration_year` | `PLAIN_TEXT` |
421
+ | `cvv` | `#reveal_cvv` | `REDACTED` |
358
422
 
423
+ **Basic usage — reveal after enrollment:**
424
+ ```html
425
+ <!-- Place these divs in your confirmation screen -->
426
+ <div id="reveal_cardholder_name"></div>
427
+ <div id="reveal_card_number"></div>
428
+ <div id="reveal_expiration_month"></div>
429
+ <div id="reveal_expiration_year"></div>
430
+ ```
431
+ ```ts
432
+ // After successful saveCustomerCard():
433
+ await liteCheckout.saveCustomerCard();
434
+
435
+ // Reveal card info in the divs above (no raw data exposed)
436
+ await liteCheckout.revealCardFields({
437
+ fields: ['cardholder_name', 'card_number', 'expiration_month', 'expiration_year']
438
+ });
439
+ // #reveal_card_number will display e.g. "4111 11•• •••• 1111" (MASKED)
440
+ // #reveal_cardholder_name will display the full name (PLAIN_TEXT)
359
441
  ```
360
442
 
443
+ **Custom redaction and altText per field:**
444
+ ```ts
445
+ await liteCheckout.revealCardFields({
446
+ fields: [
447
+ { field: 'card_number', redaction: 'PLAIN_TEXT' }, // show full number
448
+ { field: 'cardholder_name', altText: 'Loading name...' }, // placeholder while loading
449
+ { field: 'cvv', redaction: 'PLAIN_TEXT', label: 'CVV' }, // show CVV (not recommended in prod)
450
+ ]
451
+ });
452
+ ```
453
+
454
+ **Custom styles:**
455
+ ```ts
456
+ await liteCheckout.revealCardFields({
457
+ fields: ['card_number', 'cardholder_name'],
458
+ styles: {
459
+ inputStyles: {
460
+ base: {
461
+ fontFamily: 'Inter, sans-serif',
462
+ fontSize: '16px',
463
+ color: '#1d1d1d',
464
+ }
465
+ }
466
+ }
467
+ });
468
+ ```
469
+
470
+ **Available redaction values:**
471
+
472
+ | Value | Effect |
473
+ |--------------|-------------------------------------------------|
474
+ | `PLAIN_TEXT` | Full value revealed |
475
+ | `MASKED` | Partial value (e.g. `4111 11•• •••• 1111`) |
476
+ | `REDACTED` | All characters replaced (e.g. `***`) |
477
+ | `DEFAULT` | Uses the vault's configured redaction |
478
+
479
+ ---
480
+
361
481
  ## Error Handling
362
482
 
363
483
  Public SDK methods that fail due to API/SDK execution return an `AppError` (with `name: "TonderError"`).
@@ -449,136 +569,91 @@ export class TonderService {
449
569
  }
450
570
 
451
571
  // checkout.component.ts
452
- import { Component, OnInit, OnDestroy } from "@angular/core";
572
+ import { Component, OnInit } from "@angular/core";
453
573
  import { TonderService } from "./tonder.service";
454
574
 
455
575
  @Component({
456
576
  selector: "app-tonder-checkout",
457
577
  template: `
458
578
  <div id="container">
459
- <form [formGroup]="paymentForm">
460
- <div class="lite-container-tonder">
461
- <div id="id-name" class="empty-div">
462
- <label for="name">Namess: </label>
463
- <input id="name" type="text" formControlName="name">
464
- </div>
465
- <div id="id-cardNumber" class="empty-div">
466
- <label for="cardNumber">Card number: </label>
467
- <input id="cardNumber" type="text" formControlName="cardNumber">
468
- </div>
469
- <div class="collect-row">
470
- <div class="empty-div">
471
- <label for="month">Month: </label>
472
- <input id="month" type="text" formControlName="month">
473
- </div>
474
- <div class="expiration-year">
475
- <label for="expirationYear">Year: </label>
476
- <input id="expirationYear" type="text" formControlName="expirationYear">
477
- </div>
478
- <div class="empty-div">
479
- <label for="cvv">CVV: </label>
480
- <input id="cvv" type="text" formControlName="cvv">
481
- </div>
482
- </div>
483
- <div id="msgError">{{ errorMessage }}</div>
484
- <div id="msgNotification"></div>
485
- <div class="container-pay-button">
486
- <button class="lite-pay-button" (click)="onPayment($event)">Pay</button>
487
- </div>
488
- </div>
489
-
490
- </form>
579
+ <!-- Skyflow Elements will be injected into these divs -->
580
+ <div id="collect_cardholder_name"></div>
581
+ <div id="collect_card_number"></div>
582
+ <div id="collect_expiration_month"></div>
583
+ <div id="collect_expiration_year"></div>
584
+ <div id="collect_cvv"></div>
585
+
586
+ <div id="msgError">{{ errorMessage }}</div>
587
+ <button (click)="pay()">Pay</button>
491
588
  </div>
492
589
  `,
493
590
  providers: [
494
591
  {
495
- provide: TonderInlineService,
496
- // Initialization of the Tonder Lite SDK.
497
- // Note: Replace these credentials with your own in development/production.
592
+ provide: TonderService,
498
593
  useFactory: () =>
499
- new TonderInlineService({
500
- apiKey: "11e3d3c3e95e0eaabbcae61ebad34ee5f93c3d27",
594
+ new TonderService({
595
+ apiKey: "YOUR_API_KEY",
501
596
  returnUrl: "http://localhost:8100/tabs/tab5",
502
597
  mode: "stage",
503
598
  }),
504
599
  },
505
600
  ],
506
601
  })
507
- export class TonderCheckoutComponent implements OnInit, OnDestroy {
602
+ export class TonderCheckoutComponent implements OnInit {
508
603
  loading = false;
509
- checkoutData: IProcessPaymentRequest;
510
- paymentForm = new FormGroup({
511
- name: new FormControl('Pedro Paramo'),
512
- cardNumber: new FormControl('4242424242424242'),
513
- month: new FormControl('12'),
514
- expirationYear: new FormControl('28'),
515
- cvv: new FormControl('123')
516
- });
517
-
518
- constructor(private tonderService: TonderService) {
519
- this.checkoutData = {
520
- customer: {
521
- firstName: "Jhon",
522
- lastName: "Doe",
523
- email: "john.c.calhoun@examplepetstore.com",
524
- phone: "+58452258525"
525
- },
526
- cart: {
527
- total: 25,
528
- items: [
529
- {
530
- description: "Test product description",
531
- quantity: 1,
532
- price_unit: 25,
533
- discount: 1,
534
- taxes: 12,
535
- product_reference: 89456123,
536
- name: "Test product",
537
- amount_total: 25
538
- }
539
- ]
540
- },
541
- metadata: {},
542
- currency: "MXN"
543
- }
544
- }
604
+ errorMessage = "";
605
+ checkoutData: IProcessPaymentRequest = {
606
+ customer: {
607
+ firstName: "John",
608
+ lastName: "Doe",
609
+ email: "john.doe@example.com",
610
+ phone: "+1234567890"
611
+ },
612
+ cart: {
613
+ total: 25,
614
+ items: [
615
+ {
616
+ description: "Test product",
617
+ quantity: 1,
618
+ price_unit: 25,
619
+ discount: 0,
620
+ taxes: 0,
621
+ product_reference: 1,
622
+ name: "Test product",
623
+ amount_total: 25
624
+ }
625
+ ]
626
+ },
627
+ currency: "MXN"
628
+ };
545
629
 
546
- ngOnInit() {
547
- this.initCheckout();
548
- }
630
+ constructor(private tonderService: TonderService) {}
549
631
 
550
- async initCheckout() {
632
+ async ngOnInit() {
551
633
  this.tonderService.configureCheckout({
552
- customer: { email: "example@email.com" },
634
+ customer: { email: this.checkoutData.customer.email },
553
635
  });
554
636
  await this.tonderService.injectCheckout();
555
637
  this.tonderService.verify3dsTransaction().then((response) => {
556
638
  console.log("Verify 3ds response", response);
557
639
  });
558
-
559
- // Calls more functions to get payment methods, saved cards, etc.
640
+
641
+ // Mount Skyflow Elements for the new card form
642
+ await this.tonderService.mountCardFields({
643
+ fields: ['cardholder_name', 'card_number', 'expiration_month', 'expiration_year', 'cvv']
644
+ });
560
645
  }
561
646
 
562
647
  async pay() {
563
648
  this.loading = true;
564
649
  try {
565
- const response = await this.tonderService.payment({
566
- ...this.checkoutData,
567
- card: { // Card details, if not using a payment method.
568
- card_number: this.paymentForm.value.cardNumber || "",
569
- cvv: this.paymentForm.value.cvv || "",
570
- expiration_month: this.paymentForm.value.month || "",
571
- expiration_year: this.paymentForm.value.expirationYear || "",
572
- cardholder_name: this.paymentForm.value.name || ""
573
- },
574
- // card: "skyflow_id" // In case a saved card is selected.
575
- // payment_method: "" // Payment method if not using the card form
576
- });
650
+ // No `card` field needed — data is collected from Skyflow Elements
651
+ const response = await this.tonderService.payment(this.checkoutData);
577
652
  console.log("Payment successful:", response);
578
653
  alert("Payment successful");
579
654
  } catch (error) {
580
655
  console.error("Payment failed:", error);
581
- alert("Payment failed");
656
+ this.errorMessage = (error as any).message;
582
657
  } finally {
583
658
  this.loading = false;
584
659
  }
@@ -818,6 +893,11 @@ The following functions have been deprecated and should no longer be used. Consi
818
893
  - **Deprecated Reason:** This function has been renamed to `getCustomerPaymentMethods` to better align with its purpose. The method's usage has also been updated.
819
894
  - **Alternative:** Use the `getCustomerPaymentMethods` method and update your implementation to reflect the changes.
820
895
 
896
+ ### Raw card fields in `payment()` and `saveCustomerCard()`
897
+
898
+ - **Deprecated Reason:** Passing raw card values (card number, CVV, etc.) directly to `payment()` or `saveCustomerCard()` is no longer supported. Card data must be collected via Skyflow Elements using `mountCardFields()`.
899
+ - **Alternative:** Call `mountCardFields()` with the required fields, then call `payment()` or `saveCustomerCard()` without card arguments.
900
+
821
901
  ### `getSkyflowTokens`
822
902
 
823
903
  - **Deprecated Reason:** Card registration and checkout are now automatically handled during the payment process or through card management methods, making this method unnecessary.
@@ -0,0 +1,86 @@
1
+ import { ITelemetryConfig, ITelemetryContext } from "../types/telemetry";
2
+ /**
3
+ * SdkTelemetryClient - Internal SDK error reporting
4
+ *
5
+ * Features:
6
+ * - Ring buffer (max 100 events)
7
+ * - Batching (flush every 5s or 10 events)
8
+ * - Circuit breaker (3 consecutive failures = 10 min pause)
9
+ * - Non-blocking (never throws)
10
+ * - Sanitization (truncate message/stack, allowlist context)
11
+ * - Retry with backoff (max 1 retry)
12
+ */
13
+ export declare class SdkTelemetryClient {
14
+ private config;
15
+ private buffer;
16
+ private readonly MAX_BUFFER_SIZE;
17
+ private readonly BATCH_SIZE;
18
+ private readonly FLUSH_INTERVAL_MS;
19
+ private readonly REQUEST_TIMEOUT_MS;
20
+ private readonly MAX_MESSAGE_LENGTH;
21
+ private readonly MAX_STACK_LENGTH;
22
+ private readonly MAX_RETRIES;
23
+ private readonly CIRCUIT_BREAKER_THRESHOLD;
24
+ private readonly CIRCUIT_BREAKER_TIMEOUT_MS;
25
+ private flushTimer;
26
+ private circuitBreaker;
27
+ constructor(config: ITelemetryConfig);
28
+ /**
29
+ * Capture an exception and queue it for sending
30
+ * @param error - Error object or any thrown value
31
+ * @param context - Additional context (tenant_id, feature, process_id, user_id, metadata, etc.)
32
+ */
33
+ captureException(error: unknown, context?: ITelemetryContext): void;
34
+ /**
35
+ * Extract error information from error object
36
+ */
37
+ private extractErrorInfo;
38
+ /**
39
+ * Safe stringify with circular reference protection
40
+ */
41
+ private safeStringify;
42
+ /**
43
+ * Build telemetry event with API format
44
+ */
45
+ private buildEvent;
46
+ /**
47
+ * Truncate string to max length
48
+ */
49
+ private truncate;
50
+ /**
51
+ * Start automatic flush timer
52
+ */
53
+ private startFlushTimer;
54
+ /**
55
+ * Flush buffer - send all pending events
56
+ */
57
+ private flush;
58
+ /**
59
+ * Send a single event with retry logic
60
+ */
61
+ private sendEvent;
62
+ /**
63
+ * Send HTTP request to telemetry endpoint
64
+ */
65
+ private sendHttpRequest;
66
+ /**
67
+ * Handle successful send
68
+ */
69
+ private onSendSuccess;
70
+ /**
71
+ * Handle send failure with retry logic
72
+ */
73
+ private onSendFailure;
74
+ /**
75
+ * Open circuit breaker
76
+ */
77
+ private openCircuitBreaker;
78
+ /**
79
+ * Check if circuit breaker is open
80
+ */
81
+ private isCircuitBreakerOpen;
82
+ /**
83
+ * Cleanup - stop flush timer
84
+ */
85
+ destroy(): void;
86
+ }
@@ -1,11 +1,11 @@
1
1
  import { ErrorResponse } from "./errorResponse";
2
2
  import { BaseInlineCheckout } from "./BaseInlineCheckout";
3
3
  import { APM, IInlineLiteCheckoutOptions } from "../types/commons";
4
- import { ICustomerCardsResponse, IMountCardFieldsRequest, ISaveCardRequest, ISaveCardResponse } from "../types/card";
4
+ import { ICustomerCardsResponse, IMountCardFieldsRequest, IRevealCardFieldsRequest, ISaveCardResponse } from "../types/card";
5
5
  import { IPaymentMethod } from "../types/paymentMethod";
6
6
  import { CreateOrderResponse, CreatePaymentResponse, CustomerRegisterResponse, GetBusinessResponse, RegisterCustomerCardResponse, StartCheckoutResponse } from "../types/responses";
7
7
  import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutFullRequest, StartCheckoutIdRequest, StartCheckoutRequest, TokensRequest } from "../types/requests";
8
- import { ICardFields, IStartCheckoutResponse } from "../types/checkout";
8
+ import { IStartCheckoutResponse } from "../types/checkout";
9
9
  import { ILiteCheckout } from "../types/liteInlineCheckout";
10
10
  declare global {
11
11
  interface Window {
@@ -18,15 +18,35 @@ export declare class LiteCheckout extends BaseInlineCheckout implements ILiteChe
18
18
  private readonly events;
19
19
  private mountedElementsByContext;
20
20
  private customerCardsCache;
21
+ private lastCollectedTokens;
21
22
  constructor({ apiKey, mode, returnUrl, callBack, apiKeyTonder, baseUrlTonder, customization, collectorIds, events }: IInlineLiteCheckoutOptions);
22
23
  injectCheckout(): Promise<void>;
23
24
  getCustomerCards(): Promise<ICustomerCardsResponse>;
24
- saveCustomerCard(card: ISaveCardRequest): Promise<ISaveCardResponse>;
25
+ saveCustomerCard(): Promise<ISaveCardResponse>;
25
26
  removeCustomerCard(skyflowId: string): Promise<string>;
26
27
  getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
27
28
  mountCardFields(event: IMountCardFieldsRequest): Promise<void>;
28
29
  private getContainerByCardId;
29
30
  private collectCardTokens;
31
+ /**
32
+ * Collects card tokens from Skyflow Elements mounted for a new card (the 'create' context).
33
+ * Requires that `mountCardFields()` was called without a `card_id` beforehand.
34
+ */
35
+ private collectCreateCardTokens;
36
+ /**
37
+ * Reveals card data collected in the last `saveCustomerCard()` or `payment()` call
38
+ * (with a new card) in developer-provided `<div>` containers using Skyflow Reveal Elements.
39
+ *
40
+ * Must be called **after** a successful `saveCustomerCard()` or `payment()` that processed
41
+ * a new card (i.e., without a saved-card `skyflow_id`). Skyflow Reveal Elements render the
42
+ * actual (or masked) values inside secure iframes without exposing them to the application.
43
+ *
44
+ * Default container IDs: `#reveal_<field>` (e.g. `#reveal_card_number`).
45
+ * Default redaction: `MASKED` for card_number, `REDACTED` for cvv, `PLAIN_TEXT` for others.
46
+ *
47
+ * @param request - Fields to reveal and optional per-field styles/redaction/altText.
48
+ */
49
+ revealCardFields(request: IRevealCardFieldsRequest): Promise<void>;
30
50
  unmountCardFields(context?: string): void;
31
51
  /**
32
52
  * Internal helper to unmount elements from a specific context
@@ -39,7 +59,7 @@ export declare class LiteCheckout extends BaseInlineCheckout implements ILiteChe
39
59
  getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
40
60
  _setCartTotal(total: string): void;
41
61
  _checkout({ card, payment_method, isSandbox, returnUrl: returnUrlData }: {
42
- card?: ICardFields | string;
62
+ card?: string;
43
63
  payment_method?: string;
44
64
  isSandbox?: boolean;
45
65
  returnUrl?: string;
@@ -2,12 +2,11 @@ import Skyflow from "skyflow-js";
2
2
  import CollectContainer from "skyflow-js/types/core/external/collect/collect-container";
3
3
  import CollectElement from "skyflow-js/types/core/external/collect/collect-element";
4
4
  import { TokensSkyflowRequest } from "../types/requests";
5
- import { IMountCardFieldsRequest } from "../types/card";
5
+ import { IMountCardFieldsRequest, IRevealCardFieldsRequest } from "../types/card";
6
6
  import { IEvents, ILiteCustomizationOptions } from "../types/commons";
7
7
  /**
8
- * [DEPRECATION WARNING]
9
- * This function should be deprecated in favor of using mountSkyflowFields for security,
10
- * to prevent users from creating their own inputs.
8
+ * @deprecated This function is deprecated and will be removed in a future release.
9
+ * Use `mountCardFields()` to render Skyflow Elements and collect card data securely.
11
10
  */
12
11
  export declare function getSkyflowTokens({ baseUrl, apiKey, vault_id, vault_url, data, }: TokensSkyflowRequest): Promise<any>;
13
12
  export declare function initSkyflowInstance({ baseUrl, apiKey, vault_id, vault_url, }: TokensSkyflowRequest): Promise<Skyflow>;
@@ -20,3 +19,8 @@ export declare function mountSkyflowFields(event: {
20
19
  elements: CollectElement[];
21
20
  container: CollectContainer;
22
21
  }>;
22
+ export declare function mountRevealFields(event: {
23
+ skyflowInstance: Skyflow;
24
+ tokens: Record<string, string>;
25
+ request: IRevealCardFieldsRequest;
26
+ }): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ import { BaseInlineCheckout } from './classes/BaseInlineCheckout';
3
3
  import { SdkTelemetryClient } from './helpers/SdkTelemetryClient';
4
4
  import { AppError } from './shared/utils/appError';
5
5
  import { validateCVV, validateCardNumber, validateExpirationMonth, validateCardholderName, validateExpirationYear } from './helpers/validations';
6
+ export type { IRevealCardFieldsRequest, IRevealCardField, IRevealElementStyles, IRevealElementInputStyles, RevealRedaction, } from './types/card';
6
7
  export { LiteCheckout, BaseInlineCheckout, SdkTelemetryClient, AppError, validateCVV, validateCardNumber, validateCardholderName, validateExpirationMonth, validateExpirationYear };