@bigcommerce/checkout-sdk 1.927.2 → 1.928.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/cjs/wallet-button.js +1 -1
- package/dist/cjs/wallet-button.js.map +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/esm/wallet-button.js +1 -1
- package/dist/esm/wallet-button.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getScriptLoader as e}from"@bigcommerce/script-loader";import{noop as t}from"lodash";import{createFormPoster as n}from"@bigcommerce/form-poster";function i(e,t){return Object.assign(e,{resolveIds:t})}class a 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}}var s,r,o,c,d,l,u,p;!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"}(s||(s={}));class h extends a{constructor(e){super(function(e){switch(e){case s.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case s.MissingCart:return"Unable to proceed because cart data is unavailable.";case s.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case s.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case s.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case s.MissingCheckoutConfig:case s.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case s.MissingOrder:return"Unable to proceed because order data is unavailable.";case s.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case s.MissingPayment:return"Unable to proceed because payment data is unavailable.";case s.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case s.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case s.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"}(r||(r={}));class y extends a{constructor(e){super(function(e){switch(e){case r.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case r.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case r.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case r.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 m extends a{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.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(o||(o={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(c||(c={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(d||(d={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(l||(l={})),function(e){e.PILL="pill",e.RECT="rect"}(u||(u={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(p||(p={}));var g=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return g(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState();this.paymentMethod=t.getPaymentMethodOrThrow(e.methodId),this.useRedirectFlow=!0===(e.paypalexpress&&e.paypalexpress.useRedirectFlow);const n=this.paymentMethod.config.merchantId;if(!this.isInContextEnabled()||!n)throw new h(s.MissingPaymentMethod);const i=yield this.scriptLoader.loadPaypalSDK();this.paypalSdk=i,this.paypalSdk.checkout.setup(n,{button:"paypal-button",environment:this.paymentMethod.config.testMode?"sandbox":"production"})})}deinitialize(){return this.isInContextEnabled()&&this.paypalSdk&&(this.paypalSdk.checkout.closeFlow(),this.paypalSdk=void 0),Promise.resolve()}execute(e,n){return g(this,void 0,void 0,function*(){let i,a;const s=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),a=i.getPaymentRedirectUrl(),a&&this.window.top&&(this.window.top.location.href=a),new Promise(t);if(!s)throw new y(r.PaymentNotInitialized);s.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return s.checkout.closeFlow(),Promise.reject(e)}return a=i.getPaymentRedirectUrl(),a&&s.checkout.startFlow(a),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return g(this,void 0,void 0,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new m)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===p.ACKNOWLEDGE||e.getPaymentStatus()===p.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class I extends a{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 b{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new I;return this.window.paypal},new((n=void 0)||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())});var e,t,n,i}}const w=i(t=>new f(t,new b(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class P extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const M={"X-Checkout-SDK-Version":"1.927.2"};var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class S{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return v(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new P;if(!t.config.merchantId)throw new h(s.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:a}=e,{allowCredit:r,clientId:o,onPaymentError:c,shouldProcessPayment:d,style:l}=a,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new h(s.MissingPaymentMethod);const p=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:o},g=t.FUNDING.CREDIT||"credit",f=r?[g]:[],I=r?[]:[g];return t.Button.render({env:y,client:m,commit:d,funding:{allowed:f,disallowed:I},style:this.getStyle(l),payment:(e,t)=>this.setupPayment(p,t,c),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:a,shape:s,size:r,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:a,shape:s||u.RECT,size:"small"===r?c.RESPONSIVE:r,tagline:o}}setupPayment(e,t,n){return v(this,void 0,void 0,function*(){if(!t)throw new y(r.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),a=n.getHost()||"";return(yield t.request.post(`${a}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},M)})).id}catch(e){throw n&&e instanceof a&&n(e),e}})}tokenizePayment(e,t,n,i){return v(this,void 0,void 0,function*(){if(!n)throw new y(r.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new h(s.MissingPayment);const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}const E=i(t=>new S(t,new b(e()),n()),[{id:"paypalexpress"}]);export{E as createPaypalExpressButtonStrategy,w as createPaypalExpressPaymentStrategy};
|
|
1
|
+
import{getScriptLoader as e}from"@bigcommerce/script-loader";import{noop as t}from"lodash";import{createFormPoster as n}from"@bigcommerce/form-poster";function i(e,t){return Object.assign(e,{resolveIds:t})}class a 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}}var s,r,o,c,d,l,u,p;!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"}(s||(s={}));class h extends a{constructor(e){super(function(e){switch(e){case s.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case s.MissingCart:return"Unable to proceed because cart data is unavailable.";case s.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case s.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case s.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case s.MissingCheckoutConfig:case s.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case s.MissingOrder:return"Unable to proceed because order data is unavailable.";case s.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case s.MissingPayment:return"Unable to proceed because payment data is unavailable.";case s.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case s.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case s.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"}(r||(r={}));class y extends a{constructor(e){super(function(e){switch(e){case r.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case r.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case r.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case r.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 m extends a{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.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(o||(o={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(c||(c={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(d||(d={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(l||(l={})),function(e){e.PILL="pill",e.RECT="rect"}(u||(u={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(p||(p={}));var g=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return g(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState();this.paymentMethod=t.getPaymentMethodOrThrow(e.methodId),this.useRedirectFlow=!0===(e.paypalexpress&&e.paypalexpress.useRedirectFlow);const n=this.paymentMethod.config.merchantId;if(!this.isInContextEnabled()||!n)throw new h(s.MissingPaymentMethod);const i=yield this.scriptLoader.loadPaypalSDK();this.paypalSdk=i,this.paypalSdk.checkout.setup(n,{button:"paypal-button",environment:this.paymentMethod.config.testMode?"sandbox":"production"})})}deinitialize(){return this.isInContextEnabled()&&this.paypalSdk&&(this.paypalSdk.checkout.closeFlow(),this.paypalSdk=void 0),Promise.resolve()}execute(e,n){return g(this,void 0,void 0,function*(){let i,a;const s=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),a=i.getPaymentRedirectUrl(),a&&this.window.top&&(this.window.top.location.href=a),new Promise(t);if(!s)throw new y(r.PaymentNotInitialized);s.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return s.checkout.closeFlow(),Promise.reject(e)}return a=i.getPaymentRedirectUrl(),a&&s.checkout.startFlow(a),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return g(this,void 0,void 0,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new m)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===p.ACKNOWLEDGE||e.getPaymentStatus()===p.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class I extends a{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 b{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new I;return this.window.paypal},new((n=void 0)||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())});var e,t,n,i}}const w=i(t=>new f(t,new b(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class P extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const M={"X-Checkout-SDK-Version":"1.928.0"};var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class S{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return v(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new P;if(!t.config.merchantId)throw new h(s.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:a}=e,{allowCredit:r,clientId:o,onPaymentError:c,shouldProcessPayment:d,style:l}=a,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new h(s.MissingPaymentMethod);const p=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:o},g=t.FUNDING.CREDIT||"credit",f=r?[g]:[],I=r?[]:[g];return t.Button.render({env:y,client:m,commit:d,funding:{allowed:f,disallowed:I},style:this.getStyle(l),payment:(e,t)=>this.setupPayment(p,t,c),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:a,shape:s,size:r,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:a,shape:s||u.RECT,size:"small"===r?c.RESPONSIVE:r,tagline:o}}setupPayment(e,t,n){return v(this,void 0,void 0,function*(){if(!t)throw new y(r.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),a=n.getHost()||"";return(yield t.request.post(`${a}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},M)})).id}catch(e){throw n&&e instanceof a&&n(e),e}})}tokenizePayment(e,t,n,i){return v(this,void 0,void 0,function*(){if(!n)throw new y(r.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new h(s.MissingPayment);const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}const E=i(t=>new S(t,new b(e()),n()),[{id:"paypalexpress"}]);export{E as createPaypalExpressButtonStrategy,w as createPaypalExpressPaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=paypal-express.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequestSender as e}from"@bigcommerce/request-sender";var t;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(t||(t={}));const n=t,i={"X-Checkout-SDK-Version":"1.
|
|
1
|
+
import{createRequestSender as e}from"@bigcommerce/request-sender";var t;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(t||(t={}));const n=t,i={"X-Checkout-SDK-Version":"1.928.0"};var r;class s{constructor(e){this._requestSender=e}saveExternalId(e,t){return r=this,s=void 0,o=function*(){const r=`/api/storefront/payment/${e}/save-external-id`,s={headers:Object.assign({Accept:n.JsonV1,"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},i),body:{externalId:t,provider:e}};yield this._requestSender.post(r,s)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(o.next(e))}catch(e){t(e)}}function i(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a(function(e){e(r)})).then(n,i)}c((o=o.apply(r,s||[])).next())});var r,s,a,o}}class a 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 o extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends o{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"}}!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"}(r||(r={}));class d extends a{constructor(e){super(function(e){switch(e){case r.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case r.MissingCart:return"Unable to proceed because cart data is unavailable.";case r.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case r.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case r.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case r.MissingCheckoutConfig:case r.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case r.MissingOrder:return"Unable to proceed because order data is unavailable.";case r.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case r.MissingPayment:return"Unable to proceed because payment data is unavailable.";case r.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case r.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case r.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"}}class u extends a{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}class l{constructor(e,t){this.paymentIntegrationService=e,this.storefrontPaymentRequestSender=t}initialize(){return Promise.resolve()}execute(e,t){return n=this,i=void 0,a=function*(){const{payment:n}=e,i=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 r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);if(!n)throw new c(["payment"]);const{methodId:s}=n,{getPaymentMethodOrThrow:a}=yield this.paymentIntegrationService.loadPaymentMethod(s,t),{clientToken:o,initializationData:u}=a(s),l=null==u?void 0:u.redirectUrl;if(!o||!l)throw new d(r.MissingPaymentMethod);const{id:g}=JSON.parse(o);if(!g)throw new d(r.MissingPaymentToken);const{isStoreCreditApplied:p}=this.paymentIntegrationService.getState().getCheckoutOrThrow();yield this.paymentIntegrationService.applyStoreCredit(p),yield this.paymentIntegrationService.initializePayment(s,{useStoreCredit:p}),yield this.paymentIntegrationService.submitOrder(i,t),yield this._prepareForReferredRegistration(s,g);try{yield this.paymentIntegrationService.submitPayment({methodId:s,paymentData:{nonce:g}})}catch(e){if((e=>"object"==typeof e&&null!==e&&"body"in e)(e)&&"additional_action_required"===e.body.status)return new Promise(()=>window.location.replace(l));throw e}},new((s=void 0)||(s=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function o(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 s?n:new s(function(e){e(n)})).then(r,o)}c((a=a.apply(n,i||[])).next())});var n,i,s,a}finalize(){return Promise.reject(new u)}deinitialize(){return Promise.resolve()}_prepareForReferredRegistration(e,t){return this.storefrontPaymentRequestSender.saveExternalId(e,t)}}const g=(p=t=>{const{getHost:n}=t.getState(),i=e({host:n()}),r=new s(i);return new l(t,r)},y=[{id:"zip"},{id:"quadpay"}],Object.assign(p,{resolveIds:y}));var p,y;export{g as createZipPaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=zip.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequestSender as e}from"@bigcommerce/request-sender";import{uniqueId as t}from"lodash";var n={d:(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};n.r(r),n.d(r,{createPayPalCommerceWalletStrategy:()=>u});class o 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 s extends o{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class a extends o{constructor(e){super(e||"An unexpected error has occurred during payment order creation process. Please try again later."),this.name="PaymentOrderCreationError",this.type="payment_order_creation_error"}}class i{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n){return r=this,o=void 0,c=function*(){var r;const o={headers:Object.assign(Object.assign({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,o),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:s}}}}}=t.body,i=null===(r=s[0])||void 0===r?void 0:r.message;if(i)throw new a(i);return Object.assign(Object.assign({},t),{body:Object.assign({},n)})}catch(e){if(!(e instanceof a))throw new s;throw e}},new((i=void 0)||(i=Promise))(function(e,t){function n(e){try{a(c.next(e))}catch(e){t(e)}}function s(e){try{a(c.throw(e))}catch(e){t(e)}}function a(t){var r;t.done?e(t.value):(r=t.value,r instanceof i?r:new i(function(e){e(r)})).then(n,s)}a((c=c.apply(r,o||[])).next())});var r,o,i,c}}class c{constructor(e,t){this.graphQLEndpoint=e,this.paymentRequestSender=t}createPaymentOrderIntent(e,t){return n=this,r=void 0,s=function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t)},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(s.next(e))}catch(e){t(e)}}function i(e){try{c(s.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(a,i)}c((s=s.apply(n,r||[])).next())});var n,r,o,s}}class l{constructor(e){this.walletButtonIntegrationService=e}getWalletButtonIntegrationService(){return this.walletButtonIntegrationService}initialize(e){return t=this,n=void 0,o=function*(){return Promise.resolve()},new((r=void 0)||(r=Promise))(function(e,s){function a(e){try{c(o.next(e))}catch(e){s(e)}}function i(e){try{c(o.throw(e))}catch(e){s(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,i)}c((o=o.apply(t,n||[])).next())});var t,n,r,o}deinitialize(){return Promise.resolve()}}const u=(d=e=>new l(e),h=[{id:"paypalcommercepaypal"}],Object.assign(d,{resolveIds:h}));var d,h;function f(e){return e&&"resolveIds"in e}function y(){try{return"production"}catch(e){return"development"}}class p{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class g{log(){}info(){}warn(){}error(){}debug(){}}const m=function(e=!0){return e?new p(console):new g}("test"!==y());class v 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 _ extends v{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class w{constructor(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:e=>e}get(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new _(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new _(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class b{constructor(e=!1){this._useFallback=e,this._registry=new w({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var r;const o=this._decodeToken(e),s=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,r]of Object.entries(t)){if(e in o&&o[e]!==r){n.matches=0;break}e in o&&o[e]===r&&n.matches++,"default"===e&&!0===r&&(n.default=!0)}s.push(n)});const a=s.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===y()&&m.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");const i=Object.keys(o).length;if(n){const e=a.find(e=>e.matches===i&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(o)} with exact match.`);return e.token}const c=a[0];if(c&&c.token)return c.token;if(this._useFallback){const e=null===(r=s.find(e=>e.default))||void 0===r?void 0:r.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(o)}.`)}}function k(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){r=e}}}const O=e=>{const n=t(e);return document.getElementById(n)?O(e):n};let I=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,r=void 0,s=function*(){return this._registryV2.get({id:e.methodId}).initialize(Object.assign(Object.assign({},e),{containerId:t}))},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(s.next(e))}catch(e){t(e)}}function i(e){try{c(s.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(a,i)}c((s=s.apply(n,r||[])).next())});var n,r,o,s}))}deinitializeWalletButton(e){return this._registryV2.get({id:e.methodId}).deinitialize()}getContainerIds(e){return t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new _(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=O(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};I=function(e,t,n,r){var o,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(a=(s<3?o(a):s>3?o(t,n,a):o(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}([function(e,t,n){return t&&n?k(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,k(e.prototype,n,r))}),t}(e)}],I);const P=I;function j(t){const{graphQLEndpoint:n}=t,o=function(e,t){const n=new b;for(const[,r]of Object.entries(t))if(f(r))for(const t of r.resolveIds)n.register(t,()=>r(e));return n}((t=>{const n=e();return new c(t,new i(n))})(n),r);return new P(o)}export{j as createWalletButtonInitializer};
|
|
1
|
+
import{createRequestSender as e}from"@bigcommerce/request-sender";import{uniqueId as t}from"lodash";var n={d:(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};n.r(r),n.d(r,{createPayPalCommerceWalletStrategy:()=>p});var o=function(e,t,n,r){return new(n||(n=Promise))(function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())})};class s{constructor(e){this.requestSender=e}updateBillingAddress(e,t,n,r){return o(this,void 0,void 0,function*(){const{id:o}=n,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(n,["id"]),i={headers:Object.assign(Object.assign({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation UpdateCheckoutBillingAddressMutation(\n $input: UpdateCheckoutBillingAddressInput!\n ) {\n checkout {\n updateCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,addressEntityId:n.id,data:{address:Object.assign({},s)}}}}},a=yield this.requestSender.post(`${window.location.origin}/${e}`,i),{billingAddress:c}=a.body.data.checkout.updateCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},a),{body:c})})}addBillingAddress(e,t,n,r){return o(this,void 0,void 0,function*(){const o={headers:Object.assign(Object.assign({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation AddCheckoutBillingAddressMutation(\n $input: AddCheckoutBillingAddressInput!\n ) {\n checkout {\n addCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,data:{address:Object.assign({},n)}}}}},s=yield this.requestSender.post(`${window.location.origin}/${e}`,o),{billingAddress:i}=s.body.data.checkout.addCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},s),{body:i})})}}class i 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 a extends i{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class c extends i{constructor(e){super(e||"An unexpected error has occurred during payment order creation process. Please try again later."),this.name="PaymentOrderCreationError",this.type="payment_order_creation_error"}}class d{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n){return r=this,o=void 0,i=function*(){var r;const o={headers:Object.assign(Object.assign({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,o),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:s}}}}}=t.body,i=null===(r=s[0])||void 0===r?void 0:r.message;if(i)throw new c(i);return Object.assign(Object.assign({},t),{body:Object.assign({},n)})}catch(e){if(!(e instanceof c))throw new a;throw e}},new((s=void 0)||(s=Promise))(function(e,t){function n(e){try{c(i.next(e))}catch(e){t(e)}}function a(e){try{c(i.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof s?r:new s(function(e){e(r)})).then(n,a)}c((i=i.apply(r,o||[])).next())});var r,o,s,i}}var l=function(e,t,n,r){return new(n||(n=Promise))(function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())})};class u{constructor(e,t,n){this.graphQLEndpoint=e,this.billingAddressRequestSender=t,this.paymentRequestSender=n}addBillingAddress(e,t,n){return l(this,void 0,void 0,function*(){return this.billingAddressRequestSender.addBillingAddress(this.graphQLEndpoint,e,t,n)})}updateBillingAddress(e,t,n){return l(this,void 0,void 0,function*(){return this.billingAddressRequestSender.updateBillingAddress(this.graphQLEndpoint,e,t,n)})}createPaymentOrderIntent(e,t){return l(this,void 0,void 0,function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t)})}}class h{constructor(e){this.walletButtonIntegrationService=e}getWalletButtonIntegrationService(){return this.walletButtonIntegrationService}initialize(e){return t=this,n=void 0,o=function*(){return Promise.resolve()},new((r=void 0)||(r=Promise))(function(e,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(i,a)}c((o=o.apply(t,n||[])).next())});var t,n,r,o}deinitialize(){return Promise.resolve()}}const p=(y=e=>new h(e),f=[{id:"paypalcommercepaypal"}],Object.assign(y,{resolveIds:f}));var y,f;function g(e){return e&&"resolveIds"in e}function v(){try{return"production"}catch(e){return"development"}}class m{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class b{log(){}info(){}warn(){}error(){}debug(){}}const k=function(e=!0){return e?new m(console):new b}("test"!==v());class _ 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 w extends _{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class O{constructor(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:e=>e}get(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new w(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new w(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class j{constructor(e=!1){this._useFallback=e,this._registry=new O({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var r;const o=this._decodeToken(e),s=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,r]of Object.entries(t)){if(e in o&&o[e]!==r){n.matches=0;break}e in o&&o[e]===r&&n.matches++,"default"===e&&!0===r&&(n.default=!0)}s.push(n)});const i=s.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);i.length>1&&i[0].matches===i[1].matches&&"development"===v()&&k.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");const a=Object.keys(o).length;if(n){const e=i.find(e=>e.matches===a&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(o)} with exact match.`);return e.token}const c=i[0];if(c&&c.token)return c.token;if(this._useFallback){const e=null===(r=s.find(e=>e.default))||void 0===r?void 0:r.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(o)}.`)}}function I(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){r=e}}}const P=e=>{const n=t(e);return document.getElementById(n)?P(e):n};let T=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,r=void 0,s=function*(){return this._registryV2.get({id:e.methodId}).initialize(Object.assign(Object.assign({},e),{containerId:t}))},new((o=void 0)||(o=Promise))(function(e,t){function i(e){try{c(s.next(e))}catch(e){t(e)}}function a(e){try{c(s.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(i,a)}c((s=s.apply(n,r||[])).next())});var n,r,o,s}))}deinitializeWalletButton(e){return this._registryV2.get({id:e.methodId}).deinitialize()}getContainerIds(e){return t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new w(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=P(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};T=function(e,t,n,r){var o,s=arguments.length,i=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(t,n,i):o(t,n))||i);return s>3&&i&&Object.defineProperty(t,n,i),i}([function(e,t,n){return t&&n?I(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,I(e.prototype,n,r))}),t}(e)}],T);const S=T;function C(t){const{graphQLEndpoint:n}=t,o=function(e,t){const n=new j;for(const[,r]of Object.entries(t))if(g(r))for(const t of r.resolveIds)n.register(t,()=>r(e));return n}((t=>{const n=e();return new u(t,new s(n),new d(n))})(n),r);return new S(o)}export{C as createWalletButtonInitializer};
|
|
2
2
|
//# sourceMappingURL=wallet-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-button.js","mappings":"oGACA,IAAAA,EAAA,CCAAA,EAAA,CAAAC,EAAAC,KACA,QAAAC,KAAAD,EACAF,EAAAI,EAAAF,EAAAC,KAAAH,EAAAI,EAAAH,EAAAE,IACAE,OAAAC,eAAAL,EAAAE,EAAA,CAAyCI,YAAA,EAAAC,IAAAN,EAAAC,MCJzCH,EAAA,CAAAS,EAAAC,IAAAL,OAAAM,UAAAC,eAAAC,KAAAJ,EAAAC,GCCAV,EAAAC,IACA,oBAAAa,QAAAA,OAAAC,aACAV,OAAAC,eAAAL,EAAAa,OAAAC,YAAA,CAAuDC,MAAA,WAEvDX,OAAAC,eAAAL,EAAA,cAAgDe,OAAA,oECEjC,MAAeC,UAAsBC,MAIhD,WAAAC,CAAYC,GCXD,IAAqCT,EDY5CU,MAAMD,GAAW,qCAJrBE,KAAAC,KAAO,gBACPD,KAAAE,KAAO,WCTyCb,aDcZA,UCbhCN,OAAOoB,eACPpB,OAAOoB,eDYQH,KCZeX,GDYfW,KCVRI,UAAYf,EDYoB,mBAA5BO,MAAMS,kBACbT,MAAMS,kBAAkBL,iBAExBA,KAAKM,MAAQ,IAAIV,MAAMI,KAAKF,SAASQ,KAE7C,EEdW,MAAMC,UAAoCZ,EACrD,WAAAE,CAAYC,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B+B,EAAQ/K,EAAKkJ,GASrC,SAA2D6B,GAC9D,MAAMC,EAAkB,cAAcD,IAgBtC,OAdA7K,OAAO+K,oBAAoBF,EAAOvK,WAAWsH,QAAS9H,IAClD,MAAMkJ,EAAahJ,OAAOgL,yBAAyBH,EAAOvK,UAAWR,GAEhEkJ,GAAsB,gBAARlJ,GAInBE,OAAOC,eACH6K,EAAgBxK,UAChBR,EACAgJ,EAAoB+B,EAAOvK,UAAWR,EAAKkJ,MAI5C8B,CACX,CA9BeG,CAAmBJ,EAIlC,GETqBpB,aEAN,SAASyB,EACpBnJ,GAEA,MAAMF,gBAAEA,GAAoBE,EAItBoJ,ECCK,SACX3H,EACA4H,GAEA,MAAMC,EAAW,IAAIzE,EAKrB,IAAK,MAAO,CAAE0E,KAA+BtL,OAAOmI,QAAQiD,GACxD,GACKjH,EAGCmH,GAKN,IAAK,MAAMxD,KAAcwD,EAA2BrH,WAChDoH,EAAS7E,SAASsB,EAAY,IAC1BwD,EAA2B9H,IAKvC,OAAO6H,CACX,CD5BuBE,CEVsB,CACzC1J,IAEA,MAAMF,EAAgB6J,IAEtB,OAAO,IAAInI,EACPxB,EACA,IAAIH,EAAqBC,KFCU8J,CAAqC5J,GAIxE6J,GAGJ,OAAO,IAAIC,EAAwBR,EACvC","sources":["webpack://@bigcommerce/checkout-sdk/webpack/bootstrap","webpack://@bigcommerce/checkout-sdk/webpack/runtime/define property getters","webpack://@bigcommerce/checkout-sdk/webpack/runtime/hasOwnProperty shorthand","webpack://@bigcommerce/checkout-sdk/webpack/runtime/make namespace object","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/standard-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/set-prototype-of.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/payment-method-cancelled-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/payment/payment-order-intent-creation-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/payment/payment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/wallet-button-integration-service.ts","webpack://@bigcommerce/checkout-sdk/./packages/paypal-commerce-integration/src/paypal-commerce/paypal-commerce-wallet-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/paypal-commerce-integration/src/paypal-commerce/create-paypal-commerce-wallet-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/to-resolvable-module.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/is-resolvable-module.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/get-environment.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/console-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/noop-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/get-default-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/create-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/standard-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/set-prototype-of.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/invalid-argument-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/resolve-id-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/utility/src/bind-decorator/bind-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/set-unique-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/wallet-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/is-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/create-wallet-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/create-wallet-button-strategy-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/create-wallet-button-integration-service.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import CustomError from './custom-error';\nimport setPrototypeOf from './set-prototype-of';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = new Error(this.message).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when the payment flow is cancelled. It could be\n * due to a deliberate user interaction, i.e.: the user clicks on a cancel\n * button which dismisses the payment modal.\n */\nexport default class PaymentMethodCancelledError extends StandardError {\n constructor(message?: string) {\n super(message || 'Payment process was cancelled.');\n\n this.name = 'PaymentMethodCancelledError';\n this.type = 'payment_cancelled';\n }\n}\n","import { StandardError } from '@bigcommerce/checkout-sdk/payment-integration-api';\n\nexport default class PaymentOrderCreationError extends StandardError {\n constructor(message?: string) {\n super(\n message ||\n 'An unexpected error has occurred during payment order creation process. Please try again later.',\n );\n\n this.name = 'PaymentOrderCreationError';\n this.type = 'payment_order_creation_error';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { PaymentMethodCancelledError } from '@bigcommerce/checkout-sdk/payment-integration-api';\n\nimport { GraphQLRequestOptions } from '../graphql-request-options';\n\nimport {\n CreatePaymentOrderIntentInputData,\n CreatePaymentOrderIntentResponse,\n CreatePaymentOrderIntentResponseBody,\n} from './payment';\nimport PaymentOrderCreationError from './payment-order-intent-creation-error';\n\nexport class PaymentRequestSender {\n constructor(private readonly requestSender: RequestSender) {}\n\n async createPaymentOrderIntent(\n graphQLEndpoint: string,\n inputData: CreatePaymentOrderIntentInputData,\n options?: GraphQLRequestOptions,\n ): Promise<Response<CreatePaymentOrderIntentResponseBody>> {\n const document = `\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n `;\n\n const requestOptions: GraphQLRequestOptions = {\n headers: {\n ...options?.headers,\n 'Content-Type': 'application/json',\n 'x-catalyst-graphql-proxy-requester': 'checkout-sdk-js',\n },\n body: {\n query: document,\n variables: {\n input: inputData,\n },\n },\n };\n\n try {\n const response = await this.requestSender.post<CreatePaymentOrderIntentResponse>(\n `${window.location.origin}/${graphQLEndpoint}`,\n requestOptions,\n );\n\n const {\n data: {\n payment: {\n paymentWallet: {\n createPaymentWalletIntent: { paymentWalletIntentData, errors },\n },\n },\n },\n } = response.body;\n\n const errorMessage = errors[0]?.message;\n\n if (errorMessage) {\n throw new PaymentOrderCreationError(errorMessage);\n }\n\n return {\n ...response,\n body: {\n ...paymentWalletIntentData,\n },\n };\n } catch (error) {\n if (!(error instanceof PaymentOrderCreationError)) {\n throw new PaymentMethodCancelledError();\n }\n\n throw error;\n }\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { GraphQLRequestOptions } from './graphql-request-options';\nimport {\n CreatePaymentOrderIntentInputData,\n CreatePaymentOrderIntentResponseBody,\n} from './payment/payment';\nimport { PaymentRequestSender } from './payment/payment-request-sender';\n\nexport default class WalletButtonIntegrationService {\n constructor(\n private graphQLEndpoint: string,\n private paymentRequestSender: PaymentRequestSender,\n ) {}\n\n async createPaymentOrderIntent(\n inputData: CreatePaymentOrderIntentInputData,\n options?: GraphQLRequestOptions,\n ): Promise<Response<CreatePaymentOrderIntentResponseBody>> {\n return this.paymentRequestSender.createPaymentOrderIntent(\n this.graphQLEndpoint,\n inputData,\n options,\n );\n }\n}\n","import {\n CheckoutButtonInitializeOptions,\n CheckoutButtonStrategy,\n} from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport { WalletButtonIntegrationService } from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport { WithPayPalCommerceWalletInitializeOptions } from './paypal-commerce-wallet-initialize-options';\n\n/**\n * PayPal Commerce Wallet Button Strategy stub for headless wallet button integration.\n *\n * This is an empty stub class at this stage. Concrete implementation will be\n * added in follow-up tickets.\n */\nexport default class PayPalCommerceWalletStrategy implements CheckoutButtonStrategy {\n constructor(private walletButtonIntegrationService: WalletButtonIntegrationService) {}\n\n getWalletButtonIntegrationService(): WalletButtonIntegrationService {\n return this.walletButtonIntegrationService;\n }\n\n async initialize(\n _options: CheckoutButtonInitializeOptions & WithPayPalCommerceWalletInitializeOptions,\n ): Promise<void> {\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n return Promise.resolve();\n }\n}\n","import { toResolvableModule } from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport {\n WalletButtonIntegrationService,\n WalletPaymentButtonStrategyFactory,\n} from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport PayPalCommerceWalletStrategy from './paypal-commerce-wallet-strategy';\n\nconst createPayPalCommerceWalletStrategy: WalletPaymentButtonStrategyFactory<\n PayPalCommerceWalletStrategy\n> = (walletButtonIntegrationService: WalletButtonIntegrationService) => {\n return new PayPalCommerceWalletStrategy(walletButtonIntegrationService);\n};\n\nexport default toResolvableModule(createPayPalCommerceWalletStrategy, [\n { id: 'paypalcommercepaypal' },\n]);\n","import ResolvableModule from './resolvable-module';\n\nexport default function toResolvableModule<TModule extends object, TIdentifier>(\n module: TModule,\n resolveIds: TIdentifier[],\n): ResolvableModule<TModule, TIdentifier> {\n return Object.assign(module, { resolveIds });\n}\n","import ResolvableModule from './resolvable-module';\n\nexport default function isResolvableModule<TModule extends object, TIdentifier>(\n module: TModule,\n): module is ResolvableModule<TModule, TIdentifier> {\n return module && 'resolveIds' in module;\n}\n","export default function getEnvironment(): string {\n try {\n return process.env.NODE_ENV || 'development';\n } catch (e) {\n return 'development';\n }\n}\n","import Logger from './logger';\n\ntype keys = 'log' | 'info' | 'warn' | 'error' | 'debug';\n\nexport default class ConsoleLogger implements Logger {\n constructor(private _console?: Console) {}\n\n log(...messages: any[]): void {\n this._logToConsole('log', ...messages);\n }\n\n info(...messages: any[]): void {\n this._logToConsole('info', ...messages);\n }\n\n warn(...messages: any[]): void {\n this._logToConsole('warn', ...messages);\n }\n\n error(...messages: any[]): void {\n this._logToConsole('error', ...messages);\n }\n\n debug(...messages: any[]): void {\n this._logToConsole('debug', ...messages);\n }\n\n private _logToConsole(type: keys, ...messages: any[]): void {\n if (!this._console || !this._console[type]) {\n return;\n }\n\n this._console[type].call(this._console, ...messages);\n }\n}\n","import Logger from './logger';\n\nexport default class NoopLogger implements Logger {\n log(): void {}\n\n info(): void {}\n\n warn(): void {}\n\n error(): void {}\n\n debug(): void {}\n}\n","import { getEnvironment } from '../utility';\n\nimport createLogger from './create-logger';\nimport Logger from './logger';\n\nconst logger = createLogger(getEnvironment() !== 'test');\n\nexport default function getDefaultLogger(): Logger {\n return logger;\n}\n","import ConsoleLogger from './console-logger';\nimport Logger from './logger';\nimport NoopLogger from './noop-logger';\n\nexport default function createLogger(isEnabled = true): Logger {\n if (!isEnabled) {\n return new NoopLogger();\n }\n\n return new ConsoleLogger(console);\n}\n","import { setPrototypeOf } from '../../utility';\n\nimport CustomError from './custom-error';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = new Error(this.message).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import { InvalidArgumentError } from '../error/errors';\n\nimport Factory from './factory';\n\nexport default class Registry<T, K extends string = string> {\n private _factories: { [key: string]: Factory<T> };\n private _instances: { [key: string]: T };\n private _defaultToken: string;\n private _useFallback: string | boolean;\n private _tokenResolver: (\n token: string,\n registeredTokens: string[],\n exactMatch?: boolean,\n ) => string | undefined;\n\n constructor(options?: RegistryOptions) {\n this._factories = {};\n this._instances = {};\n this._defaultToken = options?.defaultToken ?? 'default';\n this._useFallback = options?.useFallback ?? true;\n this._tokenResolver = options?.tokenResolver ?? ((token) => token);\n }\n\n get(token?: K, cacheToken?: string): T {\n try {\n return this._getInstance(\n token || this._defaultToken,\n cacheToken || token || this._defaultToken,\n );\n } catch (error) {\n if (!this._useFallback) {\n throw error;\n }\n\n return this._getInstance(this._defaultToken, cacheToken || this._defaultToken);\n }\n }\n\n getFactory(token: string, exactMatch?: boolean): Factory<T> | undefined {\n const resolvedToken = this._tokenResolver(token, Object.keys(this._factories), exactMatch);\n const factory = resolvedToken ? this._factories[resolvedToken] : undefined;\n\n return factory;\n }\n\n register(token: K, factory: Factory<T>): void {\n if (this._hasFactory(token)) {\n throw new InvalidArgumentError(`'${token}' is already registered.`);\n }\n\n this._factories[token] = factory;\n }\n\n protected _hasFactory(token: string): boolean {\n return !!this._factories[token];\n }\n\n private _hasInstance(token: string): boolean {\n return !!this._instances[token];\n }\n\n private _getInstance(token: string, cacheToken: string): T {\n if (!this._hasInstance(cacheToken)) {\n const factory = this.getFactory(token);\n\n if (!factory) {\n throw new InvalidArgumentError(`'${token}' is not registered.`);\n }\n\n this._instances[cacheToken] = factory();\n }\n\n return this._instances[cacheToken];\n }\n}\n\nexport interface RegistryOptions {\n defaultToken?: string;\n useFallback?: boolean;\n tokenResolver?(token: string, registeredTokens: string[]): string | undefined;\n}\n","import { getDefaultLogger } from '../log';\nimport { getEnvironment } from '../utility';\n\nimport Factory from './factory';\nimport Registry from './registry';\n\nexport default class ResolveIdRegistry<TType, TToken extends { [key: string]: unknown }> {\n private _registry: Registry<TType>;\n\n constructor(private _useFallback = false) {\n this._registry = new Registry({\n tokenResolver: this._resolveToken.bind(this),\n defaultToken: this._encodeToken({ default: true } as unknown as TToken),\n useFallback: this._useFallback,\n });\n }\n\n get(resolveId: TToken): TType {\n return this._registry.get(this._encodeToken(resolveId));\n }\n\n getFactory(resolveId: TToken, exactMatch?: boolean): Factory<TType> | undefined {\n try {\n return this._registry.getFactory(this._encodeToken(resolveId), exactMatch);\n } catch (error) {\n return undefined;\n }\n }\n\n getUseFallback(): boolean {\n return this._useFallback;\n }\n\n register(resolveId: TToken, factory: Factory<TType>): void {\n this._registry.register(this._encodeToken(resolveId), factory);\n }\n\n private _encodeToken(resolveId: TToken): string {\n return btoa(JSON.stringify(resolveId));\n }\n\n private _decodeToken(token: string): TToken {\n return JSON.parse(atob(token));\n }\n\n private _resolveToken(\n token: string,\n registeredTokens: string[],\n exactMatch?: boolean,\n ): string | undefined {\n const query = this._decodeToken(token);\n\n const results: Array<{\n token: string;\n matches: number;\n default: boolean;\n totalKeys: number;\n }> = [];\n\n registeredTokens.forEach((registeredToken) => {\n const resolverId = this._decodeToken(registeredToken);\n\n const result = {\n token: registeredToken,\n matches: 0,\n default: false,\n totalKeys: Object.keys(resolverId).length,\n };\n\n for (const [key, value] of Object.entries(resolverId)) {\n if (key in query && query[key] !== value) {\n result.matches = 0;\n break;\n }\n\n if (key in query && query[key] === value) {\n result.matches++;\n }\n\n if (key === 'default' && value === true) {\n result.default = true;\n }\n }\n\n results.push(result);\n });\n\n const matchedResults = results\n .sort((a, b) => b.matches - a.matches)\n .filter((result) => result.matches > 0);\n\n if (matchedResults.length > 1 && matchedResults[0].matches === matchedResults[1].matches) {\n if (getEnvironment() === 'development') {\n getDefaultLogger().warn(\n 'The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.',\n );\n }\n }\n\n const queryKeyCount = Object.keys(query).length;\n\n if (exactMatch) {\n const exactResult = matchedResults.find(\n (result) => result.matches === queryKeyCount && result.matches === result.totalKeys,\n );\n\n if (!exactResult) {\n throw new Error(\n `Unable to resolve to a registered token with the provided token for ${JSON.stringify(\n query,\n )} with exact match.`,\n );\n }\n\n return exactResult.token;\n }\n\n const matched = matchedResults[0];\n\n if (matched && matched.token) {\n return matched.token;\n }\n\n if (this._useFallback) {\n const defaultToken = results.find((result) => result.default)?.token;\n\n if (defaultToken) {\n return defaultToken;\n }\n }\n\n throw new Error(\n `Unable to resolve to a registered token with the provided token for ${JSON.stringify(\n query,\n )}.`,\n );\n }\n}\n","/**\n * Decorates a class or a method by binding all its prototype methods or itself\n * to the calling instance respectively.\n */\nfunction bindDecorator<T extends Method>(\n target: object,\n key: string,\n descriptor: TypedPropertyDescriptor<T>,\n): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\n\nfunction bindDecorator(target: any, key?: any, descriptor?: any): any {\n if (!key || !descriptor) {\n return bindClassDecorator(target);\n }\n\n return bindMethodDecorator(target, key, descriptor);\n}\n\nexport default bindDecorator;\n\n/**\n * Decorates a class by binding all its prototype methods to the calling\n * instance.\n */\nexport function bindClassDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype).forEach((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);\n\n if (!descriptor || key === 'constructor') {\n return;\n }\n\n Object.defineProperty(\n decoratedTarget.prototype,\n key,\n bindMethodDecorator(target.prototype, key, descriptor),\n );\n });\n\n return decoratedTarget;\n}\n\n/**\n * Decorates a method by binding it to the calling instance.\n */\nexport function bindMethodDecorator<T extends Method>(\n _: object,\n key: string,\n descriptor: TypedPropertyDescriptor<T>,\n): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let method: T = descriptor.value;\n\n return {\n get() {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const boundMethod = method.bind(this) as T;\n\n Object.defineProperty(this, key, {\n ...descriptor,\n value: boundMethod,\n });\n\n return boundMethod;\n },\n set(value) {\n method = value;\n },\n };\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\nexport type Method = (...args: any[]) => any;\n","import { uniqueId } from 'lodash';\n\nimport { InvalidArgumentError } from '../error/errors';\n\nconst getUniqId = (idPrefix?: string): string => {\n const id = uniqueId(idPrefix);\n\n return document.getElementById(id) ? getUniqId(idPrefix) : id;\n};\n\nexport default function setUniqueElementId(selector: string, idPrefix: string): string[] {\n const containers = document.querySelectorAll(selector);\n\n if (!containers.length) {\n throw new InvalidArgumentError(\n `Unable to find any element with the specified selector: ${selector}`,\n );\n }\n\n return Array.prototype.slice.call(containers).map((container: HTMLElement) => {\n if (!container.id) {\n container.id = getUniqId(idPrefix);\n }\n\n return container.id;\n });\n}\n","import { bindDecorator as bind } from '@bigcommerce/checkout-sdk/utility';\n\nimport { isElementId, setUniqueElementId } from '../common/dom';\n\nimport { BaseWalletButtonInitializeOptions, WalletButtonOptions } from './wallet-button-options';\nimport WalletButtonRegistryV2 from './wallet-button-strategy-registry-v2';\n\n@bind\nexport default class WalletButtonInitializer {\n constructor(private _registryV2: WalletButtonRegistryV2) {}\n\n initializeWalletButton(options: BaseWalletButtonInitializeOptions): Promise<void[]> {\n const containerIds = this.getContainerIds(options);\n\n return Promise.all(\n containerIds.map(async (containerId) => {\n const strategy = this._registryV2.get({ id: options.methodId });\n\n return strategy.initialize({ ...options, containerId });\n }),\n );\n }\n\n deinitializeWalletButton(options: WalletButtonOptions): Promise<void> {\n return this._registryV2.get({ id: options.methodId }).deinitialize();\n }\n\n private getContainerIds(options: BaseWalletButtonInitializeOptions) {\n return isElementId(options.containerId)\n ? [options.containerId]\n : setUniqueElementId(options.containerId, `${options.methodId}-container`);\n }\n}\n","/* eslint-disable no-useless-escape */\nexport default function isElementId(id: string): boolean {\n return /^\\w[\\w\\-\\:\\.]*$/.test(id);\n}\n","import { createWalletButtonIntegrationService } from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport * as walletButtonStrategyFactories from '../generated/wallet-button-strategies';\n\nimport createWalletButtonStrategyRegistry from './create-wallet-button-strategy-registry';\nimport WalletButtonInitializer from './wallet-button-initializer';\nimport { WalletButtonInitializerOptions } from './wallet-buttons';\n\nexport default function createWalletButtonInitializer(\n options: WalletButtonInitializerOptions,\n): WalletButtonInitializer {\n const { graphQLEndpoint } = options;\n\n const walletButtonIntegrationService = createWalletButtonIntegrationService(graphQLEndpoint);\n\n const registryV2 = createWalletButtonStrategyRegistry(\n walletButtonIntegrationService,\n walletButtonStrategyFactories,\n );\n\n return new WalletButtonInitializer(registryV2);\n}\n","import {\n CheckoutButtonStrategy,\n CheckoutButtonStrategyResolveId,\n isResolvableModule,\n} from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport {\n WalletButtonIntegrationService,\n WalletPaymentButtonStrategyFactory,\n} from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport { ResolveIdRegistry } from '../common/registry';\n\nexport interface WalletButtonStrategyFactories {\n [key: string]: WalletPaymentButtonStrategyFactory<CheckoutButtonStrategy>;\n}\n\nexport default function createWalletButtonStrategyRegistry(\n walletButtonIntegrationService: WalletButtonIntegrationService,\n walletButtonStrategyFactories: WalletButtonStrategyFactories,\n): ResolveIdRegistry<CheckoutButtonStrategy, CheckoutButtonStrategyResolveId> {\n const registry = new ResolveIdRegistry<\n CheckoutButtonStrategy,\n CheckoutButtonStrategyResolveId\n >();\n\n for (const [, createWalletButtonStrategy] of Object.entries(walletButtonStrategyFactories)) {\n if (\n !isResolvableModule<\n WalletPaymentButtonStrategyFactory<CheckoutButtonStrategy>,\n CheckoutButtonStrategyResolveId\n >(createWalletButtonStrategy)\n ) {\n continue;\n }\n\n for (const resolverId of createWalletButtonStrategy.resolveIds) {\n registry.register(resolverId, () =>\n createWalletButtonStrategy(walletButtonIntegrationService),\n );\n }\n }\n\n return registry;\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\n\nimport { PaymentRequestSender } from './payment/payment-request-sender';\nimport WalletButtonIntegrationService from './wallet-button-integration-service';\n\nconst createWalletButtonIntegrationService = (\n graphQLEndpoint: string,\n): WalletButtonIntegrationService => {\n const requestSender = createRequestSender();\n\n return new WalletButtonIntegrationService(\n graphQLEndpoint,\n new PaymentRequestSender(requestSender),\n );\n};\n\nexport default createWalletButtonIntegrationService;\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","StandardError","Error","constructor","message","super","this","name","type","setPrototypeOf","__proto__","captureStackTrace","stack","PaymentMethodCancelledError","PaymentOrderCreationError","PaymentRequestSender","requestSender","createPaymentOrderIntent","graphQLEndpoint","inputData","options","requestOptions","headers","assign","body","query","variables","input","response","post","window","location","origin","data","payment","paymentWallet","createPaymentWalletIntent","paymentWalletIntentData","errors","errorMessage","_a","error","WalletButtonIntegrationService","paymentRequestSender","PayPalCommerceWalletStrategy","walletButtonIntegrationService","getWalletButtonIntegrationService","initialize","_options","Promise","resolve","deinitialize","create_paypal_commerce_wallet_strategy","module","resolveIds","id","isResolvableModule","getEnvironment","e","ConsoleLogger","_console","log","messages","_logToConsole","info","warn","debug","NoopLogger","logger","isEnabled","console","createLogger","standard_error_StandardError","InvalidArgumentError","Registry","_factories","_instances","_defaultToken","defaultToken","_useFallback","_b","useFallback","_tokenResolver","_c","tokenResolver","token","cacheToken","_getInstance","getFactory","exactMatch","resolvedToken","keys","undefined","register","factory","_hasFactory","_hasInstance","ResolveIdRegistry","_registry","_resolveToken","bind","_encodeToken","default","resolveId","getUseFallback","btoa","JSON","stringify","_decodeToken","parse","atob","registeredTokens","results","forEach","registeredToken","resolverId","result","matches","totalKeys","length","entries","push","matchedResults","sort","a","b","filter","queryKeyCount","exactResult","find","matched","bindMethodDecorator","_","descriptor","method","boundMethod","set","getUniqId","idPrefix","__WEBPACK_EXTERNAL_MODULE_lodash_uniqueId__","document","getElementById","WalletButtonInitializer","_registryV2","initializeWalletButton","containerIds","getContainerIds","all","map","containerId","wallet_button_initializer_awaiter","methodId","deinitializeWalletButton","test","selector","containers","querySelectorAll","Array","slice","container","setUniqueElementId","__decorate","target","decoratedTarget","getOwnPropertyNames","getOwnPropertyDescriptor","bindClassDecorator","createWalletButtonInitializer","registryV2","walletButtonStrategyFactories","registry","createWalletButtonStrategy","createWalletButtonStrategyRegistry","__WEBPACK_EXTERNAL_MODULE__bigcommerce_request_sender_01d1f546_createRequestSender__","create_wallet_button_integration_service","wallet_button_strategies_namespaceObject","wallet_button_initializer"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wallet-button.js","mappings":"oGACA,IAAAA,EAAA,CCAAA,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L,EAAgBtL,UAChBR,EACA8J,EAAoB+B,EAAOrL,UAAWR,EAAKgK,MAI5C8B,CACX,CA9BeG,CAAmBJ,EAIlC,GETqBpB,aEAN,SAASyB,EACpB5K,GAEA,MAAMH,gBAAEA,GAAoBG,EAItB6K,ECCK,SACX1H,EACA2H,GAEA,MAAMC,EAAW,IAAIzE,EAKrB,IAAK,MAAO,CAAE0E,KAA+BpM,OAAOiJ,QAAQiD,GACxD,GACKjH,EAGCmH,GAKN,IAAK,MAAMxD,KAAcwD,EAA2BpH,WAChDmH,EAAS7E,SAASsB,EAAY,IAC1BwD,EAA2B7H,IAKvC,OAAO4H,CACX,CD5BuBE,CETsB,CACzCpL,IAEA,MAAMH,EAAgBwL,IAEtB,OAAO,IAAInI,EACPlD,EACA,IAAIL,EAA4BE,GAChC,IAAI0C,EAAqB1C,KFDUyL,CAAqCtL,GAIxEuL,GAGJ,OAAO,IAAIC,EAAwBR,EACvC","sources":["webpack://@bigcommerce/checkout-sdk/webpack/bootstrap","webpack://@bigcommerce/checkout-sdk/webpack/runtime/define property getters","webpack://@bigcommerce/checkout-sdk/webpack/runtime/hasOwnProperty shorthand","webpack://@bigcommerce/checkout-sdk/webpack/runtime/make namespace object","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/billing/billing-address-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/standard-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/set-prototype-of.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/errors/payment-method-cancelled-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/payment/payment-order-intent-creation-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/payment/payment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/wallet-button-integration-service.ts","webpack://@bigcommerce/checkout-sdk/./packages/paypal-commerce-integration/src/paypal-commerce/paypal-commerce-wallet-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/paypal-commerce-integration/src/paypal-commerce/create-paypal-commerce-wallet-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/to-resolvable-module.ts","webpack://@bigcommerce/checkout-sdk/./packages/payment-integration-api/src/is-resolvable-module.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/get-environment.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/console-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/noop-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/get-default-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/log/create-logger.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/standard-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/set-prototype-of.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/invalid-argument-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/resolve-id-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/utility/src/bind-decorator/bind-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/set-unique-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/wallet-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/is-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/create-wallet-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/wallet-buttons/create-wallet-button-strategy-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/wallet-button-integration/src/create-wallet-button-integration-service.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { GraphQLRequestOptions } from '../graphql-request-options';\n\nimport {\n AddBillingAddressResponseBody,\n AddressRequestBody,\n BillingAddressResponse,\n BillingAddressUpdateRequestBody,\n UpdateBillingAddressResponseBody,\n} from './billing-address';\n\nexport default class BillingAddressRequestSender {\n constructor(private readonly requestSender: RequestSender) {}\n\n async updateBillingAddress(\n graphQLEndpoint: string,\n checkoutId: string,\n address: BillingAddressUpdateRequestBody,\n options?: GraphQLRequestOptions,\n ): Promise<Response<BillingAddressResponse>> {\n const document = `\n mutation UpdateCheckoutBillingAddressMutation(\n $input: UpdateCheckoutBillingAddressInput!\n ) {\n checkout {\n updateCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n `;\n\n const { id, ...billingAddressFields } = address;\n\n const requestOptions: GraphQLRequestOptions = {\n headers: {\n ...options?.headers,\n 'Content-Type': 'application/json',\n 'x-catalyst-graphql-proxy-requester': 'checkout-sdk-js',\n },\n body: {\n query: document,\n variables: {\n input: {\n checkoutEntityId: checkoutId,\n addressEntityId: address.id,\n data: {\n address: {\n ...billingAddressFields,\n },\n },\n },\n },\n },\n };\n\n const response = await this.requestSender.post<UpdateBillingAddressResponseBody>(\n `${window.location.origin}/${graphQLEndpoint}`,\n requestOptions,\n );\n\n const { billingAddress } =\n response.body.data.checkout.updateCheckoutBillingAddress.checkout;\n\n return {\n ...response,\n body: billingAddress,\n };\n }\n\n async addBillingAddress(\n graphQLEndpoint: string,\n checkoutId: string,\n address: AddressRequestBody,\n options?: GraphQLRequestOptions,\n ): Promise<Response<BillingAddressResponse>> {\n const document = `\n mutation AddCheckoutBillingAddressMutation(\n $input: AddCheckoutBillingAddressInput!\n ) {\n checkout {\n addCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n `;\n\n const requestOptions: GraphQLRequestOptions = {\n headers: {\n ...options?.headers,\n 'Content-Type': 'application/json',\n 'x-catalyst-graphql-proxy-requester': 'checkout-sdk-js',\n },\n body: {\n query: document,\n variables: {\n input: {\n checkoutEntityId: checkoutId,\n data: {\n address: {\n ...address,\n },\n },\n },\n },\n },\n };\n\n const response = await this.requestSender.post<AddBillingAddressResponseBody>(\n `${window.location.origin}/${graphQLEndpoint}`,\n requestOptions,\n );\n\n const { billingAddress } = response.body.data.checkout.addCheckoutBillingAddress.checkout;\n\n return {\n ...response,\n body: billingAddress,\n };\n }\n}\n","import CustomError from './custom-error';\nimport setPrototypeOf from './set-prototype-of';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = new Error(this.message).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when the payment flow is cancelled. It could be\n * due to a deliberate user interaction, i.e.: the user clicks on a cancel\n * button which dismisses the payment modal.\n */\nexport default class PaymentMethodCancelledError extends StandardError {\n constructor(message?: string) {\n super(message || 'Payment process was cancelled.');\n\n this.name = 'PaymentMethodCancelledError';\n this.type = 'payment_cancelled';\n }\n}\n","import { StandardError } from '@bigcommerce/checkout-sdk/payment-integration-api';\n\nexport default class PaymentOrderCreationError extends StandardError {\n constructor(message?: string) {\n super(\n message ||\n 'An unexpected error has occurred during payment order creation process. Please try again later.',\n );\n\n this.name = 'PaymentOrderCreationError';\n this.type = 'payment_order_creation_error';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { PaymentMethodCancelledError } from '@bigcommerce/checkout-sdk/payment-integration-api';\n\nimport { GraphQLRequestOptions } from '../graphql-request-options';\n\nimport {\n CreatePaymentOrderIntentInputData,\n CreatePaymentOrderIntentResponse,\n CreatePaymentOrderIntentResponseBody,\n} from './payment';\nimport PaymentOrderCreationError from './payment-order-intent-creation-error';\n\nexport class PaymentRequestSender {\n constructor(private readonly requestSender: RequestSender) {}\n\n async createPaymentOrderIntent(\n graphQLEndpoint: string,\n inputData: CreatePaymentOrderIntentInputData,\n options?: GraphQLRequestOptions,\n ): Promise<Response<CreatePaymentOrderIntentResponseBody>> {\n const document = `\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n `;\n\n const requestOptions: GraphQLRequestOptions = {\n headers: {\n ...options?.headers,\n 'Content-Type': 'application/json',\n 'x-catalyst-graphql-proxy-requester': 'checkout-sdk-js',\n },\n body: {\n query: document,\n variables: {\n input: inputData,\n },\n },\n };\n\n try {\n const response = await this.requestSender.post<CreatePaymentOrderIntentResponse>(\n `${window.location.origin}/${graphQLEndpoint}`,\n requestOptions,\n );\n\n const {\n data: {\n payment: {\n paymentWallet: {\n createPaymentWalletIntent: { paymentWalletIntentData, errors },\n },\n },\n },\n } = response.body;\n\n const errorMessage = errors[0]?.message;\n\n if (errorMessage) {\n throw new PaymentOrderCreationError(errorMessage);\n }\n\n return {\n ...response,\n body: {\n ...paymentWalletIntentData,\n },\n };\n } catch (error) {\n if (!(error instanceof PaymentOrderCreationError)) {\n throw new PaymentMethodCancelledError();\n }\n\n throw error;\n }\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport {\n AddressRequestBody,\n BillingAddressResponse,\n BillingAddressUpdateRequestBody,\n} from './billing/billing-address';\nimport BillingAddressRequestSender from './billing/billing-address-request-sender';\nimport { GraphQLRequestOptions } from './graphql-request-options';\nimport {\n CreatePaymentOrderIntentInputData,\n CreatePaymentOrderIntentResponseBody,\n} from './payment/payment';\nimport { PaymentRequestSender } from './payment/payment-request-sender';\n\nexport default class WalletButtonIntegrationService {\n constructor(\n private graphQLEndpoint: string,\n private billingAddressRequestSender: BillingAddressRequestSender,\n private paymentRequestSender: PaymentRequestSender,\n ) {}\n\n async addBillingAddress(\n checkoutId: string,\n address: AddressRequestBody,\n options?: GraphQLRequestOptions,\n ): Promise<Response<BillingAddressResponse>> {\n return this.billingAddressRequestSender.addBillingAddress(\n this.graphQLEndpoint,\n checkoutId,\n address,\n options,\n );\n }\n\n async updateBillingAddress(\n checkoutId: string,\n address: BillingAddressUpdateRequestBody,\n options?: GraphQLRequestOptions,\n ): Promise<Response<BillingAddressResponse>> {\n return this.billingAddressRequestSender.updateBillingAddress(\n this.graphQLEndpoint,\n checkoutId,\n address,\n options,\n );\n }\n\n async createPaymentOrderIntent(\n inputData: CreatePaymentOrderIntentInputData,\n options?: GraphQLRequestOptions,\n ): Promise<Response<CreatePaymentOrderIntentResponseBody>> {\n return this.paymentRequestSender.createPaymentOrderIntent(\n this.graphQLEndpoint,\n inputData,\n options,\n );\n }\n}\n","import {\n CheckoutButtonInitializeOptions,\n CheckoutButtonStrategy,\n} from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport { WalletButtonIntegrationService } from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport { WithPayPalCommerceWalletInitializeOptions } from './paypal-commerce-wallet-initialize-options';\n\n/**\n * PayPal Commerce Wallet Button Strategy stub for headless wallet button integration.\n *\n * This is an empty stub class at this stage. Concrete implementation will be\n * added in follow-up tickets.\n */\nexport default class PayPalCommerceWalletStrategy implements CheckoutButtonStrategy {\n constructor(private walletButtonIntegrationService: WalletButtonIntegrationService) {}\n\n getWalletButtonIntegrationService(): WalletButtonIntegrationService {\n return this.walletButtonIntegrationService;\n }\n\n async initialize(\n _options: CheckoutButtonInitializeOptions & WithPayPalCommerceWalletInitializeOptions,\n ): Promise<void> {\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n return Promise.resolve();\n }\n}\n","import { toResolvableModule } from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport {\n WalletButtonIntegrationService,\n WalletPaymentButtonStrategyFactory,\n} from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport PayPalCommerceWalletStrategy from './paypal-commerce-wallet-strategy';\n\nconst createPayPalCommerceWalletStrategy: WalletPaymentButtonStrategyFactory<\n PayPalCommerceWalletStrategy\n> = (walletButtonIntegrationService: WalletButtonIntegrationService) => {\n return new PayPalCommerceWalletStrategy(walletButtonIntegrationService);\n};\n\nexport default toResolvableModule(createPayPalCommerceWalletStrategy, [\n { id: 'paypalcommercepaypal' },\n]);\n","import ResolvableModule from './resolvable-module';\n\nexport default function toResolvableModule<TModule extends object, TIdentifier>(\n module: TModule,\n resolveIds: TIdentifier[],\n): ResolvableModule<TModule, TIdentifier> {\n return Object.assign(module, { resolveIds });\n}\n","import ResolvableModule from './resolvable-module';\n\nexport default function isResolvableModule<TModule extends object, TIdentifier>(\n module: TModule,\n): module is ResolvableModule<TModule, TIdentifier> {\n return module && 'resolveIds' in module;\n}\n","export default function getEnvironment(): string {\n try {\n return process.env.NODE_ENV || 'development';\n } catch (e) {\n return 'development';\n }\n}\n","import Logger from './logger';\n\ntype keys = 'log' | 'info' | 'warn' | 'error' | 'debug';\n\nexport default class ConsoleLogger implements Logger {\n constructor(private _console?: Console) {}\n\n log(...messages: any[]): void {\n this._logToConsole('log', ...messages);\n }\n\n info(...messages: any[]): void {\n this._logToConsole('info', ...messages);\n }\n\n warn(...messages: any[]): void {\n this._logToConsole('warn', ...messages);\n }\n\n error(...messages: any[]): void {\n this._logToConsole('error', ...messages);\n }\n\n debug(...messages: any[]): void {\n this._logToConsole('debug', ...messages);\n }\n\n private _logToConsole(type: keys, ...messages: any[]): void {\n if (!this._console || !this._console[type]) {\n return;\n }\n\n this._console[type].call(this._console, ...messages);\n }\n}\n","import Logger from './logger';\n\nexport default class NoopLogger implements Logger {\n log(): void {}\n\n info(): void {}\n\n warn(): void {}\n\n error(): void {}\n\n debug(): void {}\n}\n","import { getEnvironment } from '../utility';\n\nimport createLogger from './create-logger';\nimport Logger from './logger';\n\nconst logger = createLogger(getEnvironment() !== 'test');\n\nexport default function getDefaultLogger(): Logger {\n return logger;\n}\n","import ConsoleLogger from './console-logger';\nimport Logger from './logger';\nimport NoopLogger from './noop-logger';\n\nexport default function createLogger(isEnabled = true): Logger {\n if (!isEnabled) {\n return new NoopLogger();\n }\n\n return new ConsoleLogger(console);\n}\n","import { setPrototypeOf } from '../../utility';\n\nimport CustomError from './custom-error';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = new Error(this.message).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import { InvalidArgumentError } from '../error/errors';\n\nimport Factory from './factory';\n\nexport default class Registry<T, K extends string = string> {\n private _factories: { [key: string]: Factory<T> };\n private _instances: { [key: string]: T };\n private _defaultToken: string;\n private _useFallback: string | boolean;\n private _tokenResolver: (\n token: string,\n registeredTokens: string[],\n exactMatch?: boolean,\n ) => string | undefined;\n\n constructor(options?: RegistryOptions) {\n this._factories = {};\n this._instances = {};\n this._defaultToken = options?.defaultToken ?? 'default';\n this._useFallback = options?.useFallback ?? true;\n this._tokenResolver = options?.tokenResolver ?? ((token) => token);\n }\n\n get(token?: K, cacheToken?: string): T {\n try {\n return this._getInstance(\n token || this._defaultToken,\n cacheToken || token || this._defaultToken,\n );\n } catch (error) {\n if (!this._useFallback) {\n throw error;\n }\n\n return this._getInstance(this._defaultToken, cacheToken || this._defaultToken);\n }\n }\n\n getFactory(token: string, exactMatch?: boolean): Factory<T> | undefined {\n const resolvedToken = this._tokenResolver(token, Object.keys(this._factories), exactMatch);\n const factory = resolvedToken ? this._factories[resolvedToken] : undefined;\n\n return factory;\n }\n\n register(token: K, factory: Factory<T>): void {\n if (this._hasFactory(token)) {\n throw new InvalidArgumentError(`'${token}' is already registered.`);\n }\n\n this._factories[token] = factory;\n }\n\n protected _hasFactory(token: string): boolean {\n return !!this._factories[token];\n }\n\n private _hasInstance(token: string): boolean {\n return !!this._instances[token];\n }\n\n private _getInstance(token: string, cacheToken: string): T {\n if (!this._hasInstance(cacheToken)) {\n const factory = this.getFactory(token);\n\n if (!factory) {\n throw new InvalidArgumentError(`'${token}' is not registered.`);\n }\n\n this._instances[cacheToken] = factory();\n }\n\n return this._instances[cacheToken];\n }\n}\n\nexport interface RegistryOptions {\n defaultToken?: string;\n useFallback?: boolean;\n tokenResolver?(token: string, registeredTokens: string[]): string | undefined;\n}\n","import { getDefaultLogger } from '../log';\nimport { getEnvironment } from '../utility';\n\nimport Factory from './factory';\nimport Registry from './registry';\n\nexport default class ResolveIdRegistry<TType, TToken extends { [key: string]: unknown }> {\n private _registry: Registry<TType>;\n\n constructor(private _useFallback = false) {\n this._registry = new Registry({\n tokenResolver: this._resolveToken.bind(this),\n defaultToken: this._encodeToken({ default: true } as unknown as TToken),\n useFallback: this._useFallback,\n });\n }\n\n get(resolveId: TToken): TType {\n return this._registry.get(this._encodeToken(resolveId));\n }\n\n getFactory(resolveId: TToken, exactMatch?: boolean): Factory<TType> | undefined {\n try {\n return this._registry.getFactory(this._encodeToken(resolveId), exactMatch);\n } catch (error) {\n return undefined;\n }\n }\n\n getUseFallback(): boolean {\n return this._useFallback;\n }\n\n register(resolveId: TToken, factory: Factory<TType>): void {\n this._registry.register(this._encodeToken(resolveId), factory);\n }\n\n private _encodeToken(resolveId: TToken): string {\n return btoa(JSON.stringify(resolveId));\n }\n\n private _decodeToken(token: string): TToken {\n return JSON.parse(atob(token));\n }\n\n private _resolveToken(\n token: string,\n registeredTokens: string[],\n exactMatch?: boolean,\n ): string | undefined {\n const query = this._decodeToken(token);\n\n const results: Array<{\n token: string;\n matches: number;\n default: boolean;\n totalKeys: number;\n }> = [];\n\n registeredTokens.forEach((registeredToken) => {\n const resolverId = this._decodeToken(registeredToken);\n\n const result = {\n token: registeredToken,\n matches: 0,\n default: false,\n totalKeys: Object.keys(resolverId).length,\n };\n\n for (const [key, value] of Object.entries(resolverId)) {\n if (key in query && query[key] !== value) {\n result.matches = 0;\n break;\n }\n\n if (key in query && query[key] === value) {\n result.matches++;\n }\n\n if (key === 'default' && value === true) {\n result.default = true;\n }\n }\n\n results.push(result);\n });\n\n const matchedResults = results\n .sort((a, b) => b.matches - a.matches)\n .filter((result) => result.matches > 0);\n\n if (matchedResults.length > 1 && matchedResults[0].matches === matchedResults[1].matches) {\n if (getEnvironment() === 'development') {\n getDefaultLogger().warn(\n 'The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.',\n );\n }\n }\n\n const queryKeyCount = Object.keys(query).length;\n\n if (exactMatch) {\n const exactResult = matchedResults.find(\n (result) => result.matches === queryKeyCount && result.matches === result.totalKeys,\n );\n\n if (!exactResult) {\n throw new Error(\n `Unable to resolve to a registered token with the provided token for ${JSON.stringify(\n query,\n )} with exact match.`,\n );\n }\n\n return exactResult.token;\n }\n\n const matched = matchedResults[0];\n\n if (matched && matched.token) {\n return matched.token;\n }\n\n if (this._useFallback) {\n const defaultToken = results.find((result) => result.default)?.token;\n\n if (defaultToken) {\n return defaultToken;\n }\n }\n\n throw new Error(\n `Unable to resolve to a registered token with the provided token for ${JSON.stringify(\n query,\n )}.`,\n );\n }\n}\n","/**\n * Decorates a class or a method by binding all its prototype methods or itself\n * to the calling instance respectively.\n */\nfunction bindDecorator<T extends Method>(\n target: object,\n key: string,\n descriptor: TypedPropertyDescriptor<T>,\n): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\n\nfunction bindDecorator(target: any, key?: any, descriptor?: any): any {\n if (!key || !descriptor) {\n return bindClassDecorator(target);\n }\n\n return bindMethodDecorator(target, key, descriptor);\n}\n\nexport default bindDecorator;\n\n/**\n * Decorates a class by binding all its prototype methods to the calling\n * instance.\n */\nexport function bindClassDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype).forEach((key) => {\n const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);\n\n if (!descriptor || key === 'constructor') {\n return;\n }\n\n Object.defineProperty(\n decoratedTarget.prototype,\n key,\n bindMethodDecorator(target.prototype, key, descriptor),\n );\n });\n\n return decoratedTarget;\n}\n\n/**\n * Decorates a method by binding it to the calling instance.\n */\nexport function bindMethodDecorator<T extends Method>(\n _: object,\n key: string,\n descriptor: TypedPropertyDescriptor<T>,\n): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let method: T = descriptor.value;\n\n return {\n get() {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const boundMethod = method.bind(this) as T;\n\n Object.defineProperty(this, key, {\n ...descriptor,\n value: boundMethod,\n });\n\n return boundMethod;\n },\n set(value) {\n method = value;\n },\n };\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\nexport type Method = (...args: any[]) => any;\n","import { uniqueId } from 'lodash';\n\nimport { InvalidArgumentError } from '../error/errors';\n\nconst getUniqId = (idPrefix?: string): string => {\n const id = uniqueId(idPrefix);\n\n return document.getElementById(id) ? getUniqId(idPrefix) : id;\n};\n\nexport default function setUniqueElementId(selector: string, idPrefix: string): string[] {\n const containers = document.querySelectorAll(selector);\n\n if (!containers.length) {\n throw new InvalidArgumentError(\n `Unable to find any element with the specified selector: ${selector}`,\n );\n }\n\n return Array.prototype.slice.call(containers).map((container: HTMLElement) => {\n if (!container.id) {\n container.id = getUniqId(idPrefix);\n }\n\n return container.id;\n });\n}\n","import { bindDecorator as bind } from '@bigcommerce/checkout-sdk/utility';\n\nimport { isElementId, setUniqueElementId } from '../common/dom';\n\nimport { BaseWalletButtonInitializeOptions, WalletButtonOptions } from './wallet-button-options';\nimport WalletButtonRegistryV2 from './wallet-button-strategy-registry-v2';\n\n@bind\nexport default class WalletButtonInitializer {\n constructor(private _registryV2: WalletButtonRegistryV2) {}\n\n initializeWalletButton(options: BaseWalletButtonInitializeOptions): Promise<void[]> {\n const containerIds = this.getContainerIds(options);\n\n return Promise.all(\n containerIds.map(async (containerId) => {\n const strategy = this._registryV2.get({ id: options.methodId });\n\n return strategy.initialize({ ...options, containerId });\n }),\n );\n }\n\n deinitializeWalletButton(options: WalletButtonOptions): Promise<void> {\n return this._registryV2.get({ id: options.methodId }).deinitialize();\n }\n\n private getContainerIds(options: BaseWalletButtonInitializeOptions) {\n return isElementId(options.containerId)\n ? [options.containerId]\n : setUniqueElementId(options.containerId, `${options.methodId}-container`);\n }\n}\n","/* eslint-disable no-useless-escape */\nexport default function isElementId(id: string): boolean {\n return /^\\w[\\w\\-\\:\\.]*$/.test(id);\n}\n","import { createWalletButtonIntegrationService } from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport * as walletButtonStrategyFactories from '../generated/wallet-button-strategies';\n\nimport createWalletButtonStrategyRegistry from './create-wallet-button-strategy-registry';\nimport WalletButtonInitializer from './wallet-button-initializer';\nimport { WalletButtonInitializerOptions } from './wallet-buttons';\n\nexport default function createWalletButtonInitializer(\n options: WalletButtonInitializerOptions,\n): WalletButtonInitializer {\n const { graphQLEndpoint } = options;\n\n const walletButtonIntegrationService = createWalletButtonIntegrationService(graphQLEndpoint);\n\n const registryV2 = createWalletButtonStrategyRegistry(\n walletButtonIntegrationService,\n walletButtonStrategyFactories,\n );\n\n return new WalletButtonInitializer(registryV2);\n}\n","import {\n CheckoutButtonStrategy,\n CheckoutButtonStrategyResolveId,\n isResolvableModule,\n} from '@bigcommerce/checkout-sdk/payment-integration-api';\nimport {\n WalletButtonIntegrationService,\n WalletPaymentButtonStrategyFactory,\n} from '@bigcommerce/checkout-sdk/wallet-button-integration';\n\nimport { ResolveIdRegistry } from '../common/registry';\n\nexport interface WalletButtonStrategyFactories {\n [key: string]: WalletPaymentButtonStrategyFactory<CheckoutButtonStrategy>;\n}\n\nexport default function createWalletButtonStrategyRegistry(\n walletButtonIntegrationService: WalletButtonIntegrationService,\n walletButtonStrategyFactories: WalletButtonStrategyFactories,\n): ResolveIdRegistry<CheckoutButtonStrategy, CheckoutButtonStrategyResolveId> {\n const registry = new ResolveIdRegistry<\n CheckoutButtonStrategy,\n CheckoutButtonStrategyResolveId\n >();\n\n for (const [, createWalletButtonStrategy] of Object.entries(walletButtonStrategyFactories)) {\n if (\n !isResolvableModule<\n WalletPaymentButtonStrategyFactory<CheckoutButtonStrategy>,\n CheckoutButtonStrategyResolveId\n >(createWalletButtonStrategy)\n ) {\n continue;\n }\n\n for (const resolverId of createWalletButtonStrategy.resolveIds) {\n registry.register(resolverId, () =>\n createWalletButtonStrategy(walletButtonIntegrationService),\n );\n }\n }\n\n return registry;\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\n\nimport BillingAddressRequestSender from './billing/billing-address-request-sender';\nimport { PaymentRequestSender } from './payment/payment-request-sender';\nimport WalletButtonIntegrationService from './wallet-button-integration-service';\n\nconst createWalletButtonIntegrationService = (\n graphQLEndpoint: string,\n): WalletButtonIntegrationService => {\n const requestSender = createRequestSender();\n\n return new WalletButtonIntegrationService(\n graphQLEndpoint,\n new BillingAddressRequestSender(requestSender),\n new PaymentRequestSender(requestSender),\n );\n};\n\nexport default createWalletButtonIntegrationService;\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","BillingAddressRequestSender","constructor","requestSender","this","updateBillingAddress","graphQLEndpoint","checkoutId","address","options","id","billingAddressFields","__rest","requestOptions","headers","assign","body","query","variables","input","checkoutEntityId","addressEntityId","data","response","post","window","location","origin","billingAddress","checkout","updateCheckoutBillingAddress","addBillingAddress","addCheckoutBillingAddress","StandardError","Error","message","super","name","type","setPrototypeOf","__proto__","captureStackTrace","stack","PaymentMethodCancelledError","PaymentOrderCreationError","PaymentRequestSender","createPaymentOrderIntent","inputData","payment","paymentWallet","createPaymentWalletIntent","paymentWalletIntentData","errors","errorMessage","_a","error","WalletButtonIntegrationService","billingAddressRequestSender","paymentRequestSender","PayPalCommerceWalletStrategy","walletButtonIntegrationService","getWalletButtonIntegrationService","initialize","_options","Promise","resolve","deinitialize","create_paypal_commerce_wallet_strategy","module","resolveIds","isResolvableModule","getEnvironment","e","ConsoleLogger","_console","log","messages","_logToConsole","info","warn","debug","NoopLogger","logger","isEnabled","console","createLogger","standard_error_StandardError","InvalidArgumentError","Registry","_factories","_instances","_defaultToken","defaultToken","_useFallback","_b","useFallback","_tokenResolver","_c","tokenResolver","token","cacheToken","_getInstance","getFactory","exactMatch","resolvedToken","keys","undefined","register","factory","_hasFactory","_hasInstance","ResolveIdRegistry","_registry","_resolveToken","bind","_encodeToken","default","resolveId","getUseFallback","btoa","JSON","stringify","_decodeToken","parse","atob","registeredTokens","results","forEach","registeredToken","resolverId","result","matches","totalKeys","length","entries","push","matchedResults","sort","a","b","filter","queryKeyCount","exactResult","find","matched","bindMethodDecorator","_","descriptor","method","boundMethod","set","getUniqId","idPrefix","__WEBPACK_EXTERNAL_MODULE_lodash_uniqueId__","document","getElementById","WalletButtonInitializer","_registryV2","initializeWalletButton","containerIds","getContainerIds","all","map","containerId","wallet_button_initializer_awaiter","methodId","deinitializeWalletButton","test","selector","containers","querySelectorAll","Array","slice","container","setUniqueElementId","__decorate","target","decoratedTarget","getOwnPropertyNames","getOwnPropertyDescriptor","bindClassDecorator","createWalletButtonInitializer","registryV2","walletButtonStrategyFactories","registry","createWalletButtonStrategy","createWalletButtonStrategyRegistry","__WEBPACK_EXTERNAL_MODULE__bigcommerce_request_sender_01d1f546_createRequestSender__","create_wallet_button_integration_service","wallet_button_strategies_namespaceObject","wallet_button_initializer"],"sourceRoot":""}
|