tonder-web-sdk 1.12.0-beta.12 → 1.12.0-beta.14
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/.idea/workspace.xml +24 -20
- package/README.md +34 -3
- package/package.json +1 -1
- package/src/classes/BaseInlineCheckout.js +0 -1
- package/src/classes/LiteInlineCheckout.js +11 -3
- package/src/helpers/utils.js +4 -4
- package/src/helpers/validations.js +54 -0
- package/src/index.js +7 -1
- package/types/{card.ts → card.d.ts} +1 -0
- package/types/inlineCheckout.d.ts +5 -5
- package/types/liteInlineCheckout.d.ts +13 -13
- package/v1/bundle.min.js +3 -3
- package/webpack.config.js +4 -1
- /package/types/{checkout.ts → checkout.d.ts} +0 -0
- /package/types/{common.ts → common.d.ts} +0 -0
- /package/types/{customer.ts → customer.d.ts} +0 -0
- /package/types/{paymentMethod.ts → paymentMethod.d.ts} +0 -0
- /package/types/{transaction.ts → transaction.d.ts} +0 -0
package/.idea/workspace.xml
CHANGED
|
@@ -6,13 +6,16 @@
|
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
7
|
<list default="true" id="37fc62e5-7dd0-4a2e-b68c-304069cdf5bd" name="Changes" comment="">
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
|
9
10
|
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
10
11
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
11
12
|
<change beforePath="$PROJECT_DIR$/src/classes/BaseInlineCheckout.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/classes/BaseInlineCheckout.js" afterDir="false" />
|
|
12
13
|
<change beforePath="$PROJECT_DIR$/src/classes/LiteInlineCheckout.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/classes/LiteInlineCheckout.js" afterDir="false" />
|
|
13
|
-
<change beforePath="$PROJECT_DIR$/src/
|
|
14
|
-
<change beforePath="$PROJECT_DIR$/
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/src/helpers/utils.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/helpers/utils.js" afterDir="false" />
|
|
15
|
+
<change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
|
|
16
|
+
<change beforePath="$PROJECT_DIR$/types/card.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/types/card.d.ts" afterDir="false" />
|
|
15
17
|
<change beforePath="$PROJECT_DIR$/v1/bundle.min.js" beforeDir="false" afterPath="$PROJECT_DIR$/v1/bundle.min.js" afterDir="false" />
|
|
18
|
+
<change beforePath="$PROJECT_DIR$/webpack.config.js" beforeDir="false" afterPath="$PROJECT_DIR$/webpack.config.js" afterDir="false" />
|
|
16
19
|
</list>
|
|
17
20
|
<option name="SHOW_DIALOG" value="false" />
|
|
18
21
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -44,25 +47,25 @@
|
|
|
44
47
|
<option name="openDirectoriesWithSingleClick" value="true" />
|
|
45
48
|
<option name="showLibraryContents" value="true" />
|
|
46
49
|
</component>
|
|
47
|
-
<component name="PropertiesComponent"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
<component name="PropertiesComponent">{
|
|
51
|
+
"keyToString": {
|
|
52
|
+
"Node.js.index-dev.js.executor": "Run",
|
|
53
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
54
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
55
|
+
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
|
56
|
+
"git-widget-placeholder": "DEV-1273",
|
|
57
|
+
"last_opened_file_path": "/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/src/shared/constants",
|
|
58
|
+
"node.js.detected.package.eslint": "true",
|
|
59
|
+
"node.js.detected.package.tslint": "true",
|
|
60
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
61
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
62
|
+
"nodejs_package_manager_path": "npm",
|
|
63
|
+
"prettierjs.PrettierConfiguration.Package": "/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/node_modules/prettier",
|
|
64
|
+
"settings.editor.selected.configurable": "settings.javascript.prettier",
|
|
65
|
+
"ts.external.directory.path": "/Applications/WebStorm.app/Contents/plugins/javascript-impl/jsLanguageServicesImpl/external",
|
|
66
|
+
"vue.rearranger.settings.migration": "true"
|
|
64
67
|
}
|
|
65
|
-
}
|
|
68
|
+
}</component>
|
|
66
69
|
<component name="RecentsManager">
|
|
67
70
|
<key name="CopyFile.RECENT_KEYS">
|
|
68
71
|
<recent name="$PROJECT_DIR$/src/shared/constants" />
|
|
@@ -98,6 +101,7 @@
|
|
|
98
101
|
<workItem from="1723855727317" duration="20341000" />
|
|
99
102
|
<workItem from="1723952592527" duration="17418000" />
|
|
100
103
|
<workItem from="1724247675743" duration="41003000" />
|
|
104
|
+
<workItem from="1724435697518" duration="1616000" />
|
|
101
105
|
</task>
|
|
102
106
|
<servers />
|
|
103
107
|
</component>
|
package/README.md
CHANGED
|
@@ -11,9 +11,10 @@ Tonder SDK helps to integrate the services Tonder offers in your own website
|
|
|
11
11
|
3. [Configuration Options](#configuration-options)
|
|
12
12
|
4. [Styling InlineCheckout](#styling-inlinecheckout)
|
|
13
13
|
5. [Payment Data Structure](#payment-data-structure)
|
|
14
|
-
6. [
|
|
15
|
-
7. [
|
|
16
|
-
8. [
|
|
14
|
+
6. [Field Validation Functions](#field-validation-functions)
|
|
15
|
+
7. [API Reference](#api-reference)
|
|
16
|
+
8. [Examples](#examples)
|
|
17
|
+
9. [License](#license)
|
|
17
18
|
|
|
18
19
|
## Installation
|
|
19
20
|
|
|
@@ -301,6 +302,36 @@ const paymentData = {
|
|
|
301
302
|
};
|
|
302
303
|
```
|
|
303
304
|
|
|
305
|
+
## Field Validation Functions
|
|
306
|
+
|
|
307
|
+
For LiteCheckout implementations, the SDK provides validation functions to ensure the integrity of card data before submitting:
|
|
308
|
+
|
|
309
|
+
- `validateCardNumber(cardNumber)`: Validates the card number using the Luhn algorithm.
|
|
310
|
+
- `validateCardholderName(name)`: Checks if the cardholder name is valid.
|
|
311
|
+
- `validateCVV(cvv)`: Ensures the CVV is in the correct format.
|
|
312
|
+
- `validateExpirationDate(expirationDate)`: Validates the expiration date in MM/YY format.
|
|
313
|
+
- `validateExpirationMonth(month)`: Checks if the expiration month is valid.
|
|
314
|
+
- `validateExpirationYear(year)`: Validates the expiration year.
|
|
315
|
+
|
|
316
|
+
Example usage:
|
|
317
|
+
|
|
318
|
+
```javascript
|
|
319
|
+
import { validateCardNumber, validateCardholderName, validateCVV, validateExpirationDate } from 'tonder-web-sdk';
|
|
320
|
+
|
|
321
|
+
const cardNumber = '4111111111111111';
|
|
322
|
+
const cardholderName = 'John Doe';
|
|
323
|
+
const cvv = '123';
|
|
324
|
+
const expirationDate = '12/25';
|
|
325
|
+
|
|
326
|
+
if (validateCardNumber(cardNumber) &&
|
|
327
|
+
validateCardholderName(cardholderName) &&
|
|
328
|
+
validateCVV(cvv) &&
|
|
329
|
+
validateExpirationDate(expirationDate)) {
|
|
330
|
+
// Proceed with payment
|
|
331
|
+
} else {
|
|
332
|
+
// Show error message
|
|
333
|
+
}
|
|
334
|
+
```
|
|
304
335
|
## API Reference
|
|
305
336
|
|
|
306
337
|
### InlineCheckout Methods
|
package/package.json
CHANGED
|
@@ -115,7 +115,6 @@ export class BaseInlineCheckout {
|
|
|
115
115
|
async _handleCheckout({ card, payment_method, customer }) {
|
|
116
116
|
const { openpay_keys, reference, business } = this.merchantData;
|
|
117
117
|
const total = Number(this.cartTotal);
|
|
118
|
-
|
|
119
118
|
try {
|
|
120
119
|
let deviceSessionIdTonder;
|
|
121
120
|
if (
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "../data";
|
|
9
9
|
import { getSkyflowTokens } from "../helpers/skyflow";
|
|
10
10
|
import { getPaymentMethodDetails } from "../shared/catalog/paymentMethodsCatalog";
|
|
11
|
-
import { formatPublicErrorResponse } from "../helpers/utils";
|
|
11
|
+
import { formatPublicErrorResponse, getCardType } from "../helpers/utils";
|
|
12
12
|
import { MESSAGES } from "../shared/constants/messages";
|
|
13
13
|
|
|
14
14
|
export class LiteInlineCheckout extends BaseInlineCheckout {
|
|
@@ -39,11 +39,18 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
|
|
|
39
39
|
async getCustomerCards() {
|
|
40
40
|
try {
|
|
41
41
|
const { auth_token } = await this.#getCustomer();
|
|
42
|
-
|
|
42
|
+
const response = await fetchCustomerCards(
|
|
43
43
|
this.baseUrl,
|
|
44
44
|
auth_token,
|
|
45
45
|
this.merchantData.business.pk,
|
|
46
46
|
);
|
|
47
|
+
return {
|
|
48
|
+
...response,
|
|
49
|
+
cards: response.cards.map((ic) => ({
|
|
50
|
+
...ic,
|
|
51
|
+
icon: getCardType(ic.fields.card_scheme),
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
47
54
|
} catch (error) {
|
|
48
55
|
throw formatPublicErrorResponse(
|
|
49
56
|
{
|
|
@@ -174,8 +181,9 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
|
|
|
174
181
|
);
|
|
175
182
|
const { vault_id, vault_url } = this.merchantData;
|
|
176
183
|
let skyflowTokens;
|
|
184
|
+
console.log("_checkout", card, payment_method);
|
|
177
185
|
if (!payment_method || payment_method !== "" || payment_method === null) {
|
|
178
|
-
if (typeof
|
|
186
|
+
if (typeof card === "string") {
|
|
179
187
|
skyflowTokens = {
|
|
180
188
|
skyflow_id: card,
|
|
181
189
|
};
|