tonder-web-sdk 1.16.1 → 1.16.6-beta.DEV-1433.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 +134 -40
- package/package.json +29 -6
- package/types/card.d.ts +17 -17
- package/types/checkout.d.ts +85 -87
- package/types/common.d.ts +8 -2
- package/types/customer.d.ts +10 -10
- package/types/index.d.ts +9 -11
- package/types/inlineCheckout.d.ts +81 -61
- package/types/liteInlineCheckout.d.ts +78 -83
- package/types/paymentMethod.d.ts +17 -17
- package/types/transaction.d.ts +94 -94
- package/v1/bundle.min.js +1 -18
- package/.env-example +0 -1
- package/cypress/e2e/1-getting-started/todo.cy.js +0 -143
- package/cypress/e2e/2-advanced-examples/actions.cy.js +0 -299
- package/cypress/e2e/2-advanced-examples/aliasing.cy.js +0 -39
- package/cypress/e2e/2-advanced-examples/assertions.cy.js +0 -176
- package/cypress/e2e/2-advanced-examples/connectors.cy.js +0 -98
- package/cypress/e2e/2-advanced-examples/cookies.cy.js +0 -118
- package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +0 -185
- package/cypress/e2e/2-advanced-examples/files.cy.js +0 -85
- package/cypress/e2e/2-advanced-examples/location.cy.js +0 -32
- package/cypress/e2e/2-advanced-examples/misc.cy.js +0 -104
- package/cypress/e2e/2-advanced-examples/navigation.cy.js +0 -56
- package/cypress/e2e/2-advanced-examples/network_requests.cy.js +0 -163
- package/cypress/e2e/2-advanced-examples/querying.cy.js +0 -114
- package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +0 -201
- package/cypress/e2e/2-advanced-examples/storage.cy.js +0 -110
- package/cypress/e2e/2-advanced-examples/traversal.cy.js +0 -121
- package/cypress/e2e/2-advanced-examples/utilities.cy.js +0 -108
- package/cypress/e2e/2-advanced-examples/viewport.cy.js +0 -58
- package/cypress/e2e/2-advanced-examples/waiting.cy.js +0 -30
- package/cypress/e2e/2-advanced-examples/window.cy.js +0 -22
- package/cypress/fixtures/example.json +0 -5
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.js +0 -9
- package/index.js.example +0 -50
- package/samples/react/README.md +0 -70
- package/samples/react/build/asset-manifest.json +0 -16
- package/samples/react/build/favicon.ico +0 -0
- package/samples/react/build/index.html +0 -1
- package/samples/react/build/logo192.png +0 -0
- package/samples/react/build/logo512.png +0 -0
- package/samples/react/build/manifest.json +0 -25
- package/samples/react/build/robots.txt +0 -3
- package/samples/react/build/static/css/main.073c9b0a.css +0 -2
- package/samples/react/build/static/css/main.073c9b0a.css.map +0 -1
- package/samples/react/build/static/js/787.b83ed06f.chunk.js +0 -2
- package/samples/react/build/static/js/787.b83ed06f.chunk.js.map +0 -1
- package/samples/react/build/static/js/main.0a848807.js +0 -3
- package/samples/react/build/static/js/main.0a848807.js.LICENSE.txt +0 -39
- package/samples/react/build/static/js/main.0a848807.js.map +0 -1
- package/samples/react/build/static/media/sdk-icons.b491623214b2af4cccdb.png +0 -0
- package/samples/react/package-lock.json +0 -28973
- package/samples/react/package.json +0 -44
- package/samples/react/public/favicon.ico +0 -0
- package/samples/react/public/index.html +0 -43
- package/samples/react/public/logo192.png +0 -0
- package/samples/react/public/logo512.png +0 -0
- package/samples/react/public/manifest.json +0 -25
- package/samples/react/public/robots.txt +0 -3
- package/samples/react/src/App.css +0 -38
- package/samples/react/src/App.js +0 -22
- package/samples/react/src/App.test.js +0 -8
- package/samples/react/src/assets/img/sdk-icons.png +0 -0
- package/samples/react/src/components/Cart.js +0 -29
- package/samples/react/src/components/ProductCard.js +0 -27
- package/samples/react/src/context/CartContext.js +0 -116
- package/samples/react/src/index.css +0 -13
- package/samples/react/src/index.js +0 -17
- package/samples/react/src/logo.svg +0 -1
- package/samples/react/src/reportWebVitals.js +0 -13
- package/samples/react/src/screens/Checkout.js +0 -82
- package/samples/react/src/screens/Store.js +0 -21
- package/samples/react/src/setupTests.js +0 -5
- package/samples/react/src/storeProducts.js +0 -30
- package/src/classes/3dsHandler.js +0 -203
- package/src/classes/BaseInlineCheckout.js +0 -324
- package/src/classes/LiteInlineCheckout.js +0 -220
- package/src/classes/checkout.js +0 -125
- package/src/classes/globalLoader.js +0 -29
- package/src/classes/inlineCheckout.js +0 -515
- package/src/data/apmApi.js +0 -44
- package/src/data/businessApi.js +0 -19
- package/src/data/cardApi.js +0 -143
- package/src/data/checkoutApi.js +0 -92
- package/src/data/customerApi.js +0 -37
- package/src/data/index.js +0 -17
- package/src/data/openPayApi.js +0 -16
- package/src/data/skyflowApi.js +0 -18
- package/src/helpers/skyflow.js +0 -361
- package/src/helpers/styles.js +0 -61
- package/src/helpers/template-skeleton.js +0 -59
- package/src/helpers/template.js +0 -743
- package/src/helpers/utils.js +0 -163
- package/src/helpers/validations.js +0 -54
- package/src/index-dev.js +0 -307
- package/src/index.html +0 -172
- package/src/index.js +0 -15
- package/src/shared/catalog/paymentMethodsCatalog.js +0 -247
- package/src/shared/constants/messages.js +0 -10
- package/src/shared/constants/paymentMethodAPM.js +0 -63
- package/src/shared/constants/tonderUrl.js +0 -8
- package/webpack.config.js +0 -77
package/README.md
CHANGED
|
@@ -7,8 +7,10 @@ Tonder SDK helps to integrate the services Tonder offers in your own website
|
|
|
7
7
|
1. [Installation](#installation)
|
|
8
8
|
2. [Usage](#usage)
|
|
9
9
|
- [InlineCheckout](#inlinecheckout)
|
|
10
|
-
- [
|
|
11
|
-
3. [Configuration Options](#configuration
|
|
10
|
+
- [LiteCheckout](#litecheckout)
|
|
11
|
+
3. [Configuration Options](#configuration)
|
|
12
|
+
- [Inline Options](#inline-options)
|
|
13
|
+
- [Lite Options](#lite-options)
|
|
12
14
|
4. [Styling InlineCheckout](#styling-inlinecheckout)
|
|
13
15
|
5. [Payment Data Structure](#payment-data-structure)
|
|
14
16
|
6. [Field Validation Functions](#field-validation-functions)
|
|
@@ -96,16 +98,16 @@ inlineCheckout.verify3dsTransaction().then((response) => {
|
|
|
96
98
|
const response = await inlineCheckout.payment(checkoutData);
|
|
97
99
|
```
|
|
98
100
|
|
|
99
|
-
###
|
|
101
|
+
### LiteCheckout
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
LiteCheckout allows you to build a custom checkout interface using Tonder's core functionality.
|
|
102
104
|
|
|
103
105
|
```javascript
|
|
104
|
-
import {
|
|
106
|
+
import { LiteCheckout } from "tonder-web-sdk";
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
```javascript
|
|
108
|
-
const
|
|
110
|
+
const liteCheckout = new LiteCheckout({
|
|
109
111
|
apiKey: "your-api-key", // Your api key getted from Tonder Dashboard
|
|
110
112
|
returnUrl: "http://your-website.com/checkout",
|
|
111
113
|
});
|
|
@@ -115,57 +117,145 @@ const LiteInlineCheckout = new LiteInlineCheckout({
|
|
|
115
117
|
inlineCheckout.configureCheckout({ customer: { email: "example@email.com" } });
|
|
116
118
|
|
|
117
119
|
// Initialize the checkout
|
|
118
|
-
await
|
|
120
|
+
await liteCheckout.injectCheckout();
|
|
119
121
|
```
|
|
120
122
|
|
|
121
123
|
```javascript
|
|
122
124
|
// Retrieve customer's saved cards
|
|
123
|
-
const cards = await
|
|
125
|
+
const cards = await liteCheckout.getCustomerCards();
|
|
124
126
|
```
|
|
125
127
|
|
|
126
128
|
```javascript
|
|
127
129
|
// Save a new card
|
|
128
|
-
const newCard = await
|
|
130
|
+
const newCard = await liteCheckout.saveCustomerCard(cardData);
|
|
129
131
|
```
|
|
130
132
|
|
|
131
133
|
```javascript
|
|
132
134
|
// Remove a saved card
|
|
133
|
-
await
|
|
135
|
+
await liteCheckout.removeCustomerCard(cardId);
|
|
134
136
|
```
|
|
135
137
|
|
|
136
138
|
```javascript
|
|
137
139
|
// Get available payment methods
|
|
138
|
-
const paymentMethods = await
|
|
140
|
+
const paymentMethods = await liteCheckout.getCustomerPaymentMethods();
|
|
139
141
|
```
|
|
140
142
|
|
|
141
143
|
```javascript
|
|
142
144
|
// Process a payment
|
|
143
|
-
const paymentResponse = await
|
|
145
|
+
const paymentResponse = await liteCheckout.payment(paymentData);
|
|
144
146
|
```
|
|
145
147
|
|
|
146
148
|
```javascript
|
|
147
149
|
// Verify a 3DS transaction
|
|
148
|
-
const verificationResult = await
|
|
150
|
+
const verificationResult = await liteCheckout.verify3dsTransaction();
|
|
149
151
|
```
|
|
150
152
|
|
|
151
|
-
## Configuration
|
|
153
|
+
## Configuration
|
|
154
|
+
### Inline Options
|
|
155
|
+
|
|
156
|
+
| Property | Type | Required | Description | Default | Description |
|
|
157
|
+
|:-------------:|:--------------------:|----------|------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------:|
|
|
158
|
+
| mode | string | Yes | Environment mode for the SDK | stage | Environment mode. Options: 'stage', 'production', 'sandbox'. Default: 'stage' |
|
|
159
|
+
| apiKey | string | Yes | Your Tonder Public API key | | Your API key from the Tonder Dashboard |
|
|
160
|
+
| returnUrl | string | Yes | URL for 3DS redirect completion | | URL where the checkout form is mounted (used for 3DS) |
|
|
161
|
+
| styles | object | No | | | (InlineCheckout only) Custom styles for the checkout interface |
|
|
162
|
+
| customization | CustomizationOptions | No | UI customization options | `{displayMode: 'light',saveCards: {showSaveCardOption: false,showSaved: false,autoSave: false,},paymentButton: {show: false,text: "Pagar",showAmount: true,},cancelButton: {show: false,text: "Cancelar",},paymentMethods: {show: true,},cardForm: {show: true,},showMessages: true,}` | Object to customize the checkout behavior and UI. |
|
|
163
|
+
| callbacks | IInlineCallbacks | No | Payment process callback functions |
|
|
164
|
+
<details>
|
|
165
|
+
<summary>View Interface Definition</summary>
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
interface IInlineCheckoutBaseOptions {
|
|
169
|
+
mode?: "production" | "sandbox" | "stage" | "development";
|
|
170
|
+
apiKey: string;
|
|
171
|
+
returnUrl: string;
|
|
172
|
+
callBack?: (response: any) => void;
|
|
173
|
+
}
|
|
174
|
+
interface IInlineCheckoutOptions extends IInlineCheckoutBaseOptions {
|
|
175
|
+
styles?: Record<string, string>;
|
|
176
|
+
customization?: CustomizationOptions;
|
|
177
|
+
callbacks?: IInlineCallbacks;
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
</details>
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
### Inline Callbacks Structure
|
|
154
183
|
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
184
|
+
| Callback | Required | Parameters | Description | Return |
|
|
185
|
+
|------------|----------|------------|--------------------------------------------|---------------|
|
|
186
|
+
| `onCancel` | No | none | Called when user clicked the cancel button | Promise<void> |
|
|
187
|
+
<details>
|
|
188
|
+
<summary>View Interface Definition</summary>
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
interface IInlineCallbacks extends IBaseCallback {
|
|
192
|
+
onCancel?: () => Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
</details>
|
|
196
|
+
|
|
197
|
+
### Inline Customization Options
|
|
198
|
+
|
|
199
|
+
| Option | Type | Default | Description |
|
|
200
|
+
|------------------------------|---------|------------|-------------------------------------------------------------------------------------------|
|
|
201
|
+
| **saveCards** |
|
|
202
|
+
| saveCards.showSaveCardOption | boolean | true | Shows a checkbox allowing users to choose whether to save their card for future purchases |
|
|
203
|
+
| saveCards.showSaved | boolean | true | Displays a list of previously saved cards for the customer |
|
|
204
|
+
| saveCards.autoSave | boolean | false | Automatically saves the card without showing the save option to the user |
|
|
205
|
+
| **paymentButton** |
|
|
206
|
+
| paymentButton.show | boolean | true | Controls the visibility of the payment button |
|
|
207
|
+
| paymentButton.text | string | 'Pagar' | Custom text to display on the payment button |
|
|
208
|
+
| paymentButton.showAmount | boolean | true | Shows the payment amount on the button (e.g., "Pay $100") |
|
|
209
|
+
| **cancelButton** |
|
|
210
|
+
| cancelButton.show | boolean | true | Controls the visibility of the cancel button |
|
|
211
|
+
| cancelButton.text | string | 'Cancelar' | Custom text to display on the cancel button |
|
|
212
|
+
| **paymentMethods** |
|
|
213
|
+
| paymentMethods.show | boolean | true | Controls the visibility of alternative payment methods section |
|
|
214
|
+
| **cardForm** |
|
|
215
|
+
| cardForm.show | boolean | true | Controls the visibility of the card input form |
|
|
216
|
+
| **General** |
|
|
217
|
+
| showMessages | boolean | true | Controls the visibility of error and success messages |
|
|
218
|
+
| displayMode | string | light | Controls the display mode light or dark |
|
|
219
|
+
|
|
220
|
+
<details>
|
|
221
|
+
<summary>View Interface Definition</summary>
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
export type CustomizationOptions = {
|
|
225
|
+
displayMode?: "light" | "dark";
|
|
226
|
+
saveCards?: {
|
|
227
|
+
showSaveCardOption?: boolean;
|
|
228
|
+
showSaved?: boolean;
|
|
229
|
+
autoSave?: boolean;
|
|
230
|
+
};
|
|
231
|
+
paymentButton?: {
|
|
232
|
+
show?: boolean;
|
|
233
|
+
text?: string;
|
|
234
|
+
showAmount?: boolean;
|
|
235
|
+
};
|
|
236
|
+
cancelButton?: {
|
|
237
|
+
show?: boolean;
|
|
238
|
+
text?: string;
|
|
239
|
+
};
|
|
240
|
+
paymentMethods?: {
|
|
241
|
+
show?: boolean;
|
|
242
|
+
};
|
|
243
|
+
cardForm?: {
|
|
244
|
+
show?: boolean;
|
|
245
|
+
};
|
|
246
|
+
showMessages?: boolean;
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
</details>
|
|
250
|
+
|
|
251
|
+
## Lite Options
|
|
252
|
+
|
|
253
|
+
| Property | Type | Required | Description | Default | Description |
|
|
254
|
+
|:---------:|:------:|----------|---------------------------------|---------|:-----------------------------------------------------------------------------:|
|
|
255
|
+
| mode | string | Yes | Environment mode for the SDK | stage | Environment mode. Options: 'stage', 'production', 'sandbox'. Default: 'stage' |
|
|
256
|
+
| apiKey | string | Yes | Your Tonder Public API key | | Your API key from the Tonder Dashboard |
|
|
257
|
+
| returnUrl | string | Yes | URL for 3DS redirect completion | | URL where the checkout form is mounted (used for 3DS) |
|
|
166
258
|
|
|
167
|
-
> **Important Note about SaveCard functionality**:
|
|
168
|
-
> To properly implement the SaveCard feature, you must use a SecureToken. For detailed implementation instructions and best practices, please refer to our official documentation on [How to use SecureToken for secure card saving](https://docs.tonder.io/integration/sdks/secure-token#how-to-use-securetoken-for-secure-card-saving).
|
|
169
259
|
|
|
170
260
|
## Styling InlineCheckout
|
|
171
261
|
|
|
@@ -256,15 +346,15 @@ When calling the `payment` method, use the following data structure:
|
|
|
256
346
|
|
|
257
347
|
- **metadata**: Object for including any additional information about the transaction. This can be used for internal references or tracking.
|
|
258
348
|
|
|
259
|
-
- **card**: (for
|
|
349
|
+
- **card**: (for LiteCheckout) Object containing card information. This is used differently depending on whether it's a new card or a saved card:
|
|
260
350
|
|
|
261
351
|
- For a new card: Include `card_number`, `cvv`, `expiration_month`, `expiration_year`, and `cardholder_name`.
|
|
262
352
|
- For a saved card: Include only the `skyflow_id` of the saved card.
|
|
263
353
|
- This is only used when not paying with a payment_method.
|
|
264
354
|
|
|
265
|
-
- **payment_method**: (for
|
|
355
|
+
- **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.
|
|
266
356
|
|
|
267
|
-
Note: The exact fields required may vary depending on whether you're using InlineCheckout or
|
|
357
|
+
Note: The exact fields required may vary depending on whether you're using InlineCheckout or LiteCheckout, and the specific payment method being used.
|
|
268
358
|
|
|
269
359
|
```javascript
|
|
270
360
|
const paymentData = {
|
|
@@ -316,7 +406,7 @@ const paymentData = {
|
|
|
316
406
|
|
|
317
407
|
## Field Validation Functions
|
|
318
408
|
|
|
319
|
-
For
|
|
409
|
+
For LiteCheckout implementations, the SDK provides validation functions to ensure the integrity of card data before submitting:
|
|
320
410
|
|
|
321
411
|
- `validateCardNumber(cardNumber)`: Validates the card number using the Luhn algorithm.
|
|
322
412
|
- `validateCardholderName(name)`: Checks if the cardholder name is valid.
|
|
@@ -361,7 +451,7 @@ if (
|
|
|
361
451
|
- `payment(data)`: Process a payment
|
|
362
452
|
- `verify3dsTransaction()`: Verify a 3DS transaction
|
|
363
453
|
|
|
364
|
-
###
|
|
454
|
+
### LiteCheckout Methods
|
|
365
455
|
|
|
366
456
|
- `configureCheckout(data)`: Set initial checkout data
|
|
367
457
|
- `injectCheckout()`: Initialize the checkout
|
|
@@ -453,7 +543,11 @@ const inlineCheckout = new InlineCheckout({
|
|
|
453
543
|
apiKey,
|
|
454
544
|
returnUrl,
|
|
455
545
|
styles: customStyles,
|
|
456
|
-
|
|
546
|
+
customization: {
|
|
547
|
+
paymentButton: {
|
|
548
|
+
show: true
|
|
549
|
+
}
|
|
550
|
+
}, // activate default Tonder Payment button
|
|
457
551
|
callBack: (response) => {
|
|
458
552
|
console.log('Payment response', response)
|
|
459
553
|
}
|
|
@@ -499,16 +593,16 @@ import { LiteInlineCheckout } from "tonder-web-sdk";
|
|
|
499
593
|
const apiKey = "your-api-key";
|
|
500
594
|
const returnUrl = "http://your-website.com/checkout";
|
|
501
595
|
|
|
502
|
-
const
|
|
596
|
+
const liteCheckout = new LiteInlineCheckout({
|
|
503
597
|
mode: "development",
|
|
504
598
|
apiKey,
|
|
505
599
|
returnUrl,
|
|
506
600
|
});
|
|
507
601
|
|
|
508
|
-
|
|
509
|
-
|
|
602
|
+
liteCheckout.configureCheckout({ customer: { email: "example@email.com" } });
|
|
603
|
+
liteCheckout.injectCheckout();
|
|
510
604
|
|
|
511
|
-
|
|
605
|
+
liteCheckout.verify3dsTransaction().then((response) => {
|
|
512
606
|
console.log("Verify 3ds response", response);
|
|
513
607
|
});
|
|
514
608
|
|
|
@@ -526,7 +620,7 @@ document
|
|
|
526
620
|
|
|
527
621
|
try {
|
|
528
622
|
const paymentData = { ...checkoutData, card: cardData };
|
|
529
|
-
const response = await
|
|
623
|
+
const response = await liteCheckout.payment(paymentData);
|
|
530
624
|
console.log("Payment response:", response);
|
|
531
625
|
alert("Payment successful");
|
|
532
626
|
} catch (error) {
|
|
@@ -738,7 +832,7 @@ export class TonderService {
|
|
|
738
832
|
// Add more functions, for example for lite sdk: get payment methods
|
|
739
833
|
|
|
740
834
|
// getCustomerPaymentMethods(): Promise<IPaymentMethod[]> {
|
|
741
|
-
// return this.
|
|
835
|
+
// return this.liteCheckout.getCustomerPaymentMethods();
|
|
742
836
|
// }
|
|
743
837
|
}
|
|
744
838
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tonder-web-sdk",
|
|
3
|
-
"version": "1.16.1",
|
|
3
|
+
"version": "1.16.6-beta.DEV-1433.1",
|
|
4
4
|
"description": "tonder sdk for integrations",
|
|
5
|
-
"main": "src/index.js",
|
|
6
5
|
"scripts": {
|
|
7
6
|
"start": "webpack-dev-server",
|
|
8
|
-
"build": "webpack --config webpack.config.js --mode production"
|
|
7
|
+
"build": "webpack --config webpack.config.js --mode production",
|
|
8
|
+
"prepare": "husky install",
|
|
9
|
+
"format": "prettier --write .",
|
|
10
|
+
"lint": "eslint 'src/**/*.js'",
|
|
11
|
+
"lint:fix": "eslint 'src/**/*.js' --fix"
|
|
9
12
|
},
|
|
10
13
|
"author": "",
|
|
14
|
+
"main": "v1/bundle.min.js",
|
|
11
15
|
"types": "types/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"v1",
|
|
18
|
+
"types",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
12
22
|
"license": "ISC",
|
|
13
23
|
"dependencies": {
|
|
14
24
|
"accordion-js": "^3.4.0",
|
|
15
25
|
"crypto-js": "^4.1.1",
|
|
16
|
-
"dotenv": "^16.3.1"
|
|
26
|
+
"dotenv": "^16.3.1",
|
|
27
|
+
"lodash.get": "^4.4.2"
|
|
17
28
|
},
|
|
18
29
|
"devDependencies": {
|
|
19
30
|
"@babel/core": "^7.20.12",
|
|
@@ -22,12 +33,24 @@
|
|
|
22
33
|
"babel-loader": "^9.1.2",
|
|
23
34
|
"css-loader": "^6.7.3",
|
|
24
35
|
"cypress": "^13.6.2",
|
|
36
|
+
"eslint": "^9.18.0",
|
|
37
|
+
"eslint-config-prettier": "^10.0.1",
|
|
38
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
25
39
|
"html-webpack-plugin": "^5.5.3",
|
|
26
|
-
"
|
|
40
|
+
"husky": "^8.0.3",
|
|
41
|
+
"lint-staged": "^15.4.1",
|
|
42
|
+
"prettier": "3.4.2",
|
|
27
43
|
"style-loader": "^3.3.1",
|
|
28
44
|
"terser-webpack-plugin": "^5.3.10",
|
|
29
45
|
"webpack": "^5.75.0",
|
|
30
46
|
"webpack-cli": "^5.0.1",
|
|
31
|
-
"webpack-dev-server": "^4.11.1"
|
|
47
|
+
"webpack-dev-server": "^4.11.1",
|
|
48
|
+
"webpack-obfuscator": "^3.5.1"
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"**/*.{js,jsx,ts,tsx}": [
|
|
52
|
+
"npm run format",
|
|
53
|
+
"npm run lint:fix"
|
|
54
|
+
]
|
|
32
55
|
}
|
|
33
56
|
}
|
package/types/card.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export interface ICard {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
fields: ICardSkyflowFields;
|
|
3
|
+
icon?: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export interface ICardSkyflowFields {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
card_number: string;
|
|
8
|
+
expiration_month: string;
|
|
9
|
+
expiration_year: string;
|
|
10
|
+
skyflow_id: string;
|
|
11
|
+
card_scheme: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface ICustomerCardsResponse {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
user_id: number;
|
|
16
|
+
cards: ICard[];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface ISaveCardResponse {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
skyflow_id: string;
|
|
21
|
+
user_id: number;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface ISaveCardSkyflowRequest {
|
|
25
|
-
|
|
25
|
+
skyflow_id: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ISaveCardRequest {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
card_number: string;
|
|
30
|
+
cvv: string;
|
|
31
|
+
expiration_month: string;
|
|
32
|
+
expiration_year: string;
|
|
33
|
+
cardholder_name: string;
|
|
34
34
|
}
|
package/types/checkout.d.ts
CHANGED
|
@@ -1,118 +1,116 @@
|
|
|
1
|
-
import {ICustomer} from "./customer";
|
|
1
|
+
import { ICustomer } from "./customer";
|
|
2
2
|
|
|
3
3
|
export interface IStartCheckoutRequestBase {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
name: any;
|
|
5
|
+
last_name: string;
|
|
6
|
+
email_client: any;
|
|
7
|
+
phone_number: any;
|
|
8
|
+
return_url?: string;
|
|
9
|
+
id_product: string;
|
|
10
|
+
quantity_product: number;
|
|
11
|
+
id_ship: string;
|
|
12
|
+
instance_id_ship: string;
|
|
13
|
+
amount: any;
|
|
14
|
+
title_ship: string;
|
|
15
|
+
description: string;
|
|
16
|
+
device_session_id: any;
|
|
17
|
+
token_id: string;
|
|
18
|
+
order_id: any;
|
|
19
|
+
business_id: any;
|
|
20
|
+
payment_id: any;
|
|
21
|
+
source: string;
|
|
22
|
+
browser_info?: any;
|
|
23
|
+
metadata: any;
|
|
24
|
+
currency: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export type IStartCheckoutRequestWithCard = IStartCheckoutRequestBase & {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
card: any;
|
|
29
|
+
payment_method?: never;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export type IStartCheckoutRequestWithPaymentMethod =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
payment_method: string;
|
|
32
|
+
export type IStartCheckoutRequestWithPaymentMethod = IStartCheckoutRequestBase & {
|
|
33
|
+
card?: never;
|
|
34
|
+
payment_method: string;
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
export type IStartCheckoutRequest =
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
| IStartCheckoutRequestWithCard
|
|
39
|
+
| IStartCheckoutRequestWithPaymentMethod;
|
|
41
40
|
|
|
42
41
|
export interface IStartCheckoutIdRequest {
|
|
43
|
-
|
|
42
|
+
checkout_id: string;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
export interface IStartCheckoutErrorResponse {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
status: string;
|
|
47
|
+
message: string;
|
|
48
|
+
psp_response: [
|
|
49
|
+
{
|
|
50
|
+
status: number;
|
|
51
|
+
response: Object;
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
checkout_id: string;
|
|
55
|
+
is_route_finished: boolean;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
export interface IStartCheckoutResponse {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
iframe_resources?: {
|
|
76
|
-
iframe: string;
|
|
77
|
-
};
|
|
59
|
+
status: string;
|
|
60
|
+
message: string;
|
|
61
|
+
psp_response: Record<string, any>;
|
|
62
|
+
checkout_id: string;
|
|
63
|
+
is_route_finished: Boolean;
|
|
64
|
+
transaction_status: string;
|
|
65
|
+
transaction_id: number;
|
|
66
|
+
payment_id: number;
|
|
67
|
+
provider: string;
|
|
68
|
+
next_action: {
|
|
69
|
+
redirect_to_url: {
|
|
70
|
+
url: string;
|
|
71
|
+
return_url: string;
|
|
72
|
+
verify_transaction_status_url: string;
|
|
78
73
|
};
|
|
79
|
-
|
|
74
|
+
iframe_resources?: {
|
|
75
|
+
iframe: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
actions: IStartCheckoutActionResponse[];
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
export interface IStartCheckoutActionResponse {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
name: string;
|
|
83
|
+
url: string;
|
|
84
|
+
method: string;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
|
|
89
87
|
export interface IItem {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
description: string;
|
|
89
|
+
quantity: number;
|
|
90
|
+
price_unit: number;
|
|
91
|
+
discount: number;
|
|
92
|
+
taxes: number;
|
|
93
|
+
product_reference: string | number;
|
|
94
|
+
name: string;
|
|
95
|
+
amount_total: number;
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
export interface IProcessPaymentRequest {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
99
|
+
customer: ICustomer;
|
|
100
|
+
cart: {
|
|
101
|
+
total: string | number;
|
|
102
|
+
items: IItem[];
|
|
103
|
+
};
|
|
104
|
+
metadata?: Record<string, any>;
|
|
105
|
+
currency?: string;
|
|
106
|
+
payment_method?: string;
|
|
107
|
+
card?: ICardFields | string;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
export interface ICardFields {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
111
|
+
card_number: string;
|
|
112
|
+
cvv: string;
|
|
113
|
+
expiration_month: string;
|
|
114
|
+
expiration_year: string;
|
|
115
|
+
cardholder_name: string;
|
|
116
|
+
}
|
package/types/common.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { ICustomer } from "./customer";
|
|
2
|
-
import {IProcessPaymentRequest} from "./checkout";
|
|
2
|
+
import { IProcessPaymentRequest } from "./checkout";
|
|
3
3
|
|
|
4
4
|
export interface IInlineCheckoutBaseOptions {
|
|
5
5
|
mode?: "production" | "sandbox" | "stage" | "development";
|
|
6
6
|
apiKey: string;
|
|
7
7
|
returnUrl: string;
|
|
8
8
|
callBack?: (response: any) => void;
|
|
9
|
+
signatures?:{
|
|
10
|
+
transaction?: string;
|
|
11
|
+
customer?: string;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export interface IConfigureCheckout extends IProcessPaymentRequest{
|
|
15
|
+
export interface IConfigureCheckout extends Partial<IProcessPaymentRequest> {
|
|
12
16
|
customer: ICustomer;
|
|
13
17
|
secureToken: string;
|
|
14
18
|
}
|
|
@@ -26,3 +30,5 @@ export interface IPublicError {
|
|
|
26
30
|
message: string;
|
|
27
31
|
detail: Record<string, any> | string;
|
|
28
32
|
}
|
|
33
|
+
|
|
34
|
+
export interface IBaseCallback {}
|
package/types/customer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export type ICustomer = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
firstName: string;
|
|
3
|
+
lastName: string;
|
|
4
|
+
country?: string;
|
|
5
|
+
street?: string;
|
|
6
|
+
city?: string;
|
|
7
|
+
state?: string;
|
|
8
|
+
postCode?: string;
|
|
9
|
+
email: string;
|
|
10
|
+
phone?: string;
|
|
11
|
+
address?: string;
|
|
12
12
|
};
|