@monei-js/components 1.7.6 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { CalculateFinancingRequest, CalculateFinancingResponse, CreateApplePaySessionRequest, CreatePaymentRequest, CreateTokenRequest, CreateTokenResponse, GetPaymentMethodsRequest, GetPaymentMethodsResponse, PaymentResult, SendPaymentReceiptRequest, ValidateBizumPhoneRequest } from './types';
2
1
  import { ConfirmPaymentParams } from './paymentModal';
2
+ import { CalculateFinancingRequest, CalculateFinancingResponse, CreateApplePaySessionRequest, CreatePaymentRequest, CreateTokenRequest, CreateTokenResponse, GetPaymentMethodsRequest, GetPaymentMethodsResponse, PaymentResult, SendPaymentReceiptRequest, ValidateBizumPhoneRequest } from './types';
3
3
  export declare const getPaymentMethods: ({ accountId, paymentId }: GetPaymentMethodsRequest) => Promise<GetPaymentMethodsResponse>;
4
- export declare const createToken: ({ paymentMethod, paymentId, sessionId, amount, currency, accountId }: CreateTokenRequest) => Promise<CreateTokenResponse>;
4
+ export declare const createToken: ({ paymentMethod, paymentId, sessionId, amount, currency, accountId, transactionType }: CreateTokenRequest) => Promise<CreateTokenResponse>;
5
5
  export declare const getPayment: (paymentId: string) => Promise<PaymentResult>;
6
6
  export declare const confirmPayment: ({ paymentId, ...body }: ConfirmPaymentParams) => Promise<PaymentResult>;
7
7
  export declare const createPayment: ({ signature, ...body }: CreatePaymentRequest) => Promise<PaymentResult>;
@@ -19,7 +19,7 @@ export interface BizumProps {
19
19
  onBeforeOpen?: () => boolean;
20
20
  onOpen?: () => void;
21
21
  style?: {
22
- height?: number;
22
+ height?: string | number;
23
23
  type?: 'pay' | 'plain';
24
24
  };
25
25
  }
@@ -830,7 +830,7 @@ var loadScript = function loadScript(src, nonce, dataset, forceReload) {
830
830
  if (forceReload) {
831
831
  existingScript.remove();
832
832
  } else {
833
- resolve();
833
+ resolve(existingScript);
834
834
  return;
835
835
  }
836
836
  }
@@ -839,7 +839,7 @@ var loadScript = function loadScript(src, nonce, dataset, forceReload) {
839
839
  script.src = src;
840
840
 
841
841
  script.onload = function () {
842
- return resolve();
842
+ return resolve(script);
843
843
  };
844
844
 
845
845
  script.onerror = function (error) {
@@ -918,8 +918,34 @@ var getLanguage = function getLanguage() {
918
918
  return '';
919
919
  };
920
920
 
921
+ var safe = function safe(fn) {
922
+ try {
923
+ var _fn;
924
+
925
+ return String((_fn = fn()) != null ? _fn : '');
926
+ } catch (_unused) {
927
+ return '';
928
+ }
929
+ };
930
+
921
931
  var getClientEnv = function getClientEnv() {
922
- var env = [window.screen.colorDepth, window.screen.height, window.screen.width, new Date().getTimezoneOffset(), getLanguage()].join('|');
932
+ var env = [window.screen.colorDepth, window.screen.height, window.screen.width, new Date().getTimezoneOffset(), getLanguage(), safe(function () {
933
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
934
+ }), safe(function () {
935
+ return window.devicePixelRatio;
936
+ }), safe(function () {
937
+ return navigator.hardwareConcurrency;
938
+ }), safe(function () {
939
+ return navigator.deviceMemory;
940
+ }), safe(function () {
941
+ return navigator.maxTouchPoints;
942
+ }), safe(function () {
943
+ return navigator.platform;
944
+ }), safe(function () {
945
+ var _navigator$languages;
946
+
947
+ return (_navigator$languages = navigator.languages) == null ? void 0 : _navigator$languages.join(',');
948
+ })].join('|');
923
949
  return window.btoa(env);
924
950
  };
925
951
  var withError = /*#__PURE__*/function () {
@@ -1020,14 +1046,14 @@ var stageConfig = {
1020
1046
  cofidisLoanUrl: "http://localhost:3013/" + version + "/inner-cofidis-loan/",
1021
1047
  cofidisLoanButtonUrl: "http://localhost:3014/" + version + "/inner-cofidis-loan-button/",
1022
1048
  cofidisLoanWidgetUrl: "http://localhost:3015/" + version + "/inner-cofidis-loan-widget/",
1023
- apiUrl: 'https://api.monei.com/v1',
1024
- secureDomain: 'https://secure.monei.com',
1025
- rootDomain: 'monei.com'
1049
+ apiUrl: 'https://api.monei-dev.com/v1',
1050
+ secureDomain: 'https://secure.monei-dev.com',
1051
+ rootDomain: 'monei-dev.com'
1026
1052
  },
1027
1053
  dev: {
1028
- apiUrl: 'https://api.microapps-staging.com/v1',
1029
- secureDomain: 'https://secure.microapps-staging.com',
1030
- rootDomain: 'microapps-staging.com'
1054
+ apiUrl: 'https://api.monei-dev.com/v1',
1055
+ secureDomain: 'https://secure.monei-dev.com',
1056
+ rootDomain: 'monei-dev.com'
1031
1057
  },
1032
1058
  prod: {
1033
1059
  apiUrl: 'https://api.monei.com/v1',
@@ -1153,12 +1179,12 @@ var getPaymentMethods = /*#__PURE__*/function () {
1153
1179
  }();
1154
1180
  var createToken = /*#__PURE__*/function () {
1155
1181
  var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_ref5) {
1156
- var paymentMethod, paymentId, sessionId, amount, currency, accountId, body;
1182
+ var paymentMethod, paymentId, sessionId, amount, currency, accountId, transactionType, body;
1157
1183
  return runtime_1.wrap(function _callee3$(_context3) {
1158
1184
  while (1) {
1159
1185
  switch (_context3.prev = _context3.next) {
1160
1186
  case 0:
1161
- paymentMethod = _ref5.paymentMethod, paymentId = _ref5.paymentId, sessionId = _ref5.sessionId, amount = _ref5.amount, currency = _ref5.currency, accountId = _ref5.accountId;
1187
+ paymentMethod = _ref5.paymentMethod, paymentId = _ref5.paymentId, sessionId = _ref5.sessionId, amount = _ref5.amount, currency = _ref5.currency, accountId = _ref5.accountId, transactionType = _ref5.transactionType;
1162
1188
 
1163
1189
  if (!paymentId) {
1164
1190
  _context3.next = 5;
@@ -1183,7 +1209,8 @@ var createToken = /*#__PURE__*/function () {
1183
1209
  paymentMethod: paymentMethod,
1184
1210
  sessionId: sessionId,
1185
1211
  amount: amount,
1186
- currency: currency
1212
+ currency: currency,
1213
+ transactionType: transactionType
1187
1214
  };
1188
1215
  _context3.next = 10;
1189
1216
  break;
@@ -15165,7 +15192,7 @@ var namespace = 'monei-paypal';
15165
15192
 
15166
15193
  var onLoadPaypal = /*#__PURE__*/function () {
15167
15194
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(props, state, src) {
15168
- var defaultStyle, token;
15195
+ var script, defaultStyle, style, token;
15169
15196
  return runtime_1.wrap(function _callee2$(_context2) {
15170
15197
  while (1) {
15171
15198
  switch (_context2.prev = _context2.next) {
@@ -15177,12 +15204,20 @@ var onLoadPaypal = /*#__PURE__*/function () {
15177
15204
  }, true);
15178
15205
 
15179
15206
  case 2:
15207
+ script = _context2.sent;
15208
+ state.__scriptId = script.dataset.uidAuto;
15180
15209
  defaultStyle = {
15181
15210
  layout: 'horizontal',
15182
15211
  tagline: false
15183
15212
  };
15213
+ style = _extends({}, defaultStyle, props.style);
15214
+
15215
+ if (typeof style.height === 'string') {
15216
+ style.height = parseInt(style.height.replace('px', ''));
15217
+ }
15218
+
15184
15219
  props.onLoad == null ? void 0 : props.onLoad(true);
15185
- _context2.next = 6;
15220
+ _context2.next = 10;
15186
15221
  return window[namespace].Buttons({
15187
15222
  createOrder: function () {
15188
15223
  var _createOrder = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
@@ -15200,6 +15235,7 @@ var onLoadPaypal = /*#__PURE__*/function () {
15200
15235
  sessionId: props.sessionId,
15201
15236
  amount: props.amount,
15202
15237
  currency: props.currency,
15238
+ transactionType: props.transactionType,
15203
15239
  paymentMethod: {
15204
15240
  paypal: {}
15205
15241
  }
@@ -15248,10 +15284,10 @@ var onLoadPaypal = /*#__PURE__*/function () {
15248
15284
 
15249
15285
  if (!shouldOpen) return actions.reject();
15250
15286
  },
15251
- style: _extends({}, defaultStyle, props.style)
15287
+ style: style
15252
15288
  }).render(state.__container);
15253
15289
 
15254
- case 6:
15290
+ case 10:
15255
15291
  case "end":
15256
15292
  return _context2.stop();
15257
15293
  }
@@ -15291,6 +15327,15 @@ var options$2 = {
15291
15327
  window[namespace].Buttons.instances.forEach(function (instance) {
15292
15328
  instance.close();
15293
15329
  });
15330
+ var scriptId = params.state.__scriptId;
15331
+
15332
+ if (scriptId) {
15333
+ var script = document.querySelector("script[data-uid-auto=\"" + scriptId + "\"]");
15334
+
15335
+ if (script) {
15336
+ script.remove();
15337
+ }
15338
+ }
15294
15339
  });
15295
15340
  return container;
15296
15341
  },
@@ -15542,7 +15587,7 @@ var options$4 = {
15542
15587
  url: config.bizumButtonUrl,
15543
15588
  dimensions: {
15544
15589
  width: '100%',
15545
- height: '45px'
15590
+ height: 'auto'
15546
15591
  },
15547
15592
  autoResize: {
15548
15593
  width: false,
@@ -16494,7 +16539,7 @@ var options$c = {
16494
16539
  url: config.paymentRequestUrl,
16495
16540
  dimensions: {
16496
16541
  width: '100%',
16497
- height: '0'
16542
+ height: 'auto'
16498
16543
  },
16499
16544
  autoResize: {
16500
16545
  width: false,