tonder-web-sdk 1.11.11 → 1.12.0-beta.0
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/prettier.xml +6 -0
- package/.idea/workspace.xml +96 -11
- package/README.md +0 -3
- package/package.json +3 -1
- package/src/classes/3dsHandler.js +1 -4
- package/src/classes/BaseInlineCheckout.js +298 -0
- package/src/classes/LiteInlineCheckout.js +101 -0
- package/src/classes/inlineCheckout.js +64 -280
- package/src/data/apmApi.js +44 -0
- package/src/data/businessApi.js +19 -0
- package/src/data/cardApi.js +116 -0
- package/src/data/checkoutApi.js +81 -0
- package/src/data/customerApi.js +37 -0
- package/src/data/index.js +17 -0
- package/src/data/openPayApi.js +16 -0
- package/src/data/skyflowApi.js +18 -0
- package/src/helpers/skyflow.js +76 -15
- package/src/helpers/template.js +7 -1
- package/src/helpers/utils.js +81 -79
- package/src/index-dev.js +96 -14
- package/src/index.html +119 -8
- package/src/shared/constants/paymentMethodAPM.js +63 -0
- package/src/shared/constants/tonderUrl.js +8 -0
- package/types/index.d.ts +14 -0
- package/v1/bundle.min.js +3 -3
- package/src/data/api.js +0 -193
- package/src/helpers/constants.js +0 -64
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new order in the system.
|
|
3
|
+
* @param {string} baseUrl - The base URL of the API.
|
|
4
|
+
* @param {string} apiKey - The API key for authentication.
|
|
5
|
+
* @param {Object} orderItems - The items to be included in the order.
|
|
6
|
+
* @returns {Promise<Object>} The created order data.
|
|
7
|
+
*/
|
|
8
|
+
export async function createOrder(baseUrl, apiKey, orderItems) {
|
|
9
|
+
const url = `${baseUrl}/api/v1/orders/`;
|
|
10
|
+
const data = orderItems;
|
|
11
|
+
const response = await fetch(url, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
Authorization: `Token ${apiKey}`,
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify(data),
|
|
18
|
+
});
|
|
19
|
+
if (response.status === 201) {
|
|
20
|
+
const jsonResponse = await response.json();
|
|
21
|
+
return jsonResponse;
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new payment in the system.
|
|
29
|
+
* @param {string} baseUrl - The base URL of the API.
|
|
30
|
+
* @param {string} apiKey - The API key for authentication.
|
|
31
|
+
* @param {Object} paymentItems - The payment details.
|
|
32
|
+
* @returns {Promise<Object>} The created payment data.
|
|
33
|
+
*/
|
|
34
|
+
export async function createPayment(baseUrl, apiKey, paymentItems) {
|
|
35
|
+
const url = `${baseUrl}/api/v1/business/${paymentItems.business_pk}/payments/`;
|
|
36
|
+
const data = paymentItems;
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Authorization: `Token ${apiKey}`,
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify(data),
|
|
44
|
+
});
|
|
45
|
+
if (response.status >= 200 && response.status <=299) {
|
|
46
|
+
const jsonResponse = await response.json();
|
|
47
|
+
return jsonResponse;
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initiates the checkout process.
|
|
55
|
+
* @param {string} baseUrl - The base URL of the API.
|
|
56
|
+
* @param {string} apiKey - The API key for authentication.
|
|
57
|
+
* @param {Object} routerItems - The checkout details.
|
|
58
|
+
* @returns {Promise<Object>} The checkout process result.
|
|
59
|
+
*/
|
|
60
|
+
export async function startCheckoutRouter(baseUrl, apiKey, routerItems) {
|
|
61
|
+
try {
|
|
62
|
+
const url = `${baseUrl}/api/v1/checkout-router/`;
|
|
63
|
+
const data = routerItems;
|
|
64
|
+
const response = await fetch(url, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers: {
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
Authorization: `Token ${apiKey}`,
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(data),
|
|
71
|
+
});
|
|
72
|
+
if (response.status >= 200 && response.status <= 299) {
|
|
73
|
+
const jsonResponse = await response.json();
|
|
74
|
+
return jsonResponse;
|
|
75
|
+
} else {
|
|
76
|
+
throw new Error("Failed to start checkout router")
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw error
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a new customer or fetches an existing customer.
|
|
3
|
+
* @param {string} baseUrl - The base URL of the API.
|
|
4
|
+
* @param {string} apiKey - The API key for authentication.
|
|
5
|
+
* @param {Object} customer - The customer data.
|
|
6
|
+
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
7
|
+
* @returns {Promise<Object>} The registered or fetched customer data.
|
|
8
|
+
*/
|
|
9
|
+
export async function registerOrFetchCustomer(
|
|
10
|
+
baseUrl,
|
|
11
|
+
apiKey,
|
|
12
|
+
customer,
|
|
13
|
+
signal,
|
|
14
|
+
) {
|
|
15
|
+
const url = `${baseUrl}/api/v1/customer/`;
|
|
16
|
+
const data = {
|
|
17
|
+
email: customer.email,
|
|
18
|
+
first_name: customer?.firstName,
|
|
19
|
+
last_name: customer?.lastName,
|
|
20
|
+
phone: customer?.phone,
|
|
21
|
+
};
|
|
22
|
+
const response = await fetch(url, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
Authorization: `Token ${apiKey}`,
|
|
27
|
+
},
|
|
28
|
+
signal: signal,
|
|
29
|
+
body: JSON.stringify(data),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (response.status === 201) {
|
|
33
|
+
return await response.json();
|
|
34
|
+
} else {
|
|
35
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fetchBusiness } from './businessApi';
|
|
2
|
+
import { registerOrFetchCustomer } from './customerApi';
|
|
3
|
+
import { createOrder } from './checkoutApi';
|
|
4
|
+
import { saveCustomerCard, removeCustomerCard, fetchCustomerCards } from './cardApi';
|
|
5
|
+
import { fetchCustomerAPMs } from './apmApi';
|
|
6
|
+
import { getOpenpayDeviceSessionID } from './openPayApi';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
registerOrFetchCustomer,
|
|
10
|
+
createOrder,
|
|
11
|
+
saveCustomerCard,
|
|
12
|
+
removeCustomerCard,
|
|
13
|
+
fetchCustomerCards,
|
|
14
|
+
fetchBusiness,
|
|
15
|
+
fetchCustomerAPMs,
|
|
16
|
+
getOpenpayDeviceSessionID
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an Openpay device session ID.
|
|
3
|
+
* @param {string} merchant_id - The Openpay merchant ID.
|
|
4
|
+
* @param {string} public_key - The Openpay public key.
|
|
5
|
+
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
6
|
+
* @returns {Promise<string>} The generated device session ID.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export async function getOpenpayDeviceSessionID(merchant_id, public_key, signal) {
|
|
10
|
+
let openpay = await window.OpenPay;
|
|
11
|
+
openpay.setId(merchant_id);
|
|
12
|
+
openpay.setApiKey(public_key);
|
|
13
|
+
openpay.setSandboxMode(true);
|
|
14
|
+
var response = await openpay.deviceData.setup({signal});
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export async function getVaultToken (baseUrl, apiKey, signal = null){
|
|
4
|
+
const response = await fetch(`${baseUrl}/api/v1/vault-token/`, {
|
|
5
|
+
method: 'GET',
|
|
6
|
+
headers: {
|
|
7
|
+
'Authorization': `Token ${apiKey}`,
|
|
8
|
+
},
|
|
9
|
+
signal: signal,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
if (response.ok) {
|
|
13
|
+
const responseBody = await response.json();
|
|
14
|
+
return responseBody.token;
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error('Failed to retrieve bearer token');
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/helpers/skyflow.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { defaultStyles } from "./styles";
|
|
2
|
+
import {getVaultToken} from "../data/skyflowApi";
|
|
3
|
+
import {buildErrorResponseFromCatch} from "./utils";
|
|
2
4
|
|
|
3
5
|
export async function initSkyflow(
|
|
4
6
|
vaultId,
|
|
@@ -14,20 +16,7 @@ export async function initSkyflow(
|
|
|
14
16
|
vaultURL: vaultUrl,
|
|
15
17
|
getBearerToken: async () => {
|
|
16
18
|
// Pass the signal to the fetch call
|
|
17
|
-
|
|
18
|
-
method: 'GET',
|
|
19
|
-
headers: {
|
|
20
|
-
'Authorization': `Token ${apiKey}`,
|
|
21
|
-
},
|
|
22
|
-
signal: signal,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (response.ok) {
|
|
26
|
-
const responseBody = await response.json();
|
|
27
|
-
return responseBody.token;
|
|
28
|
-
} else {
|
|
29
|
-
throw new Error('Failed to retrieve bearer token');
|
|
30
|
-
}
|
|
19
|
+
return await getVaultToken(baseUrl, apiKey, signal)
|
|
31
20
|
},
|
|
32
21
|
options: {
|
|
33
22
|
logLevel: Skyflow.LogLevel.ERROR,
|
|
@@ -215,4 +204,76 @@ function updateErrorLabel(element, errorStyles, color = "" ){
|
|
|
215
204
|
}
|
|
216
205
|
})
|
|
217
206
|
}
|
|
218
|
-
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function getSkyflowTokens({baseUrl, apiKey, vault_id, vault_url, data }) {
|
|
210
|
+
const skyflow = Skyflow.init({
|
|
211
|
+
vaultID: vault_id,
|
|
212
|
+
vaultURL: vault_url,
|
|
213
|
+
getBearerToken: async () => await getVaultToken(baseUrl, apiKey),
|
|
214
|
+
options: {
|
|
215
|
+
logLevel: Skyflow.LogLevel.ERROR,
|
|
216
|
+
env: Skyflow.Env.DEV,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const collectContainer = skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
221
|
+
|
|
222
|
+
const fieldPromises = await getFieldsPromise(data, collectContainer);
|
|
223
|
+
|
|
224
|
+
const result = await Promise.all(fieldPromises);
|
|
225
|
+
const mountFail = result.some((item) => !item);
|
|
226
|
+
|
|
227
|
+
if (mountFail) {
|
|
228
|
+
throw buildErrorResponseFromCatch(
|
|
229
|
+
Error("Ocurrió un error al montar los campos de la tarjeta"),
|
|
230
|
+
);
|
|
231
|
+
} else {
|
|
232
|
+
try {
|
|
233
|
+
const collectResponseSkyflowTonder = await collectContainer.collect();
|
|
234
|
+
if (collectResponseSkyflowTonder)
|
|
235
|
+
return collectResponseSkyflowTonder["records"][0]["fields"];
|
|
236
|
+
throw buildErrorResponseFromCatch(
|
|
237
|
+
Error("Por favor, verifica todos los campos de tu tarjeta"),
|
|
238
|
+
);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
throw buildErrorResponseFromCatch(error);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async function getFieldsPromise(data, collectContainer) {
|
|
245
|
+
const fields = await getFields(data, collectContainer);
|
|
246
|
+
if (!fields) return [];
|
|
247
|
+
return fields.map((field) => {
|
|
248
|
+
return new Promise((resolve) => {
|
|
249
|
+
const div = document.createElement("div");
|
|
250
|
+
div.hidden = true;
|
|
251
|
+
div.id = `id-${field.key}`;
|
|
252
|
+
document.querySelector(`body`)?.appendChild(div);
|
|
253
|
+
setTimeout(() => {
|
|
254
|
+
field.element.mount(`#id-${field.key}`);
|
|
255
|
+
setInterval(() => {
|
|
256
|
+
if (field.element.isMounted()) {
|
|
257
|
+
const value = data[field.key];
|
|
258
|
+
field.element.update({ value: value });
|
|
259
|
+
return resolve(field.element.isMounted());
|
|
260
|
+
}
|
|
261
|
+
}, 120);
|
|
262
|
+
}, 120);
|
|
263
|
+
});
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async function getFields(data, collectContainer) {
|
|
268
|
+
return await Promise.all(
|
|
269
|
+
Object.keys(data).map(async (key) => {
|
|
270
|
+
const cardHolderNameElement = await collectContainer.create({
|
|
271
|
+
table: "cards",
|
|
272
|
+
column: key,
|
|
273
|
+
type: Skyflow.ElementType.INPUT_FIELD,
|
|
274
|
+
});
|
|
275
|
+
return { element: cardHolderNameElement, key: key };
|
|
276
|
+
})
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
|
package/src/helpers/template.js
CHANGED
|
@@ -19,6 +19,12 @@ 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 futuros pagos
|
|
26
|
+
</label>
|
|
27
|
+
</div>
|
|
22
28
|
<div id="msgError"></div>
|
|
23
29
|
<div id="msgNotification"></div>
|
|
24
30
|
</div>
|
|
@@ -73,7 +79,7 @@ export const cardTemplate = (data) => `
|
|
|
73
79
|
margin-right: 10px !important;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
.error-container{
|
|
82
|
+
.error-container {
|
|
77
83
|
color: red !important;
|
|
78
84
|
background-color: #FFDBDB !important;
|
|
79
85
|
margin-bottom: 13px !important;
|
package/src/helpers/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PAYMENT_METHOD_APM } from "../shared/constants/paymentMethodAPM";
|
|
2
2
|
|
|
3
3
|
export async function addScripts() {
|
|
4
4
|
try {
|
|
@@ -106,235 +106,235 @@ export const getAPMType = (scheme_data) => {
|
|
|
106
106
|
const scheme = clearSpace(scheme_data.toUpperCase())
|
|
107
107
|
|
|
108
108
|
const PAYMENT_METHODS_CATALOG = {
|
|
109
|
-
[
|
|
109
|
+
[PAYMENT_METHOD_APM.SORIANA]: {
|
|
110
110
|
label: "Soriana",
|
|
111
111
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/soriana.png",
|
|
112
112
|
},
|
|
113
|
-
[
|
|
113
|
+
[PAYMENT_METHOD_APM.OXXO]: {
|
|
114
114
|
label: "Oxxo",
|
|
115
115
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/oxxo.png",
|
|
116
116
|
},
|
|
117
|
-
[
|
|
117
|
+
[PAYMENT_METHOD_APM.CODI]: {
|
|
118
118
|
label: "CoDi",
|
|
119
119
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/codi.png",
|
|
120
120
|
},
|
|
121
|
-
[
|
|
121
|
+
[PAYMENT_METHOD_APM.SPEI]: {
|
|
122
122
|
label: "SPEI",
|
|
123
123
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/spei.png",
|
|
124
124
|
},
|
|
125
|
-
[
|
|
125
|
+
[PAYMENT_METHOD_APM.PAYPAL]: {
|
|
126
126
|
label: "Paypal",
|
|
127
127
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/paypal.png",
|
|
128
128
|
},
|
|
129
|
-
[
|
|
129
|
+
[PAYMENT_METHOD_APM.COMERCIALMEXICANA]: {
|
|
130
130
|
label: "Comercial Mexicana",
|
|
131
131
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/comercial_exicana.png",
|
|
132
132
|
},
|
|
133
|
-
[
|
|
133
|
+
[PAYMENT_METHOD_APM.BANCOMER]: {
|
|
134
134
|
label: "Bancomer",
|
|
135
135
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bancomer.png",
|
|
136
136
|
},
|
|
137
|
-
[
|
|
137
|
+
[PAYMENT_METHOD_APM.WALMART]: {
|
|
138
138
|
label: "Walmart",
|
|
139
139
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/walmart.png",
|
|
140
140
|
},
|
|
141
|
-
[
|
|
141
|
+
[PAYMENT_METHOD_APM.BODEGA]: {
|
|
142
142
|
label: "Bodega Aurrera",
|
|
143
143
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/bodega_aurrera.png",
|
|
144
144
|
},
|
|
145
|
-
[
|
|
145
|
+
[PAYMENT_METHOD_APM.SAMSCLUB]: {
|
|
146
146
|
label: "Sam´s Club",
|
|
147
147
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/sams_club.png",
|
|
148
148
|
},
|
|
149
|
-
[
|
|
149
|
+
[PAYMENT_METHOD_APM.SUPERAMA]: {
|
|
150
150
|
label: "Superama",
|
|
151
151
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/superama.png",
|
|
152
152
|
},
|
|
153
|
-
[
|
|
153
|
+
[PAYMENT_METHOD_APM.CALIMAX]: {
|
|
154
154
|
label: "Calimax",
|
|
155
155
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/calimax.png",
|
|
156
156
|
},
|
|
157
|
-
[
|
|
157
|
+
[PAYMENT_METHOD_APM.EXTRA]: {
|
|
158
158
|
label: "Tiendas Extra",
|
|
159
159
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/tiendas_extra.png",
|
|
160
160
|
},
|
|
161
|
-
[
|
|
161
|
+
[PAYMENT_METHOD_APM.CIRCULOK]: {
|
|
162
162
|
label: "Círculo K",
|
|
163
163
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/circulo_k.png",
|
|
164
164
|
},
|
|
165
|
-
[
|
|
165
|
+
[PAYMENT_METHOD_APM.SEVEN11]: {
|
|
166
166
|
label: "7 Eleven",
|
|
167
167
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/7_eleven.png",
|
|
168
168
|
},
|
|
169
|
-
[
|
|
169
|
+
[PAYMENT_METHOD_APM.TELECOMM]: {
|
|
170
170
|
label: "Telecomm",
|
|
171
171
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/telecomm.png",
|
|
172
172
|
},
|
|
173
|
-
[
|
|
173
|
+
[PAYMENT_METHOD_APM.BANORTE]: {
|
|
174
174
|
label: "Banorte",
|
|
175
175
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/banorte.png",
|
|
176
176
|
},
|
|
177
|
-
[
|
|
177
|
+
[PAYMENT_METHOD_APM.BENAVIDES]: {
|
|
178
178
|
label: "Farmacias Benavides",
|
|
179
179
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_benavides.png",
|
|
180
180
|
},
|
|
181
|
-
[
|
|
181
|
+
[PAYMENT_METHOD_APM.DELAHORRO]: {
|
|
182
182
|
label: "Farmacias del Ahorro",
|
|
183
183
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_ahorro.png",
|
|
184
184
|
},
|
|
185
|
-
[
|
|
185
|
+
[PAYMENT_METHOD_APM.ELASTURIANO]: {
|
|
186
186
|
label: "El Asturiano",
|
|
187
187
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/asturiano.png",
|
|
188
188
|
},
|
|
189
|
-
[
|
|
189
|
+
[PAYMENT_METHOD_APM.WALDOS]: {
|
|
190
190
|
label: "Waldos",
|
|
191
191
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/waldos.png",
|
|
192
192
|
},
|
|
193
|
-
[
|
|
193
|
+
[PAYMENT_METHOD_APM.ALSUPER]: {
|
|
194
194
|
label: "Alsuper",
|
|
195
195
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/al_super.png",
|
|
196
196
|
},
|
|
197
|
-
[
|
|
197
|
+
[PAYMENT_METHOD_APM.KIOSKO]: {
|
|
198
198
|
label: "Kiosko",
|
|
199
199
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/kiosko.png",
|
|
200
200
|
},
|
|
201
|
-
[
|
|
201
|
+
[PAYMENT_METHOD_APM.STAMARIA]: {
|
|
202
202
|
label: "Farmacias Santa María",
|
|
203
203
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_santa_maria.png",
|
|
204
204
|
},
|
|
205
|
-
[
|
|
205
|
+
[PAYMENT_METHOD_APM.LAMASBARATA]: {
|
|
206
206
|
label: "Farmacias la más barata",
|
|
207
207
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_barata.png",
|
|
208
208
|
},
|
|
209
|
-
[
|
|
209
|
+
[PAYMENT_METHOD_APM.FARMROMA]: {
|
|
210
210
|
label: "Farmacias Roma",
|
|
211
211
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_roma.png",
|
|
212
212
|
},
|
|
213
|
-
[
|
|
213
|
+
[PAYMENT_METHOD_APM.FARMUNION]: {
|
|
214
214
|
label: "Pago en Farmacias Unión",
|
|
215
215
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_union.png",
|
|
216
216
|
},
|
|
217
|
-
[
|
|
217
|
+
[PAYMENT_METHOD_APM.FARMATODO]: {
|
|
218
218
|
label: "Pago en Farmacias Farmatodo",
|
|
219
219
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_farmatodo.png ",
|
|
220
220
|
},
|
|
221
|
-
[
|
|
221
|
+
[PAYMENT_METHOD_APM.SFDEASIS]: {
|
|
222
222
|
label: "Pago en Farmacias San Francisco de Asís",
|
|
223
223
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/farmacias_san_francisco.png",
|
|
224
224
|
},
|
|
225
|
-
[
|
|
225
|
+
[PAYMENT_METHOD_APM.FARM911]: {
|
|
226
226
|
label: "Farmacias 911",
|
|
227
227
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
228
228
|
},
|
|
229
|
-
[
|
|
229
|
+
[PAYMENT_METHOD_APM.FARMECONOMICAS]: {
|
|
230
230
|
label: "Farmacias Economicas",
|
|
231
231
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
232
232
|
},
|
|
233
|
-
[
|
|
233
|
+
[PAYMENT_METHOD_APM.FARMMEDICITY]: {
|
|
234
234
|
label: "Farmacias Medicity",
|
|
235
235
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
236
236
|
},
|
|
237
|
-
[
|
|
237
|
+
[PAYMENT_METHOD_APM.RIANXEIRA]: {
|
|
238
238
|
label: "Rianxeira",
|
|
239
239
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
240
240
|
},
|
|
241
|
-
[
|
|
241
|
+
[PAYMENT_METHOD_APM.WESTERNUNION]: {
|
|
242
242
|
label: "Western Union",
|
|
243
243
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
244
244
|
},
|
|
245
|
-
[
|
|
245
|
+
[PAYMENT_METHOD_APM.ZONAPAGO]: {
|
|
246
246
|
label: "Zona Pago",
|
|
247
247
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
248
248
|
},
|
|
249
|
-
[
|
|
249
|
+
[PAYMENT_METHOD_APM.CAJALOSANDES]: {
|
|
250
250
|
label: "Caja Los Andes",
|
|
251
251
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
252
252
|
},
|
|
253
|
-
[
|
|
253
|
+
[PAYMENT_METHOD_APM.CAJAPAITA]: {
|
|
254
254
|
label: "Caja Paita",
|
|
255
255
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
256
256
|
},
|
|
257
|
-
[
|
|
257
|
+
[PAYMENT_METHOD_APM.CAJASANTA]: {
|
|
258
258
|
label: "Caja Santa",
|
|
259
259
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
260
260
|
},
|
|
261
|
-
[
|
|
261
|
+
[PAYMENT_METHOD_APM.CAJASULLANA]: {
|
|
262
262
|
label: "Caja Sullana",
|
|
263
263
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
264
264
|
},
|
|
265
|
-
[
|
|
265
|
+
[PAYMENT_METHOD_APM.CAJATRUJILLO]: {
|
|
266
266
|
label: "Caja Trujillo",
|
|
267
267
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
268
268
|
},
|
|
269
|
-
[
|
|
269
|
+
[PAYMENT_METHOD_APM.EDPYME]: {
|
|
270
270
|
label: "Edpyme",
|
|
271
271
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
272
272
|
},
|
|
273
|
-
[
|
|
273
|
+
[PAYMENT_METHOD_APM.KASNET]: {
|
|
274
274
|
label: "KasNet",
|
|
275
275
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
276
276
|
},
|
|
277
|
-
[
|
|
277
|
+
[PAYMENT_METHOD_APM.NORANDINO]: {
|
|
278
278
|
label: "Norandino",
|
|
279
279
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
280
280
|
},
|
|
281
|
-
[
|
|
281
|
+
[PAYMENT_METHOD_APM.QAPAQ]: {
|
|
282
282
|
label: "Qapaq",
|
|
283
283
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
284
284
|
},
|
|
285
|
-
[
|
|
285
|
+
[PAYMENT_METHOD_APM.RAIZ]: {
|
|
286
286
|
label: "Raiz",
|
|
287
287
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
288
288
|
},
|
|
289
|
-
[
|
|
289
|
+
[PAYMENT_METHOD_APM.PAYSER]: {
|
|
290
290
|
label: "Paysera",
|
|
291
291
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
292
292
|
},
|
|
293
|
-
[
|
|
293
|
+
[PAYMENT_METHOD_APM.WUNION]: {
|
|
294
294
|
label: "Western Union",
|
|
295
295
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
296
296
|
},
|
|
297
|
-
[
|
|
297
|
+
[PAYMENT_METHOD_APM.BANCOCONTINENTAL]: {
|
|
298
298
|
label: "Banco Continental",
|
|
299
299
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
300
300
|
},
|
|
301
|
-
[
|
|
301
|
+
[PAYMENT_METHOD_APM.GMONEY]: {
|
|
302
302
|
label: "Go money",
|
|
303
303
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
304
304
|
},
|
|
305
|
-
[
|
|
305
|
+
[PAYMENT_METHOD_APM.GOPAY]: {
|
|
306
306
|
label: "Go pay",
|
|
307
307
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
308
308
|
},
|
|
309
|
-
[
|
|
309
|
+
[PAYMENT_METHOD_APM.WU]: {
|
|
310
310
|
label: "Western Union",
|
|
311
311
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
312
312
|
},
|
|
313
|
-
[
|
|
313
|
+
[PAYMENT_METHOD_APM.PUNTOSHEY]: {
|
|
314
314
|
label: "Puntoshey",
|
|
315
315
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
316
316
|
},
|
|
317
|
-
[
|
|
317
|
+
[PAYMENT_METHOD_APM.AMPM]: {
|
|
318
318
|
label: "Ampm",
|
|
319
319
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
320
320
|
},
|
|
321
|
-
[
|
|
321
|
+
[PAYMENT_METHOD_APM.JUMBOMARKET]: {
|
|
322
322
|
label: "Jumbomarket",
|
|
323
323
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
324
324
|
},
|
|
325
|
-
[
|
|
325
|
+
[PAYMENT_METHOD_APM.SMELPUEBLO]: {
|
|
326
326
|
label: "Smelpueblo",
|
|
327
327
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
328
328
|
},
|
|
329
|
-
[
|
|
329
|
+
[PAYMENT_METHOD_APM.BAM]: {
|
|
330
330
|
label: "Bam",
|
|
331
331
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
332
332
|
},
|
|
333
|
-
[
|
|
333
|
+
[PAYMENT_METHOD_APM.REFACIL]: {
|
|
334
334
|
label: "Refacil",
|
|
335
335
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
336
336
|
},
|
|
337
|
-
[
|
|
337
|
+
[PAYMENT_METHOD_APM.ACYVALORES]: {
|
|
338
338
|
label: "Acyvalores",
|
|
339
339
|
icon: "https://d35a75syrgujp0.cloudfront.net/payment_methods/store.png",
|
|
340
340
|
},
|
|
@@ -348,31 +348,16 @@ export const getAPMType = (scheme_data) => {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
|
|
351
|
-
export async function buildErrorResponse(
|
|
352
|
-
response
|
|
353
|
-
|
|
354
|
-
) {
|
|
355
|
-
|
|
356
|
-
let body, status, message = "Error";
|
|
357
|
-
|
|
358
|
-
if(response && "json" in response) {
|
|
359
|
-
body = await response?.json();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if(response && "status" in response) {
|
|
363
|
-
status = response.status.toString();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if(response && "text" in response) {
|
|
367
|
-
message = await response.text();
|
|
368
|
-
}
|
|
351
|
+
export async function buildErrorResponse(response, resJson) {
|
|
352
|
+
let status = response.status.toString();
|
|
353
|
+
let message = resJson.detail || "Error";
|
|
369
354
|
|
|
370
355
|
return {
|
|
371
356
|
code: status,
|
|
372
|
-
body:
|
|
357
|
+
body: resJson,
|
|
373
358
|
name: status,
|
|
374
359
|
message: message,
|
|
375
|
-
stack,
|
|
360
|
+
stack: undefined,
|
|
376
361
|
};
|
|
377
362
|
}
|
|
378
363
|
|
|
@@ -386,3 +371,20 @@ export function buildErrorResponseFromCatch(e) {
|
|
|
386
371
|
};
|
|
387
372
|
}
|
|
388
373
|
|
|
374
|
+
export function injectMercadoPagoSecurity() {
|
|
375
|
+
try {
|
|
376
|
+
const script = document.createElement('script');
|
|
377
|
+
script.src = "https://www.mercadopago.com/v2/security.js";
|
|
378
|
+
script.setAttribute('view', '');
|
|
379
|
+
script.onload = () => {
|
|
380
|
+
console.log("Mercado Pago script loaded successfully.");
|
|
381
|
+
};
|
|
382
|
+
script.onerror = (error) => {
|
|
383
|
+
console.error("Error loading Mercado Pago script:", error);
|
|
384
|
+
};
|
|
385
|
+
document.head.appendChild(script);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
console.error("Error attempting to inject Mercado Pago script:", error);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|