@payrails/web-sdk 5.1.0 → 5.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -34,7 +34,9 @@
34
34
  }
35
35
 
36
36
  #payrails-card-payment-button .dot-flashing {
37
- position: relative;
37
+ position: absolute;
38
+ left: auto;
39
+ right: auto;
38
40
  width: 10px;
39
41
  height: 10px;
40
42
  border-radius: 5px;
@@ -73,11 +75,11 @@
73
75
 
74
76
  @keyframes dot-flashing {
75
77
  0% {
76
- background-color: #015bbb;
78
+ opacity: 1;
77
79
  }
78
80
  50%,
79
81
  100% {
80
- background-color: rgba(152, 128, 255, 0.2);
82
+ opacity: .2;
81
83
  }
82
84
  }
83
85
 
@@ -157,6 +159,15 @@
157
159
  font-weight: bolder;
158
160
  }
159
161
 
162
+ .payment-option-text {
163
+ display: inline-flex;
164
+ align-items: center;
165
+ }
166
+
167
+ .payment-option-icon {
168
+ width: 24px;
169
+ margin-right: 7px;
170
+ }
160
171
  #payrails-dropin-component {
161
172
  border-radius: 0;
162
173
  box-shadow: none;
@@ -250,6 +261,11 @@
250
261
  align-items: center;
251
262
  }
252
263
 
264
+ .payrails-dropin-item .payrails-store-instrument-icon {
265
+ width: 24px;
266
+ margin-right: 7px;
267
+ }
268
+
253
269
  .payrails-dropin-item.payrails-store-instrument {
254
270
  display: block;
255
271
  margin-top: 20px !important;
@@ -460,6 +476,72 @@
460
476
  }
461
477
  }
462
478
 
479
+ .payrails-generic-button * {
480
+ box-sizing: border-box;
481
+ }
482
+
483
+ .payrails-generic-button .dot-flashing-container {
484
+ width: 100%;
485
+ display: flex;
486
+ justify-content: center;
487
+ align-items: center;
488
+ position: relative;
489
+ }
490
+
491
+ .payrails-generic-button .dot-flashing-text {
492
+ visibility: hidden;
493
+ }
494
+
495
+ .payrails-generic-button .dot-flashing {
496
+ position: absolute;
497
+ left: auto;
498
+ right: auto;
499
+ width: 10px;
500
+ height: 10px;
501
+ border-radius: 5px;
502
+ background-color: currentColor;
503
+ color: currentColor;
504
+ animation: dot-flashing 1s infinite linear alternate;
505
+ animation-delay: 0.5s;
506
+ }
507
+ .payrails-generic-button .dot-flashing::before,
508
+ .payrails-generic-button .dot-flashing::after {
509
+ content: '';
510
+ display: inline-block;
511
+ position: absolute;
512
+ top: 0;
513
+ }
514
+ .payrails-generic-button .dot-flashing::before {
515
+ left: -15px;
516
+ width: 10px;
517
+ height: 10px;
518
+ border-radius: 5px;
519
+ background-color: currentColor;
520
+ color: currentColor;
521
+ animation: dot-flashing 1s infinite alternate;
522
+ animation-delay: 0s;
523
+ }
524
+ .payrails-generic-button .dot-flashing::after {
525
+ left: 15px;
526
+ width: 10px;
527
+ height: 10px;
528
+ border-radius: 5px;
529
+ background-color: currentColor;
530
+ color: currentColor;
531
+ animation: dot-flashing 1s infinite alternate;
532
+ animation-delay: 1s;
533
+ }
534
+
535
+ @keyframes dot-flashing {
536
+ 0% {
537
+ opacity: 1;
538
+ }
539
+ 50%,
540
+ 100% {
541
+ opacity: .2;
542
+ }
543
+ }
544
+
463
545
  #payrails-paypal-button-wrapper {
464
546
  min-height: 44px;
465
547
  margin: 8px 4px;
package/payrails.d.ts CHANGED
@@ -167,6 +167,7 @@ interface StoredPaymentInstrument<T = CardMetadata | PayPalMetadata> {
167
167
  id: string;
168
168
  status: PAYMENT_INSTRUMENT_STATUS;
169
169
  paymentMethod: PAYMENT_METHOD_CODES;
170
+ displayName?: string;
170
171
  data?: T;
171
172
  }
172
173
  interface PayPalMetadata {
@@ -175,6 +176,7 @@ interface PayPalMetadata {
175
176
  interface CardMetadata {
176
177
  bin?: string;
177
178
  suffix?: string;
179
+ network?: string;
178
180
  }
179
181
 
180
182
  interface SaveInstrumentResponse {
@@ -538,12 +540,11 @@ declare class ApplePayButton extends PayrailsElementWithStoreInstrumentCheckbox
538
540
  private execution;
539
541
  protected options: ApplePayButtonOptions;
540
542
  private appleButton;
541
- private loadScript;
542
543
  private paymentExecutor;
544
+ static isApplePayAvailable(): Promise<boolean>;
543
545
  constructor(sdkConfig: SdkConfiguration, execution: WorkflowExecution, options: ApplePayButtonOptions);
544
546
  mount(location: string): void;
545
547
  unmount(): void;
546
- private isApplePayAvailable;
547
548
  private mountApplePayButton;
548
549
  private createApplePaySession;
549
550
  private onApplePayAuthorized;
@@ -698,11 +699,8 @@ declare enum AuthorizationFailureReasons {
698
699
  }
699
700
 
700
701
  interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
701
- environment?: 'TEST' | 'PRODUCTION';
702
- merchantInfo?: {
703
- merchantId: string;
704
- merchantName?: string;
705
- };
702
+ environment?: PayrailsEnvironment;
703
+ merchantInfo?: google.payments.api.MerchantInfo;
706
704
  events?: PaymentEvents & UIEvents & {
707
705
  onGooglePayAvailable?: () => void;
708
706
  };
@@ -719,7 +717,9 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
719
717
  protected options: GooglePayButtonOptions;
720
718
  private googleButton;
721
719
  private readonly paymentExecutor;
722
- private loadScript;
720
+ private static googleSDKClient;
721
+ private static getSDKClient;
722
+ static isGooglePayAvailable(allowedPaymentMethods: google.payments.api.IsReadyToPayPaymentMethodSpecification[], environment?: PayrailsEnvironment, merchantInfo?: google.payments.api.MerchantInfo): Promise<boolean>;
723
723
  constructor(sdkConfig: SdkConfiguration, execution: WorkflowExecution, options: GooglePayButtonOptions);
724
724
  private sdkLoaded;
725
725
  private onLoadPaymentData;
@@ -735,24 +735,25 @@ interface DropinElementEvents extends PaymentEvents {
735
735
  interface DropinElementStyles {
736
736
  base?: Partial<CSSStyleDeclaration>;
737
737
  active?: Partial<CSSStyleDeclaration>;
738
- }
739
- declare abstract class DropinElement extends PayrailsElement {
740
- protected events?: DropinElementEvents | undefined;
741
- protected styles?: DropinElementStyles | undefined;
742
- protected abstract component: PayrailsElement;
743
- protected isActive: boolean;
744
- input: HTMLInputElement;
745
- protected label: HTMLLabelElement;
746
- protected constructor(id: string, label: string, events?: DropinElementEvents | undefined, styles?: DropinElementStyles | undefined);
747
- get identifier(): string;
748
- deactivate(): void;
749
- protected applyBaseStyles(): void;
750
- protected applyActiveStyles(): void;
751
- activate(): void;
738
+ }
739
+
740
+ interface ButtonOptions {
741
+ id: string;
742
+ events?: PayrailsSDKEvents & {
743
+ onClick?: () => Promise<void>;
744
+ };
745
+ translations: {
746
+ label: string;
747
+ };
748
+ styles?: {
749
+ base?: Partial<CSSStyleDeclaration>;
750
+ loading?: Partial<CSSStyleDeclaration>;
751
+ hover?: Partial<CSSStyleDeclaration>;
752
+ };
752
753
  }
753
754
 
754
755
  interface GenericRedirectButtonOptions {
755
- styles?: Partial<CSSStyleDeclaration>;
756
+ styles?: ButtonOptions['styles'];
756
757
  translations?: {
757
758
  label?: string;
758
759
  };
@@ -760,33 +761,22 @@ interface GenericRedirectButtonOptions {
760
761
  }
761
762
  declare class GenericRedirectButton extends PayrailsElement {
762
763
  private sdkConfig;
763
- private execution;
764
764
  protected options: GenericRedirectButtonOptions;
765
765
  private readonly returnInfo?;
766
- private button;
767
766
  constructor(sdkConfig: SdkConfiguration, execution: WorkflowExecution, options: GenericRedirectButtonOptions, returnInfo?: ReturnInfo | undefined);
767
+ private buildRedirectButton;
768
768
  private paymentExecutor;
769
769
  private onClick;
770
- private configureButton;
771
770
  mount(location: string): void;
772
771
  }
773
772
 
774
773
  interface GenericRedirectDropinOptions {
775
- styles?: {
776
- button?: GenericRedirectButtonOptions['styles'];
777
- } & DropinElementStyles;
774
+ styles?: DropinElementStyles;
778
775
  translations?: {
779
776
  label?: string;
780
777
  button?: GenericRedirectButtonOptions['translations'];
781
778
  };
782
779
  events?: DropinElementEvents & PaymentEvents;
783
- }
784
- declare class MercadoPagoDropin extends DropinElement {
785
- private sdkConfig;
786
- private execution;
787
- private readonly returnInfo?;
788
- protected component: GenericRedirectButton;
789
- constructor(sdkConfig: SdkConfiguration, execution: WorkflowExecution, options?: GenericRedirectDropinOptions, returnInfo?: ReturnInfo | undefined);
790
780
  }
791
781
 
792
782
  interface GooglePayDropinOptions extends GooglePayButtonOptions {
@@ -820,11 +810,11 @@ declare class PaypalButton extends PayrailsElementWithStoreInstrumentCheckbox {
820
810
  fraudNetGuid: string | undefined;
821
811
  private paymentExecutor;
822
812
  private button;
823
- private paypalLoader;
824
813
  private confirmLink;
825
814
  private buttonWrapperId;
826
815
  private checkboxWrapperId;
827
816
  private loadPaypal;
817
+ private get paypalScriptConfig();
828
818
  private createPaypalButton;
829
819
  private createPayPalButtonConfig;
830
820
  private createBillingAgreementConfig;
@@ -915,10 +905,32 @@ interface DropinOptions {
915
905
  applePayButton?: ApplePayButtonOptions['styles'];
916
906
  cardForm?: CardFormOptions['styles'];
917
907
  cardPaymentButton?: CardPaymentButtonOptions['styles'];
918
- mercadoPago?: MercadoPagoDropin['styles'];
908
+ mercadoPago?: GenericRedirectDropinOptions['styles'];
919
909
  };
920
910
  }
921
911
 
912
+ declare class SdkLoader {
913
+ static load<T = void>(sdk: ThirdPartySDK, params?: PayPalScriptConfig): Promise<T>;
914
+ static reset(): void;
915
+ static preloadCardForm(): void;
916
+ private static loadScript;
917
+ private static loadPayPalScript;
918
+ private static readonly scriptMap;
919
+ private constructor();
920
+ private static logLoadError;
921
+ }
922
+ interface PayPalScriptConfig {
923
+ clientId: string;
924
+ currency: string;
925
+ vault: boolean;
926
+ intent: 'tokenize' | 'capture' | 'authorize';
927
+ }
928
+ declare enum ThirdPartySDK {
929
+ ApplePay = "https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",
930
+ GooglePay = "https://pay.google.com/gp/p/js/pay.js",
931
+ PayPal = "paypal-sdk"
932
+ }
933
+
922
934
  type FraudNetPageId = 'home-page' | 'search-result-page' | 'category-page' | 'product-detail-page' | 'cart-page' | 'inline-cart-page' | 'checkout-page';
923
935
  declare class FraudNet implements Mountable {
924
936
  private pageId;
@@ -938,7 +950,7 @@ declare class FraudNet implements Mountable {
938
950
  }
939
951
 
940
952
  interface PayrailsClientOptions {
941
- environment?: 'TEST' | 'PRODUCTION';
953
+ environment?: PayrailsEnvironment;
942
954
  events?: {
943
955
  onClientInitialized: (execution: WorkflowExecution) => void;
944
956
  };
@@ -960,12 +972,14 @@ declare class Payrails {
960
972
  private __fraudNet;
961
973
  private __paypalButton;
962
974
  private __genericRedirectButton;
963
- static preloadCardForm: () => void;
975
+ static preloadCardForm: typeof SdkLoader.preloadCardForm;
964
976
  static init(initResponse: InitOptions, options?: PayrailsClientOptions): Payrails;
965
977
  update(amount: PayrailsAmount): void;
966
978
  collectContainer(containerOptions: CollectContainerOptions): PayrailsCollectContainer;
967
979
  googlePayButton(options: GooglePayButtonOptions): GooglePayButton;
980
+ isGooglePayAvailable(merchantInfo: google.payments.api.MerchantInfo): Promise<boolean>;
968
981
  applePayButton(options: ApplePayButtonOptions): ApplePayButton;
982
+ isApplePayAvailable(): Promise<boolean>;
969
983
  cardList(options?: CardListOptions): CardList;
970
984
  cardForm(options?: CardFormOptions): CardForm;
971
985
  dropin(options: DropinOptions): Dropin;
@@ -1027,6 +1041,10 @@ interface SdkConfiguration {
1027
1041
  interface PayrailsAmount {
1028
1042
  value: string;
1029
1043
  currency: string;
1044
+ }
1045
+ declare enum PayrailsEnvironment {
1046
+ TEST = "TEST",
1047
+ PRODUCTION = "PRODUCTION"
1030
1048
  }
1031
1049
 
1032
1050
  type TokenizedCollectResult = {