@pay-com/js 1.1.3 → 1.1.5

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/lib/index.d.ts CHANGED
@@ -2,13 +2,14 @@ import EventEmitter from 'events';
2
2
  import * as CSS from 'csstype';
3
3
 
4
4
  interface PayComScriptQueryParameters {
5
- identifier: string;
6
- sandbox?: boolean;
7
- debug?: boolean;
5
+ identifier: string
6
+ sandbox?: boolean
7
+ debug?: boolean
8
8
  }
9
9
 
10
10
  interface PayComScriptOptions extends PayComScriptQueryParameters {
11
- sdkBaseURL?: string;
11
+ sdkUrlOverride?: string
12
+ live?: boolean
12
13
  }
13
14
 
14
15
  type PayCustomPseudos = ':error'
@@ -84,11 +85,31 @@ interface CheckoutToggles {
84
85
  * @default false
85
86
  */
86
87
  acceptTermsAndConditionsCheckbox?: boolean
88
+ /**
89
+ * If true, won't display required additional fields, such as email for EU 3ds.
90
+ * @default false
91
+ */
92
+ disableAdditionalFields?: boolean
87
93
  /**
88
94
  * If true, will render native browser checkboxes instead of ours.
89
95
  * @default false
90
96
  */
91
97
  nativeCheckboxes?: boolean
98
+ /**
99
+ * If true, on mobile view all fields will be in one column.
100
+ * @default false
101
+ */
102
+ mobileColumn?: boolean
103
+ /**
104
+ * If true, will render credit card brand on number input
105
+ * @default false
106
+ */
107
+ withCardNumberBrand?: boolean
108
+ /**
109
+ * If true, will render a tooltip on the card CVV input
110
+ * @default false
111
+ */
112
+ withCvvTooltip?: boolean
92
113
  }
93
114
 
94
115
  interface PaypalOpts {
@@ -162,14 +183,25 @@ type LanguageLocalizationOverride = {
162
183
  }
163
184
  }
164
185
 
165
- interface DividerStyle {
166
- text: PayCssConfig
167
- divider: {
168
- color: PayCssConfig['color']
169
- height: PayCssConfig['height']
186
+ interface DividerStyles {
187
+ text?: PayCssConfig
188
+ divider?: {
189
+ marginBottom?: PayCssConfig['marginBottom']
190
+ color?: PayCssConfig['color']
191
+ height?: PayCssConfig['height']
192
+ ':disabled'?: {
193
+ color?: PayCssConfig['color']
194
+ height?: PayCssConfig['height']
195
+ }
170
196
  }
171
197
  }
172
198
 
199
+ type ExpandablePaymentMethods = 'upi' | 'netbanking'
200
+ interface ApmStyle {
201
+ divider?: DividerStyles
202
+ input?: PayCssConfig
203
+ }
204
+
173
205
  interface UniversalOpts {
174
206
  container: string
175
207
  cardForm?: Omit<RenderOpts, 'container' | 'style'>
@@ -185,10 +217,11 @@ interface UniversalOpts {
185
217
  savedPaymentMethods?: PayCssConfig
186
218
  expressCheckout?: PayCssConfig
187
219
  apmButtons?: PayCssConfig
220
+ apms?: Partial<Record<ExpandablePaymentMethods, ApmStyle>>
188
221
  dividers?: {
189
- showOtherWaysToPay?: DividerStyle
190
- payWith?: DividerStyle
191
- savedPaymentMethods?: DividerStyle
222
+ showOtherWaysToPay?: DividerStyles
223
+ payWith?: DividerStyles
224
+ savedPaymentMethods?: DividerStyles
192
225
  }
193
226
  existingSource?: {
194
227
  deleteText?: PayCssConfig
@@ -274,18 +307,51 @@ type ListenerFn = (
274
307
  callback: (...params: any[]) => void
275
308
  ) => EventEmitter
276
309
 
310
+ type ValidationResponse = {
311
+ valid: boolean
312
+ invalidFields: string[]
313
+ }
314
+
277
315
  enum ELEMENT_TYPES {
278
316
  CHECKOUT = 'checkout',
279
317
  UNIVERSAL = 'universal',
280
318
  PAYPAL = 'paypal'
281
319
  }
282
320
 
283
- type FormattedErrors = {
321
+ enum TransactionStatusEnum {
322
+ APPROVED = 'APPROVED',
323
+ PENDING = 'PENDING',
324
+ DECLINED = 'DECLINED',
325
+ ERROR = 'ERROR',
326
+ EXPIRED = 'EXPIRED',
327
+ CANCELLED = 'CANCELLED',
328
+ CREATED = 'CREATED'
329
+ }
330
+
331
+ type SubmitResponse = {
332
+ transactionStatus: TransactionStatusEnum
333
+ transactionId: string
334
+ transactionDateTime: string
335
+ sourceId: string
336
+ consumerId: string
337
+ }
338
+
339
+ type ValidateResponse = {
284
340
  valid: boolean
285
341
  invalidFields: string[]
342
+ paymentMethodDetails?: {
343
+ type: string
344
+ card: {
345
+ bin: string
346
+ last4: string
347
+ name: string
348
+ }
349
+ }
286
350
  }
351
+
287
352
  type RenderFn = (renderOpts: RenderOpts) => Promise<void>
288
353
  type PaypalFn = (paypalOpts: PaypalOpts) => Promise<void>
354
+ type BlurFn = () => void
289
355
  type UniversalFn = (universalOpts: UniversalOpts) => Promise<void>
290
356
  type SubmitFn = (
291
357
  opts?: SubmitOpts,
@@ -298,7 +364,9 @@ interface UpdateOpts {
298
364
  }
299
365
  type UpdateFn = (updateOpts: UpdateOpts) => Promise<void>
300
366
 
301
- type ValidateFn = (frameType?: ELEMENT_TYPES) => Promise<FormattedErrors | void>
367
+ type ValidateFn = (
368
+ frameType?: ELEMENT_TYPES
369
+ ) => Promise<ValidateResponse | void>
302
370
  type ResetFn = (frameType?: ELEMENT_TYPES) => Promise<void>
303
371
 
304
372
  type UpdateTransactionDetailsOpts = {
@@ -349,6 +417,7 @@ type CheckoutObject = {
349
417
  update: UpdateFn
350
418
  updateTransactionDetails: UpdateTransactionDetailsFn
351
419
  submit: SubmitFn
420
+ blur: BlurFn
352
421
  validate: ValidateFn
353
422
  reset: ResetFn
354
423
  pay: PayFn
@@ -392,4 +461,4 @@ declare const _default: {
392
461
  }>;
393
462
  };
394
463
 
395
- export { CheckoutFunction, CheckoutObject, CheckoutToggles, EVENT_TYPES, ListenerFn, PayComFunction, PayComNamespace, PaypalOpts, RenderOpts, SubmitOpts, UniversalOpts, UpdateTransactionDetailsOpts, _default as default };
464
+ export { ApmStyle, CheckoutFunction, CheckoutObject, CheckoutOpts, CheckoutToggles, DividerStyles, ELEMENT_TYPES, EVENT_TYPES, ExpandablePaymentMethods, FailureError, LanguageLocalizationOverride, ListenerFn, PayComFunction, PayComNamespace, PayFn, PayOpts, PaypalOpts, RenderOpts, SubmitOpts, SubmitResponse, UniversalOpts, UniversalToggles, UpdateTransactionDetailsFn, UpdateTransactionDetailsOpts, ValidationResponse, _default as default };
package/lib/index.esm.js CHANGED
@@ -1 +1 @@
1
- function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function t(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function r(e,t){if(i(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.sdkBaseURL,u="",c=window.location.hostname;u=r||(["localhost","dev","staging"].some((function(e){return window.location.hostname.includes(e)}))?"https://js.dev.pay.com/v1.js":c.includes(".sandbox.")?"https://js.sandbox.pay.com/v1.js":"https://js.pay.com/v1.js");var a="Pay",s=o(a);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=n(e,t),i=Object.assign({},r.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var u=!0;return Object.keys(i).forEach((function(e){i[e]!==o.dataset[e]&&(u=!1)})),u?r:null}(u)&&s?t.resolve(s):function(e,t){i(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=o(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function o(e){return window[e]}function i(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;var u={com:function(n,o){return void 0===o&&(o=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r(n,o)];case 1:if(!(e=t.sent()))throw new Error("Wrong script URL provided");return[2,e.com(n)]}}))}))}};export{u as default};
1
+ var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,r,n){return new(r||(r=Promise))((function(o,i){function u(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,c)}a((n=n.apply(e,t||[])).next())}))}function r(e,t){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,n=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var r=document.createElement("script");return r.src=e,Object.keys(t).forEach((function(e){r.setAttribute(e,t[e]),"data-csp-nonce"===e&&r.setAttribute("nonce",t["data-csp-nonce"])})),r}function o(t,r){if(u(t,r),"undefined"==typeof window)return r.resolve(null);var o=t.live,c=t.sdkUrlOverride,a=o?"https://js.pay.com/v1.js":"https://js.staging.pay.com/v1.js";c&&(a=c);var l="Pay",s=i(l);return function(t,r){var o=document.querySelector('script[src="'.concat(t,'"]'));if(null===o)return null;var i=n(t,r),u=e({},o.dataset);if(delete u.uidAuto,Object.keys(u).length!==Object.keys(i.dataset).length)return null;var c=!0;return Object.keys(u).forEach((function(e){u[e]!==i.dataset[e]&&(c=!1)})),c?o:null}(a)&&s?r.resolve(s):function(e,t){u(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:a},r).then((function(){var e=i(l);if(e)return e;throw new Error("The window.".concat(l," global variable is not available."))}))}function i(e){return window[e]}function u(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;var c={com:function(e,n){return void 0===n&&(n=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),t(void 0,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,o(e,n)];case 1:if(!(t=r.sent()))throw new Error("Wrong script URL provided");return[2,t.com(e)]}}))}))}};export{c as default};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Pay=t()}(this,(function(){"use strict";function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function t(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function r(e,t){if(i(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.sdkBaseURL,u="",c=window.location.hostname;u=r||(["localhost","dev","staging"].some((function(e){return window.location.hostname.includes(e)}))?"https://js.dev.pay.com/v1.js":c.includes(".sandbox.")?"https://js.sandbox.pay.com/v1.js":"https://js.pay.com/v1.js");var a="Pay",s=o(a);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=n(e,t),i=Object.assign({},r.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var u=!0;return Object.keys(i).forEach((function(e){i[e]!==o.dataset[e]&&(u=!1)})),u?r:null}(u)&&s?t.resolve(s):function(e,t){i(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=o(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function o(e){return window[e]}function i(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;return{com:function(n,o){return void 0===o&&(o=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r(n,o)];case 1:if(!(e=t.sent()))throw new Error("Wrong script URL provided");return[2,e.com(n)]}}))}))}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Pay=t()}(this,(function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function r(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function o(t,n){if(u(t,n),"undefined"==typeof window)return n.resolve(null);var o=t.live,c=t.sdkUrlOverride,a=o?"https://js.pay.com/v1.js":"https://js.staging.pay.com/v1.js";c&&(a=c);var l="Pay",f=i(l);return function(t,n){var o=document.querySelector('script[src="'.concat(t,'"]'));if(null===o)return null;var i=r(t,n),u=e({},o.dataset);if(delete u.uidAuto,Object.keys(u).length!==Object.keys(i.dataset).length)return null;var c=!0;return Object.keys(u).forEach((function(e){u[e]!==i.dataset[e]&&(c=!1)})),c?o:null}(a)&&f?n.resolve(f):function(e,t){u(e,t);var n=e.url,o=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,n=e.attributes,o=e.onSuccess,i=e.onError,u=r(t,n);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:n,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(n,'" failed to load.')))}})}))}({url:a},n).then((function(){var e=i(l);if(e)return e;throw new Error("The window.".concat(l," global variable is not available."))}))}function i(e){return window[e]}function u(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;return{com:function(e,r){return void 0===r&&(r=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),t(void 0,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,o(e,r)];case 1:if(!(t=n.sent()))throw new Error("Wrong script URL provided");return[2,t.com(e)]}}))}))}}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pay-com/js",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "payments"
@@ -11,6 +11,7 @@
11
11
  "module": "lib/index.esm.js",
12
12
  "types": "lib/index.d.ts",
13
13
  "publishConfig": {
14
+ "access": "public",
14
15
  "registry": "https://registry.npmjs.org/"
15
16
  },
16
17
  "repository": {
@@ -25,13 +26,23 @@
25
26
  "build:watch": "rollup -c --watch",
26
27
  "build": "rollup -c",
27
28
  "prepublishOnly": "npm run build",
28
- "prepublish": "npm run build"
29
+ "prepare": "husky install"
30
+ },
31
+ "lint-staged": {
32
+ "**/*.{js,ts}": "eslint . --cache --fix --ignore-path '.eslintignore' --max-warnings 0",
33
+ "**/*.{js,ts,md}": "prettier --write"
29
34
  },
30
35
  "devDependencies": {
36
+ "@pay-com/eslint-config-react": "^2.0.3",
31
37
  "@rollup/plugin-commonjs": "^21.0.0",
32
38
  "@rollup/plugin-node-resolve": "^13.0.5",
33
39
  "csstype": "^3.0.9",
40
+ "eslint": "^8.46.0",
41
+ "eslint-plugin-prettier": "^5.0.0",
34
42
  "events": "^3.3.0",
43
+ "husky": "^8.0.0",
44
+ "lint-staged": "^13.2.3",
45
+ "prettier": "^3.0.0",
35
46
  "rollup": "^2.70.1",
36
47
  "rollup-plugin-copy": "^3.4.0",
37
48
  "rollup-plugin-dts": "^4.0.0",