@pay-com/js 1.1.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.
- package/lib/index.d.ts +393 -0
- package/lib/index.esm.js +1 -0
- package/lib/index.js +1 -0
- package/package.json +38 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import * as CSS from 'csstype';
|
|
3
|
+
|
|
4
|
+
interface PayComScriptQueryParameters {
|
|
5
|
+
identifier: string;
|
|
6
|
+
sandbox?: boolean;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface PayComScriptOptions extends PayComScriptQueryParameters {
|
|
11
|
+
sdkBaseURL?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type PayCustomPseudos = ':error'
|
|
15
|
+
|
|
16
|
+
type PayCssConfig = Partial<
|
|
17
|
+
Record<CSS.SimplePseudos | PayCustomPseudos, CSS.Properties>
|
|
18
|
+
> &
|
|
19
|
+
CSS.Properties
|
|
20
|
+
interface CheckoutStyles {
|
|
21
|
+
base?: PayCssConfig
|
|
22
|
+
number?: PayCssConfig
|
|
23
|
+
cvv?: PayCssConfig
|
|
24
|
+
expiry?: PayCssConfig
|
|
25
|
+
name?: PayCssConfig
|
|
26
|
+
checkboxes?: {
|
|
27
|
+
buttonBackground?: string
|
|
28
|
+
labelColor?: string
|
|
29
|
+
}
|
|
30
|
+
submit?: PayCssConfig
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CheckoutFieldConfig {
|
|
34
|
+
label?: string
|
|
35
|
+
labelStyle?: PayCssConfig
|
|
36
|
+
errorMessageStyle?: PayCssConfig
|
|
37
|
+
inputSize?: 'small' | 'medium' | 'large'
|
|
38
|
+
placeholder?: string
|
|
39
|
+
style?: PayCssConfig
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface CheckoutFormConfig {
|
|
43
|
+
base?: {
|
|
44
|
+
inputSpacing?: string
|
|
45
|
+
formTitle?: string
|
|
46
|
+
titleStyles?: PayCssConfig
|
|
47
|
+
style?: PayCssConfig
|
|
48
|
+
}
|
|
49
|
+
number?: CheckoutFieldConfig
|
|
50
|
+
cvv?: CheckoutFieldConfig
|
|
51
|
+
expiry?: CheckoutFieldConfig
|
|
52
|
+
name?: CheckoutFieldConfig
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface CheckoutToggles {
|
|
56
|
+
/**
|
|
57
|
+
* If false, the form will render without a submission button.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
submitButton?: boolean
|
|
61
|
+
/**
|
|
62
|
+
* If false, the form will render without a title.
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
withTitle?: boolean
|
|
66
|
+
/**
|
|
67
|
+
* If false, the form will render without a card holder name.
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
withCardHolderName?: boolean
|
|
71
|
+
/**
|
|
72
|
+
* If false, the wrapping element of the form will be a div instead of a form.
|
|
73
|
+
* Good for when the form is embedded inside a larger form.
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
formWrapper?: boolean
|
|
77
|
+
/**
|
|
78
|
+
* If true, will display save for future use checkbox under the form.
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
saveSourceForFutureUseCheckbox?: boolean
|
|
82
|
+
/**
|
|
83
|
+
* If true, will display our accept T&A checkbox under the form.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
acceptTermsAndConditionsCheckbox?: boolean
|
|
87
|
+
/**
|
|
88
|
+
* If true, will render native browser checkboxes instead of ours.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
nativeCheckboxes?: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface PaypalOpts {
|
|
95
|
+
container: string
|
|
96
|
+
onClickValidation: () => Promise<boolean>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface RenderOpts {
|
|
100
|
+
container: string
|
|
101
|
+
button?: boolean
|
|
102
|
+
toggles?: CheckoutToggles
|
|
103
|
+
formConfig?: CheckoutFormConfig
|
|
104
|
+
localizations?: {
|
|
105
|
+
[language: string]: LanguageLocalizationOverride
|
|
106
|
+
}
|
|
107
|
+
style?: CheckoutStyles
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface UniversalToggles {
|
|
111
|
+
/**
|
|
112
|
+
* If false, the form will render without a submission button.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
submitButton?: boolean
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* If true, displays the card bin as well as last 4.
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
savedCardsBins?: boolean | 2 | 3 | 4 | 5 | 6
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* If true, the CVV in saved payment method will be inline
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
savedPaymentMethodInlineCvv?: boolean
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* A title to display above the Universal form.
|
|
131
|
+
*/
|
|
132
|
+
title?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type LanguageLocalizationOverride = {
|
|
136
|
+
cardForm?: {
|
|
137
|
+
nameOnCard?: string
|
|
138
|
+
cardNumber?: string
|
|
139
|
+
cvv?: string
|
|
140
|
+
expiryDate?: string
|
|
141
|
+
title?: string
|
|
142
|
+
checkboxes?: {
|
|
143
|
+
saveCardForFutureUse?: string
|
|
144
|
+
agreeToTermsAndConditions?: string
|
|
145
|
+
}
|
|
146
|
+
submit?: {
|
|
147
|
+
pay?: string
|
|
148
|
+
save_card?: string
|
|
149
|
+
DEPOSIT?: string
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
existingSource?: {
|
|
153
|
+
delete?: string
|
|
154
|
+
}
|
|
155
|
+
dividers?: {
|
|
156
|
+
myPaymentMethods?: string
|
|
157
|
+
otherPaymentMethods?: string
|
|
158
|
+
showOtherWaysToPay?: string
|
|
159
|
+
payWithCard?: string
|
|
160
|
+
payWith?: string
|
|
161
|
+
savedPaymentMethods?: string
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface DividerStyle {
|
|
166
|
+
text: PayCssConfig
|
|
167
|
+
divider: {
|
|
168
|
+
color: PayCssConfig['color']
|
|
169
|
+
height: PayCssConfig['height']
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface UniversalOpts {
|
|
174
|
+
container: string
|
|
175
|
+
cardForm?: Omit<RenderOpts, 'container' | 'style'>
|
|
176
|
+
toggles?: UniversalToggles
|
|
177
|
+
apmsOnClickValidation?: () => Promise<boolean>
|
|
178
|
+
localizations?: {
|
|
179
|
+
[language: string]: LanguageLocalizationOverride
|
|
180
|
+
}
|
|
181
|
+
style?: {
|
|
182
|
+
cardForm?: CheckoutStyles
|
|
183
|
+
base?: PayCssConfig
|
|
184
|
+
submit?: PayCssConfig
|
|
185
|
+
savedPaymentMethods?: PayCssConfig
|
|
186
|
+
expressCheckout?: PayCssConfig
|
|
187
|
+
apmButtons?: PayCssConfig
|
|
188
|
+
dividers?: {
|
|
189
|
+
showOtherWaysToPay?: DividerStyle
|
|
190
|
+
payWith?: DividerStyle
|
|
191
|
+
savedPaymentMethods?: DividerStyle
|
|
192
|
+
}
|
|
193
|
+
existingSource?: {
|
|
194
|
+
deleteText?: PayCssConfig
|
|
195
|
+
cvv?: {
|
|
196
|
+
style?: PayCssConfig
|
|
197
|
+
labelStyle?: PayCssConfig
|
|
198
|
+
errorMessageStyle?: PayCssConfig
|
|
199
|
+
}
|
|
200
|
+
icons?: {
|
|
201
|
+
delete?: PayCssConfig
|
|
202
|
+
confirmDeletion?: PayCssConfig
|
|
203
|
+
cancelDeletion?: PayCssConfig
|
|
204
|
+
}
|
|
205
|
+
base?: PayCssConfig & { ':selected'?: PayCssConfig }
|
|
206
|
+
radioButton?: {
|
|
207
|
+
color?: PayCssConfig['color']
|
|
208
|
+
':selected'?: {
|
|
209
|
+
color?: PayCssConfig['color']
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
paymentMethods?: Array<string>
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
interface SubmitOpts {
|
|
218
|
+
token?: string
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
type FailureError = {
|
|
222
|
+
message: string
|
|
223
|
+
data?: Record<string, unknown>
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface CheckoutOpts {
|
|
227
|
+
/**
|
|
228
|
+
* @deprecated Got replaced by clientSecret
|
|
229
|
+
*/
|
|
230
|
+
token?: string | (() => Promise<string>)
|
|
231
|
+
clientSecret?: string | (() => Promise<string>)
|
|
232
|
+
currency?: string
|
|
233
|
+
onSuccess?: (payment: Record<string, unknown>) => void
|
|
234
|
+
onFailure?: (error: FailureError) => void
|
|
235
|
+
mode?: modeOpts
|
|
236
|
+
throwOnSubmitFailure?: boolean
|
|
237
|
+
paymentFailurePopupConfig?: {
|
|
238
|
+
sessionExpiredPopupText?: string
|
|
239
|
+
maxAttemptsReachedPopupText?: string
|
|
240
|
+
style?: PayCssConfig
|
|
241
|
+
}
|
|
242
|
+
toggles?: {
|
|
243
|
+
displayFailureMessages: boolean
|
|
244
|
+
displayEndOfSessionFailureMessages?: boolean
|
|
245
|
+
disableAdditionalFields?: boolean
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface PayComOpts {
|
|
250
|
+
identifier?: string
|
|
251
|
+
riskIdentifier?: string
|
|
252
|
+
sandbox?: boolean
|
|
253
|
+
debug?: boolean
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
enum EVENT_TYPES {
|
|
257
|
+
THREE_DS_INIT = 'three_ds_init',
|
|
258
|
+
THREE_DS_CHALLENGE = 'three_ds_challenge',
|
|
259
|
+
THREE_DS_DONE = 'three_ds_done',
|
|
260
|
+
CONTENT_READY = 'content_ready',
|
|
261
|
+
PAYMENT_SUCCESS = 'payment_success',
|
|
262
|
+
SETUP_SUCCESS = 'setup_success',
|
|
263
|
+
PAYMENT_FAILURE = 'payment_failure',
|
|
264
|
+
SETUP_FAILURE = 'setup_failure',
|
|
265
|
+
PAYMENT_PROCESSING = 'payment_processing',
|
|
266
|
+
SETUP_PROCESSING = 'setup_processing',
|
|
267
|
+
SESSION_EXPIRED = 'session_expired',
|
|
268
|
+
MAX_ATTEMPTS_REACHED = 'max_attempts_reached'
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
type ListenerFn = (
|
|
272
|
+
eventName: EVENT_TYPES,
|
|
273
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
274
|
+
callback: (...params: any[]) => void
|
|
275
|
+
) => EventEmitter
|
|
276
|
+
|
|
277
|
+
enum ELEMENT_TYPES {
|
|
278
|
+
CHECKOUT = 'checkout',
|
|
279
|
+
UNIVERSAL = 'universal',
|
|
280
|
+
PAYPAL = 'paypal'
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
type FormattedErrors = {
|
|
284
|
+
valid: boolean
|
|
285
|
+
invalidFields: string[]
|
|
286
|
+
}
|
|
287
|
+
type RenderFn = (renderOpts: RenderOpts) => Promise<void>
|
|
288
|
+
type PaypalFn = (paypalOpts: PaypalOpts) => Promise<void>
|
|
289
|
+
type UniversalFn = (universalOpts: UniversalOpts) => Promise<void>
|
|
290
|
+
type SubmitFn = (
|
|
291
|
+
opts?: SubmitOpts,
|
|
292
|
+
frameType?: ELEMENT_TYPES
|
|
293
|
+
) => Promise<void | Record<string, unknown>>
|
|
294
|
+
|
|
295
|
+
interface UpdateOpts {
|
|
296
|
+
amount: number
|
|
297
|
+
currency?: string
|
|
298
|
+
}
|
|
299
|
+
type UpdateFn = (updateOpts: UpdateOpts) => Promise<void>
|
|
300
|
+
|
|
301
|
+
type ValidateFn = (frameType?: ELEMENT_TYPES) => Promise<FormattedErrors | void>
|
|
302
|
+
type ResetFn = (frameType?: ELEMENT_TYPES) => Promise<void>
|
|
303
|
+
|
|
304
|
+
type UpdateTransactionDetailsOpts = {
|
|
305
|
+
consumer?: {
|
|
306
|
+
firstName?: string
|
|
307
|
+
lastName?: string
|
|
308
|
+
email?: string
|
|
309
|
+
phone?: string
|
|
310
|
+
}
|
|
311
|
+
billing?: {
|
|
312
|
+
addressLine: string
|
|
313
|
+
addressLine2?: string
|
|
314
|
+
zip: string
|
|
315
|
+
city: string
|
|
316
|
+
state?: string
|
|
317
|
+
countryAlpha2: string
|
|
318
|
+
}
|
|
319
|
+
shipping?: {
|
|
320
|
+
addressLine: string
|
|
321
|
+
addressLine2?: string
|
|
322
|
+
zip: string
|
|
323
|
+
city: string
|
|
324
|
+
state?: string
|
|
325
|
+
countryAlpha2: string
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
type PayOpts = {
|
|
330
|
+
source: string
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
type PayFn = (Opts: PayOpts) => Promise<unknown>
|
|
334
|
+
|
|
335
|
+
type UpdateTransactionDetailsFn = (
|
|
336
|
+
config: UpdateTransactionDetailsOpts
|
|
337
|
+
) => Promise<unknown>
|
|
338
|
+
|
|
339
|
+
type CheckoutObject = {
|
|
340
|
+
on: ListenerFn
|
|
341
|
+
once: ListenerFn
|
|
342
|
+
removeListener: ListenerFn
|
|
343
|
+
EVENT_TYPES: typeof EVENT_TYPES
|
|
344
|
+
render: RenderFn
|
|
345
|
+
paypal: PaypalFn
|
|
346
|
+
universal: UniversalFn
|
|
347
|
+
update: UpdateFn
|
|
348
|
+
updateTransactionDetails: UpdateTransactionDetailsFn
|
|
349
|
+
submit: SubmitFn
|
|
350
|
+
validate: ValidateFn
|
|
351
|
+
reset: ResetFn
|
|
352
|
+
pay: PayFn
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
|
|
356
|
+
|
|
357
|
+
type PayComFunction = (opts: PayComOpts) => Promise<{
|
|
358
|
+
checkout: CheckoutFunction
|
|
359
|
+
}>
|
|
360
|
+
|
|
361
|
+
interface PayComNamespace {
|
|
362
|
+
com: PayComFunction
|
|
363
|
+
riskIdentifier: string
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
declare module '@pay-com/js' {
|
|
367
|
+
export function loadScript(
|
|
368
|
+
options: PayComScriptOptions,
|
|
369
|
+
PromisePonyfill?: PromiseConstructor
|
|
370
|
+
): Promise<PayComNamespace | null>
|
|
371
|
+
|
|
372
|
+
export function loadCustomScript(options: {
|
|
373
|
+
url: string
|
|
374
|
+
attributes?: Record<string, string>
|
|
375
|
+
PromisePonyfill?: PromiseConstructor
|
|
376
|
+
}): Promise<void>
|
|
377
|
+
|
|
378
|
+
export const version: string
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
declare global {
|
|
382
|
+
interface Window {
|
|
383
|
+
Pay?: PayComNamespace
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare const _default: {
|
|
388
|
+
com: (options: PayComScriptOptions, PromisePonyfill?: PromiseConstructor) => Promise<{
|
|
389
|
+
checkout: CheckoutFunction;
|
|
390
|
+
}>;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export { CheckoutFunction, CheckoutObject, CheckoutToggles, EVENT_TYPES, ListenerFn, PayComFunction, PayComNamespace, PaypalOpts, RenderOpts, SubmitOpts, UniversalOpts, UpdateTransactionDetailsOpts, _default as default };
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +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};
|
package/lib/index.js
ADDED
|
@@ -0,0 +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)]}}))}))}}}));
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pay-com/js",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"author": "",
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"module": "lib/index.esm.js",
|
|
10
|
+
"types": "lib/index.d.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib/*.js",
|
|
16
|
+
"lib/*.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build:watch": "rollup -c --watch",
|
|
20
|
+
"build": "rollup -c",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"prepublish": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@rollup/plugin-commonjs": "^21.0.0",
|
|
26
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
27
|
+
"csstype": "^3.0.9",
|
|
28
|
+
"events": "^3.3.0",
|
|
29
|
+
"rollup": "^2.70.1",
|
|
30
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
31
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
32
|
+
"rollup-plugin-node-builtins": "^2.1.2",
|
|
33
|
+
"rollup-plugin-svg": "^2.0.0",
|
|
34
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
35
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
36
|
+
"typescript": "^4.4.4"
|
|
37
|
+
}
|
|
38
|
+
}
|