@pay-com/js 1.1.16 → 1.2.1

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.
@@ -130,6 +130,12 @@ export interface UniversalToggles {
130
130
  */
131
131
  submitButton?: boolean
132
132
 
133
+ /**
134
+ * If false, the default suppoerted brands footer will not appear.
135
+ * @default true
136
+ */
137
+ withCardBrandsFooterLogos?: boolean
138
+
133
139
  /**
134
140
  * If true, displays the card bin as well as last 4.
135
141
  * @default false
@@ -146,6 +152,30 @@ export interface UniversalToggles {
146
152
  * A title to display above the Universal form.
147
153
  */
148
154
  title?: string
155
+
156
+ /**
157
+ * If true, only user's saved sources will displayed.
158
+ * @default false
159
+ */
160
+ allowOnlyExistingPaymentMethods?: boolean
161
+
162
+ /**
163
+ * If true, user will not be able the pay with saved source.
164
+ * @default false
165
+ */
166
+ newCardOnly?: boolean
167
+
168
+ /**
169
+ * If true, user will not be able to remove saved source.
170
+ * @default false
171
+ */
172
+ disablePaymentMethodDeletion?: boolean
173
+
174
+ /**
175
+ * If true, the submit button will be disabled while form invalid.
176
+ * @default false
177
+ */
178
+ disableSubmitUntilFormIsValid?: boolean
149
179
  }
150
180
 
151
181
  export type LanguageLocalizationOverride = {
@@ -201,6 +231,7 @@ export interface UniversalOpts {
201
231
  container: string
202
232
  cardForm?: Omit<RenderOpts, 'container' | 'style'>
203
233
  toggles?: UniversalToggles
234
+ selectedPaymentMethod?: string
204
235
  apmsOnClickValidation?: () => Promise<boolean>
205
236
  localizations?: {
206
237
  [language: string]: LanguageLocalizationOverride
@@ -238,8 +269,10 @@ export interface UniversalOpts {
238
269
  }
239
270
  }
240
271
  }
272
+ ctp?: CTPStyles
241
273
  }
242
274
  paymentMethods?: Array<string>
275
+ alternatives?: 'button' | 'radio'
243
276
  }
244
277
 
245
278
  export interface SubmitOpts {
@@ -335,7 +368,11 @@ export enum EVENT_TYPES {
335
368
  PAYMENT_PROCESSING = 'payment_processing',
336
369
  SETUP_PROCESSING = 'setup_processing',
337
370
  SESSION_EXPIRED = 'session_expired',
338
- MAX_ATTEMPTS_REACHED = 'max_attempts_reached'
371
+ MAX_ATTEMPTS_REACHED = 'max_attempts_reached',
372
+ PAYMENT_PENDING_APPROVAL = 'payment_pending_approval',
373
+ SET_DISABLE_UI = 'set_disable_ui',
374
+ HEADLESS_READY = 'headless_ready',
375
+ FORM_VALIDATION_UPDATED = 'form_validation_update'
339
376
  }
340
377
 
341
378
  export type ListenerFn = (
@@ -415,6 +452,7 @@ export type UpdateTransactionDetailsOpts = {
415
452
  consumer?: {
416
453
  firstName?: string
417
454
  lastName?: string
455
+ name?: string
418
456
  email?: string
419
457
  phone?: string
420
458
  }
@@ -448,22 +486,161 @@ export type UpdateTransactionDetailsFn = (
448
486
  config: UpdateTransactionDetailsOpts
449
487
  ) => Promise<unknown>
450
488
 
489
+ export type ResyncFn = () => Promise<void>
490
+
491
+ export type AddressType = {
492
+ line1: string
493
+ line2?: string
494
+ city: string
495
+ state?: string
496
+ country: string
497
+ postalCode: string
498
+ }
499
+
500
+ export type HeadlessFn = (
501
+ method: string,
502
+ paymentMethodData?: unknown,
503
+ billingDetails?: AddressType
504
+ ) => Promise<unknown>
505
+
506
+ export type CanMakePaymentsFn = () => Promise<unknown>
507
+
508
+ export type InitHeadlessCtpParams = {
509
+ emailInputRef?: HTMLDivElement | string
510
+ email: string
511
+ containers: {
512
+ mainWidget: HTMLDivElement | string
513
+ linkNewCard: HTMLDivElement | string
514
+ }
515
+ style?: CTPStyles
516
+ }
517
+
518
+ export type CTPStyles = Partial<{
519
+ mainWidgetContainer: PayCssConfig
520
+ linkNewCardContainer: PayCssConfig
521
+ }>
522
+
523
+ export enum CTP_EVENTS {
524
+ VALIDATION_CHANGED = 'validation-changed',
525
+ AUTHENTICATED = 'authenticated'
526
+ }
527
+
528
+ export declare enum CtpCompletePaymentStatus {
529
+ success = 'SUCCESS',
530
+ declined = 'DECLINED'
531
+ }
532
+
533
+ export type CheckoutCTPBillingDetails = {
534
+ address: {
535
+ addressLine: string
536
+ addressLine2?: string
537
+ zip: string
538
+ city: string
539
+ state?: string
540
+ countryAlpha2: string
541
+ }
542
+ name: string
543
+ phone: string
544
+ }
545
+
546
+ export type HeadlessCtpObject = {
547
+ on: Listener<CTP_EVENTS>
548
+ once: Listener<CTP_EVENTS>
549
+ removeListener: Listener<CTP_EVENTS>
550
+ validate: () => Promise<{ valid: boolean }>
551
+ completePayment: (status: CtpCompletePaymentStatus) => Promise<void>
552
+ updateBillingDetails: (
553
+ params: Partial<CheckoutCTPBillingDetails>
554
+ ) => Promise<void>
555
+ STATUS_SUCCESS: CtpCompletePaymentStatus.success
556
+ STATUS_DECLINED: CtpCompletePaymentStatus.declined
557
+ }
558
+
559
+ export type CustomFieldType = 'input' | 'date' | 'checkbox' | 'radio' | 'select'
560
+
561
+ export type CustomFieldsOptions = {
562
+ label: string
563
+ value: string
564
+ }
565
+
566
+ export type CustomField = {
567
+ id: string
568
+ placeholder?: string
569
+ label?: string
570
+ type?: CustomFieldType
571
+ inputType?: string
572
+ options?: CustomFieldsOptions[]
573
+ description?: string
574
+ validation?: CustomFieldsValidation
575
+ }
576
+
577
+ export type CustomFieldsValidation = {
578
+ required?: boolean
579
+ max?: number
580
+ min?: number
581
+ maxLength?: number
582
+ minLength?: number
583
+ pattern?: string
584
+ }
585
+
586
+ export type PaymentMethod = {
587
+ paymentMethodType: string
588
+ name: string
589
+ redirect?: boolean
590
+ fields?: CustomField[]
591
+ }
592
+
593
+ export type CardBrand =
594
+ | 'visa'
595
+ | 'mastercard'
596
+ | 'amex'
597
+ | 'discover'
598
+ | 'jcl'
599
+ | 'unionpay'
600
+
601
+ export type ExistingCard = {
602
+ bin: string
603
+ brand: CardBrand
604
+ cardholderCurrency: string
605
+ country: string
606
+ issuerName: string
607
+ expMonth: string
608
+ expYear: string
609
+ last4: string
610
+ fingerprint: string
611
+ funding: 'prepaid' | 'debit' | 'credit' | 'charge'
612
+ network: CardBrand
613
+ payout: string
614
+ }
615
+
616
+ export type ExistingSource = {
617
+ id: string
618
+ type: string
619
+ card?: ExistingCard
620
+ }
621
+
451
622
  export type CheckoutObject = {
452
623
  on: ListenerFn
453
624
  once: ListenerFn
454
625
  removeListener: ListenerFn
455
626
  EVENT_TYPES: typeof EVENT_TYPES
627
+ ELEMENT_TYPES: typeof ELEMENT_TYPES
456
628
  render: RenderFn
457
629
  paypal: PaypalFn
458
630
  universal: UniversalFn
631
+ blur: BlurFn
459
632
  update: UpdateFn
460
633
  updateTransactionDetails: UpdateTransactionDetailsFn
461
634
  submit: SubmitFn
462
- blur: BlurFn
635
+ resync: ResyncFn
636
+ canMakePayments: CanMakePaymentsFn
463
637
  validate: ValidateFn
464
638
  reset: ResetFn
465
639
  pay: PayFn
466
- // universalV2: UniversalFn
640
+ headless: HeadlessFn
641
+ ctp: (params: InitHeadlessCtpParams) => Promise<HeadlessCtpObject>
642
+ getPaymentMethods: () => Promise<PaymentMethod[]>
643
+ getExistingSources: () => Promise<ExistingSource[]>
467
644
  }
468
645
 
469
646
  export type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
package/lib/index.d.ts CHANGED
@@ -135,6 +135,12 @@ interface UniversalToggles {
135
135
  */
136
136
  submitButton?: boolean
137
137
 
138
+ /**
139
+ * If false, the default suppoerted brands footer will not appear.
140
+ * @default true
141
+ */
142
+ withCardBrandsFooterLogos?: boolean
143
+
138
144
  /**
139
145
  * If true, displays the card bin as well as last 4.
140
146
  * @default false
@@ -151,6 +157,30 @@ interface UniversalToggles {
151
157
  * A title to display above the Universal form.
152
158
  */
153
159
  title?: string
160
+
161
+ /**
162
+ * If true, only user's saved sources will displayed.
163
+ * @default false
164
+ */
165
+ allowOnlyExistingPaymentMethods?: boolean
166
+
167
+ /**
168
+ * If true, user will not be able the pay with saved source.
169
+ * @default false
170
+ */
171
+ newCardOnly?: boolean
172
+
173
+ /**
174
+ * If true, user will not be able to remove saved source.
175
+ * @default false
176
+ */
177
+ disablePaymentMethodDeletion?: boolean
178
+
179
+ /**
180
+ * If true, the submit button will be disabled while form invalid.
181
+ * @default false
182
+ */
183
+ disableSubmitUntilFormIsValid?: boolean
154
184
  }
155
185
 
156
186
  type LanguageLocalizationOverride = {
@@ -206,6 +236,7 @@ interface UniversalOpts {
206
236
  container: string
207
237
  cardForm?: Omit<RenderOpts, 'container' | 'style'>
208
238
  toggles?: UniversalToggles
239
+ selectedPaymentMethod?: string
209
240
  apmsOnClickValidation?: () => Promise<boolean>
210
241
  localizations?: {
211
242
  [language: string]: LanguageLocalizationOverride
@@ -243,8 +274,10 @@ interface UniversalOpts {
243
274
  }
244
275
  }
245
276
  }
277
+ ctp?: CTPStyles
246
278
  }
247
279
  paymentMethods?: Array<string>
280
+ alternatives?: 'button' | 'radio'
248
281
  }
249
282
 
250
283
  interface SubmitOpts {
@@ -334,7 +367,11 @@ enum EVENT_TYPES {
334
367
  PAYMENT_PROCESSING = 'payment_processing',
335
368
  SETUP_PROCESSING = 'setup_processing',
336
369
  SESSION_EXPIRED = 'session_expired',
337
- MAX_ATTEMPTS_REACHED = 'max_attempts_reached'
370
+ MAX_ATTEMPTS_REACHED = 'max_attempts_reached',
371
+ PAYMENT_PENDING_APPROVAL = 'payment_pending_approval',
372
+ SET_DISABLE_UI = 'set_disable_ui',
373
+ HEADLESS_READY = 'headless_ready',
374
+ FORM_VALIDATION_UPDATED = 'form_validation_update'
338
375
  }
339
376
 
340
377
  type ListenerFn = (
@@ -414,6 +451,7 @@ type UpdateTransactionDetailsOpts = {
414
451
  consumer?: {
415
452
  firstName?: string
416
453
  lastName?: string
454
+ name?: string
417
455
  email?: string
418
456
  phone?: string
419
457
  }
@@ -447,22 +485,161 @@ type UpdateTransactionDetailsFn = (
447
485
  config: UpdateTransactionDetailsOpts
448
486
  ) => Promise<unknown>
449
487
 
488
+ type ResyncFn = () => Promise<void>
489
+
490
+ type AddressType = {
491
+ line1: string
492
+ line2?: string
493
+ city: string
494
+ state?: string
495
+ country: string
496
+ postalCode: string
497
+ }
498
+
499
+ type HeadlessFn = (
500
+ method: string,
501
+ paymentMethodData?: unknown,
502
+ billingDetails?: AddressType
503
+ ) => Promise<unknown>
504
+
505
+ type CanMakePaymentsFn = () => Promise<unknown>
506
+
507
+ type InitHeadlessCtpParams = {
508
+ emailInputRef?: HTMLDivElement | string
509
+ email: string
510
+ containers: {
511
+ mainWidget: HTMLDivElement | string
512
+ linkNewCard: HTMLDivElement | string
513
+ }
514
+ style?: CTPStyles
515
+ }
516
+
517
+ type CTPStyles = Partial<{
518
+ mainWidgetContainer: PayCssConfig
519
+ linkNewCardContainer: PayCssConfig
520
+ }>
521
+
522
+ enum CTP_EVENTS {
523
+ VALIDATION_CHANGED = 'validation-changed',
524
+ AUTHENTICATED = 'authenticated'
525
+ }
526
+
527
+ declare enum CtpCompletePaymentStatus {
528
+ success = 'SUCCESS',
529
+ declined = 'DECLINED'
530
+ }
531
+
532
+ type CheckoutCTPBillingDetails = {
533
+ address: {
534
+ addressLine: string
535
+ addressLine2?: string
536
+ zip: string
537
+ city: string
538
+ state?: string
539
+ countryAlpha2: string
540
+ }
541
+ name: string
542
+ phone: string
543
+ }
544
+
545
+ type HeadlessCtpObject = {
546
+ on: Listener<CTP_EVENTS>
547
+ once: Listener<CTP_EVENTS>
548
+ removeListener: Listener<CTP_EVENTS>
549
+ validate: () => Promise<{ valid: boolean }>
550
+ completePayment: (status: CtpCompletePaymentStatus) => Promise<void>
551
+ updateBillingDetails: (
552
+ params: Partial<CheckoutCTPBillingDetails>
553
+ ) => Promise<void>
554
+ STATUS_SUCCESS: CtpCompletePaymentStatus.success
555
+ STATUS_DECLINED: CtpCompletePaymentStatus.declined
556
+ }
557
+
558
+ type CustomFieldType = 'input' | 'date' | 'checkbox' | 'radio' | 'select'
559
+
560
+ type CustomFieldsOptions = {
561
+ label: string
562
+ value: string
563
+ }
564
+
565
+ type CustomField = {
566
+ id: string
567
+ placeholder?: string
568
+ label?: string
569
+ type?: CustomFieldType
570
+ inputType?: string
571
+ options?: CustomFieldsOptions[]
572
+ description?: string
573
+ validation?: CustomFieldsValidation
574
+ }
575
+
576
+ type CustomFieldsValidation = {
577
+ required?: boolean
578
+ max?: number
579
+ min?: number
580
+ maxLength?: number
581
+ minLength?: number
582
+ pattern?: string
583
+ }
584
+
585
+ type PaymentMethod = {
586
+ paymentMethodType: string
587
+ name: string
588
+ redirect?: boolean
589
+ fields?: CustomField[]
590
+ }
591
+
592
+ type CardBrand =
593
+ | 'visa'
594
+ | 'mastercard'
595
+ | 'amex'
596
+ | 'discover'
597
+ | 'jcl'
598
+ | 'unionpay'
599
+
600
+ type ExistingCard = {
601
+ bin: string
602
+ brand: CardBrand
603
+ cardholderCurrency: string
604
+ country: string
605
+ issuerName: string
606
+ expMonth: string
607
+ expYear: string
608
+ last4: string
609
+ fingerprint: string
610
+ funding: 'prepaid' | 'debit' | 'credit' | 'charge'
611
+ network: CardBrand
612
+ payout: string
613
+ }
614
+
615
+ type ExistingSource = {
616
+ id: string
617
+ type: string
618
+ card?: ExistingCard
619
+ }
620
+
450
621
  type CheckoutObject = {
451
622
  on: ListenerFn
452
623
  once: ListenerFn
453
624
  removeListener: ListenerFn
454
625
  EVENT_TYPES: typeof EVENT_TYPES
626
+ ELEMENT_TYPES: typeof ELEMENT_TYPES
455
627
  render: RenderFn
456
628
  paypal: PaypalFn
457
629
  universal: UniversalFn
630
+ blur: BlurFn
458
631
  update: UpdateFn
459
632
  updateTransactionDetails: UpdateTransactionDetailsFn
460
633
  submit: SubmitFn
461
- blur: BlurFn
634
+ resync: ResyncFn
635
+ canMakePayments: CanMakePaymentsFn
462
636
  validate: ValidateFn
463
637
  reset: ResetFn
464
638
  pay: PayFn
465
- // universalV2: UniversalFn
639
+ headless: HeadlessFn
640
+ ctp: (params: InitHeadlessCtpParams) => Promise<HeadlessCtpObject>
641
+ getPaymentMethods: () => Promise<PaymentMethod[]>
642
+ getExistingSources: () => Promise<ExistingSource[]>
466
643
  }
467
644
 
468
645
  type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pay-com/js",
3
- "version": "1.1.16",
3
+ "version": "1.2.1",
4
4
  "description": "Pay.com JS loading utility",
5
5
  "keywords": [
6
6
  "Pay.com",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "https://github.com/pay-com/js.git"
21
+ "url": "git+https://github.com/pay-com/js.git"
22
22
  },
23
23
  "files": [
24
24
  "lib/*.js",