airwallex-payment-elements 0.2.66 → 0.2.70

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.
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [0.2.66] */
1
+ /* Airwallex Checkout Component Version [0.2.70] */
2
2
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js",t=e=>{const r=document.createElement("script");r.src=`${e}${o}`;const t=document.head||document.body;if(!t)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return t.appendChild(r),r};exports.confirmPaymentIntent=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},exports.confirmPaymentIntentWithSavedCard=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},exports.createElement=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),exports.createPaymentConsent=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},exports.createPaymentMethod=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},exports.destroyElement=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),exports.get3dsReturnUrl=e=>window.Airwallex.get3dsReturnUrl(e),exports.getBrowserInfo=e=>window.Airwallex.getBrowserInfo(e),exports.getDeviceFingerprint=e=>window.Airwallex.getDeviceFingerprint(e),exports.getElement=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),exports.getGatewayUrl=r,exports.getPaymentIntent=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},exports.handle3ds=e=>window.Airwallex.handle3ds(e),exports.init=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},exports.loadAirwallex=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const l=async()=>{const n=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||t(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),n.remove&&n.remove()}))}))};for(;n<3;)try{return await l()}catch(e){n++,await new Promise((e=>window.setTimeout(e,500)))}return null},exports.loadAirwallexJs=t,exports.redirectToCheckout=e=>{window.Airwallex?window.Airwallex.redirectToCheckout(e):console.error("Please loadAirwallex() before redirectToCheckout();")};
3
3
  //# sourceMappingURL=airwallex.cjs.js.map
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [0.2.66] */
1
+ /* Airwallex Checkout Component Version [0.2.70] */
2
2
  const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js",l=e=>{const r=document.createElement("script");r.src=`${e}${o}`;const l=document.head||document.body;if(!l)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return l.appendChild(r),r},n=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const w=async()=>{const n=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||l(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),n.remove&&n.remove()}))}))};for(;n<3;)try{return await w()}catch(e){n++,await new Promise((e=>window.setTimeout(e,500)))}return null},w=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},i=e=>{window.Airwallex?window.Airwallex.redirectToCheckout(e):console.error("Please loadAirwallex() before redirectToCheckout();")},t=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),a=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getBrowserInfo(e),f=e=>window.Airwallex.getDeviceFingerprint(e),h=e=>window.Airwallex.get3dsReturnUrl(e),y=e=>window.Airwallex.handle3ds(e);export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,t as createElement,A as createPaymentConsent,x as createPaymentMethod,a as destroyElement,h as get3dsReturnUrl,u as getBrowserInfo,f as getDeviceFingerprint,d as getElement,r as getGatewayUrl,m as getPaymentIntent,y as handle3ds,w as init,n as loadAirwallex,l as loadAirwallexJs,i as redirectToCheckout};
3
3
  //# sourceMappingURL=airwallex.es.js.map
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [0.2.66] */
1
+ /* Airwallex Checkout Component Version [0.2.70] */
2
2
  var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,o="/assets/elements.bundle.min.js",l=e=>{const r=document.createElement("script");r.src=`${e}${o}`;const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r};return e.confirmPaymentIntent=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},e.confirmPaymentIntentWithSavedCard=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},e.createElement=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),e.createPaymentConsent=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},e.createPaymentMethod=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},e.destroyElement=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),e.get3dsReturnUrl=e=>window.Airwallex.get3dsReturnUrl(e),e.getBrowserInfo=e=>window.Airwallex.getBrowserInfo(e),e.getDeviceFingerprint=e=>window.Airwallex.getDeviceFingerprint(e),e.getElement=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),e.getGatewayUrl=n,e.getPaymentIntent=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},e.handle3ds=e=>window.Airwallex.handle3ds(e),e.init=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},e.loadAirwallex=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let r=0;const t=async()=>{const r=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||l(n((null==e?void 0:e.env)||"prod"));return new Promise(((n,o)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),n(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;r<3;)try{return await t()}catch(e){r++,await new Promise((e=>window.setTimeout(e,500)))}return null},e.loadAirwallexJs=l,e.redirectToCheckout=e=>{window.Airwallex?window.Airwallex.redirectToCheckout(e):console.error("Please loadAirwallex() before redirectToCheckout();")},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
3
3
  //# sourceMappingURL=airwallex.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "airwallex-payment-elements",
3
- "version": "0.2.66",
3
+ "version": "0.2.70",
4
4
  "module": "lib/bin/airwallex.es.js",
5
5
  "main": "lib/bin/airwallex.cjs.js",
6
6
  "bin": "lib/bin/airwallex.cjs.js",
@@ -95,6 +95,7 @@
95
95
  ]
96
96
  },
97
97
  "dependencies": {
98
+ "@types/googlepay": "^0.6.4",
98
99
  "@types/applepayjs": "^3.0.3",
99
100
  "csstype": "^3.0.6"
100
101
  }
@@ -12,7 +12,7 @@ import {
12
12
  } from './element';
13
13
  import { QrcodeElementOptions } from './qrcodeElement';
14
14
  import { Intent, PaymentMethodBasicInfo } from './cardNumber';
15
- import { BoxStyle, PaymentMethodType, ApplePayHppOrDropInRequestOptions } from './element';
15
+ import { BoxStyle, PaymentMethodType, ApplePayHppOrDropInRequestOptions, GooglePayHppRequestOptions } from './element';
16
16
  import { getBrowserInfo, getDeviceFingerprint, get3dsReturnUrl, handle3ds } from './fraud';
17
17
  import { DropInElementOptions } from './dropInElement';
18
18
  import { RedirectElementOptions } from './redirectElement';
@@ -176,6 +176,10 @@ export interface HostPaymentPage {
176
176
  * If you want to integrate with apple pay, you need to provide the following options
177
177
  */
178
178
  applePayRequestOptions?: ApplePayHppOrDropInRequestOptions;
179
+ /**
180
+ * Define google pay type and it's mapped option type
181
+ */
182
+ googlePayRequestOptions?: GooglePayHppRequestOptions;
179
183
  /**
180
184
  * Currency of your payment intent or consent. Three-letter ISO currency code
181
185
  */
@@ -34,7 +34,19 @@ export interface Intent {
34
34
  status: 'PENDING_VERIFICATION' | 'VERIFIED' | 'DISABLED';
35
35
  payment_method: {
36
36
  id?: string;
37
- type: string;
37
+ type: 'card' | 'ach_direct_debit' | 'becs_direct_debit';
38
+ ach_direct_debit?: {
39
+ aba_routing_number: string;
40
+ account_number: string;
41
+ owner_name: string;
42
+ owner_email: string;
43
+ };
44
+ becs_direct_debit?: {
45
+ bsb_number: string;
46
+ account_number: string;
47
+ owner_name: string;
48
+ owner_email: string;
49
+ };
38
50
  };
39
51
  }[];
40
52
  customer_payment_methods?: {
@@ -1,6 +1,6 @@
1
1
  import { ElementOptions, PaymentMethodType, BoxStyle } from './element';
2
2
  import { Mode, HppRecurringOptions } from './airwallex';
3
- import { ApplePayHppOrDropInRequestOptions } from './element';
3
+ import { ApplePayHppOrDropInRequestOptions, GooglePayRequestOptions } from './element';
4
4
 
5
5
  /**
6
6
  * Apply to dropIn element type integration, interface used when call createElement with type `dropIn`
@@ -33,6 +33,11 @@ export interface DropInElementOptions extends ElementOptions {
33
33
  * If you want to integrate with apple pay, you need to provide the following options
34
34
  */
35
35
  applePayRequestOptions?: ApplePayHppOrDropInRequestOptions;
36
+ /**
37
+ * The options of apple pay
38
+ * If you want to integrate with apple pay, you need to provide the following options
39
+ */
40
+ googlePayRequestOptions?: GooglePayRequestOptions;
36
41
  /**
37
42
  * Indicate to improve 3DS experience, indicate if the payment form will collect billing info from shopper
38
43
  */
@@ -14,6 +14,7 @@ export type ElementType =
14
14
  | 'cardNumber'
15
15
  | 'expiry'
16
16
  | 'cvc'
17
+ | 'googlePayButton'
17
18
  /**
18
19
  * @deprecated paymentRequestButton is no longer supported by airwallex
19
20
  */
@@ -98,6 +99,7 @@ export type DirectDebitPaymentMethod =
98
99
  * Supported integration payment method type for dropin and hostPaymentPage
99
100
  */
100
101
  export type PaymentMethodType =
102
+ | 'googlepay'
101
103
  | 'applepay'
102
104
  | 'card'
103
105
  | 'wechatpay'
@@ -530,21 +532,25 @@ export interface ApplePayRequestOriginalOptions {
530
532
 
531
533
  /**
532
534
  * The shipping information that you require from the user in order to fulfill the order.
535
+ * @deprecated Airwallex won't save shipping info in apple pay
533
536
  */
534
537
  requiredShippingContactFields?: ApplePayJS.ApplePayContactField[];
535
538
 
536
539
  /**
537
540
  * Shipping contact information for the user.
541
+ * @deprecated Airwallex won't save shipping info in apple pay
538
542
  */
539
543
  shippingContact?: ApplePayJS.ApplePayPaymentContact;
540
544
 
541
545
  /**
542
546
  * A set of shipping method objects that describe the available shipping methods.
547
+ * @deprecated Airwallex won't save shipping info in apple pay
543
548
  */
544
549
  shippingMethods?: ApplePayJS.ApplePayShippingMethod[];
545
550
 
546
551
  /**
547
552
  * How the items are to be shipped.
553
+ * @deprecated Airwallex won't save shipping info in apple pay
548
554
  */
549
555
  shippingType?: ApplePayJS.ApplePayShippingType;
550
556
 
@@ -558,6 +564,185 @@ export interface ApplePayRequestOriginalOptions {
558
564
  */
559
565
  applicationData?: string;
560
566
  }
567
+ export interface GooglePayHppRequestOptions extends Omit<GooglePayRequestOptions, 'merchantInfo'> {
568
+ /**
569
+ * Detailed information about the merchant.
570
+ */
571
+ merchantInfo?: {
572
+ /**
573
+ * Merchant name encoded as UTF-8.
574
+ */
575
+ merchantName?: string;
576
+ /**
577
+ *The fully qualified domain of the requesting merchant.
578
+ */
579
+ merchantOrigin?: string;
580
+ };
581
+ }
582
+
583
+ export type GoogleSupportedCardNetWork = 'MASTERCARD' | 'MAESTRO' | 'VISA';
584
+ export interface GooglePayRequestOptions {
585
+ /**
586
+ * The two-letter ISO-3166 country code.
587
+ */
588
+ countryCode: string;
589
+ /**
590
+ * Detailed information about the merchant.
591
+ */
592
+ merchantInfo: google.payments.api.MerchantInfo;
593
+ /**
594
+ * Whether to collect the email from the buyer.
595
+ *
596
+ * If omitted, defaults to `false`.
597
+ *
598
+ * @default false
599
+ */
600
+ emailRequired?: boolean;
601
+ /**
602
+ * Specifies the text to be displayed within the Google Pay button.
603
+ *
604
+ * @default "buy"
605
+ */
606
+ buttonType?: google.payments.api.ButtonType;
607
+ /**
608
+ * Specifies the button color of the Google Pay button.
609
+ *
610
+ * @default "default"
611
+ */
612
+ buttonColor?: google.payments.api.ButtonColor;
613
+ /**
614
+ * Determines how the button's size should change relative to the
615
+ * button's parent element.
616
+ *
617
+ * @default "static"
618
+ */
619
+ buttonSizeMode?: google.payments.api.ButtonSizeMode;
620
+ /**
621
+ * Correlation ID to refer to this transaction.
622
+ *
623
+ * This field is optional. It is generated by the merchant and is used
624
+ * for referring to this transaction later on (e.g. for debugging issues
625
+ * when communicating with Google).
626
+ */
627
+ transactionId?: string;
628
+ /**
629
+ * Definition of a cart item.
630
+ */
631
+ displayItems?: google.payments.api.DisplayItem[];
632
+ /**
633
+ * Total price label of this transaction.
634
+ *
635
+ * The string will be shown as the total price label on the cart modal
636
+ * dialog page.
637
+ *
638
+ * This field is optional, but required if developer wants to show cart
639
+ * information. Otherwise the cart modal dialog will not be rendered
640
+ * even if transactionInfo.displayItems is set.
641
+ */
642
+ totalPriceLabel?: string;
643
+ /**
644
+ * The options for checkout.
645
+ */
646
+ checkoutOption?: google.payments.api.CheckoutOption;
647
+ /**
648
+ * Defines callback methods for handling payment data changed and payment
649
+ * authorized events.
650
+ *
651
+ * If you set up Dynamic Price Updates in your integration, be sure to add
652
+ * the following [[PaymentDataChangedHandler|`onPaymentDataChanged`]] and
653
+ * [[PaymentAuthorizedHandler|`onPaymentAuthorized`]] callbacks.
654
+ *
655
+ * Example:
656
+ *
657
+ * The following example configuration uses the callbacks needed to set up
658
+ * Dynamic Price Updates:
659
+ *
660
+ * ```js
661
+ * {
662
+ * onPaymentDataChanged: onPaymentDataChanged,
663
+ * onPaymentAuthorized: onPaymentAuthorized
664
+ * }
665
+ * ```
666
+ */
667
+ paymentDataCallbacks?: google.payments.api.PaymentDataCallbacks;
668
+ /**
669
+ * Allowed authentication methods. The default value is ["PAN_ONLY", "CRYPTOGRAM_3DS"]
670
+ */
671
+ allowedAuthMethods?: google.payments.api.CardAuthMethod[];
672
+ /**
673
+ * One or more card networks that you support, The default value is ["MASTERCARD", "MAESTRO", "VISA"]
674
+ */
675
+ allowedCardNetworks?: GoogleSupportedCardNetWork[];
676
+ /**
677
+ * Whether a prepaid card may be used for this transaction.
678
+ *
679
+ * If omitted, defaults to `true`.
680
+ *
681
+ * @default true
682
+ */
683
+ allowPrepaidCards?: boolean;
684
+ /**
685
+ * Whether a credit card may be used for this transaction.
686
+ *
687
+ * If omitted, defaults to `true`.
688
+ *
689
+ * @default true
690
+ */
691
+ allowCreditCards?: boolean;
692
+ /**
693
+ * Set to `true` to request assuranceDetails.
694
+ *
695
+ * If omitted, defaults to `false`.
696
+ *
697
+ * You may set if you need object provides information about the validation performed on the returned payment data.
698
+ *
699
+ * @default false
700
+ */
701
+ assuranceDetailsRequired?: boolean;
702
+ /**
703
+ * Set to `true` to request assuranceDetails.
704
+ *
705
+ * If omitted, defaults to `false`.
706
+ *
707
+ * You may set if you need object provides information about the validation performed on the returned payment data.
708
+ *
709
+ * @default false
710
+ */
711
+ billingAddressRequired?: boolean;
712
+
713
+ /**
714
+ * Optional billing address parameters for the returned billing address.
715
+ */
716
+ billingAddressParameters?: google.payments.api.BillingAddressParameters;
717
+ }
718
+
719
+ export interface GooglePayButtonOptions extends GooglePayRequestOptions, ElementOptions {
720
+ /**
721
+ * The payment intent id you would like to checkout
722
+ * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
723
+ *
724
+ */
725
+ intent_id: string;
726
+ /**
727
+ * This should be the client_secret of the intent
728
+ */
729
+ client_secret: string;
730
+ /**
731
+ * Indicate the amount and currency of the intent.
732
+ */
733
+ amount: {
734
+ value: number;
735
+ currency: string;
736
+ };
737
+ /**
738
+ * Indicate whether to capture immediate when authentication success
739
+ */
740
+ autoCapture?: boolean;
741
+ /**
742
+ * Container for authentication form
743
+ */
744
+ authFormContainer?: string;
745
+ }
561
746
 
562
747
  export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
563
748
  /**