tonder-web-sdk 1.12.0-beta.1 → 1.12.0-beta.10
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/workspace.xml +38 -32
- package/package.json +1 -1
- package/src/classes/BaseInlineCheckout.js +35 -15
- package/src/classes/LiteInlineCheckout.js +149 -46
- package/src/classes/inlineCheckout.js +30 -10
- package/src/data/apmApi.js +1 -1
- package/src/data/cardApi.js +22 -12
- package/src/data/checkoutApi.js +17 -6
- package/src/data/customerApi.js +1 -1
- package/src/helpers/template.js +5 -4
- package/src/helpers/utils.js +18 -245
- package/src/index-dev.js +3 -2
- package/src/index.js +2 -0
- package/src/shared/catalog/paymentMethodsCatalog.js +247 -0
- package/src/shared/constants/messages.js +10 -0
- package/types/card.ts +33 -0
- package/types/checkout.ts +118 -0
- package/types/common.ts +26 -0
- package/types/customer.ts +11 -0
- package/types/index.d.ts +8 -76
- package/types/inlineCheckout.d.ts +22 -0
- package/types/liteInlineCheckout.d.ts +32 -0
- package/types/paymentMethod.ts +24 -0
- package/types/transaction.ts +101 -0
- package/v1/bundle.min.js +3 -3
package/src/data/checkoutApi.js
CHANGED
|
@@ -52,10 +52,19 @@ export async function createPayment(baseUrl, apiKey, paymentItems) {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Initiates the checkout process.
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
|
+
* This function sends a POST request to the checkout router API with the provided
|
|
57
|
+
* checkout details. If the request is successful, it returns the response data.
|
|
58
|
+
* If the request fails, it throws an error that includes the status and details of the failure.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} baseUrl - The base URL of the API.
|
|
56
61
|
* @param {string} apiKey - The API key for authentication.
|
|
57
|
-
* @param {
|
|
58
|
-
* @returns {Promise<
|
|
62
|
+
* @param {import("../../types").IStartCheckoutRequest | import("../../types").IStartCheckoutIdRequest} routerItems - The checkout details to be sent in the request body.
|
|
63
|
+
* @returns {Promise<import("../../types").IStartCheckoutResponse>} The checkout process result.
|
|
64
|
+
*
|
|
65
|
+
* @throws {Error} Throws an error if the checkout process fails. The error object contains
|
|
66
|
+
* additional `details` property with the response from the server if available.
|
|
67
|
+
* @property {import("../../types").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
|
|
59
68
|
*/
|
|
60
69
|
export async function startCheckoutRouter(baseUrl, apiKey, routerItems) {
|
|
61
70
|
try {
|
|
@@ -70,10 +79,12 @@ export async function startCheckoutRouter(baseUrl, apiKey, routerItems) {
|
|
|
70
79
|
body: JSON.stringify(data),
|
|
71
80
|
});
|
|
72
81
|
if (response.status >= 200 && response.status <= 299) {
|
|
73
|
-
|
|
74
|
-
return jsonResponse;
|
|
82
|
+
return await response.json();
|
|
75
83
|
} else {
|
|
76
|
-
|
|
84
|
+
const errorResponse = await response.json();
|
|
85
|
+
const error = new Error("Failed to start checkout router");
|
|
86
|
+
error.details = errorResponse;
|
|
87
|
+
throw error;
|
|
77
88
|
}
|
|
78
89
|
} catch (error) {
|
|
79
90
|
throw error
|
package/src/data/customerApi.js
CHANGED
package/src/helpers/template.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCardType } from "./utils";
|
|
2
|
+
import {getPaymentMethodDetails} from "../shared/catalog/paymentMethodsCatalog";
|
|
2
3
|
|
|
3
4
|
export const cardTemplate = (data) => `
|
|
4
5
|
<div class="container-tonder">
|
|
@@ -162,8 +163,8 @@ export const cardTemplate = (data) => `
|
|
|
162
163
|
|
|
163
164
|
.checkbox label {
|
|
164
165
|
margin-left: 10px;
|
|
165
|
-
font-size:
|
|
166
|
-
font-weight:
|
|
166
|
+
font-size: 12px;
|
|
167
|
+
font-weight: 500;
|
|
167
168
|
color: #1D1D1D;
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -488,7 +489,7 @@ export const cardItemsTemplate = (cards) => {
|
|
|
488
489
|
export const apmItemsTemplate = (apms) => {
|
|
489
490
|
|
|
490
491
|
const apmItemsHTML = apms.reduce((total, apm) => {
|
|
491
|
-
const apm_data =
|
|
492
|
+
const apm_data = getPaymentMethodDetails(apm.payment_method);
|
|
492
493
|
return `${total}
|
|
493
494
|
<div class="apm-item" id="card_container-${apm.pk}">
|
|
494
495
|
<input id="${apm.pk}" class="card_selected" name="card_selected" type="radio"/>
|
package/src/helpers/utils.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { PAYMENT_METHOD_APM } from "../shared/constants/paymentMethodAPM";
|
|
2
|
-
|
|
3
1
|
export async function addScripts() {
|
|
4
2
|
try {
|
|
5
3
|
const skyflowScript = document.createElement("script");
|
|
@@ -102,252 +100,27 @@ export const getCardType = (scheme) => {
|
|
|
102
100
|
export const clearSpace = (text) => {
|
|
103
101
|
return text.trim().replace(/\s+/g, '');
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png",
|
|
124
|
-
},
|
|
125
|
-
[PAYMENT_METHOD_APM.PAYPAL]: {
|
|
126
|
-
label: "Paypal",
|
|
127
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png",
|
|
128
|
-
},
|
|
129
|
-
[PAYMENT_METHOD_APM.COMERCIALMEXICANA]: {
|
|
130
|
-
label: "Comercial Mexicana",
|
|
131
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png",
|
|
132
|
-
},
|
|
133
|
-
[PAYMENT_METHOD_APM.BANCOMER]: {
|
|
134
|
-
label: "Bancomer",
|
|
135
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png",
|
|
136
|
-
},
|
|
137
|
-
[PAYMENT_METHOD_APM.WALMART]: {
|
|
138
|
-
label: "Walmart",
|
|
139
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png",
|
|
140
|
-
},
|
|
141
|
-
[PAYMENT_METHOD_APM.BODEGA]: {
|
|
142
|
-
label: "Bodega Aurrera",
|
|
143
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png",
|
|
144
|
-
},
|
|
145
|
-
[PAYMENT_METHOD_APM.SAMSCLUB]: {
|
|
146
|
-
label: "Sam´s Club",
|
|
147
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png",
|
|
148
|
-
},
|
|
149
|
-
[PAYMENT_METHOD_APM.SUPERAMA]: {
|
|
150
|
-
label: "Superama",
|
|
151
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png",
|
|
152
|
-
},
|
|
153
|
-
[PAYMENT_METHOD_APM.CALIMAX]: {
|
|
154
|
-
label: "Calimax",
|
|
155
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png",
|
|
156
|
-
},
|
|
157
|
-
[PAYMENT_METHOD_APM.EXTRA]: {
|
|
158
|
-
label: "Tiendas Extra",
|
|
159
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png",
|
|
160
|
-
},
|
|
161
|
-
[PAYMENT_METHOD_APM.CIRCULOK]: {
|
|
162
|
-
label: "Círculo K",
|
|
163
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png",
|
|
164
|
-
},
|
|
165
|
-
[PAYMENT_METHOD_APM.SEVEN11]: {
|
|
166
|
-
label: "7 Eleven",
|
|
167
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png",
|
|
168
|
-
},
|
|
169
|
-
[PAYMENT_METHOD_APM.TELECOMM]: {
|
|
170
|
-
label: "Telecomm",
|
|
171
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png",
|
|
172
|
-
},
|
|
173
|
-
[PAYMENT_METHOD_APM.BANORTE]: {
|
|
174
|
-
label: "Banorte",
|
|
175
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png",
|
|
176
|
-
},
|
|
177
|
-
[PAYMENT_METHOD_APM.BENAVIDES]: {
|
|
178
|
-
label: "Farmacias Benavides",
|
|
179
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png",
|
|
180
|
-
},
|
|
181
|
-
[PAYMENT_METHOD_APM.DELAHORRO]: {
|
|
182
|
-
label: "Farmacias del Ahorro",
|
|
183
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png",
|
|
184
|
-
},
|
|
185
|
-
[PAYMENT_METHOD_APM.ELASTURIANO]: {
|
|
186
|
-
label: "El Asturiano",
|
|
187
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png",
|
|
188
|
-
},
|
|
189
|
-
[PAYMENT_METHOD_APM.WALDOS]: {
|
|
190
|
-
label: "Waldos",
|
|
191
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png",
|
|
192
|
-
},
|
|
193
|
-
[PAYMENT_METHOD_APM.ALSUPER]: {
|
|
194
|
-
label: "Alsuper",
|
|
195
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png",
|
|
196
|
-
},
|
|
197
|
-
[PAYMENT_METHOD_APM.KIOSKO]: {
|
|
198
|
-
label: "Kiosko",
|
|
199
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png",
|
|
200
|
-
},
|
|
201
|
-
[PAYMENT_METHOD_APM.STAMARIA]: {
|
|
202
|
-
label: "Farmacias Santa María",
|
|
203
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png",
|
|
204
|
-
},
|
|
205
|
-
[PAYMENT_METHOD_APM.LAMASBARATA]: {
|
|
206
|
-
label: "Farmacias la más barata",
|
|
207
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png",
|
|
208
|
-
},
|
|
209
|
-
[PAYMENT_METHOD_APM.FARMROMA]: {
|
|
210
|
-
label: "Farmacias Roma",
|
|
211
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png",
|
|
212
|
-
},
|
|
213
|
-
[PAYMENT_METHOD_APM.FARMUNION]: {
|
|
214
|
-
label: "Pago en Farmacias Unión",
|
|
215
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png",
|
|
216
|
-
},
|
|
217
|
-
[PAYMENT_METHOD_APM.FARMATODO]: {
|
|
218
|
-
label: "Pago en Farmacias Farmatodo",
|
|
219
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png ",
|
|
220
|
-
},
|
|
221
|
-
[PAYMENT_METHOD_APM.SFDEASIS]: {
|
|
222
|
-
label: "Pago en Farmacias San Francisco de Asís",
|
|
223
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png",
|
|
224
|
-
},
|
|
225
|
-
[PAYMENT_METHOD_APM.FARM911]: {
|
|
226
|
-
label: "Farmacias 911",
|
|
227
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
228
|
-
},
|
|
229
|
-
[PAYMENT_METHOD_APM.FARMECONOMICAS]: {
|
|
230
|
-
label: "Farmacias Economicas",
|
|
231
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
232
|
-
},
|
|
233
|
-
[PAYMENT_METHOD_APM.FARMMEDICITY]: {
|
|
234
|
-
label: "Farmacias Medicity",
|
|
235
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
236
|
-
},
|
|
237
|
-
[PAYMENT_METHOD_APM.RIANXEIRA]: {
|
|
238
|
-
label: "Rianxeira",
|
|
239
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
240
|
-
},
|
|
241
|
-
[PAYMENT_METHOD_APM.WESTERNUNION]: {
|
|
242
|
-
label: "Western Union",
|
|
243
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
244
|
-
},
|
|
245
|
-
[PAYMENT_METHOD_APM.ZONAPAGO]: {
|
|
246
|
-
label: "Zona Pago",
|
|
247
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
248
|
-
},
|
|
249
|
-
[PAYMENT_METHOD_APM.CAJALOSANDES]: {
|
|
250
|
-
label: "Caja Los Andes",
|
|
251
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
252
|
-
},
|
|
253
|
-
[PAYMENT_METHOD_APM.CAJAPAITA]: {
|
|
254
|
-
label: "Caja Paita",
|
|
255
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
256
|
-
},
|
|
257
|
-
[PAYMENT_METHOD_APM.CAJASANTA]: {
|
|
258
|
-
label: "Caja Santa",
|
|
259
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
260
|
-
},
|
|
261
|
-
[PAYMENT_METHOD_APM.CAJASULLANA]: {
|
|
262
|
-
label: "Caja Sullana",
|
|
263
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
264
|
-
},
|
|
265
|
-
[PAYMENT_METHOD_APM.CAJATRUJILLO]: {
|
|
266
|
-
label: "Caja Trujillo",
|
|
267
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
268
|
-
},
|
|
269
|
-
[PAYMENT_METHOD_APM.EDPYME]: {
|
|
270
|
-
label: "Edpyme",
|
|
271
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
272
|
-
},
|
|
273
|
-
[PAYMENT_METHOD_APM.KASNET]: {
|
|
274
|
-
label: "KasNet",
|
|
275
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
276
|
-
},
|
|
277
|
-
[PAYMENT_METHOD_APM.NORANDINO]: {
|
|
278
|
-
label: "Norandino",
|
|
279
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
280
|
-
},
|
|
281
|
-
[PAYMENT_METHOD_APM.QAPAQ]: {
|
|
282
|
-
label: "Qapaq",
|
|
283
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
284
|
-
},
|
|
285
|
-
[PAYMENT_METHOD_APM.RAIZ]: {
|
|
286
|
-
label: "Raiz",
|
|
287
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
288
|
-
},
|
|
289
|
-
[PAYMENT_METHOD_APM.PAYSER]: {
|
|
290
|
-
label: "Paysera",
|
|
291
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
292
|
-
},
|
|
293
|
-
[PAYMENT_METHOD_APM.WUNION]: {
|
|
294
|
-
label: "Western Union",
|
|
295
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
296
|
-
},
|
|
297
|
-
[PAYMENT_METHOD_APM.BANCOCONTINENTAL]: {
|
|
298
|
-
label: "Banco Continental",
|
|
299
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
300
|
-
},
|
|
301
|
-
[PAYMENT_METHOD_APM.GMONEY]: {
|
|
302
|
-
label: "Go money",
|
|
303
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
304
|
-
},
|
|
305
|
-
[PAYMENT_METHOD_APM.GOPAY]: {
|
|
306
|
-
label: "Go pay",
|
|
307
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
308
|
-
},
|
|
309
|
-
[PAYMENT_METHOD_APM.WU]: {
|
|
310
|
-
label: "Western Union",
|
|
311
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
312
|
-
},
|
|
313
|
-
[PAYMENT_METHOD_APM.PUNTOSHEY]: {
|
|
314
|
-
label: "Puntoshey",
|
|
315
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
316
|
-
},
|
|
317
|
-
[PAYMENT_METHOD_APM.AMPM]: {
|
|
318
|
-
label: "Ampm",
|
|
319
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
320
|
-
},
|
|
321
|
-
[PAYMENT_METHOD_APM.JUMBOMARKET]: {
|
|
322
|
-
label: "Jumbomarket",
|
|
323
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
324
|
-
},
|
|
325
|
-
[PAYMENT_METHOD_APM.SMELPUEBLO]: {
|
|
326
|
-
label: "Smelpueblo",
|
|
327
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
328
|
-
},
|
|
329
|
-
[PAYMENT_METHOD_APM.BAM]: {
|
|
330
|
-
label: "Bam",
|
|
331
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
332
|
-
},
|
|
333
|
-
[PAYMENT_METHOD_APM.REFACIL]: {
|
|
334
|
-
label: "Refacil",
|
|
335
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
336
|
-
},
|
|
337
|
-
[PAYMENT_METHOD_APM.ACYVALORES]: {
|
|
338
|
-
label: "Acyvalores",
|
|
339
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
340
|
-
},
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
const _default = {
|
|
344
|
-
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
345
|
-
label: ""
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
export function formatPublicErrorResponse(data, error) {
|
|
106
|
+
let code = 200
|
|
107
|
+
try {
|
|
108
|
+
code = Number(error?.code || 200)
|
|
109
|
+
}catch{}
|
|
110
|
+
|
|
111
|
+
const default_res = {
|
|
112
|
+
status: "error",
|
|
113
|
+
code,
|
|
114
|
+
message: "",
|
|
115
|
+
detail: error?.body?.detail || error?.body?.error || error.body || "Ocurrio un error inesperado."
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
...default_res,
|
|
120
|
+
...data
|
|
346
121
|
};
|
|
347
|
-
return PAYMENT_METHODS_CATALOG[scheme] || _default;
|
|
348
122
|
}
|
|
349
123
|
|
|
350
|
-
|
|
351
124
|
export async function buildErrorResponse(response, resJson) {
|
|
352
125
|
let status = response.status.toString();
|
|
353
126
|
let message = resJson.detail || "Error";
|
package/src/index-dev.js
CHANGED
|
@@ -109,7 +109,7 @@ const returnUrl = "http://127.0.0.1:8080/"
|
|
|
109
109
|
const commonConfig = {
|
|
110
110
|
mode: 'development',
|
|
111
111
|
apiKey,
|
|
112
|
-
returnUrl,
|
|
112
|
+
returnUrl: returnUrl+"?mode="+getCheckoutMode(),
|
|
113
113
|
styles: customStyles
|
|
114
114
|
};
|
|
115
115
|
|
|
@@ -137,9 +137,10 @@ function setupInlineCheckout() {
|
|
|
137
137
|
try {
|
|
138
138
|
payButton.textContent = 'Procesando...';
|
|
139
139
|
const response = await inlineCheckout.payment(checkoutData);
|
|
140
|
-
console.log(response)
|
|
140
|
+
console.log("Respuesta del pago:", response)
|
|
141
141
|
alert('Pago realizado con éxito');
|
|
142
142
|
} catch (error) {
|
|
143
|
+
console.log("Error en el pago:", error.details);
|
|
143
144
|
alert('Error al realizar el pago')
|
|
144
145
|
} finally {
|
|
145
146
|
payButton.textContent = 'Pagar';
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {clearSpace} from "../../helpers/utils";
|
|
2
|
+
import {PAYMENT_METHOD_APM} from "../constants/paymentMethodAPM";
|
|
3
|
+
|
|
4
|
+
const PAYMENT_METHODS_CATALOG = {
|
|
5
|
+
[PAYMENT_METHOD_APM.SORIANA]: {
|
|
6
|
+
label: "Soriana",
|
|
7
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png",
|
|
8
|
+
},
|
|
9
|
+
[PAYMENT_METHOD_APM.OXXO]: {
|
|
10
|
+
label: "Oxxo",
|
|
11
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png",
|
|
12
|
+
},
|
|
13
|
+
[PAYMENT_METHOD_APM.CODI]: {
|
|
14
|
+
label: "CoDi",
|
|
15
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png",
|
|
16
|
+
},
|
|
17
|
+
[PAYMENT_METHOD_APM.SPEI]: {
|
|
18
|
+
label: "SPEI",
|
|
19
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png",
|
|
20
|
+
},
|
|
21
|
+
[PAYMENT_METHOD_APM.PAYPAL]: {
|
|
22
|
+
label: "Paypal",
|
|
23
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png",
|
|
24
|
+
},
|
|
25
|
+
[PAYMENT_METHOD_APM.COMERCIALMEXICANA]: {
|
|
26
|
+
label: "Comercial Mexicana",
|
|
27
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png",
|
|
28
|
+
},
|
|
29
|
+
[PAYMENT_METHOD_APM.BANCOMER]: {
|
|
30
|
+
label: "Bancomer",
|
|
31
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png",
|
|
32
|
+
},
|
|
33
|
+
[PAYMENT_METHOD_APM.WALMART]: {
|
|
34
|
+
label: "Walmart",
|
|
35
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png",
|
|
36
|
+
},
|
|
37
|
+
[PAYMENT_METHOD_APM.BODEGA]: {
|
|
38
|
+
label: "Bodega Aurrera",
|
|
39
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png",
|
|
40
|
+
},
|
|
41
|
+
[PAYMENT_METHOD_APM.SAMSCLUB]: {
|
|
42
|
+
label: "Sam´s Club",
|
|
43
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png",
|
|
44
|
+
},
|
|
45
|
+
[PAYMENT_METHOD_APM.SUPERAMA]: {
|
|
46
|
+
label: "Superama",
|
|
47
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png",
|
|
48
|
+
},
|
|
49
|
+
[PAYMENT_METHOD_APM.CALIMAX]: {
|
|
50
|
+
label: "Calimax",
|
|
51
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png",
|
|
52
|
+
},
|
|
53
|
+
[PAYMENT_METHOD_APM.EXTRA]: {
|
|
54
|
+
label: "Tiendas Extra",
|
|
55
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png",
|
|
56
|
+
},
|
|
57
|
+
[PAYMENT_METHOD_APM.CIRCULOK]: {
|
|
58
|
+
label: "Círculo K",
|
|
59
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png",
|
|
60
|
+
},
|
|
61
|
+
[PAYMENT_METHOD_APM.SEVEN11]: {
|
|
62
|
+
label: "7 Eleven",
|
|
63
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png",
|
|
64
|
+
},
|
|
65
|
+
[PAYMENT_METHOD_APM.TELECOMM]: {
|
|
66
|
+
label: "Telecomm",
|
|
67
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png",
|
|
68
|
+
},
|
|
69
|
+
[PAYMENT_METHOD_APM.BANORTE]: {
|
|
70
|
+
label: "Banorte",
|
|
71
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png",
|
|
72
|
+
},
|
|
73
|
+
[PAYMENT_METHOD_APM.BENAVIDES]: {
|
|
74
|
+
label: "Farmacias Benavides",
|
|
75
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png",
|
|
76
|
+
},
|
|
77
|
+
[PAYMENT_METHOD_APM.DELAHORRO]: {
|
|
78
|
+
label: "Farmacias del Ahorro",
|
|
79
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png",
|
|
80
|
+
},
|
|
81
|
+
[PAYMENT_METHOD_APM.ELASTURIANO]: {
|
|
82
|
+
label: "El Asturiano",
|
|
83
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png",
|
|
84
|
+
},
|
|
85
|
+
[PAYMENT_METHOD_APM.WALDOS]: {
|
|
86
|
+
label: "Waldos",
|
|
87
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png",
|
|
88
|
+
},
|
|
89
|
+
[PAYMENT_METHOD_APM.ALSUPER]: {
|
|
90
|
+
label: "Alsuper",
|
|
91
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png",
|
|
92
|
+
},
|
|
93
|
+
[PAYMENT_METHOD_APM.KIOSKO]: {
|
|
94
|
+
label: "Kiosko",
|
|
95
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png",
|
|
96
|
+
},
|
|
97
|
+
[PAYMENT_METHOD_APM.STAMARIA]: {
|
|
98
|
+
label: "Farmacias Santa María",
|
|
99
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png",
|
|
100
|
+
},
|
|
101
|
+
[PAYMENT_METHOD_APM.LAMASBARATA]: {
|
|
102
|
+
label: "Farmacias la más barata",
|
|
103
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png",
|
|
104
|
+
},
|
|
105
|
+
[PAYMENT_METHOD_APM.FARMROMA]: {
|
|
106
|
+
label: "Farmacias Roma",
|
|
107
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png",
|
|
108
|
+
},
|
|
109
|
+
[PAYMENT_METHOD_APM.FARMUNION]: {
|
|
110
|
+
label: "Pago en Farmacias Unión",
|
|
111
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png",
|
|
112
|
+
},
|
|
113
|
+
[PAYMENT_METHOD_APM.FARMATODO]: {
|
|
114
|
+
label: "Pago en Farmacias Farmatodo",
|
|
115
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png ",
|
|
116
|
+
},
|
|
117
|
+
[PAYMENT_METHOD_APM.SFDEASIS]: {
|
|
118
|
+
label: "Pago en Farmacias San Francisco de Asís",
|
|
119
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png",
|
|
120
|
+
},
|
|
121
|
+
[PAYMENT_METHOD_APM.FARM911]: {
|
|
122
|
+
label: "Farmacias 911",
|
|
123
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
124
|
+
},
|
|
125
|
+
[PAYMENT_METHOD_APM.FARMECONOMICAS]: {
|
|
126
|
+
label: "Farmacias Economicas",
|
|
127
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
128
|
+
},
|
|
129
|
+
[PAYMENT_METHOD_APM.FARMMEDICITY]: {
|
|
130
|
+
label: "Farmacias Medicity",
|
|
131
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
132
|
+
},
|
|
133
|
+
[PAYMENT_METHOD_APM.RIANXEIRA]: {
|
|
134
|
+
label: "Rianxeira",
|
|
135
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
136
|
+
},
|
|
137
|
+
[PAYMENT_METHOD_APM.WESTERNUNION]: {
|
|
138
|
+
label: "Western Union",
|
|
139
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
140
|
+
},
|
|
141
|
+
[PAYMENT_METHOD_APM.ZONAPAGO]: {
|
|
142
|
+
label: "Zona Pago",
|
|
143
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
144
|
+
},
|
|
145
|
+
[PAYMENT_METHOD_APM.CAJALOSANDES]: {
|
|
146
|
+
label: "Caja Los Andes",
|
|
147
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
148
|
+
},
|
|
149
|
+
[PAYMENT_METHOD_APM.CAJAPAITA]: {
|
|
150
|
+
label: "Caja Paita",
|
|
151
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
152
|
+
},
|
|
153
|
+
[PAYMENT_METHOD_APM.CAJASANTA]: {
|
|
154
|
+
label: "Caja Santa",
|
|
155
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
156
|
+
},
|
|
157
|
+
[PAYMENT_METHOD_APM.CAJASULLANA]: {
|
|
158
|
+
label: "Caja Sullana",
|
|
159
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
160
|
+
},
|
|
161
|
+
[PAYMENT_METHOD_APM.CAJATRUJILLO]: {
|
|
162
|
+
label: "Caja Trujillo",
|
|
163
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
164
|
+
},
|
|
165
|
+
[PAYMENT_METHOD_APM.EDPYME]: {
|
|
166
|
+
label: "Edpyme",
|
|
167
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
168
|
+
},
|
|
169
|
+
[PAYMENT_METHOD_APM.KASNET]: {
|
|
170
|
+
label: "KasNet",
|
|
171
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
172
|
+
},
|
|
173
|
+
[PAYMENT_METHOD_APM.NORANDINO]: {
|
|
174
|
+
label: "Norandino",
|
|
175
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
176
|
+
},
|
|
177
|
+
[PAYMENT_METHOD_APM.QAPAQ]: {
|
|
178
|
+
label: "Qapaq",
|
|
179
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
180
|
+
},
|
|
181
|
+
[PAYMENT_METHOD_APM.RAIZ]: {
|
|
182
|
+
label: "Raiz",
|
|
183
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
184
|
+
},
|
|
185
|
+
[PAYMENT_METHOD_APM.PAYSER]: {
|
|
186
|
+
label: "Paysera",
|
|
187
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
188
|
+
},
|
|
189
|
+
[PAYMENT_METHOD_APM.WUNION]: {
|
|
190
|
+
label: "Western Union",
|
|
191
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
192
|
+
},
|
|
193
|
+
[PAYMENT_METHOD_APM.BANCOCONTINENTAL]: {
|
|
194
|
+
label: "Banco Continental",
|
|
195
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
196
|
+
},
|
|
197
|
+
[PAYMENT_METHOD_APM.GMONEY]: {
|
|
198
|
+
label: "Go money",
|
|
199
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
200
|
+
},
|
|
201
|
+
[PAYMENT_METHOD_APM.GOPAY]: {
|
|
202
|
+
label: "Go pay",
|
|
203
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
204
|
+
},
|
|
205
|
+
[PAYMENT_METHOD_APM.WU]: {
|
|
206
|
+
label: "Western Union",
|
|
207
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
208
|
+
},
|
|
209
|
+
[PAYMENT_METHOD_APM.PUNTOSHEY]: {
|
|
210
|
+
label: "Puntoshey",
|
|
211
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
212
|
+
},
|
|
213
|
+
[PAYMENT_METHOD_APM.AMPM]: {
|
|
214
|
+
label: "Ampm",
|
|
215
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
216
|
+
},
|
|
217
|
+
[PAYMENT_METHOD_APM.JUMBOMARKET]: {
|
|
218
|
+
label: "Jumbomarket",
|
|
219
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
220
|
+
},
|
|
221
|
+
[PAYMENT_METHOD_APM.SMELPUEBLO]: {
|
|
222
|
+
label: "Smelpueblo",
|
|
223
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
224
|
+
},
|
|
225
|
+
[PAYMENT_METHOD_APM.BAM]: {
|
|
226
|
+
label: "Bam",
|
|
227
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
228
|
+
},
|
|
229
|
+
[PAYMENT_METHOD_APM.REFACIL]: {
|
|
230
|
+
label: "Refacil",
|
|
231
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
232
|
+
},
|
|
233
|
+
[PAYMENT_METHOD_APM.ACYVALORES]: {
|
|
234
|
+
label: "Acyvalores",
|
|
235
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
export const getPaymentMethodDetails = (scheme_data) => {
|
|
241
|
+
const scheme = clearSpace(scheme_data.toUpperCase())
|
|
242
|
+
const _default = {
|
|
243
|
+
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
244
|
+
label: ""
|
|
245
|
+
};
|
|
246
|
+
return PAYMENT_METHODS_CATALOG[scheme] || _default;
|
|
247
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const MESSAGES = Object.freeze({
|
|
2
|
+
saveCardError: "Ha ocurrido un error guardando la tarjeta. Inténtalo nuevamente.",
|
|
3
|
+
removeCardError: "Ha ocurrido un error eliminado la tarjeta. Inténtalo nuevamente.",
|
|
4
|
+
getCardsError: "Ha ocurrido un error obteniendo las tarjetas del customer. Inténtalo nuevamente.",
|
|
5
|
+
cardExist: "La tarjeta fue registrada previamente.",
|
|
6
|
+
removedCard: "Card deleted successfully",
|
|
7
|
+
errorCheckout: "No se ha podido procesar el pago",
|
|
8
|
+
cardSaved: "Tarjeta registrada con éxito.",
|
|
9
|
+
getPaymentMethodsError: "Ha ocurrido un error obteniendo las métodos de pago del customer. Inténtalo nuevamente."
|
|
10
|
+
})
|
package/types/card.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface ICard {
|
|
2
|
+
fields: ICardSkyflowFields;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface ICardSkyflowFields {
|
|
6
|
+
card_number: string;
|
|
7
|
+
expiration_month: string;
|
|
8
|
+
expiration_year: string;
|
|
9
|
+
skyflow_id: string;
|
|
10
|
+
card_scheme: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ICustomerCardsResponse {
|
|
14
|
+
user_id: number;
|
|
15
|
+
cards: ICard[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ISaveCardResponse {
|
|
19
|
+
skyflow_id: string;
|
|
20
|
+
user_id: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ISaveCardSkyflowRequest {
|
|
24
|
+
skyflow_id: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ISaveCardRequest {
|
|
28
|
+
card_number: string;
|
|
29
|
+
cvv: string;
|
|
30
|
+
expiration_month: string;
|
|
31
|
+
expiration_year: string;
|
|
32
|
+
cardholder_name: string;
|
|
33
|
+
}
|