tonder-web-sdk 1.7.0 → 1.8.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/package.json +1 -1
- package/src/classes/inlineCheckout.js +143 -8
- package/src/data/api.js +63 -0
- package/src/helpers/skyflow.js +81 -8
- package/src/helpers/template.js +350 -7
- package/src/helpers/utils.js +71 -0
- package/src/index-dev.js +5 -5
package/src/helpers/template.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
|
+
import { getCardType } from "./utils";
|
|
2
|
+
|
|
1
3
|
export const cardTemplate = `
|
|
2
4
|
<div class="container-tonder">
|
|
5
|
+
<div id="cardsListContainer" class="cards-list-container"></div>
|
|
6
|
+
<div class="pay-new-card">
|
|
7
|
+
<input checked id="new" class="card_selected" name="card_selected" type="radio"/>
|
|
8
|
+
<label class="card-item-label-new" for="new">
|
|
9
|
+
<img class="card-image" src="${getCardType("XXXX")}" />
|
|
10
|
+
<div class="card-number">Pagar con tarjeta</div>
|
|
11
|
+
</label>
|
|
12
|
+
</div>
|
|
3
13
|
<div id="global-loader" class="global-loader"></div>
|
|
4
|
-
<div
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<div
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
<div class="container-form">
|
|
15
|
+
<div id="collectCardholderName" class="empty-div"></div>
|
|
16
|
+
<div id="collectCardNumber" class="empty-div"></div>
|
|
17
|
+
<div class="collect-row">
|
|
18
|
+
<div id="collectExpirationMonth" class="empty-div"></div>
|
|
19
|
+
<div id="collectExpirationYear" class="expiration-year"></div>
|
|
20
|
+
<div id="collectCvv" class="empty-div"></div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="checkbox">
|
|
23
|
+
<input id="save-checkout-card" type="checkbox">
|
|
24
|
+
<label for="save-checkout-card">
|
|
25
|
+
Guardar tarjeta para futuros pagos
|
|
26
|
+
</label>
|
|
27
|
+
</div>
|
|
28
|
+
<div id="msgError"></div>
|
|
29
|
+
<div id="msgNotification"></div>
|
|
10
30
|
</div>
|
|
11
|
-
<div id="msgError"></div>
|
|
12
31
|
<button id="tonderPayButton" class="pay-button">Pagar</button>
|
|
13
32
|
</div>
|
|
14
33
|
|
|
@@ -36,10 +55,12 @@ export const cardTemplate = `
|
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
.expiration-year {
|
|
58
|
+
position: relative !important;
|
|
39
59
|
padding-top: 25px !important;
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
.empty-div {
|
|
63
|
+
position: relative;
|
|
43
64
|
height: 80px !important;
|
|
44
65
|
margin-top: 2px;
|
|
45
66
|
margin-bottom: 4px;
|
|
@@ -57,6 +78,16 @@ export const cardTemplate = `
|
|
|
57
78
|
text-align: left !important;
|
|
58
79
|
}
|
|
59
80
|
|
|
81
|
+
.message-container{
|
|
82
|
+
color: #3bc635 !important;
|
|
83
|
+
background-color: #DAFCE4 !important;
|
|
84
|
+
margin-bottom: 13px !important;
|
|
85
|
+
font-size: 80% !important;
|
|
86
|
+
padding: 8px 10px !important;
|
|
87
|
+
border-radius: 10px !important;
|
|
88
|
+
text-align: left !important;
|
|
89
|
+
}
|
|
90
|
+
|
|
60
91
|
.pay-button {
|
|
61
92
|
font-size: 16px;
|
|
62
93
|
font-weight: bold;
|
|
@@ -117,5 +148,317 @@ export const cardTemplate = `
|
|
|
117
148
|
}
|
|
118
149
|
}
|
|
119
150
|
|
|
151
|
+
.checkbox label {
|
|
152
|
+
margin-left: 10px;
|
|
153
|
+
font-size: '12px';
|
|
154
|
+
font-weight: '500';
|
|
155
|
+
color: #1D1D1D;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.checkbox {
|
|
159
|
+
margin-top: 10px;
|
|
160
|
+
margin-bottom: 20px;
|
|
161
|
+
text-align: left;
|
|
162
|
+
padding: 0 10px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.cards-list-container {
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
padding: 0px 10px 0px 10px;
|
|
169
|
+
gap: 33% 20px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.pay-new-card {
|
|
173
|
+
display: flex;
|
|
174
|
+
justify-content: start;
|
|
175
|
+
align-items: center;
|
|
176
|
+
color: #1D1D1D;
|
|
177
|
+
gap: 33% 20px;
|
|
178
|
+
margin-top: 10px;
|
|
179
|
+
margin-bottom: 10px;
|
|
180
|
+
padding-left: 10px;
|
|
181
|
+
padding-right: 10px;
|
|
182
|
+
width: 90%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.pay-new-card .card-number {
|
|
186
|
+
font-size: 16px;
|
|
187
|
+
}
|
|
188
|
+
.card-image {
|
|
189
|
+
width: 39px;
|
|
190
|
+
height: 24px;
|
|
191
|
+
text-align: left;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.card-item-label-new {
|
|
195
|
+
display: flex;
|
|
196
|
+
justify-content: start;
|
|
197
|
+
align-items: center;
|
|
198
|
+
color: #1D1D1D;
|
|
199
|
+
gap: 33% 20px;
|
|
200
|
+
margin-top: 10px;
|
|
201
|
+
margin-bottom: 10px;
|
|
202
|
+
padding-left: 10px;
|
|
203
|
+
padding-right: 10px;
|
|
204
|
+
width: 90%;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.card_selected {
|
|
208
|
+
position: relative;
|
|
209
|
+
width: 16px;
|
|
210
|
+
height: 16px;
|
|
211
|
+
appearance: none;
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
border-radius: 100%;
|
|
214
|
+
border: 1px #3bc635 solid;
|
|
215
|
+
color: #3bc635;
|
|
216
|
+
transition-property: all;
|
|
217
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
218
|
+
transition-duration: 150ms;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.card_selected:before {
|
|
222
|
+
width: 8px;
|
|
223
|
+
height: 8px;
|
|
224
|
+
content: "";
|
|
225
|
+
position: absolute;
|
|
226
|
+
top: 50%;
|
|
227
|
+
left: 50%;
|
|
228
|
+
display: block;
|
|
229
|
+
transform: translate(-50%, -50%);
|
|
230
|
+
border-radius: 100%;
|
|
231
|
+
background-color: #3bc635;
|
|
232
|
+
opacity: 0;
|
|
233
|
+
transition-property: opacity;
|
|
234
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
235
|
+
transition-duration: 150ms;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.card_selected:checked {
|
|
239
|
+
border: 1px #3bc635 solid;
|
|
240
|
+
position: relative;
|
|
241
|
+
width: 16px;
|
|
242
|
+
height: 16px;
|
|
243
|
+
appearance: none;
|
|
244
|
+
cursor: pointer;
|
|
245
|
+
border-radius: 100%;
|
|
246
|
+
color: #3bc635;
|
|
247
|
+
transition-property: all;
|
|
248
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
249
|
+
transition-duration: 150ms;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.card_selected:checked:before {
|
|
253
|
+
content: "";
|
|
254
|
+
border: 1px #3bc635 solid;
|
|
255
|
+
width: 8px;
|
|
256
|
+
height: 8px;
|
|
257
|
+
position: absolute;
|
|
258
|
+
top: 50%;
|
|
259
|
+
left: 50%;
|
|
260
|
+
display: block;
|
|
261
|
+
transform: translate(-50%, -50%);
|
|
262
|
+
border-radius: 100%;
|
|
263
|
+
background-color: #3bc635;
|
|
264
|
+
opacity: 50;
|
|
265
|
+
transition-property: opacity;
|
|
266
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
267
|
+
transition-duration: 150ms;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.card_selected:hover:before {
|
|
271
|
+
width: 8px;
|
|
272
|
+
height: 8px;
|
|
273
|
+
content: "";
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: 50%;
|
|
276
|
+
left: 50%;
|
|
277
|
+
display: block;
|
|
278
|
+
transform: translate(-50%, -50%);
|
|
279
|
+
border-radius: 100%;
|
|
280
|
+
background-color: #3bc635;
|
|
281
|
+
transition-property: opacity;
|
|
282
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
283
|
+
transition-duration: 150ms;
|
|
284
|
+
opacity: 10;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.error-custom-inputs-tonder {
|
|
288
|
+
background-color: white;
|
|
289
|
+
position: absolute;
|
|
290
|
+
left: 0px;
|
|
291
|
+
bottom: -4px;
|
|
292
|
+
width: 100%;
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
color: red;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.expiration-year .error-custom-inputs-tonder {
|
|
298
|
+
background-color: white;
|
|
299
|
+
position: absolute;
|
|
300
|
+
left: 0px;
|
|
301
|
+
bottom: 3px;
|
|
302
|
+
width: 100%;
|
|
303
|
+
font-size: 12px;
|
|
304
|
+
color: red;
|
|
305
|
+
}
|
|
120
306
|
</style>
|
|
121
307
|
`
|
|
308
|
+
|
|
309
|
+
export const cardItemsTemplate = (cards) => {
|
|
310
|
+
|
|
311
|
+
const cardItemsHTML = cards.reduce((total, card) => {
|
|
312
|
+
return `${total}
|
|
313
|
+
<div class="card-item" id="card_container-${card.skyflow_id}">
|
|
314
|
+
<input id="${card.skyflow_id}" class="card_selected" name="card_selected" type="radio"/>
|
|
315
|
+
<label class="card-item-label" for="${card.skyflow_id}">
|
|
316
|
+
<img class="card-image" src="${getCardType(card.card_scheme)}" />
|
|
317
|
+
<div class="card-number">${card.card_number}</div>
|
|
318
|
+
<div class="card-expiration">Exp. ${card.expiration_month}/${card.expiration_year}</div>
|
|
319
|
+
<div class="card-delete-icon">
|
|
320
|
+
<button id="delete_button_${card.skyflow_id}" class="card-delete-button">
|
|
321
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">
|
|
322
|
+
<path fill="currentColor" d="M292.309-140.001q-30.308 0-51.308-21t-21-51.308V-720h-40v-59.999H360v-35.384h240v35.384h179.999V-720h-40v507.691q0 30.308-21 51.308t-51.308 21H292.309ZM376.155-280h59.999v-360h-59.999v360Zm147.691 0h59.999v-360h-59.999v360Z"/>
|
|
323
|
+
</svg>
|
|
324
|
+
</button>
|
|
325
|
+
</div>
|
|
326
|
+
</label>
|
|
327
|
+
</div>`
|
|
328
|
+
}, ``);
|
|
329
|
+
|
|
330
|
+
const cardItemStyle = `
|
|
331
|
+
<style>
|
|
332
|
+
.card-item-label {
|
|
333
|
+
display: flex;
|
|
334
|
+
justify-content: space-between;
|
|
335
|
+
align-items: center;
|
|
336
|
+
color: #1D1D1D;
|
|
337
|
+
gap: 33% 20px;
|
|
338
|
+
margin-top: 10px;
|
|
339
|
+
margin-bottom: 10px;
|
|
340
|
+
padding-left: 10px;
|
|
341
|
+
padding-right: 10px;
|
|
342
|
+
width: 90%;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.card-item {
|
|
346
|
+
display: flex;
|
|
347
|
+
justify-content: start;
|
|
348
|
+
align-items: center;
|
|
349
|
+
gap: 33% 20px;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.card-item .card-number {
|
|
353
|
+
font-size: 16px;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.card-item .card-expiration {
|
|
357
|
+
font-size: 16px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.card-image {
|
|
361
|
+
width: 39px;
|
|
362
|
+
height: 24px;
|
|
363
|
+
text-align: left;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.card-delete-button {
|
|
367
|
+
background-color: transparent !important;
|
|
368
|
+
color: #000000 !important;
|
|
369
|
+
border: none;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.card-delete-button:hover {
|
|
373
|
+
background-color: transparent !important;
|
|
374
|
+
color: #D91C1C !important;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.card_selected {
|
|
378
|
+
position: relative;
|
|
379
|
+
width: 16px;
|
|
380
|
+
height: 16px;
|
|
381
|
+
appearance: none;
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
border-radius: 100%;
|
|
384
|
+
border: 1px #3bc635 solid;
|
|
385
|
+
color: #3bc635;
|
|
386
|
+
transition-property: all;
|
|
387
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
388
|
+
transition-duration: 150ms;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.card_selected:before {
|
|
392
|
+
width: 8px;
|
|
393
|
+
height: 8px;
|
|
394
|
+
content: "";
|
|
395
|
+
position: absolute;
|
|
396
|
+
top: 50%;
|
|
397
|
+
left: 50%;
|
|
398
|
+
display: block;
|
|
399
|
+
transform: translate(-50%, -50%);
|
|
400
|
+
border-radius: 100%;
|
|
401
|
+
background-color: #3bc635;
|
|
402
|
+
opacity: 0;
|
|
403
|
+
transition-property: opacity;
|
|
404
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
405
|
+
transition-duration: 150ms;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.card_selected:checked {
|
|
409
|
+
border: 1px #3bc635 solid;
|
|
410
|
+
position: relative;
|
|
411
|
+
width: 16px;
|
|
412
|
+
height: 16px;
|
|
413
|
+
appearance: none;
|
|
414
|
+
cursor: pointer;
|
|
415
|
+
border-radius: 100%;
|
|
416
|
+
color: #3bc635;
|
|
417
|
+
transition-property: all;
|
|
418
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
419
|
+
transition-duration: 150ms;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.card_selected:checked:before {
|
|
423
|
+
content: "";
|
|
424
|
+
border: 1px #3bc635 solid;
|
|
425
|
+
width: 8px;
|
|
426
|
+
height: 8px;
|
|
427
|
+
position: absolute;
|
|
428
|
+
top: 50%;
|
|
429
|
+
left: 50%;
|
|
430
|
+
display: block;
|
|
431
|
+
transform: translate(-50%, -50%);
|
|
432
|
+
border-radius: 100%;
|
|
433
|
+
background-color: #3bc635;
|
|
434
|
+
opacity: 50;
|
|
435
|
+
transition-property: opacity;
|
|
436
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
437
|
+
transition-duration: 150ms;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.card_selected:hover:before {
|
|
441
|
+
width: 8px;
|
|
442
|
+
height: 8px;
|
|
443
|
+
content: "";
|
|
444
|
+
position: absolute;
|
|
445
|
+
top: 50%;
|
|
446
|
+
left: 50%;
|
|
447
|
+
display: block;
|
|
448
|
+
transform: translate(-50%, -50%);
|
|
449
|
+
border-radius: 100%;
|
|
450
|
+
background-color: #3bc635;
|
|
451
|
+
transition-property: opacity;
|
|
452
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
453
|
+
transition-duration: 150ms;
|
|
454
|
+
opacity: 10;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
</style>
|
|
458
|
+
`
|
|
459
|
+
const cardItem = `
|
|
460
|
+
${cardItemsHTML}
|
|
461
|
+
${cardItemStyle}
|
|
462
|
+
`
|
|
463
|
+
return cardItem;
|
|
464
|
+
}
|