tonder-web-sdk 1.11.0-beta.2 → 1.11.1
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/aws.xml +17 -0
- package/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +62 -0
- package/package.json +1 -1
- package/src/classes/3dsHandler.js +0 -12
- package/src/classes/globalLoader.js +29 -0
- package/src/classes/inlineCheckout.js +31 -46
- package/src/helpers/template.js +23 -13
- package/src/helpers/utils.js +5 -2
- package/src/index-dev.js +2 -3
- package/v1/bundle.min.js +1 -1
package/.idea/aws.xml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="accountSettings">
|
|
4
|
+
<option name="activeProfile" value="profile:default" />
|
|
5
|
+
<option name="activeRegion" value="us-east-1" />
|
|
6
|
+
<option name="recentlyUsedProfiles">
|
|
7
|
+
<list>
|
|
8
|
+
<option value="profile:default" />
|
|
9
|
+
</list>
|
|
10
|
+
</option>
|
|
11
|
+
<option name="recentlyUsedRegions">
|
|
12
|
+
<list>
|
|
13
|
+
<option value="us-east-1" />
|
|
14
|
+
</list>
|
|
15
|
+
</option>
|
|
16
|
+
</component>
|
|
17
|
+
</project>
|
package/.idea/misc.xml
ADDED
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="37fc62e5-7dd0-4a2e-b68c-304069cdf5bd" name="Changes" comment="">
|
|
5
|
+
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
6
|
+
<change beforePath="$PROJECT_DIR$/src/classes/inlineCheckout.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/classes/inlineCheckout.js" afterDir="false" />
|
|
7
|
+
</list>
|
|
8
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
9
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
10
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
11
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
12
|
+
</component>
|
|
13
|
+
<component name="Git.Settings">
|
|
14
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
15
|
+
</component>
|
|
16
|
+
<component name="MarkdownSettingsMigration">
|
|
17
|
+
<option name="stateVersion" value="1" />
|
|
18
|
+
</component>
|
|
19
|
+
<component name="ProjectColorInfo"><![CDATA[{
|
|
20
|
+
"customColor": "",
|
|
21
|
+
"associatedIndex": 2
|
|
22
|
+
}]]></component>
|
|
23
|
+
<component name="ProjectId" id="2iy5RvaLleBBnn8yOfQNLpzKK66" />
|
|
24
|
+
<component name="ProjectViewState">
|
|
25
|
+
<option name="autoscrollFromSource" value="true" />
|
|
26
|
+
<option name="autoscrollToSource" value="true" />
|
|
27
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
28
|
+
<option name="openDirectoriesWithSingleClick" value="true" />
|
|
29
|
+
<option name="showLibraryContents" value="true" />
|
|
30
|
+
</component>
|
|
31
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
32
|
+
"keyToString": {
|
|
33
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
34
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
35
|
+
"git-widget-placeholder": "Merging TNDR-1140",
|
|
36
|
+
"nodejs_package_manager_path": "npm",
|
|
37
|
+
"vue.rearranger.settings.migration": "true"
|
|
38
|
+
}
|
|
39
|
+
}]]></component>
|
|
40
|
+
<component name="SharedIndexes">
|
|
41
|
+
<attachedChunks>
|
|
42
|
+
<set>
|
|
43
|
+
<option value="bundled-python-sdk-50da183f06c8-2887949eec09-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-233.13135.95" />
|
|
44
|
+
</set>
|
|
45
|
+
</attachedChunks>
|
|
46
|
+
</component>
|
|
47
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
48
|
+
<component name="TaskManager">
|
|
49
|
+
<task active="true" id="Default" summary="Default task">
|
|
50
|
+
<changelist id="37fc62e5-7dd0-4a2e-b68c-304069cdf5bd" name="Changes" comment="" />
|
|
51
|
+
<created>1720449973301</created>
|
|
52
|
+
<option name="number" value="Default" />
|
|
53
|
+
<option name="presentableId" value="Default" />
|
|
54
|
+
<updated>1720449973301</updated>
|
|
55
|
+
<workItem from="1720449976262" duration="22000" />
|
|
56
|
+
</task>
|
|
57
|
+
<servers />
|
|
58
|
+
</component>
|
|
59
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
60
|
+
<option name="version" value="3" />
|
|
61
|
+
</component>
|
|
62
|
+
</project>
|
package/package.json
CHANGED
|
@@ -39,18 +39,6 @@ export class ThreeDSHandler {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
saveCheckoutId(checkoutId) {
|
|
43
|
-
localStorage.setItem('checkout_id', JSON.stringify(checkoutId))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
removeCheckoutId() {
|
|
47
|
-
localStorage.removeItem("checkout_id")
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getCurrentCheckoutId() {
|
|
51
|
-
return JSON.parse(localStorage.getItem("checkout_id"));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
42
|
getUrlWithExpiration() {
|
|
55
43
|
const item = JSON.parse(localStorage.getItem("verify_transaction_status"))
|
|
56
44
|
if (!item) return
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cardTemplateSkeleton } from '../helpers/template-skeleton.js'
|
|
2
|
+
|
|
3
|
+
class GlobalLoader {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.requestCount = 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
show() {
|
|
9
|
+
this.requestCount++;
|
|
10
|
+
const checkoutContainer = document.querySelector("#global-loader");
|
|
11
|
+
if (checkoutContainer) {
|
|
12
|
+
checkoutContainer.innerHTML = cardTemplateSkeleton;
|
|
13
|
+
checkoutContainer.style.display = 'block';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
remove() {
|
|
18
|
+
this.requestCount--;
|
|
19
|
+
if (this.requestCount <= 0) {
|
|
20
|
+
this.requestCount = 0;
|
|
21
|
+
const loader = document.querySelector('#global-loader');
|
|
22
|
+
if (loader) {
|
|
23
|
+
loader.style.display = 'none';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const globalLoader = new GlobalLoader();
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '../helpers/utils';
|
|
22
22
|
import { initSkyflow } from '../helpers/skyflow'
|
|
23
23
|
import { ThreeDSHandler } from './3dsHandler.js';
|
|
24
|
+
import { globalLoader } from './globalLoader.js';
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
export class InlineCheckout {
|
|
@@ -152,7 +153,6 @@ export class InlineCheckout {
|
|
|
152
153
|
this.#handleCard(data)
|
|
153
154
|
const response = await this.#checkout()
|
|
154
155
|
this.process3ds.setPayload(response)
|
|
155
|
-
this.process3ds.saveCheckoutId(response.checkout_id)
|
|
156
156
|
this.callBack(response);
|
|
157
157
|
const payload = await this.handle3dsRedirect(response)
|
|
158
158
|
if (payload) {
|
|
@@ -248,38 +248,29 @@ export class InlineCheckout {
|
|
|
248
248
|
|
|
249
249
|
async resumeCheckout(response) {
|
|
250
250
|
if (["Failed", "Declined", "Cancelled"].includes(response?.status)) {
|
|
251
|
+
globalLoader.show()
|
|
251
252
|
const routerItems = {
|
|
252
|
-
|
|
253
|
-
checkout_id: this.process3ds.getCurrentCheckoutId(),
|
|
253
|
+
checkout_id: response.checkout?.id,
|
|
254
254
|
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
try {
|
|
256
|
+
const routerResponse = await startCheckoutRouter(
|
|
257
|
+
this.baseUrl,
|
|
258
|
+
this.apiKeyTonder,
|
|
259
|
+
routerItems
|
|
260
|
+
);
|
|
261
|
+
return routerResponse
|
|
262
|
+
} catch (error) {
|
|
263
|
+
throw error
|
|
264
|
+
} finally {
|
|
265
|
+
globalLoader.remove()
|
|
266
|
+
}
|
|
261
267
|
}
|
|
262
268
|
return response
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
#addGlobalLoader() {
|
|
266
|
-
let checkoutContainer = document.querySelector("#global-loader");
|
|
267
|
-
if (checkoutContainer) {
|
|
268
|
-
checkoutContainer.innerHTML = cardTemplateSkeleton;
|
|
269
|
-
checkoutContainer.style.display = 'block';
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
#removeGlobalLoader() {
|
|
274
|
-
const loader = document.querySelector('#global-loader');
|
|
275
|
-
if (loader) {
|
|
276
|
-
loader.style.display = 'none';
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
271
|
#mount(containerTonderCheckout) {
|
|
281
272
|
containerTonderCheckout.innerHTML = cardTemplate({renderPaymentButton: this.renderPaymentButton, customStyles: this.customStyles});
|
|
282
|
-
|
|
273
|
+
globalLoader.show()
|
|
283
274
|
this.#mountTonder();
|
|
284
275
|
InlineCheckout.injected = true;
|
|
285
276
|
}
|
|
@@ -308,7 +299,8 @@ export class InlineCheckout {
|
|
|
308
299
|
console.warn("Error getting APMS")
|
|
309
300
|
}
|
|
310
301
|
}
|
|
311
|
-
|
|
302
|
+
|
|
303
|
+
async #mountTonder(getCards = false) {
|
|
312
304
|
this.#mountPayButton()
|
|
313
305
|
try {
|
|
314
306
|
const {
|
|
@@ -319,23 +311,16 @@ export class InlineCheckout {
|
|
|
319
311
|
const customerResponse = await this.getCustomer({ email: this.email });
|
|
320
312
|
if ("auth_token" in customerResponse) {
|
|
321
313
|
const { auth_token } = customerResponse
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
saveCardCheckbox.style.display = 'none';
|
|
325
|
-
if (this.mode !== 'production') {
|
|
326
|
-
const cards = await getCustomerCards(this.baseUrl, auth_token);
|
|
327
|
-
saveCardCheckbox.style.display = '';
|
|
314
|
+
const cards = await getCustomerCards(this.baseUrl, auth_token);
|
|
328
315
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
316
|
+
if ("cards" in cards) {
|
|
317
|
+
const cardsMapped = cards.cards.map(mapCards)
|
|
318
|
+
this.#loadCardsList(cardsMapped, auth_token)
|
|
333
319
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
320
|
}
|
|
337
321
|
}
|
|
338
|
-
|
|
322
|
+
|
|
323
|
+
await this.#mountAPMs();
|
|
339
324
|
|
|
340
325
|
this.collectContainer = await initSkyflow(
|
|
341
326
|
vault_id,
|
|
@@ -347,11 +332,11 @@ export class InlineCheckout {
|
|
|
347
332
|
this.collectorIds
|
|
348
333
|
);
|
|
349
334
|
setTimeout(() => {
|
|
350
|
-
|
|
335
|
+
globalLoader.remove()
|
|
351
336
|
}, 800)
|
|
352
337
|
} catch (e) {
|
|
353
338
|
if (e && e.name !== 'AbortError') {
|
|
354
|
-
|
|
339
|
+
globalLoader.remove()
|
|
355
340
|
showError("No se pudieron cargar los datos del comercio.")
|
|
356
341
|
}
|
|
357
342
|
}
|
|
@@ -464,7 +449,7 @@ export class InlineCheckout {
|
|
|
464
449
|
);
|
|
465
450
|
|
|
466
451
|
const selected_apm = this.apmsData ? this.apmsData.find((iapm) => iapm.pk === this.radioChecked):{};
|
|
467
|
-
|
|
452
|
+
|
|
468
453
|
// Checkout router
|
|
469
454
|
const routerItems = {
|
|
470
455
|
name: this.firstName || "",
|
|
@@ -488,7 +473,7 @@ export class InlineCheckout {
|
|
|
488
473
|
metadata: this.metadata,
|
|
489
474
|
browser_info: getBrowserInfo(),
|
|
490
475
|
currency: this.currency,
|
|
491
|
-
...(
|
|
476
|
+
...( selected_apm && Object.keys(selected_apm).length > 0
|
|
492
477
|
? {payment_method: selected_apm.payment_method}
|
|
493
478
|
: {card: cardTokens}
|
|
494
479
|
)
|
|
@@ -537,7 +522,7 @@ export class InlineCheckout {
|
|
|
537
522
|
.filter((apm) =>
|
|
538
523
|
clearSpace(apm.category.toLowerCase()) !== 'cards' && apm.status.toLowerCase() === 'active')
|
|
539
524
|
.sort((a, b) => a.priority - b.priority);
|
|
540
|
-
|
|
525
|
+
|
|
541
526
|
queryElement.innerHTML = apmItemsTemplate(filteredAndSortedApms);
|
|
542
527
|
clearInterval(injectInterval);
|
|
543
528
|
this.#mountRadioButtons();
|
|
@@ -545,7 +530,7 @@ export class InlineCheckout {
|
|
|
545
530
|
}
|
|
546
531
|
}, 500);
|
|
547
532
|
}
|
|
548
|
-
|
|
533
|
+
|
|
549
534
|
#mountRadioButtons(token = '') {
|
|
550
535
|
const radioButtons = document.getElementsByName(`card_selected`);
|
|
551
536
|
for (const radio of radioButtons) {
|
|
@@ -571,7 +556,7 @@ export class InlineCheckout {
|
|
|
571
556
|
}
|
|
572
557
|
if (radio.id === "new") {
|
|
573
558
|
if (this.radioChecked !== radio.id) {
|
|
574
|
-
|
|
559
|
+
globalLoader.show()
|
|
575
560
|
this.#mountTonder(false);
|
|
576
561
|
InlineCheckout.injected = true;
|
|
577
562
|
}
|
package/src/helpers/template.js
CHANGED
|
@@ -19,12 +19,6 @@ export const cardTemplate = (data) => `
|
|
|
19
19
|
<div id="collectExpirationYear" class="expiration-year"></div>
|
|
20
20
|
<div id="collectCvv" class="empty-div"></div>
|
|
21
21
|
</div>
|
|
22
|
-
<div class="checkbox" id="save-card-container">
|
|
23
|
-
<input id="save-checkout-card" type="checkbox">
|
|
24
|
-
<label for="save-checkout-card">
|
|
25
|
-
Guardar tarjeta para pagos futuros
|
|
26
|
-
</label>
|
|
27
|
-
</div>
|
|
28
22
|
<div id="msgError"></div>
|
|
29
23
|
<div id="msgNotification"></div>
|
|
30
24
|
</div>
|
|
@@ -184,7 +178,6 @@ export const cardTemplate = (data) => `
|
|
|
184
178
|
.apms-list-container {
|
|
185
179
|
display: flex;
|
|
186
180
|
flex-direction: column;
|
|
187
|
-
padding: ;
|
|
188
181
|
gap: 33% 20px;
|
|
189
182
|
max-height: 300px;
|
|
190
183
|
overflow-y: auto;
|
|
@@ -487,14 +480,18 @@ export const cardItemsTemplate = (cards) => {
|
|
|
487
480
|
}
|
|
488
481
|
|
|
489
482
|
export const apmItemsTemplate = (apms) => {
|
|
490
|
-
|
|
483
|
+
|
|
491
484
|
const apmItemsHTML = apms.reduce((total, apm) => {
|
|
492
485
|
const apm_data = getAPMType(apm.payment_method);
|
|
493
486
|
return `${total}
|
|
494
487
|
<div class="apm-item" id="card_container-${apm.pk}">
|
|
495
488
|
<input id="${apm.pk}" class="card_selected" name="card_selected" type="radio"/>
|
|
496
489
|
<label class="apm-item-label" for="${apm.pk}">
|
|
497
|
-
|
|
490
|
+
|
|
491
|
+
<div class="apm-image">
|
|
492
|
+
<div class="apm-image-border"></div>
|
|
493
|
+
<img src="${apm_data.icon}" />
|
|
494
|
+
</div>
|
|
498
495
|
<div class="apm-name">${apm_data.label}</div>
|
|
499
496
|
</label>
|
|
500
497
|
</div>`
|
|
@@ -530,13 +527,26 @@ export const apmItemsTemplate = (apms) => {
|
|
|
530
527
|
.apm-item .apm-name {
|
|
531
528
|
font-size: 16px;
|
|
532
529
|
}
|
|
533
|
-
|
|
534
530
|
.apm-image {
|
|
531
|
+
width: 30px;
|
|
532
|
+
height: 30px;
|
|
533
|
+
position: relative;
|
|
534
|
+
display: flex;
|
|
535
|
+
justify-content: center;
|
|
536
|
+
align-items: center;
|
|
537
|
+
}
|
|
538
|
+
.apm-image img {
|
|
535
539
|
width: auto;
|
|
536
540
|
height: 30px;
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
541
|
+
}
|
|
542
|
+
.apm-image-border{
|
|
543
|
+
position: absolute;
|
|
544
|
+
border: 1px solid #bababa36;
|
|
545
|
+
border-radius: 4px;
|
|
546
|
+
pointer-events: none;
|
|
547
|
+
box-sizing: border-box;
|
|
548
|
+
width: 100%;
|
|
549
|
+
height: 97%;
|
|
540
550
|
}
|
|
541
551
|
|
|
542
552
|
.card_selected {
|
package/src/helpers/utils.js
CHANGED
|
@@ -340,8 +340,11 @@ export const getAPMType = (scheme_data) => {
|
|
|
340
340
|
},
|
|
341
341
|
};
|
|
342
342
|
|
|
343
|
-
const
|
|
344
|
-
|
|
343
|
+
const _default = {
|
|
344
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
345
|
+
label: ""
|
|
346
|
+
};
|
|
347
|
+
return PAYMENT_METHODS_CATALOG[scheme] || _default;
|
|
345
348
|
}
|
|
346
349
|
|
|
347
350
|
|
package/src/index-dev.js
CHANGED
|
@@ -104,12 +104,11 @@ const successUrl = "http://127.0.0.1:8080/success"
|
|
|
104
104
|
// const apiKey = "8365683bdc33dd6d50fe2397188d79f1a6765852";
|
|
105
105
|
|
|
106
106
|
const inlineCheckout = new InlineCheckout({
|
|
107
|
-
mode: '
|
|
107
|
+
mode: 'stage',
|
|
108
108
|
apiKey,
|
|
109
109
|
returnUrl,
|
|
110
110
|
successUrl,
|
|
111
|
-
styles: customStyles
|
|
112
|
-
renderPaymentButton: true
|
|
111
|
+
styles: customStyles
|
|
113
112
|
});
|
|
114
113
|
inlineCheckout.configureCheckout({customer: checkoutData.customer})
|
|
115
114
|
inlineCheckout.injectCheckout();
|