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

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/src/types/card.ts CHANGED
@@ -34,6 +34,11 @@ export interface ISaveCardSkyflowRequest {
34
34
  subscription_id?: string;
35
35
  }
36
36
 
37
+ /**
38
+ * @deprecated Raw card fields are no longer accepted by `saveCustomerCard()`.
39
+ * Use `mountCardFields()` to render Skyflow Elements in your form and call
40
+ * `saveCustomerCard()` with no arguments.
41
+ */
37
42
  export interface ISaveCardRequest {
38
43
  card_number: string;
39
44
  cvv: string;
@@ -50,8 +55,99 @@ export enum CardFieldEnum {
50
55
  }
51
56
  export type CardField = "cvv" | "card_number" | "expiration_month" | "expiration_year" | "cardholder_name";
52
57
 
58
+ /**
59
+ * Configuration for mounting Skyflow Elements into developer-provided `<div>` containers.
60
+ *
61
+ * Used in two scenarios:
62
+ * - **New card form** (no `card_id`): mount all 5 fields before calling `payment()` or
63
+ * `saveCustomerCard()`. Default container IDs are `#collect_<field>` (e.g. `#collect_card_number`).
64
+ * - **Saved-card CVV** (with `card_id`): mount only `cvv` for a specific saved card before
65
+ * calling `payment()` with the card's skyflow_id. Default container ID is `#collect_cvv_<card_id>`.
66
+ *
67
+ * Custom container IDs can be set via the `{ field, container_id }` object form of each field entry.
68
+ */
53
69
  export interface IMountCardFieldsRequest {
54
70
  fields: (CardField | { container_id?: string; field: CardField })[];
55
71
  card_id?: string;
56
72
  unmount_context?: 'all' | 'current' | 'create' | string;
57
73
  }
74
+
75
+ // ─── Reveal Elements ──────────────────────────────────────────────────────────
76
+
77
+ /**
78
+ * Card fields that can be revealed via Skyflow Reveal Elements.
79
+ *
80
+ * `cvv` is intentionally excluded: PCI DSS Requirement 3.2.1 prohibits storing or
81
+ * displaying the card verification value after authorisation.
82
+ */
83
+ export type RevealableCardField = Exclude<CardField, 'cvv'>;
84
+
85
+ /**
86
+ * Styles accepted by Skyflow Reveal Elements.
87
+ * Note: Reveal elements only support `base`, `copyIcon`, and `global` style variants
88
+ * (unlike Collect elements which also support `focus`, `complete`, `invalid`, etc.).
89
+ */
90
+ export interface IRevealElementInputStyles {
91
+ base?: Record<string, any>;
92
+ copyIcon?: Record<string, any>;
93
+ global?: Record<string, any>;
94
+ }
95
+
96
+ /** Full styles object for a Skyflow Reveal Element. */
97
+ export interface IRevealElementStyles {
98
+ inputStyles?: IRevealElementInputStyles;
99
+ labelStyles?: { base?: Record<string, any>; global?: Record<string, any> };
100
+ errorTextStyles?: { base?: Record<string, any>; global?: Record<string, any> };
101
+ }
102
+
103
+ /**
104
+ * Per-field reveal configuration.
105
+ * When using the shorthand string form (e.g. `'card_number'`), defaults are applied automatically.
106
+ *
107
+ * Redaction levels are fixed by the SDK to comply with PCI DSS and cannot be overridden:
108
+ * - `card_number` → `MASKED` (shows only first-6 / last-4 digits)
109
+ * - `cardholder_name` → `PLAIN_TEXT`
110
+ * - `expiration_month` → `PLAIN_TEXT`
111
+ * - `expiration_year` → `PLAIN_TEXT`
112
+ */
113
+ export interface IRevealCardField {
114
+ /** The card field to reveal. CVV is not allowed per PCI DSS req. 3.2.1. */
115
+ field: RevealableCardField;
116
+ /**
117
+ * ID of the `<div>` container where the Reveal Element will be mounted.
118
+ * Defaults to `#reveal_<field>` (e.g. `#reveal_card_number`).
119
+ */
120
+ container_id?: string;
121
+ /**
122
+ * Placeholder text shown inside the iframe before `reveal()` is called.
123
+ * If not set, Skyflow shows the token string.
124
+ */
125
+ altText?: string;
126
+ /** Label rendered by Skyflow above the element. */
127
+ label?: string;
128
+ /** Per-field styles. Overrides `IRevealCardFieldsRequest.styles` for this field. */
129
+ styles?: IRevealElementStyles;
130
+ }
131
+
132
+ /**
133
+ * Request object for `revealCardFields()`.
134
+ *
135
+ * Call `revealCardFields()` after a successful `saveCustomerCard()` or `payment()` that
136
+ * processed a new card. The SDK stores the Skyflow tokens from the collect operation and
137
+ * uses them to populate Skyflow Reveal Elements (secure iframes) in the provided `<div>` containers.
138
+ *
139
+ * Redaction is applied automatically per PCI DSS guidelines and cannot be configured.
140
+ */
141
+ export interface IRevealCardFieldsRequest {
142
+ /**
143
+ * Fields to reveal. Each entry can be a plain `RevealableCardField` string (uses all defaults)
144
+ * or an `IRevealCardField` object for custom container, label, altText or styles.
145
+ * CVV is not a valid option.
146
+ */
147
+ fields: (RevealableCardField | IRevealCardField)[];
148
+ /**
149
+ * Global styles applied to all reveal elements.
150
+ * Per-field `styles` in `IRevealCardField` takes priority over this.
151
+ */
152
+ styles?: IRevealElementStyles;
153
+ }
@@ -109,7 +109,12 @@ export interface IProcessPaymentRequest {
109
109
  metadata?: Record<string, any>;
110
110
  currency?: string;
111
111
  payment_method?: string;
112
- card?: ICardFields | string;
112
+ /**
113
+ * For a saved card: pass the `skyflow_id` string of the saved card.
114
+ * For a new card: omit this field — card data is collected from Skyflow Elements
115
+ * mounted via `mountCardFields()`.
116
+ */
117
+ card?: string;
113
118
  isSandbox?: boolean;
114
119
  apm_config?: IMPConfigRequest | Record<string, any>;
115
120
  /**
@@ -120,6 +125,10 @@ export interface IProcessPaymentRequest {
120
125
  order_reference?: string | null;
121
126
  }
122
127
 
128
+ /**
129
+ * @deprecated Raw card fields are no longer accepted by `payment()` or `saveCustomerCard()`.
130
+ * Use `mountCardFields()` to render Skyflow Elements and collect card data securely.
131
+ */
123
132
  export interface ICardFields {
124
133
  card_number: string;
125
134
  cvv: string;
@@ -158,6 +158,14 @@ export interface IEventSecureInput {
158
158
  isEmpty: boolean;
159
159
  isFocused: boolean;
160
160
  isValid: boolean;
161
+ /**
162
+ * The current value of the field as reported by Skyflow.
163
+ * Available in non-PROD Skyflow environments (DEV/SANDBOX).
164
+ * In PROD, sensitive fields (card_number, cvv) return an empty string;
165
+ * non-sensitive fields (cardholder_name, expiration_month, expiration_year)
166
+ * may still return their value.
167
+ */
168
+ value?: string;
161
169
  }
162
170
  export interface IEvents extends ICardFormEvents {}
163
171
  export interface IApiError {
@@ -209,6 +217,22 @@ export interface IFormPlaceholder {
209
217
 
210
218
  export interface IStyles {
211
219
  cardForm?: ILiteCardFormStyles;
220
+ /** Input-element styles applied only to the cardholder name field. Overrides `cardForm.inputStyles` for this field. */
221
+ cardholderName?: CollectInputStylesVariant;
222
+ /** Input-element styles applied only to the card number field. Overrides `cardForm.inputStyles` for this field. */
223
+ cardNumber?: CollectInputStylesVariant;
224
+ /** Input-element styles applied only to the CVV field. Overrides `cardForm.inputStyles` for this field. */
225
+ cvv?: CollectInputStylesVariant;
226
+ /** Input-element styles applied only to the expiration month field. Overrides `cardForm.inputStyles` for this field. */
227
+ expirationMonth?: CollectInputStylesVariant;
228
+ /** Input-element styles applied only to the expiration year field. Overrides `cardForm.inputStyles` for this field. */
229
+ expirationYear?: CollectInputStylesVariant;
230
+ /**
231
+ * Show the card-network icon inside the card number Skyflow Element.
232
+ * Corresponds to Skyflow's `CollectElementOptions.enableCardIcon`.
233
+ * @default true
234
+ */
235
+ enableCardIcon?: boolean;
212
236
  }
213
237
 
214
238
  export interface ILiteCardFormStyles extends StylesBaseVariant, IElementStyle {}
@@ -236,7 +260,7 @@ export interface CollectInputStylesVariant
236
260
  dropdownIcon?: Record<string, any>;
237
261
  dropdown?: Record<string, any>;
238
262
  dropdownListItem?: Record<string, any>;
239
- global: Record<string, any>;
263
+ global?: Record<string, any>;
240
264
  }
241
265
 
242
266
  export interface CollectLabelStylesVariant
@@ -1,7 +1,7 @@
1
1
  import { IConfigureCheckout } from "./commons";
2
2
  import {
3
3
  ICustomerCardsResponse,
4
- ISaveCardRequest,
4
+ IRevealCardFieldsRequest,
5
5
  ISaveCardResponse,
6
6
  } from "./card";
7
7
  import { IPaymentMethod } from "./paymentMethod";
@@ -76,16 +76,19 @@ export interface ILiteCheckout {
76
76
  getCustomerCards(): Promise<ICustomerCardsResponse>;
77
77
 
78
78
  /**
79
- * Saves a card to a customer's account. This method can be used to add a new card
80
- * or update an existing one.
81
- * @param {import("./index").ISaveCardRequest} card - The card information to be saved.
79
+ * Saves a card to a customer's account using card data collected via Skyflow Elements.
80
+ *
81
+ * **Requires** that `mountCardFields()` was called first with all five fields
82
+ * (`cardholder_name`, `card_number`, `expiration_month`, `expiration_year`, `cvv`)
83
+ * and that the user has filled them in before calling this method.
84
+ *
82
85
  * @returns {Promise<import("./index").ISaveCardResponse>} A promise that resolves with the saved card data.
83
86
  *
84
87
  * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
85
88
  *
86
89
  * @public
87
90
  */
88
- saveCustomerCard(card: ISaveCardRequest): Promise<ISaveCardResponse>;
91
+ saveCustomerCard(): Promise<ISaveCardResponse>;
89
92
 
90
93
  /**
91
94
  * Removes a card from a customer's account.
@@ -224,9 +227,18 @@ export interface ILiteCheckout {
224
227
  ): Promise<string | ErrorResponse>;
225
228
 
226
229
  /**
227
- * Displays and renders card input fields in the checkout.
228
- * Uses the provided configuration to show the required fields in the payment form.
229
- * @param {import("./card").IMountCardFieldsRequest} event - Configuration for the card fields to render.
230
+ * Mounts Skyflow Elements (secure iframes) into developer-provided `<div>` containers.
231
+ *
232
+ * **New card form** (omit `card_id`): mount all 5 fields before calling `payment()` or
233
+ * `saveCustomerCard()`. Place divs with default IDs: `collect_cardholder_name`,
234
+ * `collect_card_number`, `collect_expiration_month`, `collect_expiration_year`, `collect_cvv`.
235
+ *
236
+ * **Saved-card CVV** (provide `card_id`): mount only `cvv` for a specific saved card before
237
+ * calling `payment()`. Default div ID: `collect_cvv_<card_id>`.
238
+ *
239
+ * Custom container IDs can be set via `{ field, container_id }` object form per field entry.
240
+ *
241
+ * @param {import("./card").IMountCardFieldsRequest} event - Configuration for the fields to render.
230
242
  * @returns {Promise<void>} Resolves when the fields have been successfully rendered.
231
243
  * @public
232
244
  */
@@ -239,4 +251,34 @@ export interface ILiteCheckout {
239
251
  * @public
240
252
  */
241
253
  unmountCardFields(context?: string): void;
254
+
255
+ /**
256
+ * Reveals card data (from the last `saveCustomerCard()` or `payment()` with a new card)
257
+ * in developer-provided `<div>` containers using Skyflow Reveal Elements (secure iframes).
258
+ *
259
+ * Must be called **after** a successful `saveCustomerCard()` or `payment()` that processed
260
+ * a new card. The SDK stores the Skyflow tokens from that collect operation internally.
261
+ *
262
+ * **Default container IDs:** `#reveal_<field>` (e.g. `#reveal_card_number`).
263
+ *
264
+ * **Redaction by field (fixed, cannot be overridden):**
265
+ * - `card_number` → `MASKED` (e.g. `4111 11•• •••• 1234`)
266
+ * - `cardholder_name`, `expiration_month`, `expiration_year` → `PLAIN_TEXT`
267
+ *
268
+ * > CVV cannot be revealed — PCI DSS 3.2.1 prohibits storing or displaying CVV post-authorization.
269
+ *
270
+ * @param request - Fields to reveal, plus optional styles, redaction level, and altText per field.
271
+ * @returns {Promise<void>} Resolves when all Reveal Elements have been mounted and `reveal()` called.
272
+ * @public
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * // After successful saveCustomerCard():
277
+ * await liteCheckout.revealCardFields({
278
+ * fields: ['card_number', 'cardholder_name', 'expiration_month', 'expiration_year']
279
+ * });
280
+ * // → renders masked card info in #reveal_card_number, #reveal_cardholder_name, etc.
281
+ * ```
282
+ */
283
+ revealCardFields(request: IRevealCardFieldsRequest): Promise<void>;
242
284
  }
@@ -83,6 +83,7 @@ export type TokensSkyflowRequest = {
83
83
  apiKey: string;
84
84
  vault_id: string,
85
85
  vault_url: string,
86
+ mode?: string,
86
87
  data?: {
87
88
  [key: string]: any;
88
89
  }