@tonder.io/ionic-full-sdk 0.0.4 → 0.0.6
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 +338 -88
- package/dist/classes/inlineCheckout.d.ts +1 -4
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/classes/3dsHandler.ts +1 -3
- package/src/classes/inlineCheckout.ts +50 -45
- package/src/helpers/template.ts +4 -0
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.6",
|
|
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.12",
|
|
14
14
|
"crypto-js": "^4.1.1",
|
|
15
15
|
"skyflow-js": "^1.34.1"
|
|
16
16
|
},
|
|
@@ -42,9 +42,7 @@ export class ThreeDSHandler {
|
|
|
42
42
|
redirectTo3DS() {
|
|
43
43
|
const url = this.payload?.next_action?.redirect_to_url?.url
|
|
44
44
|
if (url) {
|
|
45
|
-
this.saveVerifyTransactionUrl()
|
|
46
|
-
window.open('@tonder/ionic-full-sdk://', '_system')
|
|
47
|
-
// window.open(url, '_blank');
|
|
45
|
+
this.saveVerifyTransactionUrl();
|
|
48
46
|
return true
|
|
49
47
|
} else {
|
|
50
48
|
console.log('No redirection found');
|
|
@@ -19,11 +19,8 @@ export type InlineCheckoutConstructor = {
|
|
|
19
19
|
renderPaymentButton: boolean,
|
|
20
20
|
callBack?: (params: any) => void,
|
|
21
21
|
styles?: any,
|
|
22
|
-
form?: any,
|
|
23
|
-
totalElement?: any,
|
|
24
22
|
containerId?: string,
|
|
25
|
-
collectorIds?: CollectorIds
|
|
26
|
-
platforms?: string[]
|
|
23
|
+
collectorIds?: CollectorIds
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export class InlineCheckout {
|
|
@@ -71,8 +68,7 @@ export class InlineCheckout {
|
|
|
71
68
|
callBack = () => {},
|
|
72
69
|
styles,
|
|
73
70
|
containerId,
|
|
74
|
-
collectorIds
|
|
75
|
-
platforms
|
|
71
|
+
collectorIds
|
|
76
72
|
}: InlineCheckoutConstructor) {
|
|
77
73
|
this.apiKeyTonder = apiKey;
|
|
78
74
|
this.returnUrl = returnUrl;
|
|
@@ -80,7 +76,6 @@ export class InlineCheckout {
|
|
|
80
76
|
this.renderPaymentButton = renderPaymentButton;
|
|
81
77
|
this.callBack = callBack;
|
|
82
78
|
this.customStyles = styles
|
|
83
|
-
this.platforms = platforms
|
|
84
79
|
|
|
85
80
|
this.abortController = new AbortController()
|
|
86
81
|
|
|
@@ -154,7 +149,12 @@ export class InlineCheckout {
|
|
|
154
149
|
this.setCartItems(data.cart?.items)
|
|
155
150
|
const response: ErrorResponse | StartCheckoutResponse | false | undefined = await this.#checkout()
|
|
156
151
|
if (response) {
|
|
157
|
-
const process3ds = new ThreeDSHandler({
|
|
152
|
+
const process3ds = new ThreeDSHandler({
|
|
153
|
+
payload: response,
|
|
154
|
+
baseUrl: this.baseUrl,
|
|
155
|
+
apiKey: this.apiKeyTonder,
|
|
156
|
+
successUrl: this.successUrl
|
|
157
|
+
});
|
|
158
158
|
this.callBack(response);
|
|
159
159
|
if (!process3ds.redirectTo3DS()) {
|
|
160
160
|
resolve(response);
|
|
@@ -292,7 +292,7 @@ export class InlineCheckout {
|
|
|
292
292
|
|
|
293
293
|
if("cards" in cards) {
|
|
294
294
|
|
|
295
|
-
const cardsMapped: Card[] = cards.cards.
|
|
295
|
+
const cardsMapped: Card[] = cards.cards.map(card => ({ ...card.fields }))
|
|
296
296
|
|
|
297
297
|
this.loadCardsList(cardsMapped)
|
|
298
298
|
|
|
@@ -365,47 +365,51 @@ export class InlineCheckout {
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
async #checkout() {
|
|
368
|
+
|
|
368
369
|
try {
|
|
369
|
-
const selector: any = document.querySelector(`#${this.collectorIds.tonderPayButton}`);
|
|
370
|
-
if(selector){
|
|
371
|
-
selector.disabled = true;
|
|
372
|
-
}
|
|
373
|
-
} catch (error) {
|
|
374
|
-
}
|
|
375
370
|
|
|
376
|
-
|
|
371
|
+
try {
|
|
372
|
+
|
|
373
|
+
const selector: any = document.querySelector(`#${this.collectorIds.tonderPayButton}`);
|
|
374
|
+
|
|
375
|
+
if(selector){
|
|
376
|
+
selector.disabled = true;
|
|
377
|
+
selector.innerHTML = "Cargando..."
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
} catch (error) { }
|
|
381
|
+
|
|
382
|
+
if(this.merchantData) {
|
|
377
383
|
|
|
378
|
-
|
|
384
|
+
if("openpay_keys" in this.merchantData) {
|
|
379
385
|
|
|
380
|
-
|
|
386
|
+
const { openpay_keys, reference, business } = this.merchantData
|
|
381
387
|
|
|
382
|
-
|
|
388
|
+
const total = Number(this.cartTotal)
|
|
383
389
|
|
|
384
|
-
|
|
390
|
+
let cardTokensSkyflowTonder: any = null;
|
|
385
391
|
|
|
386
|
-
|
|
392
|
+
if(this.radioChecked === "new") {
|
|
387
393
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
394
|
+
if(this.collectContainer && "container" in this.collectContainer && "collect" in this.collectContainer.container) {
|
|
395
|
+
try {
|
|
396
|
+
const collectResponseSkyflowTonder: any = await this.collectContainer?.container.collect();
|
|
397
|
+
cardTokensSkyflowTonder = await collectResponseSkyflowTonder["records"][0]["fields"];
|
|
398
|
+
} catch (error) {
|
|
399
|
+
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
400
|
+
throw error;
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
393
403
|
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
394
|
-
throw error;
|
|
395
404
|
}
|
|
405
|
+
|
|
396
406
|
} else {
|
|
397
|
-
showError("Por favor, verifica todos los campos de tu tarjeta", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
} else {
|
|
401
407
|
|
|
402
|
-
|
|
403
|
-
|
|
408
|
+
cardTokensSkyflowTonder = {
|
|
409
|
+
skyflow_id: this.radioChecked
|
|
410
|
+
}
|
|
411
|
+
|
|
404
412
|
}
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
413
|
|
|
410
414
|
let deviceSessionIdTonder: any;
|
|
411
415
|
|
|
@@ -436,7 +440,7 @@ export class InlineCheckout {
|
|
|
436
440
|
|
|
437
441
|
if("cards" in cards) {
|
|
438
442
|
|
|
439
|
-
const cardsMapped: Card[] = cards.cards.
|
|
443
|
+
const cardsMapped: Card[] = cards.cards.map(card => ({ ...card.fields }))
|
|
440
444
|
|
|
441
445
|
this.loadCardsList(cardsMapped)
|
|
442
446
|
|
|
@@ -505,7 +509,6 @@ export class InlineCheckout {
|
|
|
505
509
|
const jsonResponseRouter = await this.liteCheckout.startCheckoutRouter(
|
|
506
510
|
routerItems
|
|
507
511
|
);
|
|
508
|
-
|
|
509
512
|
if (jsonResponseRouter) {
|
|
510
513
|
try {
|
|
511
514
|
const selector: any = document.querySelector(`#${this.collectorIds.tonderPayButton}`);
|
|
@@ -521,14 +524,16 @@ export class InlineCheckout {
|
|
|
521
524
|
}
|
|
522
525
|
}
|
|
523
526
|
}
|
|
524
|
-
} catch (error) {
|
|
525
|
-
console.log(error);
|
|
526
|
-
showError("Ha ocurrido un error", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
527
|
-
throw error;
|
|
528
527
|
}
|
|
529
|
-
|
|
528
|
+
} else {
|
|
529
|
+
showError("No se han configurado los datos del proveedor de servicio", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
530
530
|
}
|
|
531
|
-
|
|
531
|
+
} catch (error) {
|
|
532
|
+
console.log(error);
|
|
533
|
+
showError("Ha ocurrido un error", this.collectorIds.msgError, this.collectorIds.tonderPayButton)
|
|
534
|
+
throw error;
|
|
535
|
+
} finally {
|
|
536
|
+
this.fetchingPayment = false;
|
|
532
537
|
}
|
|
533
538
|
};
|
|
534
539
|
}
|
package/src/helpers/template.ts
CHANGED