@payrails/web-sdk 5.15.0 → 5.16.0-RC.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "5.15.0",
3
+ "version": "5.16.0-RC.1",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -122,6 +122,29 @@
122
122
  margin-bottom: 4px;
123
123
  }
124
124
 
125
+ .payrails-address-selector-wrapper {
126
+ display: flex;
127
+ flex-wrap: wrap;
128
+ gap: 8px;
129
+ width: 100%;
130
+ }
131
+
132
+ .payrails-address-selector-wrapper > * {
133
+ width: 48% !important; /* Default width for all children */
134
+ }
135
+ /* Styles for when there's only one child */
136
+ .payrails-address-selector-wrapper > *:first-child:last-child {
137
+ width: 100% !important;
138
+ }
139
+
140
+ .payrails-address-selector-wrapper > *.hidden {
141
+ display: none;
142
+ }
143
+
144
+ .payrails-address-selector-wrapper .payrails-error {
145
+ border-color: red;
146
+ }
147
+
125
148
  .payrails-payment-installments-dropdown {
126
149
  display: flex;
127
150
  flex-wrap: wrap;
package/payrails.d.ts CHANGED
@@ -48,6 +48,7 @@ declare class WorkflowExecution {
48
48
  supportedNetworks: string[];
49
49
  countryCode: string;
50
50
  merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
51
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
51
52
  };
52
53
  get url(): string;
53
54
  get response(): WorkflowExecutionResponse;
@@ -69,6 +70,7 @@ declare class WorkflowExecution {
69
70
  get authorizeLink(): string | undefined;
70
71
  get createSessionLink(): string | undefined;
71
72
  get storedPaymentInstruments(): StoredPaymentInstrument<PayPalMetadata & CardMetadata>[];
73
+ getFullPaymentMethodConfig(paymentMethod: PAYMENT_METHOD_CODES): StorablePaymentCompositionOption<CardMetadata | PayPalMetadata, ApplePayConfig | PayPalConfig | GooglePayConfig | undefined> | undefined;
72
74
  isPaymentInstallmentsEnabled(paymentMethod: PAYMENT_METHOD_CODES): boolean | undefined;
73
75
  getPaymentInstallmentOptions(paymentMethod: PAYMENT_METHOD_CODES): PaymentInstallmentsConfig;
74
76
  private getStoredInstrumentForPaymentMethod;
@@ -82,6 +84,7 @@ declare class WorkflowExecution {
82
84
  flow?: PAYMENT_CLIENT_FLOW;
83
85
  supportsInstallments?: boolean;
84
86
  installments?: PaymentInstallmentsConfig;
87
+ supportsBillingInfo?: boolean;
85
88
  };
86
89
  paymentMethodCode: PAYMENT_METHOD_CODES;
87
90
  } | undefined;
@@ -95,6 +98,7 @@ declare class WorkflowExecution {
95
98
  flow?: PAYMENT_CLIENT_FLOW;
96
99
  supportsInstallments?: boolean;
97
100
  installments?: PaymentInstallmentsConfig;
101
+ supportsBillingInfo?: boolean;
98
102
  };
99
103
  paymentMethodCode: PAYMENT_METHOD_CODES;
100
104
  };
@@ -181,6 +185,7 @@ interface StorablePaymentCompositionOption<I = CardMetadata | PayPalMetadata, C
181
185
  flow?: PAYMENT_CLIENT_FLOW;
182
186
  supportsInstallments?: boolean;
183
187
  installments?: PaymentInstallmentsConfig;
188
+ supportsBillingInfo?: boolean;
184
189
  };
185
190
  paymentInstruments?: Array<StoredPaymentInstrument<I>>;
186
191
  }
@@ -203,6 +208,7 @@ interface ApplePayConfig {
203
208
  supportedNetworks: string[];
204
209
  countryCode: string;
205
210
  merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
211
+ requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
206
212
  };
207
213
  type: string;
208
214
  }
@@ -598,6 +604,34 @@ declare const regexes: {
598
604
  };
599
605
  type CardNetwork = keyof typeof regexes;
600
606
 
607
+ interface IAddress {
608
+ country?: {
609
+ code?: string;
610
+ fullName?: string;
611
+ iso3?: string;
612
+ };
613
+ postalCode?: string;
614
+ }
615
+ interface IOnChange {
616
+ isValid: boolean;
617
+ billingAddress?: IAddress;
618
+ }
619
+ interface AddressSelectorElementOptions extends ElementOptions {
620
+ translations?: {
621
+ COUNTRY_SELECTOR?: string;
622
+ POSTAL_CODE_INPUT?: string;
623
+ };
624
+ styles?: {
625
+ wrapper?: Partial<CSSStyleDeclaration>;
626
+ countrySelector?: Partial<CSSStyleDeclaration>;
627
+ postalCodeInput?: Partial<CSSStyleDeclaration>;
628
+ };
629
+ events?: {
630
+ onBillingAddressChanged?: (address: IAddress) => void;
631
+ onChange?: (e: IOnChange) => void;
632
+ };
633
+ }
634
+
601
635
  interface PaymentInstallmentsElementOptions extends ElementOptions {
602
636
  showPaymentInstallmentsDropdown?: boolean;
603
637
  installmentOptions?: BaseInstallmentOption[] | null;
@@ -639,6 +673,7 @@ interface OnChange {
639
673
  isValid: boolean;
640
674
  cardNetwork: CardNetwork | '';
641
675
  bin?: string;
676
+ billingAddress?: IAddress;
642
677
  }
643
678
  interface CardFormOptions extends StoreInstrumentElementOptions {
644
679
  showCardHolderName?: boolean;
@@ -655,13 +690,14 @@ interface CardFormOptions extends StoreInstrumentElementOptions {
655
690
  storeInstrument?: string;
656
691
  paymentInstallments?: string;
657
692
  };
693
+ addressSelector?: AddressSelectorElementOptions['translations'];
658
694
  };
659
695
  events?: {
660
696
  onFocus?: () => void;
661
697
  onChange?: (e: OnChange) => void;
662
698
  onSaveInstrumentCheckboxChanged?: PayrailsSDKEvents['onSaveInstrumentCheckboxChanged'];
663
699
  onReady?: () => void;
664
- };
700
+ } & AddressSelectorElementOptions['events'];
665
701
  styles?: {
666
702
  wrapper?: Partial<CSSStyleDeclaration>;
667
703
  base?: Partial<CSSStyleDeclaration>;
@@ -675,6 +711,7 @@ interface CardFormOptions extends StoreInstrumentElementOptions {
675
711
  labels?: {
676
712
  [key in ElementType | 'all']?: Partial<CSSStyleDeclaration>;
677
713
  };
714
+ addressSelector?: AddressSelectorElementOptions['styles'];
678
715
  } & StoreInstrumentElementOptions['styles'] & PaymentInstallmentsElementOptions['styles'];
679
716
  }
680
717
  declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
@@ -684,12 +721,14 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
684
721
  get isBinLookupEnabled(): boolean;
685
722
  private readonly formFields;
686
723
  private readonly paymentInstallmentsDropdown;
724
+ private readonly addressComponent;
687
725
  private throttledFetchBinLookup;
688
726
  private lastBin;
689
727
  private lastBinLookup;
690
728
  constructor(collectContainer: PayrailsCollectContainer, options?: CardFormOptions | undefined);
691
729
  throttledFetchBinLookupIfChanged(): Promise<BinLookupResponse | null>;
692
730
  tokenize(opts: TokenizeOptions): Promise<SaveInstrumentResponse>;
731
+ private createAddressSelector;
693
732
  show(): void;
694
733
  hide(): void;
695
734
  private triggerOnReady;
@@ -704,8 +743,10 @@ declare class CardForm extends PayrailsElementWithStoreInstrumentCheckbox {
704
743
  storeInstrument: boolean;
705
744
  selectedInstallment: number | undefined;
706
745
  enrollInstrumentToNetworkOffers: boolean;
746
+ billingInfo: IAddress | undefined;
707
747
  }>;
708
748
  protected get selectedInstallment(): number | undefined;
749
+ protected get billingAddress(): IAddress | undefined;
709
750
  private enforceEnrollInstrumentToNetworkOffersForMasterCard;
710
751
  fetchBinLookup(): Promise<string | {
711
752
  bin: string;
@@ -1027,6 +1068,7 @@ interface DropinOptions {
1027
1068
  };
1028
1069
  paypalButton?: PaypalDropinOptions['translations'];
1029
1070
  mercadoPago?: GenericRedirectDropinOptions['translations'];
1071
+ addressSelector?: AddressSelectorElementOptions['translations'];
1030
1072
  };
1031
1073
  styles?: {
1032
1074
  [key: string]: any;
@@ -1039,6 +1081,7 @@ interface DropinOptions {
1039
1081
  cardPaymentButton?: CardPaymentButtonOptions['styles'];
1040
1082
  authSuccess?: Partial<CSSStyleDeclaration>;
1041
1083
  authFailed?: Partial<CSSStyleDeclaration>;
1084
+ addressSelector?: AddressSelectorElementOptions['styles'];
1042
1085
  mercadoPago?: GenericRedirectDropinOptions['styles'];
1043
1086
  };
1044
1087
  }
@@ -1155,6 +1198,7 @@ interface UIEvents {
1155
1198
  onSaveInstrumentCheckboxChanged?: ({ checked }: {
1156
1199
  checked: boolean;
1157
1200
  }) => void;
1201
+ onBillingAddressChanged?: (e: any) => void;
1158
1202
  }
1159
1203
  type onPaymentMethodSelectedParams = {
1160
1204
  paymentMethod?: StorablePaymentCompositionOption;
@@ -1162,6 +1206,7 @@ type onPaymentMethodSelectedParams = {
1162
1206
  };
1163
1207
  interface DropinEvents {
1164
1208
  onPaymentOptionSelected?: (e: onPaymentMethodSelectedParams) => void;
1209
+ onBillingAddressChanged?: (e: any) => void;
1165
1210
  }
1166
1211
  type PayrailsSDKEvents = PaymentEvents & UIEvents & DropinEvents;
1167
1212
  interface SdkConfiguration {