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