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.
@@ -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/classes/inlineCheckout.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/classes/inlineCheckout.js" afterDir="false" />
14
- <change beforePath="$PROJECT_DIR$/types/inlineCheckout.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/types/inlineCheckout.d.ts" afterDir="false" />
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"><![CDATA[{
48
- "keyToString": {
49
- "Node.js.index-dev.js.executor": "Run",
50
- "RunOnceActivity.OpenProjectViewOnStart": "true",
51
- "RunOnceActivity.ShowReadmeOnStart": "true",
52
- "SHARE_PROJECT_CONFIGURATION_FILES": "true",
53
- "git-widget-placeholder": "DEV-1273",
54
- "last_opened_file_path": "/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/src/shared/constants",
55
- "node.js.detected.package.eslint": "true",
56
- "node.js.detected.package.tslint": "true",
57
- "node.js.selected.package.eslint": "(autodetect)",
58
- "node.js.selected.package.tslint": "(autodetect)",
59
- "nodejs_package_manager_path": "npm",
60
- "prettierjs.PrettierConfiguration.Package": "/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/node_modules/prettier",
61
- "settings.editor.selected.configurable": "settings.javascript.prettier",
62
- "ts.external.directory.path": "/Applications/WebStorm.app/Contents/plugins/javascript-impl/jsLanguageServicesImpl/external",
63
- "vue.rearranger.settings.migration": "true"
50
+ <component name="PropertiesComponent">{
51
+ &quot;keyToString&quot;: {
52
+ &quot;Node.js.index-dev.js.executor&quot;: &quot;Run&quot;,
53
+ &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
54
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
55
+ &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
56
+ &quot;git-widget-placeholder&quot;: &quot;DEV-1273&quot;,
57
+ &quot;last_opened_file_path&quot;: &quot;/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/src/shared/constants&quot;,
58
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
59
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
60
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
61
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
62
+ &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
63
+ &quot;prettierjs.PrettierConfiguration.Package&quot;: &quot;/Users/davidhernandezalmagro/Desktop/Tonder/tonder-sdk/node_modules/prettier&quot;,
64
+ &quot;settings.editor.selected.configurable&quot;: &quot;settings.javascript.prettier&quot;,
65
+ &quot;ts.external.directory.path&quot;: &quot;/Applications/WebStorm.app/Contents/plugins/javascript-impl/jsLanguageServicesImpl/external&quot;,
66
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
64
67
  }
65
- }]]></component>
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. [API Reference](#api-reference)
15
- 7. [Examples](#examples)
16
- 8. [License](#license)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tonder-web-sdk",
3
- "version": "1.12.0-beta.12",
3
+ "version": "1.12.0-beta.14",
4
4
  "description": "tonder sdk for integrations",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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
- return await fetchCustomerCards(
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 payment_method === "string") {
186
+ if (typeof card === "string") {
179
187
  skyflowTokens = {
180
188
  skyflow_id: card,
181
189
  };