@pay-com/js 1.1.1 → 1.1.4
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/LICENSE +21 -0
- package/README.md +3 -3
- package/lib/index.d.ts +8 -382
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +24 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Pay.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ In order to be able to start accepting payments, intialize the checkout object:
|
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
28
|
const checkout = pay.checkout({
|
|
29
|
-
|
|
29
|
+
clientSecret: 'payment_session_client_secret',
|
|
30
30
|
onSuccess: payment => {
|
|
31
31
|
// Can be used instead of checkout event listeners
|
|
32
32
|
},
|
|
@@ -72,10 +72,10 @@ Thats it! You are now ready to securely accept payments in your website.
|
|
|
72
72
|
|
|
73
73
|
### Manual validation and submission
|
|
74
74
|
|
|
75
|
-
If you wish to render the fields without a submission button for more control, you have to pass the `
|
|
75
|
+
If you wish to render the fields without a submission button for more control, you have to pass the `submitButton: false` option to the `toggles` key under the `universal` function:
|
|
76
76
|
|
|
77
77
|
```javascript
|
|
78
|
-
checkout.
|
|
78
|
+
checkout.universal({
|
|
79
79
|
container: '#paycom_checkout',
|
|
80
80
|
toggles: {
|
|
81
81
|
submitButton: false
|
package/lib/index.d.ts
CHANGED
|
@@ -1,395 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as types from 'types';
|
|
2
|
+
export * from 'types';
|
|
3
3
|
|
|
4
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
|
|
5
|
+
identifier: string
|
|
252
6
|
sandbox?: boolean
|
|
253
7
|
debug?: boolean
|
|
254
8
|
}
|
|
255
9
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
successUrl?: string
|
|
306
|
-
failureUrl?: string
|
|
307
|
-
consumer?: {
|
|
308
|
-
firstName?: string
|
|
309
|
-
lastName?: string
|
|
310
|
-
email?: string
|
|
311
|
-
phone?: string
|
|
312
|
-
}
|
|
313
|
-
billing?: {
|
|
314
|
-
addressLine: string
|
|
315
|
-
addressLine2?: string
|
|
316
|
-
zip: string
|
|
317
|
-
city: string
|
|
318
|
-
state?: string
|
|
319
|
-
countryAlpha2: string
|
|
320
|
-
}
|
|
321
|
-
shipping?: {
|
|
322
|
-
addressLine: string
|
|
323
|
-
addressLine2?: string
|
|
324
|
-
zip: string
|
|
325
|
-
city: string
|
|
326
|
-
state?: string
|
|
327
|
-
countryAlpha2: string
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
type PayOpts = {
|
|
332
|
-
source: string
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
type PayFn = (Opts: PayOpts) => Promise<unknown>
|
|
336
|
-
|
|
337
|
-
type UpdateTransactionDetailsFn = (
|
|
338
|
-
config: UpdateTransactionDetailsOpts
|
|
339
|
-
) => Promise<unknown>
|
|
340
|
-
|
|
341
|
-
type CheckoutObject = {
|
|
342
|
-
on: ListenerFn
|
|
343
|
-
once: ListenerFn
|
|
344
|
-
removeListener: ListenerFn
|
|
345
|
-
EVENT_TYPES: typeof EVENT_TYPES
|
|
346
|
-
render: RenderFn
|
|
347
|
-
paypal: PaypalFn
|
|
348
|
-
universal: UniversalFn
|
|
349
|
-
update: UpdateFn
|
|
350
|
-
updateTransactionDetails: UpdateTransactionDetailsFn
|
|
351
|
-
submit: SubmitFn
|
|
352
|
-
validate: ValidateFn
|
|
353
|
-
reset: ResetFn
|
|
354
|
-
pay: PayFn
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
|
|
358
|
-
|
|
359
|
-
type PayComFunction = (opts: PayComOpts) => Promise<{
|
|
360
|
-
checkout: CheckoutFunction
|
|
361
|
-
}>
|
|
362
|
-
|
|
363
|
-
interface PayComNamespace {
|
|
364
|
-
com: PayComFunction
|
|
365
|
-
riskIdentifier: string
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
declare module '@pay-com/js' {
|
|
369
|
-
export function loadScript(
|
|
370
|
-
options: PayComScriptOptions,
|
|
371
|
-
PromisePonyfill?: PromiseConstructor
|
|
372
|
-
): Promise<PayComNamespace | null>
|
|
373
|
-
|
|
374
|
-
export function loadCustomScript(options: {
|
|
375
|
-
url: string
|
|
376
|
-
attributes?: Record<string, string>
|
|
377
|
-
PromisePonyfill?: PromiseConstructor
|
|
378
|
-
}): Promise<void>
|
|
379
|
-
|
|
380
|
-
export const version: string
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
declare global {
|
|
384
|
-
interface Window {
|
|
385
|
-
Pay?: PayComNamespace
|
|
386
|
-
}
|
|
10
|
+
interface PayComScriptOptions extends PayComScriptQueryParameters {
|
|
11
|
+
sdkUrlOverride?: string
|
|
12
|
+
live?: boolean
|
|
387
13
|
}
|
|
388
14
|
|
|
389
15
|
declare const _default: {
|
|
390
16
|
com: (options: PayComScriptOptions, PromisePonyfill?: PromiseConstructor) => Promise<{
|
|
391
|
-
checkout: CheckoutFunction;
|
|
17
|
+
checkout: types.CheckoutFunction;
|
|
392
18
|
}>;
|
|
393
19
|
};
|
|
394
20
|
|
|
395
|
-
export {
|
|
21
|
+
export { _default as default };
|
package/lib/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e
|
|
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};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?
|
|
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})}));
|
package/package.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pay-com/js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "",
|
|
5
|
-
"keywords": [
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"payments"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Pay.com",
|
|
8
10
|
"main": "lib/index.js",
|
|
9
11
|
"module": "lib/index.esm.js",
|
|
10
12
|
"types": "lib/index.d.ts",
|
|
11
13
|
"publishConfig": {
|
|
12
|
-
"
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/pay-com/js.git"
|
|
13
20
|
},
|
|
14
21
|
"files": [
|
|
15
22
|
"lib/*.js",
|
|
@@ -19,18 +26,28 @@
|
|
|
19
26
|
"build:watch": "rollup -c --watch",
|
|
20
27
|
"build": "rollup -c",
|
|
21
28
|
"prepublishOnly": "npm run build",
|
|
22
|
-
"
|
|
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"
|
|
23
34
|
},
|
|
24
35
|
"devDependencies": {
|
|
36
|
+
"@pay-com/eslint-config-react": "^2.0.3",
|
|
25
37
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
26
38
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
27
39
|
"csstype": "^3.0.9",
|
|
40
|
+
"eslint": "^8.46.0",
|
|
41
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
28
42
|
"events": "^3.3.0",
|
|
43
|
+
"husky": "^8.0.0",
|
|
44
|
+
"lint-staged": "^13.2.3",
|
|
45
|
+
"prettier": "^3.0.0",
|
|
29
46
|
"rollup": "^2.70.1",
|
|
30
47
|
"rollup-plugin-copy": "^3.4.0",
|
|
31
48
|
"rollup-plugin-dts": "^4.0.0",
|
|
32
49
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
33
|
-
"rollup-plugin-
|
|
50
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
34
51
|
"rollup-plugin-terser": "^7.0.2",
|
|
35
52
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
36
53
|
"typescript": "^4.4.4"
|