@tonder.io/ionic-full-sdk 0.0.16-beta → 0.0.17-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
|
@@ -64,7 +64,7 @@ export class InlineCheckout {
|
|
|
64
64
|
fetchingPayment: boolean
|
|
65
65
|
isOpenPaySandbox: boolean = true
|
|
66
66
|
metadata = {}
|
|
67
|
-
card =
|
|
67
|
+
card: { skyflow_id: string } | null= null
|
|
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: { skyflow_id: string }) {
|
|
171
|
+
this.card = data
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
payment(data: any) {
|
|
@@ -179,7 +179,6 @@ export class InlineCheckout {
|
|
|
179
179
|
this.setCartItems(data.cart?.items)
|
|
180
180
|
this.#handleMetadata(data)
|
|
181
181
|
this.#handleCurrency(data)
|
|
182
|
-
this.#handleCard(data)
|
|
183
182
|
const response: ErrorResponse | StartCheckoutResponse | false | undefined = await this.#checkout()
|
|
184
183
|
if (response) {
|
|
185
184
|
const process3ds = new ThreeDSHandler({
|
|
@@ -188,7 +187,6 @@ export class InlineCheckout {
|
|
|
188
187
|
apiKey: this.apiKeyTonder,
|
|
189
188
|
successUrl: this.successUrl
|
|
190
189
|
});
|
|
191
|
-
console.log("response", response);
|
|
192
190
|
this.callBack(response);
|
|
193
191
|
if("next_action" in response) {
|
|
194
192
|
const iframe = response?.next_action?.iframe_resources?.iframe
|
|
@@ -269,6 +267,7 @@ export class InlineCheckout {
|
|
|
269
267
|
this.#unmountForm();
|
|
270
268
|
}
|
|
271
269
|
this.radioChecked = radio.id;
|
|
270
|
+
this.#handleCard({ skyflow_id: radio.id });
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
#handleCustomer(customer: Customer) {
|
|
@@ -443,6 +442,23 @@ export class InlineCheckout {
|
|
|
443
442
|
|
|
444
443
|
}
|
|
445
444
|
|
|
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
|
+
|
|
446
462
|
async #checkout() {
|
|
447
463
|
|
|
448
464
|
try {
|
|
@@ -464,31 +480,9 @@ export class InlineCheckout {
|
|
|
464
480
|
|
|
465
481
|
const { openpay_keys, reference, business } = this.merchantData
|
|
466
482
|
|
|
467
|
-
const total = Number(this.cartTotal)
|
|
468
|
-
|
|
469
|
-
let cardTokensSkyflowTonder: any = null;
|
|
483
|
+
const total = Number(this.cartTotal);
|
|
470
484
|
|
|
471
|
-
|
|
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
|
-
}
|
|
485
|
+
const cardTokens: any = await this.#getCardTokens()
|
|
492
486
|
|
|
493
487
|
let deviceSessionIdTonder: any;
|
|
494
488
|
|
|
@@ -512,7 +506,7 @@ export class InlineCheckout {
|
|
|
512
506
|
|
|
513
507
|
if(saveCard && "checked" in saveCard && saveCard.checked) {
|
|
514
508
|
|
|
515
|
-
await this.liteCheckout.registerCustomerCard(auth_token, { skyflow_id:
|
|
509
|
+
await this.liteCheckout.registerCustomerCard(auth_token, { skyflow_id: cardTokens.skyflow_id });
|
|
516
510
|
|
|
517
511
|
this.cardsInjected = false;
|
|
518
512
|
|
|
@@ -566,8 +560,8 @@ export class InlineCheckout {
|
|
|
566
560
|
|
|
567
561
|
// Checkout router
|
|
568
562
|
const routerItems: StartCheckoutRequest = {
|
|
569
|
-
card:
|
|
570
|
-
name:
|
|
563
|
+
card: cardTokens,
|
|
564
|
+
name: cardTokens.cardholder_name,
|
|
571
565
|
last_name: "",
|
|
572
566
|
email_client: this.email,
|
|
573
567
|
phone_number: this.phone,
|