@monei-js/components 1.2.0 → 1.5.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.
@@ -830,8 +830,6 @@ var loadScript = function loadScript(src, dataset) {
830
830
 
831
831
  var script = document.createElement('script');
832
832
  script.src = src;
833
- script.async = true;
834
- script.defer = true;
835
833
 
836
834
  script.onload = function () {
837
835
  return resolve();
@@ -977,20 +975,36 @@ var globalConfig = {
977
975
  paypalUrl: domain + "/" + version + "/inner-paypal/",
978
976
  bizumUrl: domain + "/" + version + "/inner-bizum/",
979
977
  bizumButtonUrl: domain + "/" + version + "/inner-bizum-button/",
978
+ cofidisUrl: domain + "/" + version + "/inner-cofidis/",
979
+ cofidisButtonUrl: domain + "/" + version + "/inner-cofidis-button/",
980
+ cofidisWidgetUrl: domain + "/" + version + "/inner-cofidis-widget/",
981
+ cofidisLoanUrl: domain + "/" + version + "/inner-cofidis-loan/",
982
+ cofidisLoanButtonUrl: domain + "/" + version + "/inner-cofidis-loan-button/",
983
+ cofidisLoanWidgetUrl: domain + "/" + version + "/inner-cofidis-loan-widget/",
980
984
  googlePayUrl: domain + "/" + version + "/inner-google-pay/",
981
- paymentRequestUrl: domain + "/" + version + "/inner-payment-request/"
985
+ paymentRequestUrl: domain + "/" + version + "/inner-payment-request/",
986
+ click2PayUrl: domain + "/" + version + "/inner-click2pay/",
987
+ click2PayButtonUrl: domain + "/" + version + "/inner-click2pay-button/"
982
988
  };
983
989
  var stageConfig = {
984
990
  local: {
985
991
  paymentPageUrl: "http://192.168.18.3:8080/",
986
992
  posPaymentPageUrl: "http://192.168.18.3:8080/",
987
993
  cardInputUrl: "http://192.168.18.3:3001/" + version + "/inner-card-input/",
988
- paymentModalUrl: "https://monei-payment-modal.eu.ngrok.io/" + version + "/inner-payment-modal/",
994
+ paymentModalUrl: "http://192.168.18.3:3002/" + version + "/inner-payment-modal/",
989
995
  paypalUrl: "http://192.168.18.3:3003/" + version + "/inner-paypal/",
990
996
  bizumUrl: "http://192.168.18.3:3004/" + version + "/inner-bizum/",
991
997
  bizumButtonUrl: "http://192.168.18.3:3005/" + version + "/inner-bizum-button/",
992
998
  googlePayUrl: "http://192.168.18.3:3006/" + version + "/inner-google-pay/",
993
999
  paymentRequestUrl: "https://monei-payment-request.eu.ngrok.io/" + version + "/inner-payment-request/",
1000
+ click2PayUrl: "http://192.168.18.3:3008/inner-click2pay/",
1001
+ click2PayButtonUrl: "http://192.168.18.3:3009/inner-click2pay-button/",
1002
+ cofidisUrl: "http://192.168.18.3:3010/" + version + "/inner-cofidis/",
1003
+ cofidisButtonUrl: "http://192.168.18.3:3011/" + version + "/inner-cofidis-button/",
1004
+ cofidisWidgetUrl: "http://192.168.18.3:3012/" + version + "/inner-cofidis-widget/",
1005
+ cofidisLoanUrl: "http://192.168.18.3:3013/" + version + "/inner-cofidis-loan/",
1006
+ cofidisLoanButtonUrl: "http://192.168.18.3:3014/" + version + "/inner-cofidis-loan-button/",
1007
+ cofidisLoanWidgetUrl: "http://192.168.18.3:3015/" + version + "/inner-cofidis-loan-widget/",
994
1008
  apiUrl: 'https://api.microapps-staging.com/v1',
995
1009
  secureDomain: 'https://secure.microapps-staging.com'
996
1010
  },
@@ -1005,65 +1019,45 @@ var stageConfig = {
1005
1019
  };
1006
1020
  var config = /*#__PURE__*/_extends({}, globalConfig, stageConfig[stage]);
1007
1021
 
1008
- var getPaymentMethods = /*#__PURE__*/function () {
1009
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1010
- var accountId, paymentId, params, query, res, result;
1022
+ var request = /*#__PURE__*/function () {
1023
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url, _temp) {
1024
+ var _ref2, _ref2$method, method, headers, body, res, _yield$withError, result;
1025
+
1011
1026
  return runtime_1.wrap(function _callee$(_context) {
1012
1027
  while (1) {
1013
1028
  switch (_context.prev = _context.next) {
1014
1029
  case 0:
1015
- accountId = _ref.accountId, paymentId = _ref.paymentId;
1016
-
1017
- if (!paymentId) {
1018
- _context.next = 5;
1019
- break;
1020
- }
1021
-
1022
- params = {
1023
- paymentId: paymentId
1024
- };
1025
- _context.next = 10;
1026
- break;
1027
-
1028
- case 5:
1029
- if (!accountId) {
1030
- _context.next = 9;
1031
- break;
1032
- }
1033
-
1034
- params = {
1035
- accountId: accountId
1036
- };
1037
- _context.next = 10;
1038
- break;
1039
-
1040
- case 9:
1041
- throw new Error('You need to provide paymentId or accountId');
1042
-
1043
- case 10:
1044
- query = stringify(params);
1045
- _context.next = 13;
1046
- return fetch(config.apiUrl + "/payment-methods?" + query);
1030
+ _ref2 = _temp === void 0 ? {} : _temp, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'GET' : _ref2$method, headers = _ref2.headers, body = _ref2.body;
1031
+ if (method === 'POST') headers = _extends({
1032
+ 'Content-Type': 'application/json'
1033
+ }, headers);
1034
+ _context.next = 4;
1035
+ return fetch("" + config.apiUrl + url, {
1036
+ method: method,
1037
+ headers: headers,
1038
+ body: body ? JSON.stringify(body) : undefined
1039
+ });
1047
1040
 
1048
- case 13:
1041
+ case 4:
1049
1042
  res = _context.sent;
1050
- _context.next = 16;
1051
- return res.json();
1043
+ _context.next = 7;
1044
+ return withError(res.json());
1052
1045
 
1053
- case 16:
1054
- result = _context.sent;
1046
+ case 7:
1047
+ _yield$withError = _context.sent;
1048
+ result = _yield$withError[1];
1055
1049
 
1056
1050
  if (res.ok) {
1057
- _context.next = 19;
1051
+ _context.next = 11;
1058
1052
  break;
1059
1053
  }
1060
1054
 
1061
- throw result;
1055
+ throw result || new Error(res.statusText);
1062
1056
 
1063
- case 19:
1057
+ case 11:
1064
1058
  return _context.abrupt("return", result);
1065
1059
 
1066
- case 20:
1060
+ case 12:
1067
1061
  case "end":
1068
1062
  return _context.stop();
1069
1063
  }
@@ -1071,18 +1065,20 @@ var getPaymentMethods = /*#__PURE__*/function () {
1071
1065
  }, _callee);
1072
1066
  }));
1073
1067
 
1074
- return function getPaymentMethods(_x) {
1075
- return _ref2.apply(this, arguments);
1068
+ return function request(_x, _x2) {
1069
+ return _ref.apply(this, arguments);
1076
1070
  };
1077
1071
  }();
1078
- var createToken = /*#__PURE__*/function () {
1072
+
1073
+ var pmCache = {};
1074
+ var getPaymentMethods = /*#__PURE__*/function () {
1079
1075
  var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref3) {
1080
- var paymentMethod, paymentId, sessionId, amount, currency, accountId, params, res, result;
1076
+ var accountId, paymentId, params, query, promise;
1081
1077
  return runtime_1.wrap(function _callee2$(_context2) {
1082
1078
  while (1) {
1083
1079
  switch (_context2.prev = _context2.next) {
1084
1080
  case 0:
1085
- paymentMethod = _ref3.paymentMethod, paymentId = _ref3.paymentId, sessionId = _ref3.sessionId, amount = _ref3.amount, currency = _ref3.currency, accountId = _ref3.accountId;
1081
+ accountId = _ref3.accountId, paymentId = _ref3.paymentId;
1086
1082
 
1087
1083
  if (!paymentId) {
1088
1084
  _context2.next = 5;
@@ -1090,8 +1086,7 @@ var createToken = /*#__PURE__*/function () {
1090
1086
  }
1091
1087
 
1092
1088
  params = {
1093
- paymentId: paymentId,
1094
- paymentMethod: paymentMethod
1089
+ paymentId: paymentId
1095
1090
  };
1096
1091
  _context2.next = 10;
1097
1092
  break;
@@ -1103,11 +1098,7 @@ var createToken = /*#__PURE__*/function () {
1103
1098
  }
1104
1099
 
1105
1100
  params = {
1106
- accountId: accountId,
1107
- paymentMethod: paymentMethod,
1108
- sessionId: sessionId,
1109
- amount: amount,
1110
- currency: currency
1101
+ accountId: accountId
1111
1102
  };
1112
1103
  _context2.next = 10;
1113
1104
  break;
@@ -1116,35 +1107,21 @@ var createToken = /*#__PURE__*/function () {
1116
1107
  throw new Error('You need to provide paymentId or accountId');
1117
1108
 
1118
1109
  case 10:
1119
- _context2.next = 12;
1120
- return fetch(config.apiUrl + "/tokens", {
1121
- method: 'POST',
1122
- headers: {
1123
- 'Content-Type': 'application/json',
1124
- 'Client-Env': getClientEnv()
1125
- },
1126
- body: JSON.stringify(params)
1127
- });
1128
-
1129
- case 12:
1130
- res = _context2.sent;
1131
- _context2.next = 15;
1132
- return res.json();
1133
-
1134
- case 15:
1135
- result = _context2.sent;
1110
+ query = stringify(params);
1136
1111
 
1137
- if (res.ok) {
1138
- _context2.next = 18;
1112
+ if (!pmCache[query]) {
1113
+ _context2.next = 13;
1139
1114
  break;
1140
1115
  }
1141
1116
 
1142
- throw result;
1117
+ return _context2.abrupt("return", pmCache[query]);
1143
1118
 
1144
- case 18:
1145
- return _context2.abrupt("return", result);
1119
+ case 13:
1120
+ promise = request("/payment-methods?" + query);
1121
+ pmCache[query] = promise;
1122
+ return _context2.abrupt("return", promise);
1146
1123
 
1147
- case 19:
1124
+ case 16:
1148
1125
  case "end":
1149
1126
  return _context2.stop();
1150
1127
  }
@@ -1152,39 +1129,60 @@ var createToken = /*#__PURE__*/function () {
1152
1129
  }, _callee2);
1153
1130
  }));
1154
1131
 
1155
- return function createToken(_x2) {
1132
+ return function getPaymentMethods(_x3) {
1156
1133
  return _ref4.apply(this, arguments);
1157
1134
  };
1158
1135
  }();
1159
- var getPayment = /*#__PURE__*/function () {
1160
- var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(paymentId) {
1161
- var res, result;
1136
+ var createToken = /*#__PURE__*/function () {
1137
+ var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_ref5) {
1138
+ var paymentMethod, paymentId, sessionId, amount, currency, accountId, body;
1162
1139
  return runtime_1.wrap(function _callee3$(_context3) {
1163
1140
  while (1) {
1164
1141
  switch (_context3.prev = _context3.next) {
1165
1142
  case 0:
1166
- _context3.next = 2;
1167
- return fetch(config.apiUrl + "/payments/" + paymentId + "/client-get");
1143
+ paymentMethod = _ref5.paymentMethod, paymentId = _ref5.paymentId, sessionId = _ref5.sessionId, amount = _ref5.amount, currency = _ref5.currency, accountId = _ref5.accountId;
1168
1144
 
1169
- case 2:
1170
- res = _context3.sent;
1171
- _context3.next = 5;
1172
- return res.json();
1145
+ if (!paymentId) {
1146
+ _context3.next = 5;
1147
+ break;
1148
+ }
1173
1149
 
1174
- case 5:
1175
- result = _context3.sent;
1150
+ body = {
1151
+ paymentId: paymentId,
1152
+ paymentMethod: paymentMethod
1153
+ };
1154
+ _context3.next = 10;
1155
+ break;
1176
1156
 
1177
- if (res.ok) {
1178
- _context3.next = 8;
1157
+ case 5:
1158
+ if (!accountId) {
1159
+ _context3.next = 9;
1179
1160
  break;
1180
1161
  }
1181
1162
 
1182
- throw result;
1183
-
1184
- case 8:
1185
- return _context3.abrupt("return", result);
1163
+ body = {
1164
+ accountId: accountId,
1165
+ paymentMethod: paymentMethod,
1166
+ sessionId: sessionId,
1167
+ amount: amount,
1168
+ currency: currency
1169
+ };
1170
+ _context3.next = 10;
1171
+ break;
1186
1172
 
1187
1173
  case 9:
1174
+ throw new Error('You need to provide paymentId or accountId');
1175
+
1176
+ case 10:
1177
+ return _context3.abrupt("return", request('/tokens', {
1178
+ method: 'POST',
1179
+ headers: {
1180
+ 'Client-Env': getClientEnv()
1181
+ },
1182
+ body: body
1183
+ }));
1184
+
1185
+ case 11:
1188
1186
  case "end":
1189
1187
  return _context3.stop();
1190
1188
  }
@@ -1192,47 +1190,19 @@ var getPayment = /*#__PURE__*/function () {
1192
1190
  }, _callee3);
1193
1191
  }));
1194
1192
 
1195
- return function getPayment(_x3) {
1196
- return _ref5.apply(this, arguments);
1193
+ return function createToken(_x4) {
1194
+ return _ref6.apply(this, arguments);
1197
1195
  };
1198
1196
  }();
1199
- var confirmPayment = /*#__PURE__*/function () {
1200
- var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(_ref6) {
1201
- var paymentId, params, res, result;
1197
+ var getPayment = /*#__PURE__*/function () {
1198
+ var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(paymentId) {
1202
1199
  return runtime_1.wrap(function _callee4$(_context4) {
1203
1200
  while (1) {
1204
1201
  switch (_context4.prev = _context4.next) {
1205
1202
  case 0:
1206
- paymentId = _ref6.paymentId, params = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref6, ["paymentId"]);
1207
- _context4.next = 3;
1208
- return fetch(config.apiUrl + "/payments/" + paymentId + "/client-confirm", {
1209
- method: 'POST',
1210
- headers: {
1211
- 'Content-Type': 'application/json',
1212
- 'Client-Env': getClientEnv()
1213
- },
1214
- body: JSON.stringify(params)
1215
- });
1216
-
1217
- case 3:
1218
- res = _context4.sent;
1219
- _context4.next = 6;
1220
- return res.json();
1221
-
1222
- case 6:
1223
- result = _context4.sent;
1224
-
1225
- if (res.ok) {
1226
- _context4.next = 9;
1227
- break;
1228
- }
1229
-
1230
- throw result;
1231
-
1232
- case 9:
1233
- return _context4.abrupt("return", result);
1203
+ return _context4.abrupt("return", request("/payments/" + paymentId + "/client-get"));
1234
1204
 
1235
- case 10:
1205
+ case 1:
1236
1206
  case "end":
1237
1207
  return _context4.stop();
1238
1208
  }
@@ -1240,48 +1210,27 @@ var confirmPayment = /*#__PURE__*/function () {
1240
1210
  }, _callee4);
1241
1211
  }));
1242
1212
 
1243
- return function confirmPayment(_x4) {
1213
+ return function getPayment(_x5) {
1244
1214
  return _ref7.apply(this, arguments);
1245
1215
  };
1246
1216
  }();
1247
- var createPayment = /*#__PURE__*/function () {
1217
+ var confirmPayment = /*#__PURE__*/function () {
1248
1218
  var _ref9 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(_ref8) {
1249
- var signature, params, res, result;
1219
+ var paymentId, body;
1250
1220
  return runtime_1.wrap(function _callee5$(_context5) {
1251
1221
  while (1) {
1252
1222
  switch (_context5.prev = _context5.next) {
1253
1223
  case 0:
1254
- signature = _ref8.signature, params = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref8, ["signature"]);
1255
- _context5.next = 3;
1256
- return fetch(config.apiUrl + "/client-payments", {
1224
+ paymentId = _ref8.paymentId, body = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref8, ["paymentId"]);
1225
+ return _context5.abrupt("return", request("/payments/" + paymentId + "/client-confirm", {
1257
1226
  method: 'POST',
1258
1227
  headers: {
1259
- 'Content-Type': 'application/json',
1260
- 'Client-Env': getClientEnv(),
1261
- 'Client-Signature': signature
1228
+ 'Client-Env': getClientEnv()
1262
1229
  },
1263
- body: JSON.stringify(params)
1264
- });
1265
-
1266
- case 3:
1267
- res = _context5.sent;
1268
- _context5.next = 6;
1269
- return res.json();
1270
-
1271
- case 6:
1272
- result = _context5.sent;
1273
-
1274
- if (res.ok) {
1275
- _context5.next = 9;
1276
- break;
1277
- }
1278
-
1279
- throw result;
1280
-
1281
- case 9:
1282
- return _context5.abrupt("return", result);
1230
+ body: body
1231
+ }));
1283
1232
 
1284
- case 10:
1233
+ case 2:
1285
1234
  case "end":
1286
1235
  return _context5.stop();
1287
1236
  }
@@ -1289,50 +1238,28 @@ var createPayment = /*#__PURE__*/function () {
1289
1238
  }, _callee5);
1290
1239
  }));
1291
1240
 
1292
- return function createPayment(_x5) {
1241
+ return function confirmPayment(_x6) {
1293
1242
  return _ref9.apply(this, arguments);
1294
1243
  };
1295
1244
  }();
1296
- var sendPaymentReceipt = /*#__PURE__*/function () {
1245
+ var createPayment = /*#__PURE__*/function () {
1297
1246
  var _ref11 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(_ref10) {
1298
- var paymentId, customerEmail, signature, language, res, result;
1247
+ var signature, body;
1299
1248
  return runtime_1.wrap(function _callee6$(_context6) {
1300
1249
  while (1) {
1301
1250
  switch (_context6.prev = _context6.next) {
1302
1251
  case 0:
1303
- paymentId = _ref10.paymentId, customerEmail = _ref10.customerEmail, signature = _ref10.signature, language = _ref10.language;
1304
- _context6.next = 3;
1305
- return fetch(config.apiUrl + "/payments/" + paymentId + "/client-receipt", {
1252
+ signature = _ref10.signature, body = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref10, ["signature"]);
1253
+ return _context6.abrupt("return", request('/client-payments', {
1306
1254
  method: 'POST',
1307
1255
  headers: {
1308
- 'Content-Type': 'application/json'
1256
+ 'Client-Env': getClientEnv(),
1257
+ 'Client-Signature': signature
1309
1258
  },
1310
- body: JSON.stringify({
1311
- customerEmail: customerEmail,
1312
- signature: signature,
1313
- language: language
1314
- })
1315
- });
1316
-
1317
- case 3:
1318
- res = _context6.sent;
1319
- _context6.next = 6;
1320
- return res.json();
1321
-
1322
- case 6:
1323
- result = _context6.sent;
1324
-
1325
- if (res.ok) {
1326
- _context6.next = 9;
1327
- break;
1328
- }
1329
-
1330
- throw result;
1331
-
1332
- case 9:
1333
- return _context6.abrupt("return", result);
1259
+ body: body
1260
+ }));
1334
1261
 
1335
- case 10:
1262
+ case 2:
1336
1263
  case "end":
1337
1264
  return _context6.stop();
1338
1265
  }
@@ -1340,54 +1267,80 @@ var sendPaymentReceipt = /*#__PURE__*/function () {
1340
1267
  }, _callee6);
1341
1268
  }));
1342
1269
 
1343
- return function sendPaymentReceipt(_x6) {
1270
+ return function createPayment(_x7) {
1344
1271
  return _ref11.apply(this, arguments);
1345
1272
  };
1346
1273
  }();
1347
- var createApplePaySession = /*#__PURE__*/function () {
1348
- var _ref12 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(params) {
1349
- var res, result;
1274
+ var sendPaymentReceipt = /*#__PURE__*/function () {
1275
+ var _ref13 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(_ref12) {
1276
+ var paymentId, customerEmail, signature, language;
1350
1277
  return runtime_1.wrap(function _callee7$(_context7) {
1351
1278
  while (1) {
1352
1279
  switch (_context7.prev = _context7.next) {
1353
1280
  case 0:
1354
- _context7.next = 2;
1355
- return fetch(config.apiUrl + "/apple-pay/sessions", {
1281
+ paymentId = _ref12.paymentId, customerEmail = _ref12.customerEmail, signature = _ref12.signature, language = _ref12.language;
1282
+ return _context7.abrupt("return", request("/payments/" + paymentId + "/client-receipt", {
1356
1283
  method: 'POST',
1357
- headers: {
1358
- 'Content-Type': 'application/json'
1359
- },
1360
- body: JSON.stringify(params)
1361
- });
1284
+ body: {
1285
+ customerEmail: customerEmail,
1286
+ signature: signature,
1287
+ language: language
1288
+ }
1289
+ }));
1362
1290
 
1363
1291
  case 2:
1364
- res = _context7.sent;
1365
- _context7.next = 5;
1366
- return res.json();
1367
-
1368
- case 5:
1369
- result = _context7.sent;
1292
+ case "end":
1293
+ return _context7.stop();
1294
+ }
1295
+ }
1296
+ }, _callee7);
1297
+ }));
1370
1298
 
1371
- if (res.ok) {
1372
- _context7.next = 8;
1373
- break;
1374
- }
1299
+ return function sendPaymentReceipt(_x8) {
1300
+ return _ref13.apply(this, arguments);
1301
+ };
1302
+ }();
1303
+ var createApplePaySession = /*#__PURE__*/function () {
1304
+ var _ref14 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(body) {
1305
+ return runtime_1.wrap(function _callee8$(_context8) {
1306
+ while (1) {
1307
+ switch (_context8.prev = _context8.next) {
1308
+ case 0:
1309
+ return _context8.abrupt("return", request("/apple-pay/sessions", {
1310
+ method: 'POST',
1311
+ body: body
1312
+ }));
1375
1313
 
1376
- throw result;
1314
+ case 1:
1315
+ case "end":
1316
+ return _context8.stop();
1317
+ }
1318
+ }
1319
+ }, _callee8);
1320
+ }));
1377
1321
 
1378
- case 8:
1379
- return _context7.abrupt("return", result);
1322
+ return function createApplePaySession(_x9) {
1323
+ return _ref14.apply(this, arguments);
1324
+ };
1325
+ }();
1326
+ var calculateFinancing = /*#__PURE__*/function () {
1327
+ var _ref15 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(req) {
1328
+ return runtime_1.wrap(function _callee9$(_context9) {
1329
+ while (1) {
1330
+ switch (_context9.prev = _context9.next) {
1331
+ case 0:
1332
+ return _context9.abrupt("return", request("/calculate-financing?" + stringify(req)));
1380
1333
 
1381
- case 9:
1334
+ case 1:
1382
1335
  case "end":
1383
- return _context7.stop();
1336
+ return _context9.stop();
1384
1337
  }
1385
1338
  }
1386
- }, _callee7);
1339
+ }, _callee9);
1387
1340
  }));
1388
1341
 
1389
- return function createApplePaySession(_x7) {
1390
- return _ref12.apply(this, arguments);
1342
+ return function calculateFinancing(_x10) {
1343
+ return _ref15.apply(this, arguments);
1391
1344
  };
1392
1345
  }();
1393
1346
 
@@ -1399,7 +1352,8 @@ var _api = {
1399
1352
  confirmPayment: confirmPayment,
1400
1353
  createPayment: createPayment,
1401
1354
  sendPaymentReceipt: sendPaymentReceipt,
1402
- createApplePaySession: createApplePaySession
1355
+ createApplePaySession: createApplePaySession,
1356
+ calculateFinancing: calculateFinancing
1403
1357
  };
1404
1358
 
1405
1359
  var postRobot = createCommonjsModule(function (module, exports) {
@@ -14148,7 +14102,7 @@ var getCreateTokenFunction = function getCreateTokenFunction(ref) {
14148
14102
  };
14149
14103
 
14150
14104
  var createToken$1 = /*#__PURE__*/function () {
14151
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(component) {
14105
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(component, options) {
14152
14106
  var _yield$getCreateToken, data;
14153
14107
 
14154
14108
  return runtime_1.wrap(function _callee$(_context) {
@@ -14156,7 +14110,7 @@ var createToken$1 = /*#__PURE__*/function () {
14156
14110
  switch (_context.prev = _context.next) {
14157
14111
  case 0:
14158
14112
  _context.next = 2;
14159
- return getCreateTokenFunction(component)();
14113
+ return getCreateTokenFunction(component)(options);
14160
14114
 
14161
14115
  case 2:
14162
14116
  _yield$getCreateToken = _context.sent;
@@ -14171,7 +14125,7 @@ var createToken$1 = /*#__PURE__*/function () {
14171
14125
  }, _callee);
14172
14126
  }));
14173
14127
 
14174
- return function createToken(_x) {
14128
+ return function createToken(_x, _x2) {
14175
14129
  return _ref.apply(this, arguments);
14176
14130
  };
14177
14131
  }();
@@ -14244,12 +14198,16 @@ var options = {
14244
14198
  },
14245
14199
  validate: validateComponentProps,
14246
14200
  containerTemplate: function containerTemplate$1(params) {
14247
- params.state.__createToken = function () {
14201
+ params.state.__createToken = function (data) {
14202
+ if (data === void 0) {
14203
+ data = {};
14204
+ }
14205
+
14248
14206
  if (!params.frame) {
14249
14207
  throw new Error('CardInput instance is not registered');
14250
14208
  }
14251
14209
 
14252
- return postRobot$3.send(params.frame.contentWindow, CREATE_TOKEN_EVENT, {}, {
14210
+ return postRobot$3.send(params.frame.contentWindow, CREATE_TOKEN_EVENT, data, {
14253
14211
  domain: config.domain
14254
14212
  });
14255
14213
  };
@@ -14322,6 +14280,10 @@ var options$1 = {
14322
14280
  type: zoid.PROP_TYPE.OBJECT,
14323
14281
  required: false
14324
14282
  },
14283
+ paymentMethod: {
14284
+ type: zoid.PROP_TYPE.OBJECT,
14285
+ required: false
14286
+ },
14325
14287
  billingDetails: {
14326
14288
  type: zoid.PROP_TYPE.OBJECT,
14327
14289
  required: false
@@ -14601,12 +14563,20 @@ var options$2 = {
14601
14563
  alias: 'innerStyle',
14602
14564
  required: false
14603
14565
  },
14604
- __onLoadPayPal: {
14566
+ __getConfig: {
14605
14567
  type: zoid.PROP_TYPE.FUNCTION,
14606
14568
  required: false,
14607
14569
  value: function value(_ref2) {
14608
- var props = _ref2.props,
14609
- state = _ref2.state;
14570
+ var props = _ref2.props;
14571
+ return getPaymentMethods.bind(null, props);
14572
+ }
14573
+ },
14574
+ __onLoadPayPal: {
14575
+ type: zoid.PROP_TYPE.FUNCTION,
14576
+ required: false,
14577
+ value: function value(_ref3) {
14578
+ var props = _ref3.props,
14579
+ state = _ref3.state;
14610
14580
  return onLoadPaypal.bind(null, props, state);
14611
14581
  }
14612
14582
  }
@@ -14731,7 +14701,7 @@ var options$3 = {
14731
14701
  type: zoid.PROP_TYPE.FUNCTION,
14732
14702
  required: false
14733
14703
  },
14734
- onSuccess: {
14704
+ onSubmit: {
14735
14705
  type: zoid.PROP_TYPE.FUNCTION,
14736
14706
  required: false
14737
14707
  },
@@ -14815,15 +14785,27 @@ var options$4 = {
14815
14785
  alias: 'innerStyle',
14816
14786
  required: false
14817
14787
  },
14818
- __onClick: {
14788
+ __getConfig: {
14819
14789
  type: zoid.PROP_TYPE.FUNCTION,
14820
14790
  required: false,
14821
14791
  value: function value(_ref) {
14822
14792
  var props = _ref.props;
14793
+ return getPaymentMethods.bind(null, props);
14794
+ }
14795
+ },
14796
+ __onClick: {
14797
+ type: zoid.PROP_TYPE.FUNCTION,
14798
+ required: false,
14799
+ value: function value(_ref2) {
14800
+ var props = _ref2.props;
14823
14801
  var rootNode = document.createElement('div');
14824
14802
  document.body.appendChild(rootNode);
14825
- return function () {
14803
+ return function (_ref3) {
14804
+ var amount = _ref3.amount,
14805
+ currency = _ref3.currency;
14826
14806
  var bizumModal = new BizumModal(_extends({}, props, {
14807
+ amount: amount,
14808
+ currency: currency,
14827
14809
  onClose: function onClose() {
14828
14810
  window.onpopstate = null;
14829
14811
  document.body.style.overflow = '';
@@ -14849,50 +14831,654 @@ var options$4 = {
14849
14831
  };
14850
14832
  var Bizum = /*#__PURE__*/zoid.create(options$4);
14851
14833
 
14852
- // @ts-ignore
14853
- var options$5 = {
14854
- tag: 'monei-google-pay',
14855
- url: config.googlePayUrl,
14856
- dimensions: {
14857
- width: '100%',
14858
- height: '0'
14859
- },
14860
- autoResize: {
14861
- width: false,
14862
- height: true
14863
- },
14864
- validate: validateComponentProps,
14865
- containerTemplate: containerTemplate,
14866
- prerenderTemplate: function prerenderTemplate() {
14867
- return undefined;
14868
- },
14869
- props: {
14870
- accountId: {
14871
- type: zoid.PROP_TYPE.STRING,
14872
- required: false
14873
- },
14874
- sessionId: {
14875
- type: zoid.PROP_TYPE.STRING,
14876
- required: false
14877
- },
14878
- paymentId: {
14879
- type: zoid.PROP_TYPE.STRING,
14880
- required: false
14881
- },
14882
- amount: {
14883
- type: zoid.PROP_TYPE.NUMBER,
14884
- required: false
14885
- },
14886
- currency: {
14887
- type: zoid.PROP_TYPE.STRING,
14888
- required: false
14889
- },
14890
- language: {
14891
- type: zoid.PROP_TYPE.STRING,
14892
- required: false
14893
- },
14894
- onError: {
14895
- type: zoid.PROP_TYPE.FUNCTION,
14834
+ var EVENT$1;
14835
+
14836
+ (function (EVENT) {
14837
+ EVENT["BEFORE_CLOSE"] = "BEFORE_CLOSE";
14838
+ })(EVENT$1 || (EVENT$1 = {}));
14839
+
14840
+ function containerTemplate$2(_ref) {
14841
+ var uid = _ref.uid,
14842
+ frame = _ref.frame,
14843
+ prerenderFrame = _ref.prerenderFrame,
14844
+ doc = _ref.doc,
14845
+ props = _ref.props,
14846
+ event = _ref.event,
14847
+ _ref$dimensions = _ref.dimensions,
14848
+ width = _ref$dimensions.width,
14849
+ height = _ref$dimensions.height;
14850
+
14851
+ if (!frame || !prerenderFrame) {
14852
+ return;
14853
+ }
14854
+
14855
+ var div = doc.createElement('div');
14856
+ var backdrop = doc.createElement('div');
14857
+ div.setAttribute('id', uid);
14858
+ backdrop.classList.add('backdrop');
14859
+ div.appendChild(backdrop);
14860
+ var style = doc.createElement('style');
14861
+
14862
+ if (props.cspNonce) {
14863
+ style.setAttribute('nonce', props.cspNonce);
14864
+ }
14865
+
14866
+ style.appendChild(doc.createTextNode("\n #" + uid + " {\n position: fixed;\n overflow: hidden;\n display: block;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n width: " + width + ";\n height: " + height + ";\n z-index: 99999;\n }\n #" + uid + " > .backdrop {\n position: fixed;\n display: block;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(40, 40, 40, 0.7);\n transition: opacity 0.35s ease-in-out;\n opacity: 0;\n will-change: opacity;\n }\n #" + uid + " > .backdrop." + CLASS.VISIBLE + " {\n opacity: 1;\n }\n #" + uid + " > iframe {\n display: inline-block;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n transition: all .2s ease-in-out;\n }\n #" + uid + " > iframe." + CLASS.INVISIBLE + " {\n opacity: 0;\n }\n #" + uid + " > iframe." + CLASS.VISIBLE + " {\n opacity: 1;\n }\n "));
14867
+ div.appendChild(frame);
14868
+ div.appendChild(prerenderFrame);
14869
+ div.appendChild(style);
14870
+ prerenderFrame.classList.add(CLASS.VISIBLE);
14871
+ frame.classList.add(CLASS.INVISIBLE);
14872
+ setTimeout(function () {
14873
+ backdrop.classList.add(CLASS.VISIBLE);
14874
+ }, 1);
14875
+ event.on(zoid.EVENT.RENDERED, function () {
14876
+ prerenderFrame.classList.remove(CLASS.VISIBLE);
14877
+ prerenderFrame.classList.add(CLASS.INVISIBLE);
14878
+ frame.classList.remove(CLASS.INVISIBLE);
14879
+ frame.classList.add(CLASS.VISIBLE);
14880
+ setTimeout(function () {
14881
+ belter$3.destroyElement(prerenderFrame);
14882
+ }, 1);
14883
+ });
14884
+ event.on(EVENT$1.BEFORE_CLOSE, function () {
14885
+ backdrop.classList.remove(CLASS.VISIBLE);
14886
+ });
14887
+ event.on(zoid.EVENT.RESIZE, function (_ref2) {
14888
+ var newWidth = _ref2.width,
14889
+ newHeight = _ref2.height;
14890
+
14891
+ if (typeof newWidth === 'number') {
14892
+ div.style.width = belter$3.toCSS(newWidth);
14893
+ }
14894
+
14895
+ if (typeof newHeight === 'number') {
14896
+ div.style.height = belter$3.toCSS(newHeight);
14897
+ }
14898
+ });
14899
+ return div;
14900
+ }
14901
+
14902
+ // @ts-ignore
14903
+ var options$5 = {
14904
+ tag: 'monei-cofidis',
14905
+ url: config.cofidisUrl,
14906
+ dimensions: {
14907
+ width: '100%',
14908
+ height: '100%'
14909
+ },
14910
+ autoResize: {
14911
+ width: false,
14912
+ height: false
14913
+ },
14914
+ prerenderTemplate: function prerenderTemplate() {
14915
+ return undefined;
14916
+ },
14917
+ containerTemplate: containerTemplate$2,
14918
+ props: {
14919
+ paymentId: {
14920
+ type: zoid.PROP_TYPE.STRING,
14921
+ required: false
14922
+ },
14923
+ amount: {
14924
+ type: zoid.PROP_TYPE.NUMBER,
14925
+ required: false
14926
+ },
14927
+ currency: {
14928
+ type: zoid.PROP_TYPE.STRING,
14929
+ required: false
14930
+ },
14931
+ language: {
14932
+ type: zoid.PROP_TYPE.STRING,
14933
+ required: false
14934
+ },
14935
+ onError: {
14936
+ type: zoid.PROP_TYPE.FUNCTION,
14937
+ required: false
14938
+ },
14939
+ onLoad: {
14940
+ type: zoid.PROP_TYPE.FUNCTION,
14941
+ required: false
14942
+ },
14943
+ onSubmit: {
14944
+ type: zoid.PROP_TYPE.FUNCTION,
14945
+ required: false
14946
+ },
14947
+ onOpen: {
14948
+ type: zoid.PROP_TYPE.FUNCTION,
14949
+ required: false
14950
+ },
14951
+ onBeforeClose: {
14952
+ type: zoid.PROP_TYPE.FUNCTION,
14953
+ required: false,
14954
+ "default": function _default(_ref) {
14955
+ var event = _ref.event;
14956
+ return function () {
14957
+ event.trigger(EVENT$1.BEFORE_CLOSE);
14958
+ };
14959
+ }
14960
+ }
14961
+ }
14962
+ };
14963
+ var CofidisModal = /*#__PURE__*/zoid.create(options$5);
14964
+
14965
+ // @ts-ignore
14966
+ var options$6 = {
14967
+ tag: 'monei-cofidis-widget',
14968
+ url: config.cofidisWidgetUrl,
14969
+ dimensions: {
14970
+ width: '100%',
14971
+ height: '46px'
14972
+ },
14973
+ autoResize: {
14974
+ width: false,
14975
+ height: true
14976
+ },
14977
+ prerenderTemplate: function prerenderTemplate() {
14978
+ return undefined;
14979
+ },
14980
+ props: {
14981
+ accountId: {
14982
+ type: zoid.PROP_TYPE.STRING,
14983
+ required: true
14984
+ },
14985
+ amount: {
14986
+ type: zoid.PROP_TYPE.NUMBER,
14987
+ required: false
14988
+ },
14989
+ amountInt: {
14990
+ type: zoid.PROP_TYPE.NUMBER,
14991
+ required: false
14992
+ },
14993
+ language: {
14994
+ type: zoid.PROP_TYPE.STRING,
14995
+ required: false,
14996
+ "default": function _default() {
14997
+ return 'es';
14998
+ }
14999
+ },
15000
+ showLogo: {
15001
+ type: zoid.PROP_TYPE.BOOLEAN,
15002
+ required: false
15003
+ },
15004
+ style: {
15005
+ type: zoid.PROP_TYPE.OBJECT,
15006
+ alias: 'innerStyle',
15007
+ required: false
15008
+ },
15009
+ onError: {
15010
+ type: zoid.PROP_TYPE.FUNCTION,
15011
+ required: false
15012
+ },
15013
+ onLoad: {
15014
+ type: zoid.PROP_TYPE.FUNCTION,
15015
+ required: false
15016
+ },
15017
+ __onClick: {
15018
+ type: zoid.PROP_TYPE.FUNCTION,
15019
+ required: false,
15020
+ value: function value() {
15021
+ return function (url) {
15022
+ window.open(url, '_blank');
15023
+ };
15024
+ }
15025
+ }
15026
+ }
15027
+ };
15028
+ var CofidisWidget = /*#__PURE__*/zoid.create(options$6);
15029
+
15030
+ var options$7 = {
15031
+ tag: 'monei-cofidis-button',
15032
+ url: config.cofidisButtonUrl,
15033
+ dimensions: {
15034
+ width: '100%',
15035
+ height: '45px'
15036
+ },
15037
+ autoResize: {
15038
+ width: false,
15039
+ height: true
15040
+ },
15041
+ validate: validateComponentProps,
15042
+ containerTemplate: containerTemplate,
15043
+ prerenderTemplate: function prerenderTemplate() {
15044
+ return undefined;
15045
+ },
15046
+ props: {
15047
+ paymentId: {
15048
+ type: zoid.PROP_TYPE.STRING,
15049
+ required: false
15050
+ },
15051
+ language: {
15052
+ type: zoid.PROP_TYPE.STRING,
15053
+ required: false
15054
+ },
15055
+ hint: {
15056
+ type: zoid.PROP_TYPE.BOOLEAN,
15057
+ "default": function _default() {
15058
+ return true;
15059
+ },
15060
+ required: false
15061
+ },
15062
+ onError: {
15063
+ type: zoid.PROP_TYPE.FUNCTION,
15064
+ required: false
15065
+ },
15066
+ onLoad: {
15067
+ type: zoid.PROP_TYPE.FUNCTION,
15068
+ required: false
15069
+ },
15070
+ onOpen: {
15071
+ type: zoid.PROP_TYPE.FUNCTION,
15072
+ required: false
15073
+ },
15074
+ style: {
15075
+ type: zoid.PROP_TYPE.OBJECT,
15076
+ alias: 'innerStyle',
15077
+ required: false
15078
+ },
15079
+ __getConfig: {
15080
+ type: zoid.PROP_TYPE.FUNCTION,
15081
+ required: false,
15082
+ value: function value(_ref) {
15083
+ var props = _ref.props;
15084
+ return getPaymentMethods.bind(null, props);
15085
+ }
15086
+ },
15087
+ __onHintClick: {
15088
+ type: zoid.PROP_TYPE.FUNCTION,
15089
+ required: false,
15090
+ value: function value() {
15091
+ return function (url) {
15092
+ window.open(url, '_blank');
15093
+ };
15094
+ }
15095
+ },
15096
+ __onClick: {
15097
+ type: zoid.PROP_TYPE.FUNCTION,
15098
+ required: false,
15099
+ value: function value(_ref2) {
15100
+ var props = _ref2.props;
15101
+ var rootNode = document.createElement('div');
15102
+ document.body.appendChild(rootNode);
15103
+ return function (_ref3) {
15104
+ var amount = _ref3.amount,
15105
+ currency = _ref3.currency,
15106
+ accountId = _ref3.accountId;
15107
+ var cofidisModal = new CofidisModal(_extends({}, props, {
15108
+ amount: amount,
15109
+ currency: currency,
15110
+ accountId: accountId,
15111
+ onClose: function onClose() {
15112
+ window.onpopstate = null;
15113
+ document.body.style.overflow = '';
15114
+ },
15115
+ isOpen: true
15116
+ }));
15117
+ window.history.pushState(null, '', window.location.href);
15118
+
15119
+ window.onpopstate = function () {
15120
+ return cofidisModal.updateProps({
15121
+ isOpen: false
15122
+ });
15123
+ };
15124
+
15125
+ Object.assign(document.body.style, {
15126
+ overflow: 'hidden'
15127
+ });
15128
+ return cofidisModal.render(rootNode);
15129
+ };
15130
+ }
15131
+ }
15132
+ }
15133
+ };
15134
+ var Cofidis = /*#__PURE__*/zoid.create(options$7);
15135
+
15136
+ var EVENT$2;
15137
+
15138
+ (function (EVENT) {
15139
+ EVENT["BEFORE_CLOSE"] = "BEFORE_CLOSE";
15140
+ })(EVENT$2 || (EVENT$2 = {}));
15141
+
15142
+ function containerTemplate$3(_ref) {
15143
+ var uid = _ref.uid,
15144
+ frame = _ref.frame,
15145
+ prerenderFrame = _ref.prerenderFrame,
15146
+ doc = _ref.doc,
15147
+ props = _ref.props,
15148
+ event = _ref.event,
15149
+ _ref$dimensions = _ref.dimensions,
15150
+ width = _ref$dimensions.width,
15151
+ height = _ref$dimensions.height;
15152
+
15153
+ if (!frame || !prerenderFrame) {
15154
+ return;
15155
+ }
15156
+
15157
+ var div = doc.createElement('div');
15158
+ var backdrop = doc.createElement('div');
15159
+ div.setAttribute('id', uid);
15160
+ backdrop.classList.add('backdrop');
15161
+ div.appendChild(backdrop);
15162
+ var style = doc.createElement('style');
15163
+
15164
+ if (props.cspNonce) {
15165
+ style.setAttribute('nonce', props.cspNonce);
15166
+ }
15167
+
15168
+ style.appendChild(doc.createTextNode("\n #" + uid + " {\n position: fixed;\n overflow: hidden;\n display: block;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n width: " + width + ";\n height: " + height + ";\n z-index: 99999;\n }\n #" + uid + " > .backdrop {\n position: fixed;\n display: block;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(40, 40, 40, 0.7);\n transition: opacity 0.35s ease-in-out;\n opacity: 0;\n will-change: opacity;\n }\n #" + uid + " > .backdrop." + CLASS.VISIBLE + " {\n opacity: 1;\n }\n #" + uid + " > iframe {\n display: inline-block;\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n transition: all .2s ease-in-out;\n }\n #" + uid + " > iframe." + CLASS.INVISIBLE + " {\n opacity: 0;\n }\n #" + uid + " > iframe." + CLASS.VISIBLE + " {\n opacity: 1;\n }\n "));
15169
+ div.appendChild(frame);
15170
+ div.appendChild(prerenderFrame);
15171
+ div.appendChild(style);
15172
+ prerenderFrame.classList.add(CLASS.VISIBLE);
15173
+ frame.classList.add(CLASS.INVISIBLE);
15174
+ setTimeout(function () {
15175
+ backdrop.classList.add(CLASS.VISIBLE);
15176
+ }, 1);
15177
+ event.on(zoid.EVENT.RENDERED, function () {
15178
+ prerenderFrame.classList.remove(CLASS.VISIBLE);
15179
+ prerenderFrame.classList.add(CLASS.INVISIBLE);
15180
+ frame.classList.remove(CLASS.INVISIBLE);
15181
+ frame.classList.add(CLASS.VISIBLE);
15182
+ setTimeout(function () {
15183
+ belter$3.destroyElement(prerenderFrame);
15184
+ }, 1);
15185
+ });
15186
+ event.on(EVENT$2.BEFORE_CLOSE, function () {
15187
+ backdrop.classList.remove(CLASS.VISIBLE);
15188
+ });
15189
+ event.on(zoid.EVENT.RESIZE, function (_ref2) {
15190
+ var newWidth = _ref2.width,
15191
+ newHeight = _ref2.height;
15192
+
15193
+ if (typeof newWidth === 'number') {
15194
+ div.style.width = belter$3.toCSS(newWidth);
15195
+ }
15196
+
15197
+ if (typeof newHeight === 'number') {
15198
+ div.style.height = belter$3.toCSS(newHeight);
15199
+ }
15200
+ });
15201
+ return div;
15202
+ }
15203
+
15204
+ // @ts-ignore
15205
+ var options$8 = {
15206
+ tag: 'monei-cofidis-loan',
15207
+ url: config.cofidisLoanUrl,
15208
+ dimensions: {
15209
+ width: '100%',
15210
+ height: '100%'
15211
+ },
15212
+ autoResize: {
15213
+ width: false,
15214
+ height: false
15215
+ },
15216
+ prerenderTemplate: function prerenderTemplate() {
15217
+ return undefined;
15218
+ },
15219
+ containerTemplate: containerTemplate$3,
15220
+ props: {
15221
+ paymentId: {
15222
+ type: zoid.PROP_TYPE.STRING,
15223
+ required: false
15224
+ },
15225
+ amount: {
15226
+ type: zoid.PROP_TYPE.NUMBER,
15227
+ required: false
15228
+ },
15229
+ currency: {
15230
+ type: zoid.PROP_TYPE.STRING,
15231
+ required: false
15232
+ },
15233
+ language: {
15234
+ type: zoid.PROP_TYPE.STRING,
15235
+ required: false
15236
+ },
15237
+ onError: {
15238
+ type: zoid.PROP_TYPE.FUNCTION,
15239
+ required: false
15240
+ },
15241
+ onLoad: {
15242
+ type: zoid.PROP_TYPE.FUNCTION,
15243
+ required: false
15244
+ },
15245
+ onSubmit: {
15246
+ type: zoid.PROP_TYPE.FUNCTION,
15247
+ required: false
15248
+ },
15249
+ onOpen: {
15250
+ type: zoid.PROP_TYPE.FUNCTION,
15251
+ required: false
15252
+ },
15253
+ onBeforeClose: {
15254
+ type: zoid.PROP_TYPE.FUNCTION,
15255
+ required: false,
15256
+ "default": function _default(_ref) {
15257
+ var event = _ref.event;
15258
+ return function () {
15259
+ event.trigger(EVENT$2.BEFORE_CLOSE);
15260
+ };
15261
+ }
15262
+ }
15263
+ }
15264
+ };
15265
+ var CofidisLoanModal = /*#__PURE__*/zoid.create(options$8);
15266
+
15267
+ // @ts-ignore
15268
+ var options$9 = {
15269
+ tag: 'monei-cofidis-loan-widget',
15270
+ url: config.cofidisLoanWidgetUrl,
15271
+ dimensions: {
15272
+ width: '100%',
15273
+ height: '46px'
15274
+ },
15275
+ autoResize: {
15276
+ width: false,
15277
+ height: true
15278
+ },
15279
+ prerenderTemplate: function prerenderTemplate() {
15280
+ return undefined;
15281
+ },
15282
+ props: {
15283
+ accountId: {
15284
+ type: zoid.PROP_TYPE.STRING,
15285
+ required: true
15286
+ },
15287
+ amount: {
15288
+ type: zoid.PROP_TYPE.NUMBER,
15289
+ required: false
15290
+ },
15291
+ amountInt: {
15292
+ type: zoid.PROP_TYPE.NUMBER,
15293
+ required: false
15294
+ },
15295
+ language: {
15296
+ type: zoid.PROP_TYPE.STRING,
15297
+ required: false,
15298
+ "default": function _default() {
15299
+ return 'es';
15300
+ }
15301
+ },
15302
+ showLogo: {
15303
+ type: zoid.PROP_TYPE.BOOLEAN,
15304
+ required: false
15305
+ },
15306
+ style: {
15307
+ type: zoid.PROP_TYPE.OBJECT,
15308
+ alias: 'innerStyle',
15309
+ required: false
15310
+ },
15311
+ onError: {
15312
+ type: zoid.PROP_TYPE.FUNCTION,
15313
+ required: false
15314
+ },
15315
+ onLoad: {
15316
+ type: zoid.PROP_TYPE.FUNCTION,
15317
+ required: false
15318
+ },
15319
+ __onClick: {
15320
+ type: zoid.PROP_TYPE.FUNCTION,
15321
+ required: false,
15322
+ value: function value() {
15323
+ return function (url) {
15324
+ window.open(url, '_blank');
15325
+ };
15326
+ }
15327
+ }
15328
+ }
15329
+ };
15330
+ var CofidisLoanWidget = /*#__PURE__*/zoid.create(options$9);
15331
+
15332
+ var options$a = {
15333
+ tag: 'monei-cofidis-loan-button',
15334
+ url: config.cofidisLoanButtonUrl,
15335
+ dimensions: {
15336
+ width: '100%',
15337
+ height: '45px'
15338
+ },
15339
+ autoResize: {
15340
+ width: false,
15341
+ height: true
15342
+ },
15343
+ validate: validateComponentProps,
15344
+ containerTemplate: containerTemplate,
15345
+ prerenderTemplate: function prerenderTemplate() {
15346
+ return undefined;
15347
+ },
15348
+ props: {
15349
+ paymentId: {
15350
+ type: zoid.PROP_TYPE.STRING,
15351
+ required: false
15352
+ },
15353
+ language: {
15354
+ type: zoid.PROP_TYPE.STRING,
15355
+ required: false
15356
+ },
15357
+ hint: {
15358
+ type: zoid.PROP_TYPE.BOOLEAN,
15359
+ "default": function _default() {
15360
+ return true;
15361
+ },
15362
+ required: false
15363
+ },
15364
+ onError: {
15365
+ type: zoid.PROP_TYPE.FUNCTION,
15366
+ required: false
15367
+ },
15368
+ onLoad: {
15369
+ type: zoid.PROP_TYPE.FUNCTION,
15370
+ required: false
15371
+ },
15372
+ onOpen: {
15373
+ type: zoid.PROP_TYPE.FUNCTION,
15374
+ required: false
15375
+ },
15376
+ style: {
15377
+ type: zoid.PROP_TYPE.OBJECT,
15378
+ alias: 'innerStyle',
15379
+ required: false
15380
+ },
15381
+ __getConfig: {
15382
+ type: zoid.PROP_TYPE.FUNCTION,
15383
+ required: false,
15384
+ value: function value(_ref) {
15385
+ var props = _ref.props;
15386
+ return getPaymentMethods.bind(null, props);
15387
+ }
15388
+ },
15389
+ __onHintClick: {
15390
+ type: zoid.PROP_TYPE.FUNCTION,
15391
+ required: false,
15392
+ value: function value() {
15393
+ return function (url) {
15394
+ window.open(url, '_blank');
15395
+ };
15396
+ }
15397
+ },
15398
+ __onClick: {
15399
+ type: zoid.PROP_TYPE.FUNCTION,
15400
+ required: false,
15401
+ value: function value(_ref2) {
15402
+ var props = _ref2.props;
15403
+ var rootNode = document.createElement('div');
15404
+ document.body.appendChild(rootNode);
15405
+ return function (_ref3) {
15406
+ var amount = _ref3.amount,
15407
+ currency = _ref3.currency,
15408
+ accountId = _ref3.accountId;
15409
+ var cofidisModal = new CofidisLoanModal(_extends({}, props, {
15410
+ amount: amount,
15411
+ currency: currency,
15412
+ accountId: accountId,
15413
+ onClose: function onClose() {
15414
+ window.onpopstate = null;
15415
+ document.body.style.overflow = '';
15416
+ },
15417
+ isOpen: true
15418
+ }));
15419
+ window.history.pushState(null, '', window.location.href);
15420
+
15421
+ window.onpopstate = function () {
15422
+ return cofidisModal.updateProps({
15423
+ isOpen: false
15424
+ });
15425
+ };
15426
+
15427
+ Object.assign(document.body.style, {
15428
+ overflow: 'hidden'
15429
+ });
15430
+ return cofidisModal.render(rootNode);
15431
+ };
15432
+ }
15433
+ }
15434
+ }
15435
+ };
15436
+ var CofidisLoan = /*#__PURE__*/zoid.create(options$a);
15437
+
15438
+ // @ts-ignore
15439
+ var options$b = {
15440
+ tag: 'monei-google-pay',
15441
+ url: config.googlePayUrl,
15442
+ dimensions: {
15443
+ width: '100%',
15444
+ height: '0'
15445
+ },
15446
+ autoResize: {
15447
+ width: false,
15448
+ height: true
15449
+ },
15450
+ validate: validateComponentProps,
15451
+ containerTemplate: containerTemplate,
15452
+ prerenderTemplate: function prerenderTemplate() {
15453
+ return undefined;
15454
+ },
15455
+ props: {
15456
+ accountId: {
15457
+ type: zoid.PROP_TYPE.STRING,
15458
+ required: false
15459
+ },
15460
+ sessionId: {
15461
+ type: zoid.PROP_TYPE.STRING,
15462
+ required: false
15463
+ },
15464
+ paymentId: {
15465
+ type: zoid.PROP_TYPE.STRING,
15466
+ required: false
15467
+ },
15468
+ amount: {
15469
+ type: zoid.PROP_TYPE.NUMBER,
15470
+ required: false
15471
+ },
15472
+ currency: {
15473
+ type: zoid.PROP_TYPE.STRING,
15474
+ required: false
15475
+ },
15476
+ language: {
15477
+ type: zoid.PROP_TYPE.STRING,
15478
+ required: false
15479
+ },
15480
+ onError: {
15481
+ type: zoid.PROP_TYPE.FUNCTION,
14896
15482
  required: false
14897
15483
  },
14898
15484
  onLoad: {
@@ -14911,80 +15497,136 @@ var options$5 = {
14911
15497
  type: zoid.PROP_TYPE.OBJECT,
14912
15498
  alias: 'innerStyle',
14913
15499
  required: false
15500
+ },
15501
+ __getConfig: {
15502
+ type: zoid.PROP_TYPE.FUNCTION,
15503
+ required: false,
15504
+ value: function value(_ref) {
15505
+ var props = _ref.props;
15506
+ return getPaymentMethods.bind(null, props);
15507
+ }
14914
15508
  }
14915
15509
  }
14916
15510
  };
14917
- var GooglePay = /*#__PURE__*/zoid.create(options$5);
15511
+ var GooglePay = /*#__PURE__*/zoid.create(options$b);
14918
15512
 
14919
15513
  var onApplePayButtonClicked = /*#__PURE__*/function () {
14920
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(props, paymentMethodData, paymentDetails, paymentOptions, context) {
14921
- var request, response, paymentToken, token, result;
14922
- return runtime_1.wrap(function _callee$(_context) {
15514
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(props, request, context) {
15515
+ var session;
15516
+ return runtime_1.wrap(function _callee3$(_context3) {
14923
15517
  while (1) {
14924
- switch (_context.prev = _context.next) {
15518
+ switch (_context3.prev = _context3.next) {
14925
15519
  case 0:
14926
- request = new window.PaymentRequest(paymentMethodData, paymentDetails, paymentOptions); // @ts-ignore
15520
+ session = new window.ApplePaySession(3, request);
14927
15521
 
14928
- request.onmerchantvalidation = function (event) {
14929
- event.complete(createApplePaySession(_extends({}, context, {
14930
- validationUrl: event.validationURL
14931
- })));
14932
- };
15522
+ session.onvalidatemerchant = /*#__PURE__*/function () {
15523
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
15524
+ var merchantSession;
15525
+ return runtime_1.wrap(function _callee$(_context) {
15526
+ while (1) {
15527
+ switch (_context.prev = _context.next) {
15528
+ case 0:
15529
+ _context.prev = 0;
15530
+ _context.next = 3;
15531
+ return createApplePaySession(_extends({}, context, {
15532
+ validationUrl: event.validationURL
15533
+ }));
14933
15534
 
14934
- _context.next = 4;
14935
- return request.show();
15535
+ case 3:
15536
+ merchantSession = _context.sent;
15537
+ session.completeMerchantValidation(merchantSession);
15538
+ _context.next = 10;
15539
+ break;
14936
15540
 
14937
- case 4:
14938
- response = _context.sent;
14939
- paymentToken = JSON.stringify(response.details.token);
14940
- token = window.btoa(paymentToken);
14941
- _context.prev = 7;
14942
- _context.next = 10;
14943
- return createToken({
14944
- accountId: props.accountId,
14945
- paymentId: props.paymentId,
14946
- sessionId: props.sessionId,
14947
- paymentMethod: {
14948
- applePay: {
14949
- token: token
14950
- }
14951
- }
14952
- });
15541
+ case 7:
15542
+ _context.prev = 7;
15543
+ _context.t0 = _context["catch"](0);
15544
+ session.abort();
14953
15545
 
14954
- case 10:
14955
- result = _context.sent;
14956
- props.onSubmit({
14957
- token: result.paymentToken,
14958
- error: result.error
14959
- });
14960
- _context.next = 14;
14961
- return response.complete('success');
15546
+ case 10:
15547
+ case "end":
15548
+ return _context.stop();
15549
+ }
15550
+ }
15551
+ }, _callee, null, [[0, 7]]);
15552
+ }));
14962
15553
 
14963
- case 14:
14964
- _context.next = 21;
14965
- break;
15554
+ return function (_x4) {
15555
+ return _ref2.apply(this, arguments);
15556
+ };
15557
+ }();
14966
15558
 
14967
- case 16:
14968
- _context.prev = 16;
14969
- _context.t0 = _context["catch"](7);
14970
- props.onError == null ? void 0 : props.onError(_context.t0);
14971
- _context.next = 21;
14972
- return response.complete('fail');
15559
+ session.onpaymentauthorized = /*#__PURE__*/function () {
15560
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(event) {
15561
+ var paymentToken, token, result;
15562
+ return runtime_1.wrap(function _callee2$(_context2) {
15563
+ while (1) {
15564
+ switch (_context2.prev = _context2.next) {
15565
+ case 0:
15566
+ paymentToken = JSON.stringify(event.payment.token);
15567
+ token = window.btoa(paymentToken);
15568
+ _context2.prev = 2;
15569
+ _context2.next = 5;
15570
+ return createToken({
15571
+ accountId: props.accountId,
15572
+ paymentId: props.paymentId,
15573
+ sessionId: props.sessionId,
15574
+ paymentMethod: {
15575
+ applePay: {
15576
+ token: token
15577
+ }
15578
+ }
15579
+ });
15580
+
15581
+ case 5:
15582
+ result = _context2.sent;
15583
+ props.onSubmit({
15584
+ token: result.paymentToken,
15585
+ error: result.error
15586
+ });
15587
+ session.completePayment({
15588
+ status: window.ApplePaySession.STATUS_SUCCESS
15589
+ });
15590
+ _context2.next = 14;
15591
+ break;
15592
+
15593
+ case 10:
15594
+ _context2.prev = 10;
15595
+ _context2.t0 = _context2["catch"](2);
15596
+ props.onError == null ? void 0 : props.onError(_context2.t0);
15597
+ session.completePayment({
15598
+ status: window.ApplePaySession.STATUS_FAILURE
15599
+ });
15600
+
15601
+ case 14:
15602
+ case "end":
15603
+ return _context2.stop();
15604
+ }
15605
+ }
15606
+ }, _callee2, null, [[2, 10]]);
15607
+ }));
15608
+
15609
+ return function (_x5) {
15610
+ return _ref3.apply(this, arguments);
15611
+ };
15612
+ }();
14973
15613
 
14974
- case 21:
15614
+ session.begin();
15615
+
15616
+ case 4:
14975
15617
  case "end":
14976
- return _context.stop();
15618
+ return _context3.stop();
14977
15619
  }
14978
15620
  }
14979
- }, _callee, null, [[7, 16]]);
15621
+ }, _callee3);
14980
15622
  }));
14981
15623
 
14982
- return function onApplePayButtonClicked(_x, _x2, _x3, _x4, _x5) {
15624
+ return function onApplePayButtonClicked(_x, _x2, _x3) {
14983
15625
  return _ref.apply(this, arguments);
14984
15626
  };
14985
15627
  }();
14986
15628
 
14987
- var options$6 = {
15629
+ var options$c = {
14988
15630
  tag: 'monei-payment-request',
14989
15631
  url: config.paymentRequestUrl,
14990
15632
  dimensions: {
@@ -15046,6 +15688,14 @@ var options$6 = {
15046
15688
  alias: 'innerStyle',
15047
15689
  required: false
15048
15690
  },
15691
+ __getConfig: {
15692
+ type: zoid.PROP_TYPE.FUNCTION,
15693
+ required: false,
15694
+ value: function value(_ref4) {
15695
+ var props = _ref4.props;
15696
+ return getPaymentMethods.bind(null, props);
15697
+ }
15698
+ },
15049
15699
  __isApplePaySupported: {
15050
15700
  type: zoid.PROP_TYPE.BOOLEAN,
15051
15701
  required: false,
@@ -15062,14 +15712,14 @@ var options$6 = {
15062
15712
  __onApplePayButtonClicked: {
15063
15713
  type: zoid.PROP_TYPE.FUNCTION,
15064
15714
  required: false,
15065
- value: function value(_ref2) {
15066
- var props = _ref2.props;
15715
+ value: function value(_ref5) {
15716
+ var props = _ref5.props;
15067
15717
  return onApplePayButtonClicked.bind(null, props);
15068
15718
  }
15069
15719
  }
15070
15720
  }
15071
15721
  };
15072
- var PaymentRequest = /*#__PURE__*/zoid.create(options$6);
15722
+ var PaymentRequest = /*#__PURE__*/zoid.create(options$c);
15073
15723
 
15074
15724
  (function (NextActionType) {
15075
15725
  NextActionType["CONFIRM"] = "CONFIRM";
@@ -15084,6 +15734,12 @@ var utils = _utils;
15084
15734
  exports.Bizum = Bizum;
15085
15735
  exports.BizumModal = BizumModal;
15086
15736
  exports.CardInput = CardInput;
15737
+ exports.Cofidis = Cofidis;
15738
+ exports.CofidisLoan = CofidisLoan;
15739
+ exports.CofidisLoanModal = CofidisLoanModal;
15740
+ exports.CofidisLoanWidget = CofidisLoanWidget;
15741
+ exports.CofidisModal = CofidisModal;
15742
+ exports.CofidisWidget = CofidisWidget;
15087
15743
  exports.GooglePay = GooglePay;
15088
15744
  exports.PayPal = PayPal;
15089
15745
  exports.PaymentModal = PaymentModal;