@monei-js/components 1.4.0 → 1.5.2

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.
@@ -896,7 +896,11 @@ var getLanguage = function getLanguage() {
896
896
  lang = localStorage.getItem('i18nextLng');
897
897
  } catch (error) {}
898
898
 
899
- return lang || '';
899
+ if (lang) {
900
+ return lang.split('-')[0];
901
+ }
902
+
903
+ return '';
900
904
  };
901
905
 
902
906
  var getClientEnv = function getClientEnv() {
@@ -974,6 +978,9 @@ var globalConfig = {
974
978
  cofidisUrl: domain + "/" + version + "/inner-cofidis/",
975
979
  cofidisButtonUrl: domain + "/" + version + "/inner-cofidis-button/",
976
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/",
977
984
  googlePayUrl: domain + "/" + version + "/inner-google-pay/",
978
985
  paymentRequestUrl: domain + "/" + version + "/inner-payment-request/",
979
986
  click2PayUrl: domain + "/" + version + "/inner-click2pay/",
@@ -981,7 +988,7 @@ var globalConfig = {
981
988
  };
982
989
  var stageConfig = {
983
990
  local: {
984
- paymentPageUrl: "http://192.168.18.3:8080/",
991
+ paymentPageUrl: "http://localhost:8080/",
985
992
  posPaymentPageUrl: "http://192.168.18.3:8080/",
986
993
  cardInputUrl: "http://192.168.18.3:3001/" + version + "/inner-card-input/",
987
994
  paymentModalUrl: "http://192.168.18.3:3002/" + version + "/inner-payment-modal/",
@@ -989,14 +996,17 @@ var stageConfig = {
989
996
  bizumUrl: "http://192.168.18.3:3004/" + version + "/inner-bizum/",
990
997
  bizumButtonUrl: "http://192.168.18.3:3005/" + version + "/inner-bizum-button/",
991
998
  googlePayUrl: "http://192.168.18.3:3006/" + version + "/inner-google-pay/",
992
- paymentRequestUrl: "https://monei-payment-request.eu.ngrok.io/" + version + "/inner-payment-request/",
999
+ paymentRequestUrl: "https://monei-local.ngrok.io/" + version + "/inner-payment-request/",
993
1000
  click2PayUrl: "http://192.168.18.3:3008/inner-click2pay/",
994
1001
  click2PayButtonUrl: "http://192.168.18.3:3009/inner-click2pay-button/",
995
1002
  cofidisUrl: "http://192.168.18.3:3010/" + version + "/inner-cofidis/",
996
1003
  cofidisButtonUrl: "http://192.168.18.3:3011/" + version + "/inner-cofidis-button/",
997
1004
  cofidisWidgetUrl: "http://192.168.18.3:3012/" + version + "/inner-cofidis-widget/",
998
- apiUrl: 'https://api.microapps-staging.com/v1',
999
- secureDomain: 'https://secure.microapps-staging.com'
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/",
1008
+ apiUrl: 'https://api.monei.com/v1',
1009
+ secureDomain: 'https://secure.monei.com'
1000
1010
  },
1001
1011
  dev: {
1002
1012
  apiUrl: 'https://api.microapps-staging.com/v1',
@@ -1319,7 +1329,10 @@ var calculateFinancing = /*#__PURE__*/function () {
1319
1329
  while (1) {
1320
1330
  switch (_context9.prev = _context9.next) {
1321
1331
  case 0:
1322
- return _context9.abrupt("return", request("/calculate-financing?" + stringify(req)));
1332
+ return _context9.abrupt("return", request("/cofidis/calculate-financing", {
1333
+ method: 'POST',
1334
+ body: req
1335
+ }));
1323
1336
 
1324
1337
  case 1:
1325
1338
  case "end":
@@ -1333,6 +1346,29 @@ var calculateFinancing = /*#__PURE__*/function () {
1333
1346
  return _ref15.apply(this, arguments);
1334
1347
  };
1335
1348
  }();
1349
+ var validateBizumPhone = /*#__PURE__*/function () {
1350
+ var _ref16 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(req) {
1351
+ return runtime_1.wrap(function _callee10$(_context10) {
1352
+ while (1) {
1353
+ switch (_context10.prev = _context10.next) {
1354
+ case 0:
1355
+ return _context10.abrupt("return", request("/bizum/validate-phone", {
1356
+ method: 'POST',
1357
+ body: req
1358
+ }));
1359
+
1360
+ case 1:
1361
+ case "end":
1362
+ return _context10.stop();
1363
+ }
1364
+ }
1365
+ }, _callee10);
1366
+ }));
1367
+
1368
+ return function validateBizumPhone(_x11) {
1369
+ return _ref16.apply(this, arguments);
1370
+ };
1371
+ }();
1336
1372
 
1337
1373
  var _api = {
1338
1374
  __proto__: null,
@@ -1343,7 +1379,8 @@ var _api = {
1343
1379
  createPayment: createPayment,
1344
1380
  sendPaymentReceipt: sendPaymentReceipt,
1345
1381
  createApplePaySession: createApplePaySession,
1346
- calculateFinancing: calculateFinancing
1382
+ calculateFinancing: calculateFinancing,
1383
+ validateBizumPhone: validateBizumPhone
1347
1384
  };
1348
1385
 
1349
1386
  var postRobot = createCommonjsModule(function (module, exports) {
@@ -14184,6 +14221,14 @@ var options = {
14184
14221
  type: zoid.PROP_TYPE.OBJECT,
14185
14222
  alias: 'innerStyle',
14186
14223
  required: false
14224
+ },
14225
+ __getConfig: {
14226
+ type: zoid.PROP_TYPE.FUNCTION,
14227
+ required: false,
14228
+ value: function value(_ref2) {
14229
+ var props = _ref2.props;
14230
+ return getPaymentMethods.bind(null, props);
14231
+ }
14187
14232
  }
14188
14233
  },
14189
14234
  validate: validateComponentProps,
@@ -14204,9 +14249,9 @@ var options = {
14204
14249
 
14205
14250
  return containerTemplate(params);
14206
14251
  },
14207
- prerenderTemplate: function prerenderTemplate(_ref2) {
14208
- var doc = _ref2.doc,
14209
- props = _ref2.props;
14252
+ prerenderTemplate: function prerenderTemplate(_ref3) {
14253
+ var doc = _ref3.doc,
14254
+ props = _ref3.props;
14210
14255
  var html = doc.createElement('html');
14211
14256
  var body = doc.createElement('body');
14212
14257
  body.style.margin = '0';
@@ -14987,6 +15032,10 @@ var options$6 = {
14987
15032
  return 'es';
14988
15033
  }
14989
15034
  },
15035
+ showLogo: {
15036
+ type: zoid.PROP_TYPE.BOOLEAN,
15037
+ required: false
15038
+ },
14990
15039
  style: {
14991
15040
  type: zoid.PROP_TYPE.OBJECT,
14992
15041
  alias: 'innerStyle',
@@ -15119,8 +15168,313 @@ var options$7 = {
15119
15168
  };
15120
15169
  var Cofidis = /*#__PURE__*/zoid.create(options$7);
15121
15170
 
15171
+ var EVENT$2;
15172
+
15173
+ (function (EVENT) {
15174
+ EVENT["BEFORE_CLOSE"] = "BEFORE_CLOSE";
15175
+ })(EVENT$2 || (EVENT$2 = {}));
15176
+
15177
+ function containerTemplate$3(_ref) {
15178
+ var uid = _ref.uid,
15179
+ frame = _ref.frame,
15180
+ prerenderFrame = _ref.prerenderFrame,
15181
+ doc = _ref.doc,
15182
+ props = _ref.props,
15183
+ event = _ref.event,
15184
+ _ref$dimensions = _ref.dimensions,
15185
+ width = _ref$dimensions.width,
15186
+ height = _ref$dimensions.height;
15187
+
15188
+ if (!frame || !prerenderFrame) {
15189
+ return;
15190
+ }
15191
+
15192
+ var div = doc.createElement('div');
15193
+ var backdrop = doc.createElement('div');
15194
+ div.setAttribute('id', uid);
15195
+ backdrop.classList.add('backdrop');
15196
+ div.appendChild(backdrop);
15197
+ var style = doc.createElement('style');
15198
+
15199
+ if (props.cspNonce) {
15200
+ style.setAttribute('nonce', props.cspNonce);
15201
+ }
15202
+
15203
+ 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 "));
15204
+ div.appendChild(frame);
15205
+ div.appendChild(prerenderFrame);
15206
+ div.appendChild(style);
15207
+ prerenderFrame.classList.add(CLASS.VISIBLE);
15208
+ frame.classList.add(CLASS.INVISIBLE);
15209
+ setTimeout(function () {
15210
+ backdrop.classList.add(CLASS.VISIBLE);
15211
+ }, 1);
15212
+ event.on(zoid.EVENT.RENDERED, function () {
15213
+ prerenderFrame.classList.remove(CLASS.VISIBLE);
15214
+ prerenderFrame.classList.add(CLASS.INVISIBLE);
15215
+ frame.classList.remove(CLASS.INVISIBLE);
15216
+ frame.classList.add(CLASS.VISIBLE);
15217
+ setTimeout(function () {
15218
+ belter$3.destroyElement(prerenderFrame);
15219
+ }, 1);
15220
+ });
15221
+ event.on(EVENT$2.BEFORE_CLOSE, function () {
15222
+ backdrop.classList.remove(CLASS.VISIBLE);
15223
+ });
15224
+ event.on(zoid.EVENT.RESIZE, function (_ref2) {
15225
+ var newWidth = _ref2.width,
15226
+ newHeight = _ref2.height;
15227
+
15228
+ if (typeof newWidth === 'number') {
15229
+ div.style.width = belter$3.toCSS(newWidth);
15230
+ }
15231
+
15232
+ if (typeof newHeight === 'number') {
15233
+ div.style.height = belter$3.toCSS(newHeight);
15234
+ }
15235
+ });
15236
+ return div;
15237
+ }
15238
+
15122
15239
  // @ts-ignore
15123
15240
  var options$8 = {
15241
+ tag: 'monei-cofidis-loan',
15242
+ url: config.cofidisLoanUrl,
15243
+ dimensions: {
15244
+ width: '100%',
15245
+ height: '100%'
15246
+ },
15247
+ autoResize: {
15248
+ width: false,
15249
+ height: false
15250
+ },
15251
+ prerenderTemplate: function prerenderTemplate() {
15252
+ return undefined;
15253
+ },
15254
+ containerTemplate: containerTemplate$3,
15255
+ props: {
15256
+ paymentId: {
15257
+ type: zoid.PROP_TYPE.STRING,
15258
+ required: false
15259
+ },
15260
+ amount: {
15261
+ type: zoid.PROP_TYPE.NUMBER,
15262
+ required: false
15263
+ },
15264
+ currency: {
15265
+ type: zoid.PROP_TYPE.STRING,
15266
+ required: false
15267
+ },
15268
+ language: {
15269
+ type: zoid.PROP_TYPE.STRING,
15270
+ required: false
15271
+ },
15272
+ onError: {
15273
+ type: zoid.PROP_TYPE.FUNCTION,
15274
+ required: false
15275
+ },
15276
+ onLoad: {
15277
+ type: zoid.PROP_TYPE.FUNCTION,
15278
+ required: false
15279
+ },
15280
+ onSubmit: {
15281
+ type: zoid.PROP_TYPE.FUNCTION,
15282
+ required: false
15283
+ },
15284
+ onOpen: {
15285
+ type: zoid.PROP_TYPE.FUNCTION,
15286
+ required: false
15287
+ },
15288
+ onBeforeClose: {
15289
+ type: zoid.PROP_TYPE.FUNCTION,
15290
+ required: false,
15291
+ "default": function _default(_ref) {
15292
+ var event = _ref.event;
15293
+ return function () {
15294
+ event.trigger(EVENT$2.BEFORE_CLOSE);
15295
+ };
15296
+ }
15297
+ }
15298
+ }
15299
+ };
15300
+ var CofidisLoanModal = /*#__PURE__*/zoid.create(options$8);
15301
+ var CofidisPayModal = CofidisLoanModal;
15302
+
15303
+ // @ts-ignore
15304
+ var options$9 = {
15305
+ tag: 'monei-cofidis-loan-widget',
15306
+ url: config.cofidisLoanWidgetUrl,
15307
+ dimensions: {
15308
+ width: '100%',
15309
+ height: '46px'
15310
+ },
15311
+ autoResize: {
15312
+ width: false,
15313
+ height: true
15314
+ },
15315
+ prerenderTemplate: function prerenderTemplate() {
15316
+ return undefined;
15317
+ },
15318
+ props: {
15319
+ accountId: {
15320
+ type: zoid.PROP_TYPE.STRING,
15321
+ required: true
15322
+ },
15323
+ amount: {
15324
+ type: zoid.PROP_TYPE.NUMBER,
15325
+ required: false
15326
+ },
15327
+ amountInt: {
15328
+ type: zoid.PROP_TYPE.NUMBER,
15329
+ required: false
15330
+ },
15331
+ language: {
15332
+ type: zoid.PROP_TYPE.STRING,
15333
+ required: false,
15334
+ "default": function _default() {
15335
+ return 'es';
15336
+ }
15337
+ },
15338
+ showLogo: {
15339
+ type: zoid.PROP_TYPE.BOOLEAN,
15340
+ required: false
15341
+ },
15342
+ style: {
15343
+ type: zoid.PROP_TYPE.OBJECT,
15344
+ alias: 'innerStyle',
15345
+ required: false
15346
+ },
15347
+ onError: {
15348
+ type: zoid.PROP_TYPE.FUNCTION,
15349
+ required: false
15350
+ },
15351
+ onLoad: {
15352
+ type: zoid.PROP_TYPE.FUNCTION,
15353
+ required: false
15354
+ },
15355
+ __onClick: {
15356
+ type: zoid.PROP_TYPE.FUNCTION,
15357
+ required: false,
15358
+ value: function value() {
15359
+ return function (url) {
15360
+ window.open(url, '_blank');
15361
+ };
15362
+ }
15363
+ }
15364
+ }
15365
+ };
15366
+ var CofidisLoanWidget = /*#__PURE__*/zoid.create(options$9);
15367
+ var CofidisPayWidget = CofidisLoanWidget;
15368
+
15369
+ var options$a = {
15370
+ tag: 'monei-cofidis-loan-button',
15371
+ url: config.cofidisLoanButtonUrl,
15372
+ dimensions: {
15373
+ width: '100%',
15374
+ height: '45px'
15375
+ },
15376
+ autoResize: {
15377
+ width: false,
15378
+ height: true
15379
+ },
15380
+ validate: validateComponentProps,
15381
+ containerTemplate: containerTemplate,
15382
+ prerenderTemplate: function prerenderTemplate() {
15383
+ return undefined;
15384
+ },
15385
+ props: {
15386
+ paymentId: {
15387
+ type: zoid.PROP_TYPE.STRING,
15388
+ required: false
15389
+ },
15390
+ language: {
15391
+ type: zoid.PROP_TYPE.STRING,
15392
+ required: false
15393
+ },
15394
+ hint: {
15395
+ type: zoid.PROP_TYPE.BOOLEAN,
15396
+ "default": function _default() {
15397
+ return true;
15398
+ },
15399
+ required: false
15400
+ },
15401
+ onError: {
15402
+ type: zoid.PROP_TYPE.FUNCTION,
15403
+ required: false
15404
+ },
15405
+ onLoad: {
15406
+ type: zoid.PROP_TYPE.FUNCTION,
15407
+ required: false
15408
+ },
15409
+ onOpen: {
15410
+ type: zoid.PROP_TYPE.FUNCTION,
15411
+ required: false
15412
+ },
15413
+ style: {
15414
+ type: zoid.PROP_TYPE.OBJECT,
15415
+ alias: 'innerStyle',
15416
+ required: false
15417
+ },
15418
+ __getConfig: {
15419
+ type: zoid.PROP_TYPE.FUNCTION,
15420
+ required: false,
15421
+ value: function value(_ref) {
15422
+ var props = _ref.props;
15423
+ return getPaymentMethods.bind(null, props);
15424
+ }
15425
+ },
15426
+ __onHintClick: {
15427
+ type: zoid.PROP_TYPE.FUNCTION,
15428
+ required: false,
15429
+ value: function value() {
15430
+ return function (url) {
15431
+ window.open(url, '_blank');
15432
+ };
15433
+ }
15434
+ },
15435
+ __onClick: {
15436
+ type: zoid.PROP_TYPE.FUNCTION,
15437
+ required: false,
15438
+ value: function value(_ref2) {
15439
+ var props = _ref2.props;
15440
+ var rootNode = document.createElement('div');
15441
+ document.body.appendChild(rootNode);
15442
+ return function (_ref3) {
15443
+ var amount = _ref3.amount,
15444
+ currency = _ref3.currency,
15445
+ accountId = _ref3.accountId;
15446
+ var cofidisModal = new CofidisLoanModal(_extends({}, props, {
15447
+ amount: amount,
15448
+ currency: currency,
15449
+ accountId: accountId,
15450
+ onClose: function onClose() {
15451
+ window.onpopstate = null;
15452
+ document.body.style.overflow = '';
15453
+ },
15454
+ isOpen: true
15455
+ }));
15456
+ window.history.pushState(null, '', window.location.href);
15457
+
15458
+ window.onpopstate = function () {
15459
+ return cofidisModal.updateProps({
15460
+ isOpen: false
15461
+ });
15462
+ };
15463
+
15464
+ Object.assign(document.body.style, {
15465
+ overflow: 'hidden'
15466
+ });
15467
+ return cofidisModal.render(rootNode);
15468
+ };
15469
+ }
15470
+ }
15471
+ }
15472
+ };
15473
+ var CofidisLoan = /*#__PURE__*/zoid.create(options$a);
15474
+ var CofidisPay = CofidisLoan;
15475
+
15476
+ // @ts-ignore
15477
+ var options$b = {
15124
15478
  tag: 'monei-google-pay',
15125
15479
  url: config.googlePayUrl,
15126
15480
  dimensions: {
@@ -15192,7 +15546,7 @@ var options$8 = {
15192
15546
  }
15193
15547
  }
15194
15548
  };
15195
- var GooglePay = /*#__PURE__*/zoid.create(options$8);
15549
+ var GooglePay = /*#__PURE__*/zoid.create(options$b);
15196
15550
 
15197
15551
  var onApplePayButtonClicked = /*#__PURE__*/function () {
15198
15552
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(props, request, context) {
@@ -15310,7 +15664,7 @@ var onApplePayButtonClicked = /*#__PURE__*/function () {
15310
15664
  };
15311
15665
  }();
15312
15666
 
15313
- var options$9 = {
15667
+ var options$c = {
15314
15668
  tag: 'monei-payment-request',
15315
15669
  url: config.paymentRequestUrl,
15316
15670
  dimensions: {
@@ -15403,7 +15757,7 @@ var options$9 = {
15403
15757
  }
15404
15758
  }
15405
15759
  };
15406
- var PaymentRequest = /*#__PURE__*/zoid.create(options$9);
15760
+ var PaymentRequest = /*#__PURE__*/zoid.create(options$c);
15407
15761
 
15408
15762
  var NextActionType;
15409
15763
 
@@ -15414,8 +15768,23 @@ var NextActionType;
15414
15768
  NextActionType["COMPLETE"] = "COMPLETE";
15415
15769
  })(NextActionType || (NextActionType = {}));
15416
15770
 
15771
+ var CardBrand;
15772
+
15773
+ (function (CardBrand) {
15774
+ CardBrand["Visa"] = "visa";
15775
+ CardBrand["Mastercard"] = "mastercard";
15776
+ CardBrand["Amex"] = "amex";
15777
+ CardBrand["Discover"] = "discover";
15778
+ CardBrand["Diners"] = "diners";
15779
+ CardBrand["JCB"] = "jcb";
15780
+ CardBrand["Maestro"] = "maestro";
15781
+ CardBrand["UnionPay"] = "unionpay";
15782
+ CardBrand["Elo"] = "elo";
15783
+ CardBrand["Hipercard"] = "hipercard";
15784
+ })(CardBrand || (CardBrand = {}));
15785
+
15417
15786
  var api = _api;
15418
15787
  var utils = _utils;
15419
15788
 
15420
- export { Bizum, BizumModal, CardInput, Cofidis, CofidisModal, CofidisWidget, GooglePay, NextActionType, PayPal, PaymentModal, PaymentRequest, api, config, confirmPayment$1 as confirmPayment, createToken$1 as createToken, utils };
15789
+ export { Bizum, BizumModal, CardBrand, CardInput, Cofidis, CofidisLoan, CofidisLoanModal, CofidisLoanWidget, CofidisModal, CofidisPay, CofidisPayModal, CofidisPayWidget, CofidisWidget, GooglePay, NextActionType, PayPal, PaymentModal, PaymentRequest, api, config, confirmPayment$1 as confirmPayment, createToken$1 as createToken, utils };
15421
15790
  //# sourceMappingURL=components.esm.js.map