@bigcommerce/checkout-sdk 1.848.0 → 1.849.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/dist/cjs/checkout-button.js +1 -1
- package/dist/cjs/checkout-sdk-essential.js +1 -1
- package/dist/cjs/checkout-sdk.js +1 -1
- package/dist/cjs/hosted-form-v2-iframe-host.js +1 -1
- package/dist/cjs/integrations/amazon-pay.js +1 -1
- package/dist/cjs/integrations/bigcommerce-payments.js +1 -1
- package/dist/cjs/integrations/braintree.js +1 -1
- package/dist/cjs/integrations/google-pay.js +1 -1
- package/dist/cjs/integrations/klarna.js +1 -1
- package/dist/cjs/integrations/paypal-commerce.js +1 -1
- package/dist/cjs/integrations/paypal-express.js +1 -1
- package/dist/cjs/integrations/zip.js +1 -1
- package/dist/esm/checkout-button.js +1 -1
- package/dist/esm/checkout-sdk-essential.js +1 -1
- package/dist/esm/checkout-sdk.js +1 -1
- package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
- package/dist/esm/integrations/amazon-pay.js +1 -1
- package/dist/esm/integrations/bigcommerce-payments.js +1 -1
- package/dist/esm/integrations/braintree.js +1 -1
- package/dist/esm/integrations/google-pay.js +1 -1
- package/dist/esm/integrations/klarna.js +1 -1
- package/dist/esm/integrations/paypal-commerce.js +1 -1
- package/dist/esm/integrations/paypal-express.js +1 -1
- package/dist/esm/integrations/zip.js +1 -1
- package/dist/types/checkout-sdk.d.ts +5 -0
- package/dist/types/internal-mappers.d.ts +5 -0
- package/docs/interfaces/Order.md +35 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createFormPoster as e}from"@bigcommerce/form-poster";import{createRequestSender as t}from"@bigcommerce/request-sender";import{getScriptLoader as n,getStylesheetLoader as i}from"@bigcommerce/script-loader";import{find as o,includes as a,isArray as r,isObject as s,round as c,some as d}from"lodash";class l extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class h extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var u;class y{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,a,r;return i=this,o=void 0,r=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-8ofgICZZ/k5cC5N7xegqFZOA73H9RQ7H13439JfAZW8Gj3qjuKL2isaTD3GMIhDE",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-wG2z9zSQo61EIvyXmiFCo+zB3y0ZB4hsrXVcANmpP8HLthjoQJQPBh7tZKJSV8jA",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new h;return new this._window.AdyenCheckout(e)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,s)}c((r=r.apply(i,o||[])).next())})}}function g(e,t){return Object.assign(e,{resolveIds:t})}function p(e){return"object"==typeof e&&null!==e&&"errors"in e&&Array.isArray(e.errors)&&"code"in e.errors[0]&&"string"==typeof e.errors[0].code&&"provider_data"in e&&"object"==typeof e.provider_data}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(u||(u={}));class m extends l{constructor(e){super(function(e){switch(e){case u.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case u.MissingCart:return"Unable to proceed because cart data is unavailable.";case u.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case u.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case u.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case u.MissingCheckoutConfig:case u.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case u.MissingOrder:return"Unable to proceed because order data is unavailable.";case u.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case u.MissingPayment:return"Unable to proceed because payment data is unavailable.";case u.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case u.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case u.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function f(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}const w=e=>"object"==typeof e&&null!==e&&"body"in e;class P extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var v;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(v||(v={}));class _ extends l{constructor(e){super(function(e){switch(e){case v.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case v.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case v.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case v.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class b extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function C(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class S{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:o,decimalSeparator:a}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof o||"string"!=typeof a||"string"!=typeof t)throw new b("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=o,this._decimalSeparator=a}format(e){if("number"!=typeof e)throw new b("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),o=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?o:[o,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let I=class{constructor(e){this._storeConfig=e,this._customerFormatter=new S(this._storeConfig.shopperCurrency),this._storeFormatter=new S(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};I=function(e,t,n,i){var o,a=arguments.length,r=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(r=(a<3?o(r):a>3?o(t,n,r):o(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}([function(e,t,n){return t&&n?C(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,C(e.prototype,n,i))}),t}(e)}],I);const O=I;function k(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function T(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var A,M,D,E,N,z,x,R,G;function B(e){return e in z}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(A||(A={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(M||(M={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(D||(D={})),function(e){e.pill="pill",e.rect="rect"}(E||(E={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(N||(N={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(z||(z={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(x||(x={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(R||(R={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(G||(G={}));var j=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class L{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:o,customFields:a=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,a)),{email:o||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:o}}}=e;if(!n)throw new m(u.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:o}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){var e;return j(this,void 0,void 0,function*(){const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=yield this._paymentIntegrationService.loadShippingCountries(),i=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},i&&{allowedCountryCodes:i}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[x.OFFER,x.SHIPPING_ADDRESS,x.SHIPPING_OPTION]:[x.OFFER]}getCallbackTriggers(){const e=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-2875.googlepay_coupons_handling"]||!1;return{availableTriggers:[G.INITIALIZE,G.SHIPPING_ADDRESS,G.SHIPPING_OPTION,...e?[G.OFFER]:[]],initializationTrigger:[G.INITIALIZE],addressChangeTriggers:[G.INITIALIZE,G.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[G.SHIPPING_OPTION],offerChangeTriggers:e?[G.OFFER]:[]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new m(u.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;if(this._isBuyNowFlow)e=this._getCurrencyCodeOrThrow();else{const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=t().currency.code}const t=this.getGooglePayInitializationData().storeCountry;return Object.assign(Object.assign({},t&&{countryCode:t}),{currencyCode:e,totalPriceStatus:N.ESTIMATED,totalPrice:"0"})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new b("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(B).map(e=>z[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){var t,n,i,o;return j(this,void 0,void 0,function*(){e&&(e.name=e.name||"",e.address1=e.address1||"");const a=this.mapToShippingAddressRequestBody({shippingAddress:e});a&&(yield this._paymentIntegrationService.updateShippingAddress(a));const r=this._paymentIntegrationService.getState(),s=r.getConsignments();if(!(null==s?void 0:s[0]))return;const c=s[0],d=r.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new O(d));const l=(c.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),h=null===(t=c.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(l.length){const e=(null===(n=c.selectedShippingOption)||void 0===n?void 0:n.id)||(null==h?void 0:h.id)||(null===(i=l[0])||void 0===i?void 0:i.id);return!(null===(o=c.selectedShippingOption)||void 0===o?void 0:o.id)&&l[0]&&(yield this.handleShippingOptionChange((null==h?void 0:h.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return j(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t}=this._paymentIntegrationService.getState(),{decimalPlaces:n}=t().currency;return c(e().outstandingBalance,n).toFixed(n)}handleCoupons(e){return j(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons();let i;return yield t.reduce((e,t)=>j(this,void 0,void 0,function*(){if(yield e,n.some(({redemptionCode:e})=>e===t))return;const o=yield this.applyCoupon(t);o&&(i=o)}),Promise.resolve()),yield n.reduce((e,n)=>j(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return j(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:R.OFFER_INVALID,message:e.message,intent:G.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return k(this.getPaymentMethod().initializationData,()=>new b("Missing initialization data."))}getPaymentMethod(){return k(this._getPaymentMethodFn,()=>new _(v.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let o;return o=T(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),o&&(a=e(),r=i,!!a&&(!!a.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!r||!a.lineItems.customItems)&&a.lineItems.customItems.length>0));var a,r}_mapToAddressRequestBody(e,t,n,i){const{name:o,address1:a,address2:r,address3:s,locality:c,administrativeArea:d,countryCode:l,postalCode:h,phoneNumber:u}=e,[y,g]=this._getFirstAndLastName(o);return{firstName:y,lastName:g,company:t,address1:a,address2:`${r} ${s}`.trim(),city:c||d,stateOrProvince:d,stateOrProvinceCode:d,countryCode:l,postalCode:h,phone:u||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var o;const a=null===(o=this._currencyService)||void 0===o?void 0:o.toCustomerCurrency(t);return this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-3540.googlepay_new_shipping_options_description"]?{id:e,label:`${a||t} ${n}`,description:i}:{id:e,label:n,description:a||t}}}var F=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class U extends L{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return F(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),a=this._service.getState().getStoreConfig();if(!a)throw new m(u.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:a.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return F(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}processAdditionalAction(e){return F(this,void 0,void 0,function*(){if(!w(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new P)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const q={"X-Checkout-SDK-Version":"1.848.0"};class V extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var H=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class W{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return H(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return H(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return H(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return H(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return H(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return H(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return H(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return H(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return H(this,void 0,void 0,function*(){const o="/checkout.php",a=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:o,Object.assign(Object.assign({},a),{card_information:JSON.stringify(a.card_information)}),e)});yield this._requestSender.post(o,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},q),body:a})})}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return H(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new V("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof V)throw e;throw new V}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return H(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}}),this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()}),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return k(e,()=>new _(v.PaymentNotInitialized))}}class Y extends b{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class J extends l{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}const K={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Z={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},X="embedded-checkout-loading-indicator-rotation";class Q{constructor(e){this.styles=Object.assign(Object.assign({},K),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${X} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(X))return;const t=document.createElement("style");t.id=X,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${X} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function $(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var ee;function te(e){return Object.values(ee).includes(e)}!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(ee||(ee={}));var ne=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ie{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._loadingIndicator=new Q({containerStyles:Z})}initialize(e){var t;return ne(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const n=e[this._getMethodId()];if(!(null==n?void 0:n.walletButton))throw new b("Unable to proceed without valid options.");const{walletButton:i,loadingContainerId:o}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(n,["walletButton","loadingContainerId"]);this._loadingIndicatorContainer=o,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const r=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());yield this._googlePayPaymentProcessor.initialize(()=>r,this._getGooglePayClientOptions(null===(t=r.initializationData)||void 0===t?void 0:t.storeCountry)),this._addPaymentButton(i,a)})}execute({payment:e}){return ne(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(Object.assign(Object.assign({},e),{paymentData:Object.assign({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new J)}deinitialize(){var e;return this._isDeinitializationBlocked||(this._clickListener&&(null===(e=this._paymentButton)||void 0===e||e.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new b("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_handleClick({onPaymentSelect:e,onError:t}){return n=>ne(this,void 0,void 0,function*(){n.preventDefault();try{this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),$(e)){if("CANCELED"===e.statusCode)throw new P;n=new V(JSON.stringify(e))}throw null==t||t(new V("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheet(){return ne(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(this._getMethodId(),e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ne(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof m&&e.subtype===u.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return ne(this,void 0,void 0,function*(){let t=!1,n="Sign in to Google Pay first to apply or remove promo codes.";try{t=yield this._getIsSignedInOrThrow()}catch(e){e instanceof m&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:R.OFFER_INVALID,message:n,intent:G.OFFER}}})}_getGooglePayClientOptions(e){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ne(this,void 0,void 0,function*(){const i=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-2875.googlepay_coupons_handling"]||!1;if(t!==G.INITIALIZE&&(!i||t!==G.OFFER))return;const{offerChangeTriggers:o}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:a,error:r}=o.includes(t)?yield this._handleOfferTrigger(n):{},s=r;yield this._paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:d,getCartOrThrow:l}=this._paymentIntegrationService.getState(),{code:h,decimalPlaces:u}=l().currency,y=c(d().outstandingBalance,u).toFixed(u);return Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:h,totalPriceStatus:N.FINAL,totalPrice:y})},a&&{newOfferInfo:a}),s&&{error:s})})}}}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}class oe{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,i=void 0,a=function*(){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new h;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}function ae(){return new oe(n())}const re=g(o=>new ie(o,new W(ae(),new U(o,new y(n(),i())),t(),e())),[{id:"googlepayadyenv2"}]);class se{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,a,r;return i=this,o=void 0,r=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-5MvB4RnzvviA3VBT4KYABZ4HXNZG5LRqREEgd41xt/pf/QvKmsj2O9GuNuywRXx9",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-yvY2yFNR4WqIjPqP9MzjI+gJimmaJnAvj4rLHKvgJbgFD5fMuf8zIJrFJOW8Lhhf",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new h;return yield this._window.AdyenCheckout(e)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,s)}c((r=r.apply(i,o||[])).next())})}}var ce=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class de extends L{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ce(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),a=this._service.getState().getStoreConfig();if(!a)throw new m(u.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:a.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return ce(this,void 0,void 0,function*(){if(!w(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ce(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new P)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const le=g(o=>new ie(o,new W(ae(),new de(o,new se(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class he extends L{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new m(u.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ue=g(n=>new ie(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]);var ye;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(ye||(ye={}));const ge=ye;function pe(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new m(u.MissingPaymentMethod)}var me=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class fe extends L{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(w(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return me(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return pe(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return me(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();pe(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":ge.Json,"X-XSRF-TOKEN":null}});return i.token})}}const we=g(n=>{const i=t();return new ie(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class Pe extends L{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const ve=g(n=>new ie(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class _e extends L{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const be=g(n=>new ie(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),Ce={body:{},headers:{},status:0};class Se extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:a}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=o,this.status=a,this.errors=n||[]}}function Ie(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new m(u.MissingPaymentMethod)}var Oe=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ke extends L{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Oe(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Ie(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){var n;return Oe(this,void 0,void 0,function*(){if(!t)throw new Y(["payment"]);if(!w(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;var i;if(d(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Ie(i);const{stripePublishableKey:o,stripeConnectedAccount:a}=i;this.stripeUPEClient=yield this.loadStripeJs(o,a);const r=e.body.three_ds_result.token;let s,c=!1;try{s=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{s=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){c=!0}}if(null==s?void 0:s.error){if(this._throwDisplayableStripeError(s.error),this._isCancellationError(s.error))throw new P;throw new V}if(!(null==s?void 0:s.paymentIntent)&&!c)throw new Se;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==s?void 0:s.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return Oe(this,void 0,void 0,function*(){return this.stripeUPEClient?this.stripeUPEClient:this.scriptLoader.getStripeClient(e,t)})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(a(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}var Te=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ae{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n){return Te(this,void 0,void 0,function*(){let i=this.stripeWindow.bcStripeClient;return i||(i=(yield this.load())(e,{stripeAccount:t,locale:n,betas:["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"],apiVersion:"2020-03-02;alipay_beta=v1;link_beta=v1"}),Object.assign(this.stripeWindow,{bcStripeClient:i})),i})}load(){return Te(this,void 0,void 0,function*(){if(this.stripeWindow.Stripe||(yield this.scriptLoader.loadScript("https://js.stripe.com/v3/")),!this.stripeWindow.Stripe)throw new h;return this.stripeWindow.Stripe})}}const Me=g(i=>new ie(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class De extends L{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const Ee=g(n=>new ie(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ne="3.128.0",ze="3.123.2",xe="3.106.0";class Re{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(T(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ne:T(t,"PAYPAL-5636.update_braintree_sdk_version")?ze:xe)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=o(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Ge extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Be,je,Le,Fe,Ue,qe,Ve;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Be||(Be={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(je||(je={})),function(e){e.TRUSTLY="trustly"}(Le||(Le={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Fe||(Fe={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Ue||(Ue={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(qe||(qe={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Ve||(Ve={}));var He,We,Ye,Je=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ke{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return Je(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return Je(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return Je(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===qe.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return Je(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return Je(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return Je(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,o)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&o(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return Je(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return Je(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return Je(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Ge;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new _(v.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(He||(He={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(We||(We={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Ye||(Ye={}));const Ze={[xe]:{[We.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[We.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[We.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[We.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[We.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[We.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[We.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[We.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[We.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[We.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[We.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[We.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[ze]:{[We.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[We.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[We.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[We.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[We.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[We.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[We.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[We.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[We.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[We.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[We.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[We.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[Ne]:{[We.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[We.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[We.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[We.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[We.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[We.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[We.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[We.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[We.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[We.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[We.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[We.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var Xe=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Qe{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Client,"client.min.js")})}loadFastlane(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Paypal,"paypal.min.js")})}loadLocalPayment(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.GooglePayment,"google-payment.min.js")})}load3DS(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(We.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(We.Venmo,"venmo.min.js")}loadHostedFields(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return Xe(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new h;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return Xe(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),o=`//js.braintreegateway.com/web/${i}/js/${t}`,a=i in Ze?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(o,a?{async:!0,attributes:{integrity:a,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new h;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=Ze[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class $e{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var et=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class tt extends L{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=ee.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return et(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let o=i.getPaymentMethod.call(this);if(o.clientToken||(o=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!o.clientToken||!o.initializationData)throw new m(u.MissingPaymentMethod);return this._braintreeSdk.initialize(o.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});var n;return et(this,void 0,void 0,function*(){const i=yield t.getNonce.call(this,e),{clientToken:o,initializationData:a}=t.getPaymentMethod.call(this);if(!o||!a||!(null===(n=a.card_information)||void 0===n?void 0:n.bin))throw new m(u.MissingPaymentMethod);const{isThreeDSecureEnabled:r,card_information:{bin:s,isNetworkTokenized:c}}=a;if(r&&!c){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return et(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return et(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return et(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new m(u.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return et(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new $e(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}const nt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new ie(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]);var it=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ot{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return it(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return it(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return it(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t){return it(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return it(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,attributionId:c}=o;return{options:{"client-id":r,"merchant-id":s,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":r,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:r,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=l,y=d.filter(e=>!l.includes(e));return{options:Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":r}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:r,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},r&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function at(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new m(u.MissingPaymentMethod)}var rt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class st extends L{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,a,r,s,c;return rt(this,void 0,void 0,function*(){const d=null!==(a=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==a?a:n;if(!d)throw new m(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(u.MissingPaymentMethod);at(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(r=y[0])||void 0===r?void 0:r.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return rt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ct="This API endpoint is for internal use only and may change in the future";var dt,lt;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(dt||(dt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(lt||(lt={}));var ht=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ut extends ie{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return ht(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:a}=i||{},r=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(r)},info:{cardNetwork:(null==a?void 0:a.type)||"",cardDetails:(null==a?void 0:a.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return ht(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,a=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,!0),{status:r}=yield a.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(r===dt.PayerActionRequired)return yield a.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(r!==dt.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return ht(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Object.assign({"X-API-INTERNAL":ct,"Content-Type":ge.Json},q),body:t});return n})}}const yt=g(i=>{const o=new ot(n());return new ut(i,new W(ae(),new st(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class pt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return gt(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return gt(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return gt(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t){return gt(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return gt(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,attributionId:c}=o;return{options:{"client-id":r,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:a},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":r,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:r,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":r}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:r,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},r&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var mt,ft,wt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Pt extends L{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,a,r,s,c;return wt(this,void 0,void 0,function*(){const d=null!==(a=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==a?a:n;if(!d)throw new m(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(u.MissingPaymentMethod);at(l);const h=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(r=y[0])||void 0===r?void 0:r.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return wt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(mt||(mt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ft||(ft={}));var vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class _t extends ie{constructor(e,t,n,i){super(e,t),this._payPalSdkHelper=n,this._requestSender=i}execute({payment:e}){return vt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:a}=i||{},r=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(r)},info:{cardNetwork:(null==a?void 0:a.type)||"",cardDetails:(null==a?void 0:a.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return vt(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,a=yield this._payPalSdkHelper.getPayPalGooglePaySdk(i,o,!0),{status:r}=yield a.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(r===mt.PayerActionRequired)return yield a.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(r!==mt.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return vt(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Object.assign({"X-API-INTERNAL":ct,"Content-Type":ge.Json},q),body:t});return n})}}const bt=g(i=>{const o=new pt(n());return new _t(i,new W(ae(),new Pt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var Ct=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class St extends L{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Ct(this,void 0,void 0,function*(){return Promise.resolve({browser_info:f()})})}processAdditionalAction(e){return Ct(this,void 0,void 0,function*(){if(!function(e){return w(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&r(t.errors)&&d(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:o}=t||{};if(!n||!i||!o)throw new Y(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const It=g(n=>new ie(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Ot extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var kt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Tt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t;return kt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const n=e[this._getMethodId()];if(!n)throw new b("Unable to proceed without valid options.");let i,o=this._paymentIntegrationService.getState();try{i=o.getPaymentMethodOrThrow(this._getMethodId())}catch(e){o=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),i=o.getPaymentMethodOrThrow(this._getMethodId())}try{yield this._googlePayPaymentProcessor.initialize(()=>i,this._getGooglePayClientOptions(null===(t=i.initializationData)||void 0===t?void 0:t.storeCountry))}catch(e){return}this._addPaymentButton(n)})}signIn(){return Promise.reject(new Ot('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return kt(this,void 0,void 0,function*(){const t=null===(e=this._paymentIntegrationService.getState().getPaymentId())||void 0===e?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null===(t=null==e?void 0:e.continueWithCheckoutCallback)||void 0===t||t.call(e),Promise.resolve()}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,shippingAddress:n,shippingOptionData:i,offerData:o})=>kt(this,void 0,void 0,function*(){const{availableTriggers:a,addressChangeTriggers:r,shippingOptionsChangeTriggers:s,offerChangeTriggers:c}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!a.includes(t))return;const d=r.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(i.id));const{newOfferInfo:l,error:h}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},u=h;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:g}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:g,totalPriceStatus:N.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),u&&{error:u})})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:i,onError:o}){var a;this._paymentButton=null!==(a=this._paymentButton)&&void 0!==a?a:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(o,i)})}_handleClick(e,t){return n=>kt(this,void 0,void 0,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if($(t)){if("CANCELED"===t.statusCode)throw new P;n=new V(JSON.stringify(t))}throw null==e||e(new V("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return kt(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),n&&(yield this._paymentIntegrationService.updateShippingAddress(n)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodId(),e,i)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}}const At=g(n=>{const i=t();return new Tt(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),Mt=g(n=>{const i=t();return new Tt(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Dt=g(n=>new Tt(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Et=g(n=>{const i=t();return new Tt(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Nt=g(n=>new Tt(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"}]),zt=g(n=>new Tt(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaybnz"}]),xt=g(n=>new Tt(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),Rt=g(i=>new Tt(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Gt=g(i=>new Tt(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripeupe"}]),Bt=g(n=>new Tt(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),jt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new Tt(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]),Lt=g(i=>new Tt(i,new W(ae(),new st(i,new ot(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Ft=g(i=>new Tt(i,new W(ae(),new Pt(i,new pt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Ut=g(n=>new Tt(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class qt extends l{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}var Vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ht{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Vt(this,void 0,void 0,function*(){if(!e.methodId||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new b('Unable to proceed because "containerId" is not a valid key.');const i=e[this._getMethodOrThrow()];if(!i)throw new b("Unable to proceed without valid options.");const{buyNowInitializeOptions:o,currencyCode:a,buttonColor:r,buttonType:s,onError:c}=i;let d,l=this._paymentIntegrationService.getState();try{d=l.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){l=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),d=l.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=d.initializationData)||void 0===t?void 0:t.storeCountry,o){if(!a)throw new b('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=o,yield this._googlePayPaymentProcessor.initialize(()=>d,this._getGooglePayClientOptions(),!!o,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>d,this._getGooglePayClientOptions());this._paymentButton=null!==(n=this._paymentButton)&&void 0!==n?n:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=r?r:"default",buttonType:null!=s?s:"plain",onClick:this._handleClick(c)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Vt(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if($(t)){if("CANCELED"===t.statusCode)throw new P;n=new V(JSON.stringify(t))}throw null==e||e(new V("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return Vt(this,void 0,void 0,function*(){const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),o="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,o)})}_getGooglePayClientOptions(){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i})=>Vt(this,void 0,void 0,function*(){const{availableTriggers:o,addressChangeTriggers:a,shippingOptionsChangeTriggers:r,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(e))return;const c=a.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;r.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:d,error:l}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},h=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,h):this._getTransactionInfo(c,d,h)})}}}_createBuyNowCartOrThrow(e){return Vt(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new qt(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,o=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:o||String(i),totalPriceStatus:N.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Vt(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:o}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:o,totalPriceStatus:N.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const Wt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new Ht(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]),Yt=g(i=>new Ht(i,new W(ae(),new st(i,new ot(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Jt=g(i=>new Ht(i,new W(ae(),new Pt(i,new pt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Kt=g(n=>{const i=t();return new Ht(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),Zt=g(n=>{const i=t();return new Ht(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Xt=g(n=>new Ht(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Qt=g(n=>{const i=t();return new Ht(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),$t=g(n=>new Ht(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),en=g(n=>new Ht(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),tn=g(i=>new Ht(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),nn=g(n=>new Ht(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),on=g(n=>new Ht(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{Kt as createGooglePayAdyenV2ButtonStrategy,At as createGooglePayAdyenV2CustomerStrategy,re as createGooglePayAdyenV2PaymentStrategy,Zt as createGooglePayAdyenV3ButtonStrategy,Mt as createGooglePayAdyenV3CustomerStrategy,le as createGooglePayAdyenV3PaymentStrategy,Xt as createGooglePayAuthorizeDotNetButtonStrategy,Dt as createGooglePayAuthorizeDotNetCustomerStrategy,ue as createGooglePayAuthorizeNetPaymentStrategy,Jt as createGooglePayBigCommercePaymentsButtonStrategy,Ft as createGooglePayBigCommercePaymentsCustomerStrategy,bt as createGooglePayBigCommercePaymentsPaymentStrategy,zt as createGooglePayBnzCustomerStrategy,Wt as createGooglePayBraintreeButtonStrategy,jt as createGooglePayBraintreeCustomerStrategy,nt as createGooglePayBraintreePaymentStrategy,Qt as createGooglePayCheckoutComButtonStrategy,Et as createGooglePayCheckoutComCustomerStrategy,we as createGooglePayCheckoutComPaymentStrategy,$t as createGooglePayCybersourceButtonStrategy,Nt as createGooglePayCybersourceCustomerStrategy,ve as createGooglePayCybersourcePaymentStrategy,en as createGooglePayOrbitalButtonStrategy,xt as createGooglePayOrbitalCustomerStrategy,be as createGooglePayOrbitalPaymentStrategy,yt as createGooglePayPPCPPaymentStrategy,Yt as createGooglePayPayPalCommerceButtonStrategy,Lt as createGooglePayPayPalCommerceCustomerStrategy,tn as createGooglePayStripeButtonStrategy,Rt as createGooglePayStripeCustomerStrategy,Me as createGooglePayStripePaymentStrategy,Gt as createGooglePayStripeUpeCustomerStrategy,on as createGooglePayTdOnlineMartButtonStrategy,Ut as createGooglePayTdOnlineMartCustomerStrategy,It as createGooglePayTdOnlineMartPaymentStrategy,nn as createGooglePayWorldpayAccessButtonStrategy,Bt as createGooglePayWorldpayAccessCustomerStrategy,Ee as createGooglePayWorldpayAccessPaymentStrategy};
|
|
1
|
+
import{createFormPoster as e}from"@bigcommerce/form-poster";import{createRequestSender as t}from"@bigcommerce/request-sender";import{getScriptLoader as n,getStylesheetLoader as i}from"@bigcommerce/script-loader";import{find as o,includes as a,isArray as r,isObject as s,round as c,some as d}from"lodash";class l extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class h extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var u;class y{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,a,r;return i=this,o=void 0,r=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-8ofgICZZ/k5cC5N7xegqFZOA73H9RQ7H13439JfAZW8Gj3qjuKL2isaTD3GMIhDE",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-wG2z9zSQo61EIvyXmiFCo+zB3y0ZB4hsrXVcANmpP8HLthjoQJQPBh7tZKJSV8jA",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new h;return new this._window.AdyenCheckout(e)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,s)}c((r=r.apply(i,o||[])).next())})}}function g(e,t){return Object.assign(e,{resolveIds:t})}function p(e){return"object"==typeof e&&null!==e&&"errors"in e&&Array.isArray(e.errors)&&"code"in e.errors[0]&&"string"==typeof e.errors[0].code&&"provider_data"in e&&"object"==typeof e.provider_data}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(u||(u={}));class m extends l{constructor(e){super(function(e){switch(e){case u.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case u.MissingCart:return"Unable to proceed because cart data is unavailable.";case u.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case u.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case u.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case u.MissingCheckoutConfig:case u.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case u.MissingOrder:return"Unable to proceed because order data is unavailable.";case u.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case u.MissingPayment:return"Unable to proceed because payment data is unavailable.";case u.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case u.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case u.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function f(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}const w=e=>"object"==typeof e&&null!==e&&"body"in e;class P extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var v;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(v||(v={}));class _ extends l{constructor(e){super(function(e){switch(e){case v.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case v.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case v.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case v.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class b extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function C(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class S{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:o,decimalSeparator:a}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof o||"string"!=typeof a||"string"!=typeof t)throw new b("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=o,this._decimalSeparator=a}format(e){if("number"!=typeof e)throw new b("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),o=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?o:[o,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let I=class{constructor(e){this._storeConfig=e,this._customerFormatter=new S(this._storeConfig.shopperCurrency),this._storeFormatter=new S(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};I=function(e,t,n,i){var o,a=arguments.length,r=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(r=(a<3?o(r):a>3?o(t,n,r):o(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}([function(e,t,n){return t&&n?C(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,C(e.prototype,n,i))}),t}(e)}],I);const O=I;function k(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function T(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var A,M,D,E,N,z,x,R,G;function B(e){return e in z}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(A||(A={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(M||(M={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(D||(D={})),function(e){e.pill="pill",e.rect="rect"}(E||(E={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(N||(N={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(z||(z={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(x||(x={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(R||(R={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(G||(G={}));var j=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class L{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:o,customFields:a=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,a)),{email:o||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:o}}}=e;if(!n)throw new m(u.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:o}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){var e;return j(this,void 0,void 0,function*(){const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=yield this._paymentIntegrationService.loadShippingCountries(),i=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},i&&{allowedCountryCodes:i}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[x.OFFER,x.SHIPPING_ADDRESS,x.SHIPPING_OPTION]:[x.OFFER]}getCallbackTriggers(){const e=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-2875.googlepay_coupons_handling"]||!1;return{availableTriggers:[G.INITIALIZE,G.SHIPPING_ADDRESS,G.SHIPPING_OPTION,...e?[G.OFFER]:[]],initializationTrigger:[G.INITIALIZE],addressChangeTriggers:[G.INITIALIZE,G.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[G.SHIPPING_OPTION],offerChangeTriggers:e?[G.OFFER]:[]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new m(u.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;if(this._isBuyNowFlow)e=this._getCurrencyCodeOrThrow();else{const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=t().currency.code}const t=this.getGooglePayInitializationData().storeCountry;return Object.assign(Object.assign({},t&&{countryCode:t}),{currencyCode:e,totalPriceStatus:N.ESTIMATED,totalPrice:"0"})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new b("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(B).map(e=>z[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){var t,n,i,o;return j(this,void 0,void 0,function*(){e&&(e.name=e.name||"",e.address1=e.address1||"");const a=this.mapToShippingAddressRequestBody({shippingAddress:e});a&&(yield this._paymentIntegrationService.updateShippingAddress(a));const r=this._paymentIntegrationService.getState(),s=r.getConsignments();if(!(null==s?void 0:s[0]))return;const c=s[0],d=r.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new O(d));const l=(c.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),h=null===(t=c.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(l.length){const e=(null===(n=c.selectedShippingOption)||void 0===n?void 0:n.id)||(null==h?void 0:h.id)||(null===(i=l[0])||void 0===i?void 0:i.id);return!(null===(o=c.selectedShippingOption)||void 0===o?void 0:o.id)&&l[0]&&(yield this.handleShippingOptionChange((null==h?void 0:h.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return j(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t}=this._paymentIntegrationService.getState(),{decimalPlaces:n}=t().currency;return c(e().outstandingBalance,n).toFixed(n)}handleCoupons(e){return j(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons();let i;return yield t.reduce((e,t)=>j(this,void 0,void 0,function*(){if(yield e,n.some(({redemptionCode:e})=>e===t))return;const o=yield this.applyCoupon(t);o&&(i=o)}),Promise.resolve()),yield n.reduce((e,n)=>j(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return j(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:R.OFFER_INVALID,message:e.message,intent:G.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return k(this.getPaymentMethod().initializationData,()=>new b("Missing initialization data."))}getPaymentMethod(){return k(this._getPaymentMethodFn,()=>new _(v.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let o;return o=T(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),o&&(a=e(),r=i,!!a&&(!!a.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!r||!a.lineItems.customItems)&&a.lineItems.customItems.length>0));var a,r}_mapToAddressRequestBody(e,t,n,i){const{name:o,address1:a,address2:r,address3:s,locality:c,administrativeArea:d,countryCode:l,postalCode:h,phoneNumber:u}=e,[y,g]=this._getFirstAndLastName(o);return{firstName:y,lastName:g,company:t,address1:a,address2:`${r} ${s}`.trim(),city:c||d,stateOrProvince:d,stateOrProvinceCode:d,countryCode:l,postalCode:h,phone:u||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var o;const a=null===(o=this._currencyService)||void 0===o?void 0:o.toCustomerCurrency(t);return this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-3540.googlepay_new_shipping_options_description"]?{id:e,label:`${a||t} ${n}`,description:i}:{id:e,label:n,description:a||t}}}var F=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class U extends L{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return F(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),a=this._service.getState().getStoreConfig();if(!a)throw new m(u.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:a.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return F(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}processAdditionalAction(e){return F(this,void 0,void 0,function*(){if(!w(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new P)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const q={"X-Checkout-SDK-Version":"1.849.0"};class V extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var H=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class W{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return H(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return H(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return H(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return H(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return H(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return H(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return H(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return H(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return H(this,void 0,void 0,function*(){const o="/checkout.php",a=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:o,Object.assign(Object.assign({},a),{card_information:JSON.stringify(a.card_information)}),e)});yield this._requestSender.post(o,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},q),body:a})})}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return H(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new V("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof V)throw e;throw new V}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return H(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}}),this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()}),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return k(e,()=>new _(v.PaymentNotInitialized))}}class Y extends b{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class J extends l{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}const K={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Z={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},X="embedded-checkout-loading-indicator-rotation";class Q{constructor(e){this.styles=Object.assign(Object.assign({},K),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${X} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(X))return;const t=document.createElement("style");t.id=X,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${X} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function $(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var ee;function te(e){return Object.values(ee).includes(e)}!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(ee||(ee={}));var ne=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ie{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._loadingIndicator=new Q({containerStyles:Z})}initialize(e){var t;return ne(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const n=e[this._getMethodId()];if(!(null==n?void 0:n.walletButton))throw new b("Unable to proceed without valid options.");const{walletButton:i,loadingContainerId:o}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(n,["walletButton","loadingContainerId"]);this._loadingIndicatorContainer=o,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const r=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());yield this._googlePayPaymentProcessor.initialize(()=>r,this._getGooglePayClientOptions(null===(t=r.initializationData)||void 0===t?void 0:t.storeCountry)),this._addPaymentButton(i,a)})}execute({payment:e}){return ne(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(Object.assign(Object.assign({},e),{paymentData:Object.assign({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new J)}deinitialize(){var e;return this._isDeinitializationBlocked||(this._clickListener&&(null===(e=this._paymentButton)||void 0===e||e.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new b("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_handleClick({onPaymentSelect:e,onError:t}){return n=>ne(this,void 0,void 0,function*(){n.preventDefault();try{this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),$(e)){if("CANCELED"===e.statusCode)throw new P;n=new V(JSON.stringify(e))}throw null==t||t(new V("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheet(){return ne(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(this._getMethodId(),e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ne(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof m&&e.subtype===u.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return ne(this,void 0,void 0,function*(){let t=!1,n="Sign in to Google Pay first to apply or remove promo codes.";try{t=yield this._getIsSignedInOrThrow()}catch(e){e instanceof m&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:R.OFFER_INVALID,message:n,intent:G.OFFER}}})}_getGooglePayClientOptions(e){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ne(this,void 0,void 0,function*(){const i=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings.features["PI-2875.googlepay_coupons_handling"]||!1;if(t!==G.INITIALIZE&&(!i||t!==G.OFFER))return;const{offerChangeTriggers:o}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:a,error:r}=o.includes(t)?yield this._handleOfferTrigger(n):{},s=r;yield this._paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:d,getCartOrThrow:l}=this._paymentIntegrationService.getState(),{code:h,decimalPlaces:u}=l().currency,y=c(d().outstandingBalance,u).toFixed(u);return Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:h,totalPriceStatus:N.FINAL,totalPrice:y})},a&&{newOfferInfo:a}),s&&{error:s})})}}}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}class oe{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,i=void 0,a=function*(){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new h;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}function ae(){return new oe(n())}const re=g(o=>new ie(o,new W(ae(),new U(o,new y(n(),i())),t(),e())),[{id:"googlepayadyenv2"}]);class se{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,a,r;return i=this,o=void 0,r=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-5MvB4RnzvviA3VBT4KYABZ4HXNZG5LRqREEgd41xt/pf/QvKmsj2O9GuNuywRXx9",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-yvY2yFNR4WqIjPqP9MzjI+gJimmaJnAvj4rLHKvgJbgFD5fMuf8zIJrFJOW8Lhhf",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new h;return yield this._window.AdyenCheckout(e)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,s)}c((r=r.apply(i,o||[])).next())})}}var ce=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class de extends L{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ce(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),a=this._service.getState().getStoreConfig();if(!a)throw new m(u.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:a.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return ce(this,void 0,void 0,function*(){if(!w(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ce(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new P)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const le=g(o=>new ie(o,new W(ae(),new de(o,new se(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class he extends L{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new m(u.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ue=g(n=>new ie(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]);var ye;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(ye||(ye={}));const ge=ye;function pe(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new m(u.MissingPaymentMethod)}var me=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class fe extends L{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(w(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return me(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return pe(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return me(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();pe(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":ge.Json,"X-XSRF-TOKEN":null}});return i.token})}}const we=g(n=>{const i=t();return new ie(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class Pe extends L{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const ve=g(n=>new ie(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class _e extends L{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const be=g(n=>new ie(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),Ce={body:{},headers:{},status:0};class Se extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:a}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=o,this.status=a,this.errors=n||[]}}function Ie(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new m(u.MissingPaymentMethod)}var Oe=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ke extends L{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Oe(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Ie(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){var n;return Oe(this,void 0,void 0,function*(){if(!t)throw new Y(["payment"]);if(!w(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;var i;if(d(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Ie(i);const{stripePublishableKey:o,stripeConnectedAccount:a}=i;this.stripeUPEClient=yield this.loadStripeJs(o,a);const r=e.body.three_ds_result.token;let s,c=!1;try{s=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{s=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){c=!0}}if(null==s?void 0:s.error){if(this._throwDisplayableStripeError(s.error),this._isCancellationError(s.error))throw new P;throw new V}if(!(null==s?void 0:s.paymentIntent)&&!c)throw new Se;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==s?void 0:s.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return Oe(this,void 0,void 0,function*(){return this.stripeUPEClient?this.stripeUPEClient:this.scriptLoader.getStripeClient(e,t)})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(a(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}var Te=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ae{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n){return Te(this,void 0,void 0,function*(){let i=this.stripeWindow.bcStripeClient;return i||(i=(yield this.load())(e,{stripeAccount:t,locale:n,betas:["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"],apiVersion:"2020-03-02;alipay_beta=v1;link_beta=v1"}),Object.assign(this.stripeWindow,{bcStripeClient:i})),i})}load(){return Te(this,void 0,void 0,function*(){if(this.stripeWindow.Stripe||(yield this.scriptLoader.loadScript("https://js.stripe.com/v3/")),!this.stripeWindow.Stripe)throw new h;return this.stripeWindow.Stripe})}}const Me=g(i=>new ie(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class De extends L{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,a=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(r,s)}c((a=a.apply(n,i||[])).next())});var n,i,o,a}}const Ee=g(n=>new ie(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ne="3.128.0",ze="3.123.2",xe="3.106.0";class Re{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(T(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ne:T(t,"PAYPAL-5636.update_braintree_sdk_version")?ze:xe)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=o(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Ge extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Be,je,Le,Fe,Ue,qe,Ve;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Be||(Be={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(je||(je={})),function(e){e.TRUSTLY="trustly"}(Le||(Le={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Fe||(Fe={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Ue||(Ue={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(qe||(qe={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Ve||(Ve={}));var He,We,Ye,Je=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ke{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return Je(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return Je(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return Je(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===qe.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return Je(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return Je(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return Je(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,o)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&o(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return Je(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return Je(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return Je(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Ge;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new _(v.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(He||(He={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(We||(We={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Ye||(Ye={}));const Ze={[xe]:{[We.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[We.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[We.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[We.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[We.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[We.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[We.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[We.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[We.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[We.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[We.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[We.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[ze]:{[We.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[We.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[We.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[We.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[We.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[We.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[We.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[We.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[We.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[We.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[We.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[We.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[Ne]:{[We.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[We.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[We.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[We.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[We.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[We.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[We.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[We.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[We.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[We.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[We.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[We.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var Xe=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Qe{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Client,"client.min.js")})}loadFastlane(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.Paypal,"paypal.min.js")})}loadLocalPayment(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.GooglePayment,"google-payment.min.js")})}load3DS(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(We.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(We.Venmo,"venmo.min.js")}loadHostedFields(){return Xe(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(We.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return Xe(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new h;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return Xe(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),o=`//js.braintreegateway.com/web/${i}/js/${t}`,a=i in Ze?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(o,a?{async:!0,attributes:{integrity:a,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new h;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=Ze[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class $e{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var et=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class tt extends L{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=ee.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return et(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let o=i.getPaymentMethod.call(this);if(o.clientToken||(o=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!o.clientToken||!o.initializationData)throw new m(u.MissingPaymentMethod);return this._braintreeSdk.initialize(o.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});var n;return et(this,void 0,void 0,function*(){const i=yield t.getNonce.call(this,e),{clientToken:o,initializationData:a}=t.getPaymentMethod.call(this);if(!o||!a||!(null===(n=a.card_information)||void 0===n?void 0:n.bin))throw new m(u.MissingPaymentMethod);const{isThreeDSecureEnabled:r,card_information:{bin:s,isNetworkTokenized:c}}=a;if(r&&!c){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return et(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return et(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new m(u.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return et(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new m(u.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return et(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new $e(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}const nt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new ie(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]);var it=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ot{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return it(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return it(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return it(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t){return it(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return it(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,attributionId:c}=o;return{options:{"client-id":r,"merchant-id":s,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":r,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:r,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=l,y=d.filter(e=>!l.includes(e));return{options:Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":r}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:r,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},r&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function at(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new m(u.MissingPaymentMethod)}var rt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class st extends L{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,a,r,s,c;return rt(this,void 0,void 0,function*(){const d=null!==(a=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==a?a:n;if(!d)throw new m(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(u.MissingPaymentMethod);at(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(r=y[0])||void 0===r?void 0:r.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return rt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ct="This API endpoint is for internal use only and may change in the future";var dt,lt;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(dt||(dt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(lt||(lt={}));var ht=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class ut extends ie{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return ht(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:a}=i||{},r=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(r)},info:{cardNetwork:(null==a?void 0:a.type)||"",cardDetails:(null==a?void 0:a.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return ht(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,a=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,!0),{status:r}=yield a.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(r===dt.PayerActionRequired)return yield a.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(r!==dt.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return ht(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Object.assign({"X-API-INTERNAL":ct,"Content-Type":ge.Json},q),body:t});return n})}}const yt=g(i=>{const o=new ot(n());return new ut(i,new W(ae(),new st(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class pt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return gt(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return gt(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return gt(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t){return gt(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return gt(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,attributionId:c}=o;return{options:{"client-id":r,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:a},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(u.MissingPaymentMethod);const{intent:a,clientId:r,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":r,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:r,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":r}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(u.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:r,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},r&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var mt,ft,wt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Pt extends L{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,a,r,s,c;return wt(this,void 0,void 0,function*(){const d=null!==(a=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==a?a:n;if(!d)throw new m(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(u.MissingPaymentMethod);at(l);const h=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(r=y[0])||void 0===r?void 0:r.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return wt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(mt||(mt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ft||(ft={}));var vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class _t extends ie{constructor(e,t,n,i){super(e,t),this._payPalSdkHelper=n,this._requestSender=i}execute({payment:e}){return vt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:a}=i||{},r=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(r)},info:{cardNetwork:(null==a?void 0:a.type)||"",cardDetails:(null==a?void 0:a.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return vt(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,a=yield this._payPalSdkHelper.getPayPalGooglePaySdk(i,o,!0),{status:r}=yield a.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(r===mt.PayerActionRequired)return yield a.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(r!==mt.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return vt(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Object.assign({"X-API-INTERNAL":ct,"Content-Type":ge.Json},q),body:t});return n})}}const bt=g(i=>{const o=new pt(n());return new _t(i,new W(ae(),new Pt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var Ct=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class St extends L{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Ct(this,void 0,void 0,function*(){return Promise.resolve({browser_info:f()})})}processAdditionalAction(e){return Ct(this,void 0,void 0,function*(){if(!function(e){return w(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&r(t.errors)&&d(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:o}=t||{};if(!n||!i||!o)throw new Y(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const It=g(n=>new ie(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Ot extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var kt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Tt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t;return kt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const n=e[this._getMethodId()];if(!n)throw new b("Unable to proceed without valid options.");let i,o=this._paymentIntegrationService.getState();try{i=o.getPaymentMethodOrThrow(this._getMethodId())}catch(e){o=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),i=o.getPaymentMethodOrThrow(this._getMethodId())}try{yield this._googlePayPaymentProcessor.initialize(()=>i,this._getGooglePayClientOptions(null===(t=i.initializationData)||void 0===t?void 0:t.storeCountry))}catch(e){return}this._addPaymentButton(n)})}signIn(){return Promise.reject(new Ot('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return kt(this,void 0,void 0,function*(){const t=null===(e=this._paymentIntegrationService.getState().getPaymentId())||void 0===e?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null===(t=null==e?void 0:e.continueWithCheckoutCallback)||void 0===t||t.call(e),Promise.resolve()}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,shippingAddress:n,shippingOptionData:i,offerData:o})=>kt(this,void 0,void 0,function*(){const{availableTriggers:a,addressChangeTriggers:r,shippingOptionsChangeTriggers:s,offerChangeTriggers:c}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!a.includes(t))return;const d=r.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(i.id));const{newOfferInfo:l,error:h}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},u=h;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:g}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:g,totalPriceStatus:N.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),u&&{error:u})})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:i,onError:o}){var a;this._paymentButton=null!==(a=this._paymentButton)&&void 0!==a?a:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(o,i)})}_handleClick(e,t){return n=>kt(this,void 0,void 0,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if($(t)){if("CANCELED"===t.statusCode)throw new P;n=new V(JSON.stringify(t))}throw null==e||e(new V("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return kt(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),n&&(yield this._paymentIntegrationService.updateShippingAddress(n)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodId(),e,i)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}}const At=g(n=>{const i=t();return new Tt(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),Mt=g(n=>{const i=t();return new Tt(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Dt=g(n=>new Tt(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Et=g(n=>{const i=t();return new Tt(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Nt=g(n=>new Tt(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"}]),zt=g(n=>new Tt(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaybnz"}]),xt=g(n=>new Tt(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),Rt=g(i=>new Tt(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Gt=g(i=>new Tt(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripeupe"}]),Bt=g(n=>new Tt(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),jt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new Tt(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]),Lt=g(i=>new Tt(i,new W(ae(),new st(i,new ot(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Ft=g(i=>new Tt(i,new W(ae(),new Pt(i,new pt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Ut=g(n=>new Tt(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class qt extends l{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}var Vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,a){function r(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,s)}c((i=i.apply(e,t||[])).next())})};class Ht{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Vt(this,void 0,void 0,function*(){if(!e.methodId||!te(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new b('Unable to proceed because "containerId" is not a valid key.');const i=e[this._getMethodOrThrow()];if(!i)throw new b("Unable to proceed without valid options.");const{buyNowInitializeOptions:o,currencyCode:a,buttonColor:r,buttonType:s,onError:c}=i;let d,l=this._paymentIntegrationService.getState();try{d=l.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){l=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),d=l.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=d.initializationData)||void 0===t?void 0:t.storeCountry,o){if(!a)throw new b('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=o,yield this._googlePayPaymentProcessor.initialize(()=>d,this._getGooglePayClientOptions(),!!o,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>d,this._getGooglePayClientOptions());this._paymentButton=null!==(n=this._paymentButton)&&void 0!==n?n:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=r?r:"default",buttonType:null!=s?s:"plain",onClick:this._handleClick(c)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Vt(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if($(t)){if("CANCELED"===t.statusCode)throw new P;n=new V(JSON.stringify(t))}throw null==e||e(new V("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return Vt(this,void 0,void 0,function*(){const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),o="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,o)})}_getGooglePayClientOptions(){return{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i})=>Vt(this,void 0,void 0,function*(){const{availableTriggers:o,addressChangeTriggers:a,shippingOptionsChangeTriggers:r,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(e))return;const c=a.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;r.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:d,error:l}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},h=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,h):this._getTransactionInfo(c,d,h)})}}}_createBuyNowCartOrThrow(e){return Vt(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new qt(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,o=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:o||String(i),totalPriceStatus:N.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Vt(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:o}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:o,totalPriceStatus:N.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const Wt=g(i=>{const o=t(),a=window,r=new Re(i),s=new Ke(new Qe(n(),a,r));return new Ht(i,new W(ae(),new tt(i,s),o,e()))},[{id:"googlepaybraintree"}]),Yt=g(i=>new Ht(i,new W(ae(),new st(i,new ot(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Jt=g(i=>new Ht(i,new W(ae(),new Pt(i,new pt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Kt=g(n=>{const i=t();return new Ht(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),Zt=g(n=>{const i=t();return new Ht(n,new W(ae(),new L("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Xt=g(n=>new Ht(n,new W(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Qt=g(n=>{const i=t();return new Ht(n,new W(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),$t=g(n=>new Ht(n,new W(ae(),new Pe(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),en=g(n=>new Ht(n,new W(ae(),new _e(n),t(),e())),[{id:"googlepayorbital"}]),tn=g(i=>new Ht(i,new W(ae(),new ke(i,new Ae(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),nn=g(n=>new Ht(n,new W(ae(),new De(n),t(),e())),[{id:"googlepayworldpayaccess"}]),on=g(n=>new Ht(n,new W(ae(),new St(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{Kt as createGooglePayAdyenV2ButtonStrategy,At as createGooglePayAdyenV2CustomerStrategy,re as createGooglePayAdyenV2PaymentStrategy,Zt as createGooglePayAdyenV3ButtonStrategy,Mt as createGooglePayAdyenV3CustomerStrategy,le as createGooglePayAdyenV3PaymentStrategy,Xt as createGooglePayAuthorizeDotNetButtonStrategy,Dt as createGooglePayAuthorizeDotNetCustomerStrategy,ue as createGooglePayAuthorizeNetPaymentStrategy,Jt as createGooglePayBigCommercePaymentsButtonStrategy,Ft as createGooglePayBigCommercePaymentsCustomerStrategy,bt as createGooglePayBigCommercePaymentsPaymentStrategy,zt as createGooglePayBnzCustomerStrategy,Wt as createGooglePayBraintreeButtonStrategy,jt as createGooglePayBraintreeCustomerStrategy,nt as createGooglePayBraintreePaymentStrategy,Qt as createGooglePayCheckoutComButtonStrategy,Et as createGooglePayCheckoutComCustomerStrategy,we as createGooglePayCheckoutComPaymentStrategy,$t as createGooglePayCybersourceButtonStrategy,Nt as createGooglePayCybersourceCustomerStrategy,ve as createGooglePayCybersourcePaymentStrategy,en as createGooglePayOrbitalButtonStrategy,xt as createGooglePayOrbitalCustomerStrategy,be as createGooglePayOrbitalPaymentStrategy,yt as createGooglePayPPCPPaymentStrategy,Yt as createGooglePayPayPalCommerceButtonStrategy,Lt as createGooglePayPayPalCommerceCustomerStrategy,tn as createGooglePayStripeButtonStrategy,Rt as createGooglePayStripeCustomerStrategy,Me as createGooglePayStripePaymentStrategy,Gt as createGooglePayStripeUpeCustomerStrategy,on as createGooglePayTdOnlineMartButtonStrategy,Ut as createGooglePayTdOnlineMartCustomerStrategy,It as createGooglePayTdOnlineMartPaymentStrategy,nn as createGooglePayWorldpayAccessButtonStrategy,Bt as createGooglePayWorldpayAccessCustomerStrategy,Ee as createGooglePayWorldpayAccessPaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=google-pay.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getScriptLoader as e}from"@bigcommerce/script-loader";import{includes as t}from"lodash";import{createRequestSender as n}from"@bigcommerce/request-sender";var i,a,r={};function o(e,t){return Object.assign(e,{resolveIds:t})}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class s extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class d extends s{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends s{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(i||(i={}));class l extends s{constructor(e){super(function(e){switch(e){case i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case i.MissingCart:return"Unable to proceed because cart data is unavailable.";case i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case i.MissingCheckoutConfig:case i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case i.MissingOrder:return"Unable to proceed because order data is unavailable.";case i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(a||(a={}));class u extends s{constructor(e){super(function(e){switch(e){case a.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case a.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case a.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case a.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class h extends s{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}const p={body:{},headers:{},status:0};class m extends s{constructor(e,{message:t,errors:n}={}){const{body:i,headers:a,status:r}=e||p;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=a,this.status=r,this.errors=n||[]}}class y extends m{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}const g=["AT","BE","CA","CH","CZ","DE","DK","ES","FI","FR","GB","GR","IE","IT","NL","NO","NZ","PL","PT","SE"],b=["AU"];var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.klarnaScriptLoader=t}initialize(e){return v(this,void 0,void 0,function*(){this.klarnaCredit=yield this.klarnaScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return v(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=e.payment,{paymentData:i}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(n,["paymentData"]),{authorization_token:r}=yield this.authorize();yield this.paymentIntegrationService.initializePayment(a.methodId,{authorizationToken:r}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:a,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadWidget(e){return v(this,void 0,void 0,function*(){if(!e.klarna)throw new d('Unable to load widget because "options.klarna" argument is not provided.');const{methodId:t,klarna:{container:n,onLoad:r}}=e;return yield this.paymentIntegrationService.loadPaymentMethod(t),new Promise(e=>{const o=this.paymentIntegrationService.getState().getPaymentMethod(t);if(!o)throw new l(i.MissingPaymentMethod);if(!this.klarnaCredit||!o.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaCredit.init({client_token:o.clientToken}),this.klarnaCredit.load({container:n},t=>{r&&r(t),e(t)})})})}getUpdateSessionData(e,n){if(!t([...g,...b],e.countryCode))return{};const i={billing_address:this.mapToKlarnaAddress(e,e.email)};return n&&(i.shipping_address=this.mapToKlarnaAddress(n,e.email)),i}needsStateCode(e){return t(b,e)}mapToKlarnaAddress(e,t){const n={street_address:e.address1,city:e.city,country:e.countryCode,given_name:e.firstName,family_name:e.lastName,postal_code:e.postalCode,region:this.needsStateCode(e.countryCode)?e.stateOrProvinceCode:e.stateOrProvince,email:t};return e.address2&&(n.street_address2=e.address2),e.phone&&(n.phone=e.phone),n}authorize(){return new Promise((e,t)=>{const n=this.paymentIntegrationService.getState(),r=n.getBillingAddress(),o=n.getShippingAddress();if(!r)throw new l(i.MissingBillingAddress);if(!this.klarnaCredit)throw new u(a.PaymentNotInitialized);const s=this.getUpdateSessionData(r,o);this.klarnaCredit.authorize(s,n=>n.approved?e(n):n.show_form?t(new h):void t(new y))})}}class w extends s{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class P{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Credit)||(yield this.scriptLoader.loadScript("//credit.klarnacdn.net/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Credit))throw new w;return this.klarnaWindow.Klarna.Credit},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}const k=o(t=>new f(t,new P(e())),[{id:"klarna"}]);var I=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class M{constructor(e,t,n){this.paymentIntegrationService=e,this.klarnav2ScriptLoader=t,this.klarnav2TokenUpdater=n}initialize(e){return I(this,void 0,void 0,function*(){this.klarnaPayments=yield this.klarnav2ScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadPaymentsWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadPaymentsWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return I(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(e.payment,[]),{gatewayId:i,methodId:a}=n;if(!i)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const r=this.paymentIntegrationService.getState(),{id:o}=r.getCartOrThrow(),{clientToken:s,initializationData:c}=r.getPaymentMethodOrThrow(a),{klarnaMultipleRadioButton:l}=c||{};yield this.klarnav2TokenUpdater.klarnaOrderInitialization(o,s);const u=this.isKlarnaMultipleRadioButtonEnabled(l,i,a),{authorization_token:h}=yield this.authorizeOrThrow(u,a);yield this.paymentIntegrationService.initializePayment(i,{authorizationToken:h}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:n,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadPaymentsWidget(e){return I(this,void 0,void 0,function*(){if(!e.klarnav2)throw new d('Unable to load widget because "options.klarnav2" argument is not provided.');const{methodId:t,gatewayId:n,klarnav2:{container:r,onLoad:o}}=e;if(!n)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const s=this.paymentIntegrationService.getState(),c={params:s.getCartOrThrow().id};return yield this.klarnav2TokenUpdater.updateClientToken(n,{params:c}).catch(()=>{throw new l(i.MissingPaymentMethod)}),new Promise(e=>{const i=s.getPaymentMethodOrThrow(t),{klarnaMultipleRadioButton:d}=i.initializationData||{};if(!this.klarnaPayments||!i.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaPayments.init({client_token:i.clientToken}),this.klarnaPayments.load({container:r,payment_method_category:this.isKlarnaMultipleRadioButtonEnabled(d,n,t)},t=>{o&&o(t),e(t)})})})}getUpdateSessionData(e,n,i){if(!t([...g,...b],n.countryCode))return{};const a={billing_address:this.mapToKlarnaAddress(e,n,n.email)};return i&&(a.shipping_address=this.mapToKlarnaAddress(e,i,n.email)),a}needsStateCode(e){return t(b,e)}isKlarnaMultipleRadioButtonEnabled(e,t,n){return e?n:t}mapToKlarnaAddress(e,t,n){const i=this.paymentIntegrationService.getState(),{checkoutSettings:a}=i.getStoreConfigOrThrow(),r=i.getPaymentMethodOrThrow(e),{enableBillie:o}=r.initializationData||{},s={street_address:t.address1,city:t.city,country:t.countryCode,given_name:t.firstName,family_name:t.lastName,postal_code:t.postalCode,region:this.needsStateCode(t.countryCode)?t.stateOrProvinceCode:t.stateOrProvince,email:n};return t.address2&&(s.street_address2=t.address2),t.phone&&(s.phone=t.phone),t.company&&o&&function(e,t,n=!0){var i;return null!==(i=e["PI-3915.b2b_payment_session_for_klarna"])&&void 0!==i?i:n}(a.features)&&(s.organization_name=t.company),s}authorizeOrThrow(e,t){return I(this,void 0,void 0,function*(){yield this.paymentIntegrationService.loadCheckout();const n=this.paymentIntegrationService.getState(),i=n.getBillingAddressOrThrow(),r=n.getShippingAddress(),o=this.getUpdateSessionData(t,i,r);return new Promise((t,n)=>{if(!this.klarnaPayments)return n(new u(a.PaymentNotInitialized));this.klarnaPayments.authorize({payment_method_category:e},o,e=>e.approved?t(e):e.show_form?n(new h):void n(new y))})})}}var S;class C{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Payments)||(yield this.scriptLoader.loadScript("https://x.klarnacdn.net/kp/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Payments))throw new w;return this.klarnaWindow.Klarna.Payments},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(S||(S={}));const O=S,z="This API endpoint is for internal use only and may change in the future",_={"X-Checkout-SDK-Version":"1.848.0"};class T{constructor(e){this.requestSender=e}updateClientToken(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this.requestSender.get(i,{timeout:t,headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),params:n})}klarnaOrderInitialization(e,t){return n=this,i=void 0,r=function*(){const n={headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),body:{cartId:e,clientToken:t}};yield this.requestSender.put("/api/storefront/initialization/klarna",n)},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())});var n,i,a,r}}const U=o(t=>{const{getHost:i}=t.getState(),a=n({host:i()});return new M(t,new C(e()),new T(a))},[{gateway:"klarna"}]);export{k as createKlarnaPaymentStrategy,U as createKlarnaV2PaymentStrategy};
|
|
1
|
+
import{getScriptLoader as e}from"@bigcommerce/script-loader";import{includes as t}from"lodash";import{createRequestSender as n}from"@bigcommerce/request-sender";var i,a,r={};function o(e,t){return Object.assign(e,{resolveIds:t})}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class s extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class d extends s{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends s{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(i||(i={}));class l extends s{constructor(e){super(function(e){switch(e){case i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case i.MissingCart:return"Unable to proceed because cart data is unavailable.";case i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case i.MissingCheckoutConfig:case i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case i.MissingOrder:return"Unable to proceed because order data is unavailable.";case i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(a||(a={}));class u extends s{constructor(e){super(function(e){switch(e){case a.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case a.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case a.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case a.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class h extends s{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}const p={body:{},headers:{},status:0};class m extends s{constructor(e,{message:t,errors:n}={}){const{body:i,headers:a,status:r}=e||p;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=a,this.status=r,this.errors=n||[]}}class y extends m{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}const g=["AT","BE","CA","CH","CZ","DE","DK","ES","FI","FR","GB","GR","IE","IT","NL","NO","NZ","PL","PT","SE"],b=["AU"];var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.klarnaScriptLoader=t}initialize(e){return v(this,void 0,void 0,function*(){this.klarnaCredit=yield this.klarnaScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return v(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=e.payment,{paymentData:i}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(n,["paymentData"]),{authorization_token:r}=yield this.authorize();yield this.paymentIntegrationService.initializePayment(a.methodId,{authorizationToken:r}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:a,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadWidget(e){return v(this,void 0,void 0,function*(){if(!e.klarna)throw new d('Unable to load widget because "options.klarna" argument is not provided.');const{methodId:t,klarna:{container:n,onLoad:r}}=e;return yield this.paymentIntegrationService.loadPaymentMethod(t),new Promise(e=>{const o=this.paymentIntegrationService.getState().getPaymentMethod(t);if(!o)throw new l(i.MissingPaymentMethod);if(!this.klarnaCredit||!o.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaCredit.init({client_token:o.clientToken}),this.klarnaCredit.load({container:n},t=>{r&&r(t),e(t)})})})}getUpdateSessionData(e,n){if(!t([...g,...b],e.countryCode))return{};const i={billing_address:this.mapToKlarnaAddress(e,e.email)};return n&&(i.shipping_address=this.mapToKlarnaAddress(n,e.email)),i}needsStateCode(e){return t(b,e)}mapToKlarnaAddress(e,t){const n={street_address:e.address1,city:e.city,country:e.countryCode,given_name:e.firstName,family_name:e.lastName,postal_code:e.postalCode,region:this.needsStateCode(e.countryCode)?e.stateOrProvinceCode:e.stateOrProvince,email:t};return e.address2&&(n.street_address2=e.address2),e.phone&&(n.phone=e.phone),n}authorize(){return new Promise((e,t)=>{const n=this.paymentIntegrationService.getState(),r=n.getBillingAddress(),o=n.getShippingAddress();if(!r)throw new l(i.MissingBillingAddress);if(!this.klarnaCredit)throw new u(a.PaymentNotInitialized);const s=this.getUpdateSessionData(r,o);this.klarnaCredit.authorize(s,n=>n.approved?e(n):n.show_form?t(new h):void t(new y))})}}class w extends s{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class P{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Credit)||(yield this.scriptLoader.loadScript("//credit.klarnacdn.net/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Credit))throw new w;return this.klarnaWindow.Klarna.Credit},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}const k=o(t=>new f(t,new P(e())),[{id:"klarna"}]);var I=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class M{constructor(e,t,n){this.paymentIntegrationService=e,this.klarnav2ScriptLoader=t,this.klarnav2TokenUpdater=n}initialize(e){return I(this,void 0,void 0,function*(){this.klarnaPayments=yield this.klarnav2ScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadPaymentsWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadPaymentsWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return I(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(e.payment,[]),{gatewayId:i,methodId:a}=n;if(!i)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const r=this.paymentIntegrationService.getState(),{id:o}=r.getCartOrThrow(),{clientToken:s,initializationData:c}=r.getPaymentMethodOrThrow(a),{klarnaMultipleRadioButton:l}=c||{};yield this.klarnav2TokenUpdater.klarnaOrderInitialization(o,s);const u=this.isKlarnaMultipleRadioButtonEnabled(l,i,a),{authorization_token:h}=yield this.authorizeOrThrow(u,a);yield this.paymentIntegrationService.initializePayment(i,{authorizationToken:h}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:n,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadPaymentsWidget(e){return I(this,void 0,void 0,function*(){if(!e.klarnav2)throw new d('Unable to load widget because "options.klarnav2" argument is not provided.');const{methodId:t,gatewayId:n,klarnav2:{container:r,onLoad:o}}=e;if(!n)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const s=this.paymentIntegrationService.getState(),c={params:s.getCartOrThrow().id};return yield this.klarnav2TokenUpdater.updateClientToken(n,{params:c}).catch(()=>{throw new l(i.MissingPaymentMethod)}),new Promise(e=>{const i=s.getPaymentMethodOrThrow(t),{klarnaMultipleRadioButton:d}=i.initializationData||{};if(!this.klarnaPayments||!i.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaPayments.init({client_token:i.clientToken}),this.klarnaPayments.load({container:r,payment_method_category:this.isKlarnaMultipleRadioButtonEnabled(d,n,t)},t=>{o&&o(t),e(t)})})})}getUpdateSessionData(e,n,i){if(!t([...g,...b],n.countryCode))return{};const a={billing_address:this.mapToKlarnaAddress(e,n,n.email)};return i&&(a.shipping_address=this.mapToKlarnaAddress(e,i,n.email)),a}needsStateCode(e){return t(b,e)}isKlarnaMultipleRadioButtonEnabled(e,t,n){return e?n:t}mapToKlarnaAddress(e,t,n){const i=this.paymentIntegrationService.getState(),{checkoutSettings:a}=i.getStoreConfigOrThrow(),r=i.getPaymentMethodOrThrow(e),{enableBillie:o}=r.initializationData||{},s={street_address:t.address1,city:t.city,country:t.countryCode,given_name:t.firstName,family_name:t.lastName,postal_code:t.postalCode,region:this.needsStateCode(t.countryCode)?t.stateOrProvinceCode:t.stateOrProvince,email:n};return t.address2&&(s.street_address2=t.address2),t.phone&&(s.phone=t.phone),t.company&&o&&function(e,t,n=!0){var i;return null!==(i=e["PI-3915.b2b_payment_session_for_klarna"])&&void 0!==i?i:n}(a.features)&&(s.organization_name=t.company),s}authorizeOrThrow(e,t){return I(this,void 0,void 0,function*(){yield this.paymentIntegrationService.loadCheckout();const n=this.paymentIntegrationService.getState(),i=n.getBillingAddressOrThrow(),r=n.getShippingAddress(),o=this.getUpdateSessionData(t,i,r);return new Promise((t,n)=>{if(!this.klarnaPayments)return n(new u(a.PaymentNotInitialized));this.klarnaPayments.authorize({payment_method_category:e},o,e=>e.approved?t(e):e.show_form?n(new h):void n(new y))})})}}var S;class C{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Payments)||(yield this.scriptLoader.loadScript("https://x.klarnacdn.net/kp/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Payments))throw new w;return this.klarnaWindow.Klarna.Payments},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(S||(S={}));const O=S,z="This API endpoint is for internal use only and may change in the future",_={"X-Checkout-SDK-Version":"1.849.0"};class T{constructor(e){this.requestSender=e}updateClientToken(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this.requestSender.get(i,{timeout:t,headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),params:n})}klarnaOrderInitialization(e,t){return n=this,i=void 0,r=function*(){const n={headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),body:{cartId:e,clientToken:t}};yield this.requestSender.put("/api/storefront/initialization/klarna",n)},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())});var n,i,a,r}}const U=o(t=>{const{getHost:i}=t.getState(),a=n({host:i()});return new M(t,new C(e()),new T(a))},[{gateway:"klarna"}]);export{k as createKlarnaPaymentStrategy,U as createKlarnaV2PaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=klarna.js.map
|