@pay-com/js 1.1.4 → 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
@@ -1,5 +1,5 @@
1
- import * as types from 'types';
2
- export * from 'types';
1
+ import EventEmitter from 'events';
2
+ import * as CSS from 'csstype';
3
3
 
4
4
  interface PayComScriptQueryParameters {
5
5
  identifier: string
@@ -12,10 +12,453 @@ interface PayComScriptOptions extends PayComScriptQueryParameters {
12
12
  live?: boolean
13
13
  }
14
14
 
15
+ type PayCustomPseudos = ':error'
16
+
17
+ type PayCssConfig = Partial<
18
+ Record<CSS.SimplePseudos | PayCustomPseudos, CSS.Properties>
19
+ > &
20
+ CSS.Properties
21
+ interface CheckoutStyles {
22
+ base?: PayCssConfig
23
+ number?: PayCssConfig
24
+ cvv?: PayCssConfig
25
+ expiry?: PayCssConfig
26
+ name?: PayCssConfig
27
+ checkboxes?: {
28
+ buttonBackground?: string
29
+ labelColor?: string
30
+ }
31
+ submit?: PayCssConfig
32
+ }
33
+
34
+ interface CheckoutFieldConfig {
35
+ label?: string
36
+ labelStyle?: PayCssConfig
37
+ errorMessageStyle?: PayCssConfig
38
+ inputSize?: 'small' | 'medium' | 'large'
39
+ placeholder?: string
40
+ style?: PayCssConfig
41
+ }
42
+
43
+ interface CheckoutFormConfig {
44
+ base?: {
45
+ inputSpacing?: string
46
+ formTitle?: string
47
+ titleStyles?: PayCssConfig
48
+ style?: PayCssConfig
49
+ }
50
+ number?: CheckoutFieldConfig
51
+ cvv?: CheckoutFieldConfig
52
+ expiry?: CheckoutFieldConfig
53
+ name?: CheckoutFieldConfig
54
+ }
55
+
56
+ interface CheckoutToggles {
57
+ /**
58
+ * If false, the form will render without a submission button.
59
+ * @default true
60
+ */
61
+ submitButton?: boolean
62
+ /**
63
+ * If false, the form will render without a title.
64
+ * @default true
65
+ */
66
+ withTitle?: boolean
67
+ /**
68
+ * If false, the form will render without a card holder name.
69
+ * @default true
70
+ */
71
+ withCardHolderName?: boolean
72
+ /**
73
+ * If false, the wrapping element of the form will be a div instead of a form.
74
+ * Good for when the form is embedded inside a larger form.
75
+ * @default true
76
+ */
77
+ formWrapper?: boolean
78
+ /**
79
+ * If true, will display save for future use checkbox under the form.
80
+ * @default false
81
+ */
82
+ saveSourceForFutureUseCheckbox?: boolean
83
+ /**
84
+ * If true, will display our accept T&A checkbox under the form.
85
+ * @default false
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
93
+ /**
94
+ * If true, will render native browser checkboxes instead of ours.
95
+ * @default false
96
+ */
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
113
+ }
114
+
115
+ interface PaypalOpts {
116
+ container: string
117
+ onClickValidation: () => Promise<boolean>
118
+ }
119
+
120
+ interface RenderOpts {
121
+ container: string
122
+ button?: boolean
123
+ toggles?: CheckoutToggles
124
+ formConfig?: CheckoutFormConfig
125
+ localizations?: {
126
+ [language: string]: LanguageLocalizationOverride
127
+ }
128
+ style?: CheckoutStyles
129
+ }
130
+
131
+ interface UniversalToggles {
132
+ /**
133
+ * If false, the form will render without a submission button.
134
+ * @default true
135
+ */
136
+ submitButton?: boolean
137
+
138
+ /**
139
+ * If true, displays the card bin as well as last 4.
140
+ * @default false
141
+ */
142
+ savedCardsBins?: boolean | 2 | 3 | 4 | 5 | 6
143
+
144
+ /**
145
+ * If true, the CVV in saved payment method will be inline
146
+ * @default false
147
+ */
148
+ savedPaymentMethodInlineCvv?: boolean
149
+
150
+ /**
151
+ * A title to display above the Universal form.
152
+ */
153
+ title?: string
154
+ }
155
+
156
+ type LanguageLocalizationOverride = {
157
+ cardForm?: {
158
+ nameOnCard?: string
159
+ cardNumber?: string
160
+ cvv?: string
161
+ expiryDate?: string
162
+ title?: string
163
+ checkboxes?: {
164
+ saveCardForFutureUse?: string
165
+ agreeToTermsAndConditions?: string
166
+ }
167
+ submit?: {
168
+ pay?: string
169
+ save_card?: string
170
+ DEPOSIT?: string
171
+ }
172
+ }
173
+ existingSource?: {
174
+ delete?: string
175
+ }
176
+ dividers?: {
177
+ myPaymentMethods?: string
178
+ otherPaymentMethods?: string
179
+ showOtherWaysToPay?: string
180
+ payWithCard?: string
181
+ payWith?: string
182
+ savedPaymentMethods?: string
183
+ }
184
+ }
185
+
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
+ }
196
+ }
197
+ }
198
+
199
+ type ExpandablePaymentMethods = 'upi' | 'netbanking'
200
+ interface ApmStyle {
201
+ divider?: DividerStyles
202
+ input?: PayCssConfig
203
+ }
204
+
205
+ interface UniversalOpts {
206
+ container: string
207
+ cardForm?: Omit<RenderOpts, 'container' | 'style'>
208
+ toggles?: UniversalToggles
209
+ apmsOnClickValidation?: () => Promise<boolean>
210
+ localizations?: {
211
+ [language: string]: LanguageLocalizationOverride
212
+ }
213
+ style?: {
214
+ cardForm?: CheckoutStyles
215
+ base?: PayCssConfig
216
+ submit?: PayCssConfig
217
+ savedPaymentMethods?: PayCssConfig
218
+ expressCheckout?: PayCssConfig
219
+ apmButtons?: PayCssConfig
220
+ apms?: Partial<Record<ExpandablePaymentMethods, ApmStyle>>
221
+ dividers?: {
222
+ showOtherWaysToPay?: DividerStyles
223
+ payWith?: DividerStyles
224
+ savedPaymentMethods?: DividerStyles
225
+ }
226
+ existingSource?: {
227
+ deleteText?: PayCssConfig
228
+ cvv?: {
229
+ style?: PayCssConfig
230
+ labelStyle?: PayCssConfig
231
+ errorMessageStyle?: PayCssConfig
232
+ }
233
+ icons?: {
234
+ delete?: PayCssConfig
235
+ confirmDeletion?: PayCssConfig
236
+ cancelDeletion?: PayCssConfig
237
+ }
238
+ base?: PayCssConfig & { ':selected'?: PayCssConfig }
239
+ radioButton?: {
240
+ color?: PayCssConfig['color']
241
+ ':selected'?: {
242
+ color?: PayCssConfig['color']
243
+ }
244
+ }
245
+ }
246
+ }
247
+ paymentMethods?: Array<string>
248
+ }
249
+
250
+ interface SubmitOpts {
251
+ token?: string
252
+ }
253
+
254
+ type FailureError = {
255
+ message: string
256
+ data?: Record<string, unknown>
257
+ }
258
+
259
+ interface CheckoutOpts {
260
+ /**
261
+ * @deprecated Got replaced by clientSecret
262
+ */
263
+ token?: string | (() => Promise<string>)
264
+ clientSecret?: string | (() => Promise<string>)
265
+ currency?: string
266
+ onSuccess?: (payment: Record<string, unknown>) => void
267
+ onFailure?: (error: FailureError) => void
268
+ mode?: modeOpts
269
+ throwOnSubmitFailure?: boolean
270
+ paymentFailurePopupConfig?: {
271
+ sessionExpiredPopupText?: string
272
+ maxAttemptsReachedPopupText?: string
273
+ style?: PayCssConfig
274
+ }
275
+ toggles?: {
276
+ displayFailureMessages: boolean
277
+ displayEndOfSessionFailureMessages?: boolean
278
+ disableAdditionalFields?: boolean
279
+ }
280
+ }
281
+
282
+ interface PayComOpts {
283
+ identifier?: string
284
+ riskIdentifier?: string
285
+ sandbox?: boolean
286
+ debug?: boolean
287
+ }
288
+
289
+ enum EVENT_TYPES {
290
+ THREE_DS_INIT = 'three_ds_init',
291
+ THREE_DS_CHALLENGE = 'three_ds_challenge',
292
+ THREE_DS_DONE = 'three_ds_done',
293
+ CONTENT_READY = 'content_ready',
294
+ PAYMENT_SUCCESS = 'payment_success',
295
+ SETUP_SUCCESS = 'setup_success',
296
+ PAYMENT_FAILURE = 'payment_failure',
297
+ SETUP_FAILURE = 'setup_failure',
298
+ PAYMENT_PROCESSING = 'payment_processing',
299
+ SETUP_PROCESSING = 'setup_processing',
300
+ SESSION_EXPIRED = 'session_expired',
301
+ MAX_ATTEMPTS_REACHED = 'max_attempts_reached'
302
+ }
303
+
304
+ type ListenerFn = (
305
+ eventName: EVENT_TYPES,
306
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
307
+ callback: (...params: any[]) => void
308
+ ) => EventEmitter
309
+
310
+ type ValidationResponse = {
311
+ valid: boolean
312
+ invalidFields: string[]
313
+ }
314
+
315
+ enum ELEMENT_TYPES {
316
+ CHECKOUT = 'checkout',
317
+ UNIVERSAL = 'universal',
318
+ PAYPAL = 'paypal'
319
+ }
320
+
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 = {
340
+ valid: boolean
341
+ invalidFields: string[]
342
+ paymentMethodDetails?: {
343
+ type: string
344
+ card: {
345
+ bin: string
346
+ last4: string
347
+ name: string
348
+ }
349
+ }
350
+ }
351
+
352
+ type RenderFn = (renderOpts: RenderOpts) => Promise<void>
353
+ type PaypalFn = (paypalOpts: PaypalOpts) => Promise<void>
354
+ type BlurFn = () => void
355
+ type UniversalFn = (universalOpts: UniversalOpts) => Promise<void>
356
+ type SubmitFn = (
357
+ opts?: SubmitOpts,
358
+ frameType?: ELEMENT_TYPES
359
+ ) => Promise<void | Record<string, unknown>>
360
+
361
+ interface UpdateOpts {
362
+ amount: number
363
+ currency?: string
364
+ }
365
+ type UpdateFn = (updateOpts: UpdateOpts) => Promise<void>
366
+
367
+ type ValidateFn = (
368
+ frameType?: ELEMENT_TYPES
369
+ ) => Promise<ValidateResponse | void>
370
+ type ResetFn = (frameType?: ELEMENT_TYPES) => Promise<void>
371
+
372
+ type UpdateTransactionDetailsOpts = {
373
+ successUrl?: string
374
+ failureUrl?: string
375
+ consumer?: {
376
+ firstName?: string
377
+ lastName?: string
378
+ email?: string
379
+ phone?: string
380
+ }
381
+ billing?: {
382
+ addressLine: string
383
+ addressLine2?: string
384
+ zip: string
385
+ city: string
386
+ state?: string
387
+ countryAlpha2: string
388
+ }
389
+ shipping?: {
390
+ addressLine: string
391
+ addressLine2?: string
392
+ zip: string
393
+ city: string
394
+ state?: string
395
+ countryAlpha2: string
396
+ }
397
+ }
398
+
399
+ type PayOpts = {
400
+ source: string
401
+ }
402
+
403
+ type PayFn = (Opts: PayOpts) => Promise<unknown>
404
+
405
+ type UpdateTransactionDetailsFn = (
406
+ config: UpdateTransactionDetailsOpts
407
+ ) => Promise<unknown>
408
+
409
+ type CheckoutObject = {
410
+ on: ListenerFn
411
+ once: ListenerFn
412
+ removeListener: ListenerFn
413
+ EVENT_TYPES: typeof EVENT_TYPES
414
+ render: RenderFn
415
+ paypal: PaypalFn
416
+ universal: UniversalFn
417
+ update: UpdateFn
418
+ updateTransactionDetails: UpdateTransactionDetailsFn
419
+ submit: SubmitFn
420
+ blur: BlurFn
421
+ validate: ValidateFn
422
+ reset: ResetFn
423
+ pay: PayFn
424
+ }
425
+
426
+ type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
427
+
428
+ type PayComFunction = (opts: PayComOpts) => Promise<{
429
+ checkout: CheckoutFunction
430
+ }>
431
+
432
+ interface PayComNamespace {
433
+ com: PayComFunction
434
+ riskIdentifier: string
435
+ }
436
+
437
+ declare module '@pay-com/js' {
438
+ export function loadScript(
439
+ options: PayComScriptOptions,
440
+ PromisePonyfill?: PromiseConstructor
441
+ ): Promise<PayComNamespace | null>
442
+
443
+ export function loadCustomScript(options: {
444
+ url: string
445
+ attributes?: Record<string, string>
446
+ PromisePonyfill?: PromiseConstructor
447
+ }): Promise<void>
448
+
449
+ export const version: string
450
+ }
451
+
452
+ declare global {
453
+ interface Window {
454
+ Pay?: PayComNamespace
455
+ }
456
+ }
457
+
15
458
  declare const _default: {
16
459
  com: (options: PayComScriptOptions, PromisePonyfill?: PromiseConstructor) => Promise<{
17
- checkout: types.CheckoutFunction;
460
+ checkout: CheckoutFunction;
18
461
  }>;
19
462
  };
20
463
 
21
- export { _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
- export*from"types";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};
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?t(exports,require("types")):"function"==typeof define&&define.amd?define(["exports","types"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Pay={},e.types)}(this,(function(e,t){"use strict";var n=function(){return n=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},n.apply(this,arguments)};function r(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 o(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 i(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 u(e,t){if(a(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.live,o=e.sdkUrlOverride,u=r?"https://js.pay.com/v1.js":"https://js.staging.pay.com/v1.js";o&&(u=o);var f="Pay",s=c(f);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=i(e,t),u=n({},r.dataset);if(delete u.uidAuto,Object.keys(u).length!==Object.keys(o.dataset).length)return null;var c=!0;return Object.keys(u).forEach((function(e){u[e]!==o.dataset[e]&&(c=!1)})),c?r:null}(u)&&s?t.resolve(s):function(e,t){a(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)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,r=e.onSuccess,o=e.onError,u=i(t,n);u.onerror=o,u.onload=r,document.head.insertBefore(u,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(n,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=c(f);if(e)return e;throw new Error("The window.".concat(f," global variable is not available."))}))}function c(e){return window[e]}function a(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 f={com:function(e,t){return void 0===t&&(t=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),r(void 0,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,u(e,t)];case 1:if(!(n=r.sent()))throw new Error("Wrong script URL provided");return[2,n.com(e)]}}))}))}};e.default=f,Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
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.4",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "payments"