airwallex-payment-elements 0.2.73 → 0.2.75

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.73] */
1
+ /* Airwallex Checkout Component Version [0.2.75] */
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.73] */
1
+ /* Airwallex Checkout Component Version [0.2.75] */
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.73] */
1
+ /* Airwallex Checkout Component Version [0.2.75] */
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.73",
3
+ "version": "0.2.75",
4
4
  "module": "lib/bin/airwallex.es.js",
5
5
  "main": "lib/bin/airwallex.cjs.js",
6
6
  "bin": "lib/bin/airwallex.cjs.js",
@@ -102,6 +102,10 @@ export interface HppRecurringOptions {
102
102
  * Currency of the initial PaymentIntent to verify the PaymentConsent. Three-letter ISO currency code
103
103
  */
104
104
  currency?: string;
105
+ /**
106
+ * It is to be used by the platform to indicate the connected entity in the transaction where platform is the owner of transaction.
107
+ */
108
+ connected_account_id?: string;
105
109
  };
106
110
  }
107
111
 
@@ -186,7 +190,7 @@ export interface HostPaymentPage {
186
190
  currency: string;
187
191
  /**
188
192
  * The 2-letter ISO country code from which the consumer will be paying
189
- * If you want to integrate with `applepay`, `bank_transfer`, `online_banking`, `skrill` or `seven_eleven` payment method, it would be required
193
+ * If you want to integrate with `bank_transfer`, `online_banking`, `skrill` or `seven_eleven` payment method, it would be required
190
194
  */
191
195
  country_code?: string;
192
196
  /**
@@ -439,6 +443,49 @@ export interface PaymentMethodWithConsent {
439
443
  payment_consent_id: string;
440
444
  }
441
445
 
446
+ export interface Consent {
447
+ /**
448
+ * The id of the consent which would be confirmed
449
+ */
450
+ id: string;
451
+ /**
452
+ * The `client_secret` of the consent.
453
+ */
454
+ client_secret: string;
455
+ /**
456
+ * The status of the consent.
457
+ */
458
+ status: 'PENDING_VERIFICATION' | 'VERIFIED' | 'DISABLED';
459
+ /**
460
+ * The create time of the consent.
461
+ */
462
+ created_at: string;
463
+ /**
464
+ * The update time of the consent.
465
+ */
466
+ updated_at: string;
467
+ /**
468
+ * Whether the consent is required cvc.
469
+ */
470
+ requires_cvc: boolean;
471
+ /**
472
+ * It determines who will be the next one to trigger this consent.
473
+ */
474
+ next_triggered_by: 'merchant' | 'customer';
475
+ /**
476
+ * The reason why the consent is triggered.
477
+ */
478
+ merchant_trigger_reason?: 'scheduled' | 'unscheduled';
479
+ /**
480
+ * The id of the customer
481
+ */
482
+ customer_id: string;
483
+ /**
484
+ * The id of the initial payment intent
485
+ */
486
+ initial_payment_intent_id?: string;
487
+ }
488
+
442
489
  /**
443
490
  * Element integration `step #2`
444
491
  * Create payment element for checkout
@@ -536,6 +583,10 @@ export interface PaymentConsentRequest {
536
583
  * The billing info for the payment consent
537
584
  */
538
585
  billing?: Billing;
586
+ /**
587
+ * It is to be used by the platform to indicate the connected entity in the transaction where platform is the owner of transaction.
588
+ */
589
+ connected_account_id?: string;
539
590
  }
540
591
 
541
592
  /**
@@ -5,7 +5,7 @@ import { HppRecurringOptions } from './airwallex';
5
5
  import { DropInElementOptions } from './dropInElement';
6
6
  import { RedirectElementOptions } from './redirectElement';
7
7
  import { NextAction } from './fraud';
8
-
8
+ import { Mode } from './airwallex';
9
9
  /**
10
10
  * Supported integration element type
11
11
  */
@@ -510,6 +510,14 @@ export interface PaymentShippingOption {
510
510
 
511
511
  export type ApplePayHppOrDropInRequestOptions = ApplePayRequestOptions;
512
512
 
513
+ export type ApplePayRecurringLineItem = {
514
+ paymentTiming: 'recurring' | 'deferred';
515
+ recurringPaymentStartDate: Date;
516
+ recurringPaymentIntervalUnit: 'year' | 'month' | 'day' | 'hour' | 'minute';
517
+ recurringPaymentIntervalCount: number;
518
+ recurringPaymentEndDate: Date;
519
+ };
520
+
513
521
  export interface ApplePayRequestOriginalOptions {
514
522
  /**
515
523
  * The merchant's two-letter ISO 3166 country code. Like 'US'
@@ -519,7 +527,7 @@ export interface ApplePayRequestOriginalOptions {
519
527
  /**
520
528
  * A set of line items that explain recurring payments and/or additional charges.
521
529
  */
522
- lineItems?: ApplePayJS.ApplePayLineItem[];
530
+ lineItems?: (ApplePayJS.ApplePayLineItem & ApplePayRecurringLineItem)[];
523
531
 
524
532
  /**
525
533
  * Billing contact information for the user.
@@ -635,6 +643,26 @@ export interface GooglePayRequestOptions {
635
643
  * Definition of a cart item.
636
644
  */
637
645
  displayItems?: google.payments.api.DisplayItem[];
646
+ /**
647
+ * The status of the total price used.
648
+ * If it is a variable subscription, the status should be NOT_CURRENTLY_KNOWN.
649
+ *
650
+ * Options:
651
+ *
652
+ * - `NOT_CURRENTLY_KNOWN`:
653
+ * The total price is not known currently.
654
+ *
655
+ * - `ESTIMATED`:
656
+ * The total price provided is an estimated price. The final price may
657
+ * change depending on the selected shipping address or billing address,
658
+ * if requested.
659
+ *
660
+ * - `FINAL`:
661
+ * The total price is the final total price of the transaction, and will
662
+ * not change based on selections made by the buyer.
663
+ * * @default "FINAL"
664
+ */
665
+ totalPriceStatus?: 'NOT_CURRENTLY_KNOWN' | 'ESTIMATED' | 'FINAL';
638
666
  /**
639
667
  * Total price label of this transaction.
640
668
  *
@@ -725,21 +753,35 @@ export interface GooglePayRequestOptions {
725
753
  export interface GooglePayButtonOptions extends GooglePayRequestOptions, ElementOptions {
726
754
  /**
727
755
  * The payment intent id you would like to checkout
756
+ * It's required for payment mode and optional for recurring mode
728
757
  * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
729
758
  *
730
759
  */
731
- intent_id: string;
760
+ intent_id?: string;
732
761
  /**
733
- * This should be the client_secret of the intent
762
+ * If the intent_id provided, this should be the client_secret of the intent
763
+ * If no intent_id provided, this should be the client_secret of the customer
734
764
  */
735
765
  client_secret: string;
766
+ /**
767
+ * Checkout for know customer, refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Customers/Intro)
768
+ * It's required for recurring mode
769
+ */
770
+ customer_id?: string;
771
+ /**
772
+ * Checkout mode
773
+ * @default "payment"
774
+ */
775
+ mode?: Mode;
736
776
  /**
737
777
  * Indicate the amount and currency of the intent.
778
+ * If the mode is recurring and there is no intent_id provided, amount should be {value: 0, currency: 'Replace with payment currency'}.
738
779
  */
739
780
  amount: {
740
781
  value: number;
741
782
  currency: string;
742
783
  };
784
+
743
785
  /**
744
786
  * Indicate whether to capture immediate when authentication success
745
787
  */
@@ -764,6 +806,17 @@ export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
764
806
  * Provide a business name for the label field. Use the same business name people will see when they look for the charge on their bank or credit card statement. For example, "COMPANY, INC."
765
807
  */
766
808
  totalPriceLabel?: string;
809
+ /**
810
+ * A type that indicates whether a line item is final or pending.
811
+ * if the mode is recurring and it's a variable subscription, the value should be pending.
812
+ * @default "final"
813
+ */
814
+ totalPriceType?: 'final' | 'pending';
815
+ /**
816
+ * Card networks supported by the merchant.
817
+ * For more details, please refer to https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916122-supportednetworks
818
+ */
819
+ supportedNetworks?: string[];
767
820
  /**
768
821
  * Payment capabilities supported by the merchant. Default value is ['supports3DS', 'supportsDebit', 'supportsCredit', 'supportsEMV'].
769
822
  */
@@ -772,16 +825,29 @@ export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
772
825
  export interface ApplePayButtonOptions extends ElementOptions, ApplePayRequestOptions {
773
826
  /**
774
827
  * The payment intent id you would like to checkout
828
+ * It's required for payment mode and optional for recurring mode
775
829
  * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
776
830
  *
777
831
  */
778
- intent_id: string;
832
+ intent_id?: string;
779
833
  /**
780
- * This should be the client_secret of the intent
834
+ * If the intent_id provided, this should be the client_secret of the intent
835
+ * If no intent_id provided, this should be the client_secret of the customer
781
836
  */
782
837
  client_secret: string;
838
+ /**
839
+ * Checkout for know customer, refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Customers/Intro)
840
+ * It's required for recurring mode
841
+ */
842
+ customer_id?: string;
843
+ /**
844
+ * Checkout mode
845
+ * @default "payment"
846
+ */
847
+ mode?: Mode;
783
848
  /**
784
849
  * Indicate the amount and currency of the intent.
850
+ * If the mode is recurring and there is no intent_id provided, amount should be {value: 0, currency: 'Replace with payment currency'}.
785
851
  */
786
852
  amount: {
787
853
  value: number;
package/types/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import Airwallex, {
28
28
  HostPaymentPage,
29
29
  Mode,
30
30
  HppRecurringOptions,
31
+ Consent,
31
32
  } from './airwallex';
32
33
 
33
34
  export {
@@ -52,6 +53,7 @@ export {
52
53
  HppTheme,
53
54
  HostPaymentPage,
54
55
  HppRecurringOptions,
56
+ Consent,
55
57
  };
56
58
 
57
59
  /**