@tonder.io/ionic-full-sdk 0.0.17-beta → 0.0.18-beta
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonder.io/ionic-full-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18-beta",
|
|
4
4
|
"description": "Tonder ionic full SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tonder.io/ionic-lite-sdk": "^0.0.
|
|
13
|
+
"@tonder.io/ionic-lite-sdk": "^0.0.26-beta",
|
|
14
14
|
"crypto-js": "^4.1.1",
|
|
15
15
|
"skyflow-js": "^1.34.1"
|
|
16
16
|
},
|
|
@@ -64,7 +64,7 @@ export class InlineCheckout {
|
|
|
64
64
|
fetchingPayment: boolean
|
|
65
65
|
isOpenPaySandbox: boolean = true
|
|
66
66
|
metadata = {}
|
|
67
|
-
card
|
|
67
|
+
card = {}
|
|
68
68
|
currency: string = ""
|
|
69
69
|
|
|
70
70
|
constructor ({
|
|
@@ -167,8 +167,8 @@ export class InlineCheckout {
|
|
|
167
167
|
this.currency = data?.currency
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
#handleCard(data: {
|
|
171
|
-
this.card = data
|
|
170
|
+
#handleCard(data: { card: string }) {
|
|
171
|
+
this.card = data?.card
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
payment(data: any) {
|
|
@@ -179,6 +179,7 @@ export class InlineCheckout {
|
|
|
179
179
|
this.setCartItems(data.cart?.items)
|
|
180
180
|
this.#handleMetadata(data)
|
|
181
181
|
this.#handleCurrency(data)
|
|
182
|
+
this.#handleCard(data)
|
|
182
183
|
const response: ErrorResponse | StartCheckoutResponse | false | undefined = await this.#checkout()
|
|
183
184
|
if (response) {
|
|
184
185
|
const process3ds = new ThreeDSHandler({
|
|
@@ -187,6 +188,7 @@ export class InlineCheckout {
|
|
|
187
188
|
apiKey: this.apiKeyTonder,
|
|
188
189
|
successUrl: this.successUrl
|
|
189
190
|
});
|
|
191
|
+
console.log("response", response);
|
|
190
192
|
this.callBack(response);
|
|
191
193
|
if("next_action" in response) {
|
|
192
194
|
const iframe = response?.next_action?.iframe_resources?.iframe
|
|
@@ -267,7 +269,6 @@ export class InlineCheckout {
|
|
|
267
269
|
this.#unmountForm();
|
|
268
270
|
}
|
|
269
271
|
this.radioChecked = radio.id;
|
|
270
|
-
this.#handleCard({ skyflow_id: radio.id });
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
#handleCustomer(customer: Customer) {
|
|
@@ -442,23 +443,6 @@ export class InlineCheckout {
|
|
|
442
443
|
|
|
443
444
|
}
|
|
444
445
|
|
|
445
|
-
async #getCardTokens() {
|
|
446
|
-
if (this.card?.skyflow_id) return this.card
|
|
447
|
-
if(this.collectContainer && "container" in this.collectContainer && "collect" in this.collectContainer.container) {
|
|
448
|
-
try {
|
|
449
|
-
const collectResponseSkyflowTonder: any = await this.collectContainer?.container.collect();
|
|
450
|
-
const cardTokens = await collectResponseSkyflowTonder["records"][0]["fields"];
|
|
451
|
-
return cardTokens;
|
|
452
|
-
} catch (error) {
|
|
453
|
-
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
454
|
-
throw error;
|
|
455
|
-
}
|
|
456
|
-
} else {
|
|
457
|
-
showError("Ocurrió un error al conectar con skyflow", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
458
|
-
throw "Ocurrió un error al conectar con skyflow";
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
446
|
async #checkout() {
|
|
463
447
|
|
|
464
448
|
try {
|
|
@@ -480,9 +464,31 @@ export class InlineCheckout {
|
|
|
480
464
|
|
|
481
465
|
const { openpay_keys, reference, business } = this.merchantData
|
|
482
466
|
|
|
483
|
-
const total = Number(this.cartTotal)
|
|
467
|
+
const total = Number(this.cartTotal)
|
|
468
|
+
|
|
469
|
+
let cardTokensSkyflowTonder: any = null;
|
|
484
470
|
|
|
485
|
-
|
|
471
|
+
if(this.radioChecked === "new") {
|
|
472
|
+
|
|
473
|
+
if(this.collectContainer && "container" in this.collectContainer && "collect" in this.collectContainer.container) {
|
|
474
|
+
try {
|
|
475
|
+
const collectResponseSkyflowTonder: any = await this.collectContainer?.container.collect();
|
|
476
|
+
cardTokensSkyflowTonder = await collectResponseSkyflowTonder["records"][0]["fields"];
|
|
477
|
+
} catch (error) {
|
|
478
|
+
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
479
|
+
throw error;
|
|
480
|
+
}
|
|
481
|
+
} else {
|
|
482
|
+
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
} else {
|
|
486
|
+
|
|
487
|
+
cardTokensSkyflowTonder = {
|
|
488
|
+
skyflow_id: this.radioChecked
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
}
|
|
486
492
|
|
|
487
493
|
let deviceSessionIdTonder: any;
|
|
488
494
|
|
|
@@ -506,7 +512,7 @@ export class InlineCheckout {
|
|
|
506
512
|
|
|
507
513
|
if(saveCard && "checked" in saveCard && saveCard.checked) {
|
|
508
514
|
|
|
509
|
-
await this.liteCheckout.registerCustomerCard(auth_token, { skyflow_id:
|
|
515
|
+
await this.liteCheckout.registerCustomerCard(auth_token, { skyflow_id: cardTokensSkyflowTonder.skyflow_id });
|
|
510
516
|
|
|
511
517
|
this.cardsInjected = false;
|
|
512
518
|
|
|
@@ -560,8 +566,8 @@ export class InlineCheckout {
|
|
|
560
566
|
|
|
561
567
|
// Checkout router
|
|
562
568
|
const routerItems: StartCheckoutRequest = {
|
|
563
|
-
card:
|
|
564
|
-
name:
|
|
569
|
+
card: cardTokensSkyflowTonder,
|
|
570
|
+
name: cardTokensSkyflowTonder.cardholder_name,
|
|
565
571
|
last_name: "",
|
|
566
572
|
email_client: this.email,
|
|
567
573
|
phone_number: this.phone,
|
package/src/helpers/skyflow.ts
CHANGED
|
@@ -77,6 +77,16 @@ export async function initSkyflow(
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
const regexJustText = /^[A-Za-z\s]*$/;
|
|
81
|
+
|
|
82
|
+
const regexJustTextRule = {
|
|
83
|
+
type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
|
|
84
|
+
params: {
|
|
85
|
+
regex: regexJustText,
|
|
86
|
+
error: "Debe contener solo letras"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
const cardHolderNameElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
|
|
81
91
|
table: "cards",
|
|
82
92
|
column: "cardholder_name",
|
|
@@ -84,7 +94,7 @@ export async function initSkyflow(
|
|
|
84
94
|
label: "Titular de la tarjeta",
|
|
85
95
|
placeholder: "Nombre como aparece en la tarjeta",
|
|
86
96
|
type: Skyflow.ElementType.CARDHOLDER_NAME,
|
|
87
|
-
validations: [regexMatchRule, lengthMatchRule],
|
|
97
|
+
validations: [regexMatchRule, lengthMatchRule, regexJustTextRule],
|
|
88
98
|
});
|
|
89
99
|
|
|
90
100
|
// Create collect elements.
|