@bigcommerce/checkout-sdk 1.932.1 → 1.933.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.
Files changed (32) hide show
  1. package/dist/cjs/checkout-button.js +1 -1
  2. package/dist/cjs/checkout-sdk-essential.js +1 -1
  3. package/dist/cjs/checkout-sdk.js +1 -1
  4. package/dist/cjs/hosted-form-v2-iframe-content.js +1 -1
  5. package/dist/cjs/hosted-form-v2-iframe-content.js.map +1 -1
  6. package/dist/cjs/hosted-form-v2-iframe-host.js +1 -1
  7. package/dist/cjs/hosted-form-v2-iframe-host.js.map +1 -1
  8. package/dist/cjs/integrations/amazon-pay.js +1 -1
  9. package/dist/cjs/integrations/bigcommerce-payments.js +1 -1
  10. package/dist/cjs/integrations/braintree.js +1 -1
  11. package/dist/cjs/integrations/google-pay.js +1 -1
  12. package/dist/cjs/integrations/klarna.js +1 -1
  13. package/dist/cjs/integrations/paypal-commerce.js +1 -1
  14. package/dist/cjs/integrations/paypal-express.js +1 -1
  15. package/dist/cjs/integrations/zip.js +1 -1
  16. package/dist/esm/checkout-button.js +1 -1
  17. package/dist/esm/checkout-sdk-essential.js +1 -1
  18. package/dist/esm/checkout-sdk.js +1 -1
  19. package/dist/esm/hosted-form-v2-iframe-content.js +1 -1
  20. package/dist/esm/hosted-form-v2-iframe-content.js.map +1 -1
  21. package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
  22. package/dist/esm/integrations/amazon-pay.js +1 -1
  23. package/dist/esm/integrations/bigcommerce-payments.js +1 -1
  24. package/dist/esm/integrations/braintree.js +1 -1
  25. package/dist/esm/integrations/google-pay.js +1 -1
  26. package/dist/esm/integrations/klarna.js +1 -1
  27. package/dist/esm/integrations/paypal-commerce.js +1 -1
  28. package/dist/esm/integrations/paypal-express.js +1 -1
  29. package/dist/esm/integrations/zip.js +1 -1
  30. package/dist/hosted-form-v2-iframe-content.d.ts +1 -0
  31. package/dist/hosted-form-v2-iframe-host.d.ts +6 -5
  32. package/package.json +6 -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.932.1"};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.933.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.932.1"};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};
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.933.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
@@ -77,6 +77,7 @@ declare type HostedFormErrorsData = Partial<Record<HostedFormErrorDataKeys, Host
77
77
  declare interface HostedFormManualOrderData {
78
78
  paymentMethodId: string;
79
79
  paymentSessionToken: string;
80
+ token?: string;
80
81
  }
81
82
 
82
83
  declare class HostedInput {
@@ -24,7 +24,7 @@ declare interface HostedCardFieldOptions {
24
24
  placeholder?: string;
25
25
  }
26
26
 
27
- declare interface HostedCardFieldOptionsMap {
27
+ export declare interface HostedCardFieldOptionsMap {
28
28
  [HostedFieldType.CardCode]?: HostedCardFieldOptions;
29
29
  [HostedFieldType.CardExpiry]?: HostedCardFieldOptions;
30
30
  [HostedFieldType.CardName]?: HostedCardFieldOptions;
@@ -185,6 +185,7 @@ declare interface HostedFormInterface {
185
185
  declare interface HostedFormManualOrderData {
186
186
  paymentMethodId: string;
187
187
  paymentSessionToken: string;
188
+ token?: string;
188
189
  }
189
190
 
190
191
  declare interface HostedFormOptions {
@@ -216,7 +217,7 @@ declare class HostedFormOrderDataTransformer {
216
217
  transform(payload: OrderPaymentRequestBody, additionalAction?: PaymentAdditionalAction): HostedFormOrderData;
217
218
  }
218
219
 
219
- declare class HostedFormService {
220
+ export declare class HostedFormService {
220
221
  protected _host: string;
221
222
  protected _hostedFormFactory: HostedFormFactory;
222
223
  protected _hostedForm?: HostedForm;
@@ -342,7 +343,7 @@ declare interface HostedInputSubmitManualOrderErrorEvent {
342
343
  };
343
344
  }
344
345
 
345
- declare interface HostedInputSubmitManualOrderSuccessEvent {
346
+ export declare interface HostedInputSubmitManualOrderSuccessEvent {
346
347
  type: HostedInputEventType.SubmitManualOrderSucceeded;
347
348
  payload: {
348
349
  response: Response<unknown>;
@@ -362,7 +363,7 @@ declare interface HostedInputValidateErrorData {
362
363
  type: string;
363
364
  }
364
365
 
365
- declare interface HostedInputValidateErrorDataMap {
366
+ export declare interface HostedInputValidateErrorDataMap {
366
367
  [HostedFieldType.CardCode]?: HostedInputValidateErrorData[];
367
368
  [HostedFieldType.CardExpiry]?: HostedInputValidateErrorData[];
368
369
  [HostedFieldType.CardName]?: HostedInputValidateErrorData[];
@@ -376,7 +377,7 @@ declare interface HostedInputValidateEvent {
376
377
  payload: HostedInputValidateResults;
377
378
  }
378
379
 
379
- declare interface HostedInputValidateResults {
380
+ export declare interface HostedInputValidateResults {
380
381
  errors: HostedInputValidateErrorDataMap;
381
382
  isValid: boolean;
382
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/checkout-sdk",
3
- "version": "1.932.1",
3
+ "version": "1.933.0",
4
4
  "description": "BigCommerce Checkout JavaScript SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs/checkout-sdk.js",
@@ -21,6 +21,11 @@
21
21
  "types": "./dist/types/integrations/*.d.ts",
22
22
  "import": "./dist/esm/integrations/*.js",
23
23
  "require": "./dist/cjs/integrations/*.js"
24
+ },
25
+ "./hosted-form-v2-iframe-host": {
26
+ "types": "./dist/hosted-form-v2-iframe-host.d.ts",
27
+ "import": "./dist/esm/hosted-form-v2-iframe-host.js",
28
+ "require": "./dist/cjs/hosted-form-v2-iframe-host.js"
24
29
  }
25
30
  },
26
31
  "files": [