@bigcommerce/checkout-sdk 1.258.1 → 1.261.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/CHANGELOG.md +26 -0
- package/dist/checkout-button.d.ts +8 -17
- package/dist/checkout-button.js +1 -1
- package/dist/checkout-button.js.map +1 -1
- package/dist/checkout-button.umd.js +1 -1
- package/dist/checkout-button.umd.js.map +1 -1
- package/dist/checkout-sdk.d.ts +8 -17
- package/dist/checkout-sdk.js +1 -1
- package/dist/checkout-sdk.js.map +1 -1
- package/dist/checkout-sdk.umd.js +1 -1
- package/dist/checkout-sdk.umd.js.map +1 -1
- package/dist/hosted-form.js +1 -1
- package/dist/hosted-form.js.map +1 -1
- package/dist/hosted-form.umd.js +1 -1
- package/dist/hosted-form.umd.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/interfaces/{braintreepaypalv1buttoninitializeoptions.md → braintreepaypalbuttoninitializeoptions.md} +9 -18
- package/docs/interfaces/checkoutbuttoninitializeoptions.md +2 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-button.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,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xiB,GACIplB,EACA,IAAI,QAKhB2nC,EAAS1yD,SAAS,qBAA2C,WACzD,WAAI,GACA+qB,EACAynC,EACAG,EACAxiB,GACIplB,EACA,IAAI,QAKhB2nC,EAAS1yD,SAAS,wBAA8C,WAC5D,WAAI,GACA+qB,EACAynC,EACAG,EACAxiB,GACIplB,EACA,IAAI,QAKhB2nC,EAAS1yD,SAAS,kBAAwC,WACtD,WAAI,GACA+qB,EACA4nC,EACA,IAAI,GAAmBpiB,GACvBiiB,EACAP,MAIRS,EAAS1yD,SAAS,mBAAyC,WACvD,WAAI,GACA+qB,EACA4nC,EACAH,EACAe,MAIRb,EAAS1yD,SAAS,kBAAwC,WACtD,WAAI,GACA+qB,EACA4nC,EErRD,IAAI,GACP,IAAI,IAAwB,KAAAniB,yBFyRzBkiB,EFlPCkB,CAA6B7oC,EAAOonC,EAAe9hB,EAAemiB,EAAYN,EAAQD,GACtF,IAAI,GAA2B,IAAI,GAA2B5hB,M","sources":["webpack://@bigcommerce/checkout-sdk/webpack/bootstrap","webpack://@bigcommerce/checkout-sdk/webpack/runtime/compat get default export","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/external commonjs \"@bigcommerce/request-sender\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/form-poster\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"tslib\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/data-store\"","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/request-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-invalid-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/unrecoverable-error.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"lodash\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-internal-error-response.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-payment-error-response.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/timeout-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/request-error-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-storefront-error-response.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"rxjs\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"rxjs/operators\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/error-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/omit-deep.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/clear-error-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-equal.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/replace.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-set.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-plain-object.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/array-replace.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-merge.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/merge-or-push.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-flatten.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-with-sorted-keys.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/spam-protection-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-reducer.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/memoize\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/missing-data-error.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"reselect\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/create-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/with-memoized-combiner.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/guard.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/create-freeze-proxy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/supported-payment-instruments.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/address/is-address-equal.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-internal-checkout-selectors.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-address-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-types.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-status-types.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-checkout-store.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/create-request-error-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-action-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-checkout-store-reducer.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/bigpay-client\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/cache-action.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/is-action-options.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/cachable-action-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/apple-pay/is-apple-pay-window.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/content-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/internal-api-headers.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/sdk-version-headers.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/invalid-argument-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/bind-decorator.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"shallowequal\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/cache-key-maps.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/cache-key-resolver.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-private.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/selector-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-error-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-status-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-selectors.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/is-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/set-unique-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/throw-error-action.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/checkout-button-method-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-strategy-action-creator.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/script-loader\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/errors/unable-to-continue-as-guest-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/join-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/join-or-merge-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/merge-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-default-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/errors/checkout-not-available-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-comparator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/errors/cart-changed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-validator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/errors/order-tax-provider-unavailable-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/address/map-to-internal-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/is-billing-address-like.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/amount-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/map-to-internal-coupon.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/map-to-internal-gift-certificate.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-line-items.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-gift-certificate-to-internal-line-item.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-line-item.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-cart.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/promotion/map-to-discount-notifications.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/map-to-internal-customer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/hosted-form/iframe-content/card-expiry-formatter.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"card-validator\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/hosted-form/iframe-content/card-number-formatter.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/map-to-internal-order.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/map-to-internal-shipping-option.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-request-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/is-vaulted-instrument.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/not-initialized-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-client-unavailable-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/apple-pay/apple-pay-session-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/unsupported-browser-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree-sdk-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-params.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/errors/update-subscriptions-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/errors/remote-checkout-synchronization-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-get-first-and-last-name.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/create-googlepay-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-adyenv2-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-adyenv3-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-authorizenet-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-braintree-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-checkoutcom-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-cybersourcev2-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-orbital-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-stripe-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-stripe-upe-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/masterpass-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal/paypal-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/not-implemented-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-sdk.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-challenge-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/carding-protection-challenge-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/carding-protection-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/payment-human-verification-handler.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/mutation-observer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-not-loaded-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/google-recaptcha.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/google-recaptcha-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/create-spam-protection.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/getShippableItemsCount.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/getLineItemsCount.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/amazon-pay-v2/amazon-pay-v2-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-cancelled-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/apple-pay/apple-pay-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/map-to-braintree-shipping-address-override.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal/paypal-sdk.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/get-valid-button-style.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/map-to-legacy-billing-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/map-to-legacy-shipping-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-paypal-v1-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-paypal-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-paypal-credit-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-venmo-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/googlepay/googlepay-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/masterpass-supported-locales.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/format-locale.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/masterpass/masterpass-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/get-callback-url.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/paypal/paypal-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/paypal-commerce/paypal-commerce-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/create-payment-client.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/create-paypal-commerce-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/create-amazon-pay-v2-payment-processor.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\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};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/request-sender\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/form-poster\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"tslib\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/data-store\");","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 { Response } from '@bigcommerce/request-sender';\n\nimport StandardError from './standard-error';\n\nconst DEFAULT_RESPONSE = {\n body: {},\n headers: {},\n status: 0,\n};\n\n/**\n * Throw this error if we are unable to make a request to the server. It wraps\n * any server response into a JS error object.\n */\nexport default class RequestError<TBody = any> extends StandardError {\n body: TBody | {};\n headers: { [key: string]: any };\n errors: Array<{ code: string; message?: string }>;\n status: number;\n\n constructor(\n response?: Response<TBody | {}>,\n { message, errors }: {\n message?: string;\n errors?: Array<{ code: string; message?: string }>;\n } = {}\n ) {\n const { body, headers, status } = response || DEFAULT_RESPONSE;\n\n super(message || 'An unexpected error has occurred.');\n\n this.name = 'RequestError';\n this.type = 'request';\n this.body = body;\n this.headers = headers;\n this.status = status;\n this.errors = errors || [];\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error if we are unable to successfully submit a server request\n * using a payment method because the method has invalid configuration or is in\n * an invalid state.\n */\nexport default class PaymentMethodInvalidError<T = any> extends RequestError<T> {\n constructor(response?: Response<T>) {\n super(response, { message: 'There is a problem processing your payment. Please try again later.' });\n\n this.name = 'PaymentMethodInvalidError';\n this.type = 'payment_method_invalid';\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport RequestError from './request-error';\n\n/**\n * Throw this error if there is an unexpected error and it is not possible to\n * recover from unless the shopper creates a new checkout session.\n */\nexport default class UnrecoverableError<T = any> extends RequestError {\n constructor(response: Response<T>, message?: string) {\n super(response, {\n message: message || 'An unexpected error has occurred. The checkout process cannot continue as a result.',\n });\n\n this.name = 'UnrecoverableError';\n this.type = 'unrecoverable';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"lodash\");","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromInternalErrorResponse(\n response: Response<InternalErrorResponseBody>,\n message?: string\n): RequestError {\n const { body } = response;\n const { errors = [] } = body;\n\n return new RequestError(response, {\n message: joinErrors(errors) || body.detail || body.title || message,\n errors: errors.length ?\n errors.map(message => ({ code: body.type, message })) :\n [{ code: body.type, message: body.detail || body.title }],\n });\n}\n\nfunction joinErrors(errors: string[]): string | undefined {\n return errors.reduce((result: string[], error) => {\n if (error) {\n return [...result, error];\n }\n\n return result;\n }, []).join(' ');\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { PaymentErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromPaymentErrorResponse(\n response: Response<PaymentErrorResponseBody>,\n message?: string\n): RequestError {\n const { body } = response;\n const { errors = [] } = body;\n\n return new RequestError(response, {\n message: joinErrors(errors) || message,\n errors,\n });\n}\n\nfunction joinErrors(errors: Array<{ code: string; message?: string }>): string | undefined {\n if (!Array.isArray(errors)) {\n return;\n }\n\n return errors.reduce((result: string[], error) => {\n if (error && error.message) {\n return [...result, error.message];\n }\n\n return result;\n }, []).join(' ');\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport RequestError from './request-error';\n\n/**\n * Throw this error if a request fails to complete within its required timeframe\n * because of a network issue.\n */\nexport default class TimeoutError<T = any> extends RequestError<T> {\n constructor(response?: Response<T>) {\n super(response, {\n message: 'The request has timed out or aborted.',\n });\n\n this.name = 'TimeoutError';\n this.type = 'timeout';\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\nimport { last } from 'lodash';\n\nimport ErrorResponseBody, { InternalErrorResponseBody, StorefrontErrorResponseBody } from './error-response-body';\nimport { mapFromInternalErrorResponse, mapFromPaymentErrorResponse, mapFromStorefrontErrorResponse, RequestError, TimeoutError } from './errors';\n\nexport default class RequestErrorFactory {\n private _factoryMethods: { [key: string]: ErrorFactoryMethod } = {};\n\n constructor() {\n this.register('default', (response, message) => new RequestError(response, { message }));\n this.register('internal', (response, message) => mapFromInternalErrorResponse(response, message));\n this.register('storefront', (response, message) => mapFromStorefrontErrorResponse(response, message));\n this.register('payment', (response, message) => mapFromPaymentErrorResponse(response, message));\n this.register('timeout', response => new TimeoutError(response));\n }\n\n register(type: string, factoryMethod: ErrorFactoryMethod): void {\n this._factoryMethods[type] = factoryMethod;\n }\n\n createError(response: Response<any>, message?: string): RequestError {\n const factoryMethod = this._factoryMethods[this._getType(response)] || this._factoryMethods.default;\n\n return factoryMethod(response, message);\n }\n\n private _getType(response: Response<ErrorResponseBody>): string {\n if (response.status === 0) {\n return 'timeout';\n }\n\n if (this._isStorefrontErrorResponseBody(response.body)) {\n return 'storefront';\n }\n\n if (this._isInternalErrorResponseBody(response.body)) {\n const internalType = last(response.body.type.split('/'));\n\n return internalType && this._factoryMethods[internalType] ?\n internalType :\n 'internal';\n }\n\n const error = last(response.body && response.body.errors);\n\n if (error && error.code && this._factoryMethods[error.code]) {\n return error.code;\n }\n\n return 'payment';\n }\n\n private _isStorefrontErrorResponseBody(\n errorResponse: ErrorResponseBody\n ): errorResponse is StorefrontErrorResponseBody {\n const storefrontErrorResponse = errorResponse as StorefrontErrorResponseBody;\n\n return !this._isInternalErrorResponseBody(errorResponse) &&\n typeof storefrontErrorResponse.title === 'string' &&\n typeof storefrontErrorResponse.type === 'string' &&\n typeof storefrontErrorResponse.status === 'number' &&\n typeof storefrontErrorResponse.detail === 'string';\n }\n\n private _isInternalErrorResponseBody(\n errorResponse: ErrorResponseBody\n ): errorResponse is InternalErrorResponseBody {\n const internalErrorResponse = errorResponse as InternalErrorResponseBody;\n\n return typeof internalErrorResponse.errors === 'object' &&\n typeof internalErrorResponse.title === 'string' &&\n typeof internalErrorResponse.type === 'string' &&\n typeof internalErrorResponse.status === 'number';\n }\n}\n\nexport type ErrorFactoryMethod<T = any> = (response: Response<T>, message?: string) => RequestError;\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { StorefrontErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromStorefrontErrorResponse(\n response: Response<StorefrontErrorResponseBody>,\n message?: string\n): RequestError<StorefrontErrorResponseBody> {\n const { body } = response;\n\n return new RequestError(response, {\n message: message || body.detail || body.title,\n errors: [{\n code: body.code || body.type,\n message: body.detail || body.title,\n }],\n });\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rxjs\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rxjs/operators\");","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadConfigAction } from '../config';\nimport { LoadFormFieldsAction } from '../form';\n\nimport Checkout from './checkout';\n\nexport enum CheckoutActionType {\n LoadCheckoutRequested = 'LOAD_CHECKOUT_REQUESTED',\n LoadCheckoutSucceeded = 'LOAD_CHECKOUT_SUCCEEDED',\n LoadCheckoutFailed = 'LOAD_CHECKOUT_FAILED',\n\n UpdateCheckoutRequested = 'UPDATE_CHECKOUT_REQUESTED',\n UpdateCheckoutSucceeded = 'UPDATE_CHECKOUT_SUCCEEDED',\n UpdateCheckoutFailed = 'UPDATE_CHECKOUT_FAILED',\n}\n\nexport type CheckoutAction = LoadCheckoutAction | UpdateCheckoutAction;\n\nexport type LoadCheckoutAction =\n LoadCheckoutRequestedAction |\n LoadCheckoutSucceededAction |\n LoadCheckoutFailedAction |\n LoadFormFieldsAction |\n LoadConfigAction;\n\nexport type UpdateCheckoutAction =\n UpdateCheckoutRequestedAction |\n UpdateCheckoutSucceededAction |\n UpdateCheckoutFailedAction;\n\nexport interface LoadCheckoutRequestedAction extends Action {\n type: CheckoutActionType.LoadCheckoutRequested;\n}\n\nexport interface LoadCheckoutSucceededAction extends Action<Checkout> {\n type: CheckoutActionType.LoadCheckoutSucceeded;\n}\n\nexport interface LoadCheckoutFailedAction extends Action<Error> {\n type: CheckoutActionType.LoadCheckoutFailed;\n}\n\nexport interface UpdateCheckoutRequestedAction extends Action {\n type: CheckoutActionType.UpdateCheckoutRequested;\n}\n\nexport interface UpdateCheckoutSucceededAction extends Action<Checkout> {\n type: CheckoutActionType.UpdateCheckoutSucceeded;\n}\n\nexport interface UpdateCheckoutFailedAction extends Action<Error> {\n type: CheckoutActionType.UpdateCheckoutFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum ErrorActionType {\n ClearError = 'CLEAR_ERROR',\n}\n\nexport type ErrorAction = ClearErrorAction;\n\nexport interface ClearErrorAction extends Action {\n type: ErrorActionType.ClearError;\n payload: Error;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { InternalOrderResponseData } from './internal-order-responses';\nimport Order from './order';\n\nexport enum OrderActionType {\n LoadOrderRequested = 'LOAD_ORDER_REQUESTED',\n LoadOrderSucceeded = 'LOAD_ORDER_SUCCEEDED',\n LoadOrderFailed = 'LOAD_ORDER_FAILED',\n\n LoadOrderPaymentsRequested = 'LOAD_ORDER_PAYMENTS_REQUESTED',\n LoadOrderPaymentsSucceeded = 'LOAD_ORDER_PAYMENTS_SUCCEEDED',\n LoadOrderPaymentsFailed = 'LOAD_ORDER_PAYMENTS_FAILED',\n\n SubmitOrderRequested = 'SUBMIT_ORDER_REQUESTED',\n SubmitOrderSucceeded = 'SUBMIT_ORDER_SUCCEEDED',\n SubmitOrderFailed = 'SUBMIT_ORDER_FAILED',\n\n FinalizeOrderRequested = 'FINALIZE_ORDER_REQUESTED',\n FinalizeOrderSucceeded = 'FINALIZE_ORDER_SUCCEEDED',\n FinalizeOrderFailed = 'FINALIZE_ORDER_FAILED',\n}\n\nexport type OrderAction = LoadOrderAction |\n LoadOrderPaymentsAction |\n SubmitOrderAction |\n FinalizeOrderAction;\n\nexport type LoadOrderPaymentsAction = LoadOrderPaymentsRequestedAction |\n LoadOrderPaymentsSucceededAction |\n LoadOrderPaymentsFailedAction;\n\nexport type LoadOrderAction =\n LoadOrderRequestedAction |\n LoadOrderSucceededAction |\n LoadOrderFailedAction;\n\nexport type SubmitOrderAction =\n SubmitOrderRequestedAction |\n SubmitOrderSucceededAction |\n SubmitOrderFailedAction |\n LoadOrderAction;\n\nexport type FinalizeOrderAction =\n FinalizeOrderRequestedAction |\n FinalizeOrderSucceededAction |\n FinalizeOrderFailedAction |\n LoadOrderAction;\n\nexport interface LoadOrderRequestedAction extends Action {\n type: OrderActionType.LoadOrderRequested;\n}\n\nexport interface LoadOrderSucceededAction extends Action<Order> {\n type: OrderActionType.LoadOrderSucceeded;\n}\n\nexport interface LoadOrderFailedAction extends Action<Error> {\n type: OrderActionType.LoadOrderFailed;\n}\n\nexport interface LoadOrderPaymentsRequestedAction extends Action {\n type: OrderActionType.LoadOrderPaymentsRequested;\n}\n\nexport interface LoadOrderPaymentsSucceededAction extends Action<Order> {\n type: OrderActionType.LoadOrderPaymentsSucceeded;\n}\n\nexport interface LoadOrderPaymentsFailedAction extends Action<Error> {\n type: OrderActionType.LoadOrderPaymentsFailed;\n}\n\nexport interface SubmitOrderRequestedAction extends Action {\n type: OrderActionType.SubmitOrderRequested;\n}\n\nexport interface SubmitOrderSucceededAction extends Action<InternalOrderResponseData> {\n type: OrderActionType.SubmitOrderSucceeded;\n}\n\nexport interface SubmitOrderFailedAction extends Action<Error> {\n type: OrderActionType.SubmitOrderFailed;\n}\n\nexport interface FinalizeOrderRequestedAction extends Action {\n type: OrderActionType.FinalizeOrderRequested;\n}\n\nexport interface FinalizeOrderSucceededAction extends Action<InternalOrderResponseData> {\n type: OrderActionType.FinalizeOrderSucceeded;\n}\n\nexport interface FinalizeOrderFailedAction extends Action<Error> {\n type: OrderActionType.FinalizeOrderFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Subscriptions } from './subscriptions';\n\nexport enum SubscriptionsActionType {\n UpdateSubscriptionsRequested = 'UPDATE_SUBSCRIPTIONS_REQUESTED',\n UpdateSubscriptionsSucceeded = 'UPDATE_SUBSCRIPTIONS_SUCCEEDED',\n UpdateSubscriptionsFailed = 'UPDATE_SUBSCRIPTIONS_FAILED',\n}\nexport type UpdateSubscriptionsAction =\n UpdateSubscriptionsRequestedAction |\n UpdateSubscriptionsSucceededAction |\n UpdateSubscriptionsFailedAction;\n\nexport interface UpdateSubscriptionsRequestedAction extends Action {\n type: SubscriptionsActionType.UpdateSubscriptionsRequested;\n}\n\nexport interface UpdateSubscriptionsSucceededAction extends Action<Subscriptions> {\n type: SubscriptionsActionType.UpdateSubscriptionsSucceeded;\n}\n\nexport interface UpdateSubscriptionsFailedAction extends Action<Error> {\n type: SubscriptionsActionType.UpdateSubscriptionsFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nexport enum BillingAddressActionType {\n UpdateBillingAddressRequested = 'UPDATE_BILLING_ADDRESS_REQUESTED',\n UpdateBillingAddressSucceeded = 'UPDATE_BILLING_ADDRESS_SUCCEEDED',\n UpdateBillingAddressFailed = 'UPDATE_BILLING_ADDRESS_FAILED',\n\n ContinueAsGuestRequested = 'CONTINUE_AS_GUEST_REQUESTED',\n ContinueAsGuestSucceeded = 'CONTINUE_AS_GUEST_SUCCEEDED',\n ContinueAsGuestFailed = 'CONTINUE_AS_GUEST_FAILED',\n}\n\nexport type BillingAddressAction =\n ContinueAsGuestAction |\n UpdateBillingAddressAction;\n\nexport type UpdateBillingAddressAction =\n UpdateBillingAddressRequested |\n UpdateBillingAddressSucceeded |\n UpdateBillingAddressFailed;\n\nexport type ContinueAsGuestAction =\n ContinueAsGuestRequested |\n ContinueAsGuestSucceeded |\n ContinueAsGuestFailed;\n\nexport interface UpdateBillingAddressRequested extends Action {\n type: BillingAddressActionType.UpdateBillingAddressRequested;\n}\n\nexport interface UpdateBillingAddressSucceeded extends Action<Checkout> {\n type: BillingAddressActionType.UpdateBillingAddressSucceeded;\n}\n\nexport interface UpdateBillingAddressFailed extends Action<Error> {\n type: BillingAddressActionType.UpdateBillingAddressFailed;\n}\n\nexport interface ContinueAsGuestRequested extends Action {\n type: BillingAddressActionType.ContinueAsGuestRequested;\n}\n\nexport interface ContinueAsGuestSucceeded extends Action<Checkout> {\n type: BillingAddressActionType.ContinueAsGuestSucceeded;\n}\n\nexport interface ContinueAsGuestFailed extends Action<Error> {\n type: BillingAddressActionType.ContinueAsGuestFailed;\n}\n","import { isPlainObject, omitBy, transform } from 'lodash';\n\nexport default function omitDeep(object: any, predicate: (value: any, key: string) => boolean): any {\n if (Array.isArray(object)) {\n return object.map(value => omitDeep(value, predicate));\n }\n\n if (isPlainObject(object)) {\n return transform(omitBy(object, predicate), (result, value, key) => {\n result[key] = omitDeep(value, predicate);\n }, {} as { [key: string]: any });\n }\n\n return object;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { omitDeep } from '../utility';\n\nimport { ClearErrorAction, ErrorActionType } from './error-actions';\n\nexport default function clearErrorReducer<TState extends { [key: string]: any }, TAction extends Action>(\n state: TState,\n action: TAction\n): TState | undefined {\n if (isClearErrorAction(action)) {\n return omitDeep(state, value => value === action.payload);\n }\n\n return state;\n}\n\nfunction isClearErrorAction(action: Action): action is ClearErrorAction {\n return action.type === ErrorActionType.ClearError;\n}\n","export interface CompareOptions {\n keyFilter?(key: string): boolean;\n}\n\nexport default function isEqual(objectA: any, objectB: any, options?: CompareOptions): boolean {\n if (objectA === objectB) {\n return true;\n }\n\n if (objectA && objectB && typeof objectA === 'object' && typeof objectB === 'object') {\n if (Array.isArray(objectA) && Array.isArray(objectB)) {\n return isArrayEqual(objectA, objectB, options);\n }\n\n if (Array.isArray(objectA) || Array.isArray(objectB)) {\n return false;\n }\n\n if ((objectA instanceof Date) && (objectB instanceof Date)) {\n return isDateEqual(objectA, objectB);\n }\n\n if ((objectA instanceof Date) || (objectB instanceof Date)) {\n return false;\n }\n\n if ((objectA instanceof RegExp) && (objectB instanceof RegExp)) {\n return isRegExpEqual(objectA, objectB);\n }\n\n if ((objectA instanceof RegExp) || (objectB instanceof RegExp)) {\n return false;\n }\n\n return isObjectEqual(objectA, objectB, options);\n }\n\n return objectA === objectB;\n}\n\nfunction isRegExpEqual(objectA: RegExp, objectB: RegExp): boolean {\n return objectA.toString() === objectB.toString();\n}\n\nfunction isDateEqual(objectA: Date, objectB: Date): boolean {\n return objectA.getTime() === objectB.getTime();\n}\n\nfunction isArrayEqual(objectA: any[], objectB: any[], options?: CompareOptions): boolean {\n if (objectA.length !== objectB.length) {\n return false;\n }\n\n for (let index = 0, length = objectA.length; index < length; index++) {\n if (!isEqual(objectA[index], objectB[index], options)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction isObjectEqual(\n objectA: { [key: string]: any },\n objectB: { [key: string]: any },\n options?: CompareOptions\n): boolean {\n const filter = options && options.keyFilter;\n const keysA = filter ? Object.keys(objectA).filter(filter) : Object.keys(objectA);\n const keysB = filter ? Object.keys(objectB).filter(filter) : Object.keys(objectB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n for (let index = 0, length = keysA.length; index < length; index++) {\n const key = keysA[index];\n\n if (!Object.prototype.hasOwnProperty.call(objectB, key)) {\n return false;\n }\n\n if (!isEqual(objectA[key], objectB[key], options)) {\n return false;\n }\n }\n\n return true;\n}\n","import isEqual from './is-equal';\n\n/**\n * Replace the current value with a new value if the former is different to the\n * latter.\n */\nexport default function replace<T>(currentValue: T, newValue?: T): T {\n if (newValue === undefined || isEqual(currentValue, newValue)) {\n return currentValue;\n }\n\n return newValue;\n}\n","import isEqual from './is-equal';\n\n/**\n * Set a new value to an object under a key if the new value is different to the\n * current value of the key.\n */\nexport default function objectSet<T extends { [key: string]: any }, K extends keyof T>(\n object: T | undefined,\n key: K,\n value: T[K]\n): T {\n if (object && Object.prototype.hasOwnProperty.call(object, key) && isEqual(object[key], value)) {\n return object;\n }\n\n return {\n ...object as any,\n [key]: value,\n };\n}\n","import BillingAddress from './billing-address';\n\nexport default interface BillingAddressState {\n data?: BillingAddress;\n errors: BillingAddressErrorsState;\n statuses: BillingAddressStatusesState;\n}\n\nexport interface BillingAddressErrorsState {\n loadError?: Error;\n updateError?: Error;\n continueAsGuestError?: Error;\n}\n\nexport interface BillingAddressStatusesState {\n isLoading?: boolean;\n isUpdating?: boolean;\n isContinuingAsGuest?: boolean;\n}\n\nexport const DEFAULT_STATE: BillingAddressState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet, replace } from '../common/utility';\nimport { OrderAction, OrderActionType } from '../order';\nimport { SubscriptionsActionType, UpdateSubscriptionsAction } from '../subscription';\n\nimport BillingAddress from './billing-address';\nimport { BillingAddressAction, BillingAddressActionType } from './billing-address-actions';\nimport BillingAddressState, { BillingAddressErrorsState, BillingAddressStatusesState, DEFAULT_STATE } from './billing-address-state';\n\nexport default function billingAddressReducer(\n state: BillingAddressState = DEFAULT_STATE,\n action: Action\n): BillingAddressState {\n const reducer = combineReducers<BillingAddressState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: BillingAddress | undefined,\n action: CheckoutAction | BillingAddressAction | OrderAction\n): BillingAddress | undefined {\n switch (action.type) {\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case OrderActionType.LoadOrderSucceeded:\n return replace(data, action.payload && action.payload.billingAddress);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: BillingAddressErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | BillingAddressAction | OrderAction | UpdateSubscriptionsAction\n): BillingAddressErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case BillingAddressActionType.UpdateBillingAddressRequested:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case BillingAddressActionType.UpdateBillingAddressFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n case BillingAddressActionType.ContinueAsGuestRequested:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n return objectSet(errors, 'continueAsGuestError', undefined);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case BillingAddressActionType.ContinueAsGuestFailed:\n return objectSet(errors, 'continueAsGuestError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: BillingAddressStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | BillingAddressAction | OrderAction | UpdateSubscriptionsAction\n): BillingAddressStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case BillingAddressActionType.UpdateBillingAddressRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case BillingAddressActionType.UpdateBillingAddressFailed:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n\n case BillingAddressActionType.ContinueAsGuestRequested:\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n return objectSet(statuses, 'isContinuingAsGuest', true);\n\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case BillingAddressActionType.ContinueAsGuestFailed:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n return objectSet(statuses, 'isContinuingAsGuest', false);\n\n default:\n return statuses;\n }\n}\n","import { isPlainObject as lodashIsPlainObject } from 'lodash';\n\n// We need this wrapper because Lodash's version doesn't act as a type guard\nexport default function isPlainObject(value: any): value is object {\n return lodashIsPlainObject(value);\n}\n","import { isArray } from 'lodash';\n\nimport isPlainObject from './is-plain-object';\nimport objectMerge from './object-merge';\nimport replace from './replace';\n\nexport interface ArrayReplaceOptions {\n matchObject(objectA: any, objectB: any): boolean;\n}\n\nfunction arrayReplace<T>(currentArray: T[] | undefined, newArray: T[], options?: ArrayReplaceOptions): T[];\nfunction arrayReplace<T>(currentArray: T[], newArray?: T[], options?: ArrayReplaceOptions): undefined;\nfunction arrayReplace<T>(currentArray?: T[], newArray?: T[], options?: ArrayReplaceOptions): T[] | undefined;\nfunction arrayReplace<T>(currentArray?: T[], newArray?: T[], options?: ArrayReplaceOptions): T[] | undefined {\n const { matchObject = (a: any, b: any) => a.id !== undefined && a.id === b.id } = options || {};\n\n // Return the new array if the current array does not exist\n if (!currentArray) {\n return newArray;\n }\n\n // If the new array does not exist, or the current array is strictly equal\n // to the new array, exit early and return the current array so that the\n // object reference doesn't change\n if (!newArray || currentArray === newArray) {\n return currentArray;\n }\n\n // Otherwise, try to replace the items of the current array with the new\n // array. If the item from the two arrays are the same, keep the current\n // one. Do it recursively until all arrays are replaced.\n let sameAsCurrentCount = 0;\n let sameAsNewCount = 0;\n\n const countSameAsReplaced = <T>(replacedValue: T, currentValue: T, newValue: T): T => {\n sameAsCurrentCount += replacedValue === currentValue ? 1 : 0;\n sameAsNewCount += replacedValue === newValue ? 1 : 0;\n\n return replacedValue;\n };\n\n const result = newArray.map((newItem, index) => {\n const currentItem = currentArray && currentArray[index];\n\n if (isPlainObject(currentItem) && isPlainObject(newItem)) {\n if (matchObject(currentItem, newItem)) {\n return countSameAsReplaced(\n objectMerge(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n return countSameAsReplaced(\n replace(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n if (isArray(currentItem) && isArray(newItem)) {\n return countSameAsReplaced(\n arrayReplace(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n return countSameAsReplaced(\n replace(currentItem, newItem),\n currentItem,\n newItem\n );\n }) as T[];\n\n // If all items in the result are identical to the current array, and the\n // current array and the new array have the same size, simply return the\n // current array instead of the result.\n if (sameAsCurrentCount === newArray.length && (currentArray && currentArray.length === newArray.length)) {\n return currentArray;\n }\n\n // If all items in the result are identical to the new array, simply return\n // the new array.\n if (sameAsNewCount === newArray.length) {\n return newArray;\n }\n\n return result;\n}\n\nexport default arrayReplace;\n","import { isArray } from 'lodash';\n\nimport arrayReplace from './array-replace';\nimport isPlainObject from './is-plain-object';\nimport objectSet from './object-set';\n\nfunction objectMerge<T extends object>(currentObject: T, newObject?: Partial<T>): T;\nfunction objectMerge<T extends object>(currentObject: T | undefined, newObject: Partial<T>): Partial<T>;\nfunction objectMerge<T extends object>(currentObject?: T, newObject?: Partial<T>): T | undefined;\nfunction objectMerge<T extends object>(currentObject?: T, newObject?: Partial<T>): T | Partial<T> | undefined {\n if (!currentObject) {\n return newObject;\n }\n\n // If the new object does not exist but the current object does, or the new\n // object is strictly equal to the current object, return the current object\n if (!newObject || currentObject === newObject) {\n return currentObject;\n }\n\n // If both objects exist, but some values might be different, perform a merge.\n // Retain values that are equal and only replace them with the new values if\n // they are different.\n return (Object.keys(newObject) as Array<keyof T>)\n .reduce((result, key) => {\n const currentValue = result[key];\n const newValue = newObject[key];\n\n if (isPlainObject(currentValue) && isPlainObject(newValue)) {\n return objectSet(result, key, objectMerge(currentValue, newValue));\n }\n\n if (isArray(currentValue) && isArray(newValue)) {\n return objectSet(result, key, arrayReplace(currentValue, newValue) as any);\n }\n\n return objectSet(result, key, newValue as any);\n }, currentObject);\n}\n\nexport default objectMerge;\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum CouponActionType {\n ApplyCouponRequested = 'APPLY_COUPON_REQUESTED',\n ApplyCouponSucceeded = 'APPLY_COUPON_SUCCEEDED',\n ApplyCouponFailed = 'APPLY_COUPON_FAILED',\n\n RemoveCouponRequested = 'REMOVE_COUPON_REQUESTED',\n RemoveCouponSucceeded = 'REMOVE_COUPON_SUCCEEDED',\n RemoveCouponFailed = 'REMOVE_COUPON_FAILED',\n}\n\nexport type CouponAction =\n ApplyCouponAction |\n RemoveCouponAction;\n\nexport type ApplyCouponAction =\n ApplyCouponRequestedAction |\n ApplyCouponSucceededAction |\n ApplyCouponFailedAction;\n\nexport type RemoveCouponAction =\n RemoveCouponRequestedAction |\n RemoveCouponSucceededAction |\n RemoveCouponFailedAction;\n\nexport interface ApplyCouponRequestedAction extends Action {\n type: CouponActionType.ApplyCouponRequested;\n}\n\nexport interface ApplyCouponSucceededAction extends Action<Checkout> {\n type: CouponActionType.ApplyCouponSucceeded;\n}\n\nexport interface ApplyCouponFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: CouponActionType.ApplyCouponFailed;\n}\n\nexport interface RemoveCouponRequestedAction extends Action {\n type: CouponActionType.RemoveCouponRequested;\n}\n\nexport interface RemoveCouponSucceededAction extends Action<Checkout> {\n type: CouponActionType.RemoveCouponSucceeded;\n}\n\nexport interface RemoveCouponFailedAction extends Action<RequestError> {\n type: CouponActionType.RemoveCouponFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum GiftCertificateActionType {\n ApplyGiftCertificateRequested = 'APPLY_GIFT_CERTIFICATE_REQUESTED',\n ApplyGiftCertificateSucceeded = 'APPLY_GIFT_CERTIFICATE_SUCCEEDED',\n ApplyGiftCertificateFailed = 'APPLY_GIFT_CERTIFICATE_FAILED',\n\n RemoveGiftCertificateRequested = 'REMOVE_GIFT_CERTIFICATE_REQUESTED',\n RemoveGiftCertificateSucceeded = 'REMOVE_GIFT_CERTIFICATE_SUCCEEDED',\n RemoveGiftCertificateFailed = 'REMOVE_GIFT_CERTIFICATE_FAILED',\n}\n\nexport type GiftCertificateAction =\n ApplyGiftCertificateAction |\n RemoveGiftCertificateAction;\n\nexport type ApplyGiftCertificateAction =\n ApplyGiftCertificateRequestedAction |\n ApplyGiftCertificateSucceededAction |\n ApplyGiftCertificateFailedAction;\n\nexport type RemoveGiftCertificateAction =\n RemoveGiftCertificateRequestedAction |\n RemoveGiftCertificateSucceededAction |\n RemoveGiftCertificateFailedAction;\n\nexport interface ApplyGiftCertificateRequestedAction extends Action {\n type: GiftCertificateActionType.ApplyGiftCertificateRequested;\n}\n\nexport interface ApplyGiftCertificateSucceededAction extends Action<Checkout> {\n type: GiftCertificateActionType.ApplyGiftCertificateSucceeded;\n}\n\nexport interface ApplyGiftCertificateFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: GiftCertificateActionType.ApplyGiftCertificateFailed;\n}\n\nexport interface RemoveGiftCertificateRequestedAction extends Action {\n type: GiftCertificateActionType.RemoveGiftCertificateRequested;\n}\n\nexport interface RemoveGiftCertificateSucceededAction extends Action<Checkout> {\n type: GiftCertificateActionType.RemoveGiftCertificateSucceeded;\n}\n\nexport interface RemoveGiftCertificateFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: GiftCertificateActionType.RemoveGiftCertificateFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nimport { ConsignmentMeta } from './consignment';\n\nexport enum ConsignmentActionType {\n CreateConsignmentsRequested = 'CREATE_CONSIGNMENTS_REQUESTED',\n CreateConsignmentsSucceeded = 'CREATE_CONSIGNMENTS_SUCCEEDED',\n CreateConsignmentsFailed = 'CREATE_CONSIGNMENTS_FAILED',\n\n UpdateConsignmentRequested = 'UPDATE_CONSIGNMENT_REQUESTED',\n UpdateConsignmentSucceeded = 'UPDATE_CONSIGNMENT_SUCCEEDED',\n UpdateConsignmentFailed = 'UPDATE_CONSIGNMENT_FAILED',\n\n DeleteConsignmentRequested = 'DELETE_CONSIGNMENT_REQUESTED',\n DeleteConsignmentSucceeded = 'DELETE_CONSIGNMENT_SUCCEEDED',\n DeleteConsignmentFailed = 'DELETE_CONSIGNMENT_FAILED',\n\n UpdateShippingOptionRequested = 'UPDATE_SHIPPING_OPTION_REQUESTED',\n UpdateShippingOptionSucceeded = 'UPDATE_SHIPPING_OPTION_SUCCEEDED',\n UpdateShippingOptionFailed = 'UPDATE_SHIPPING_OPTION_FAILED',\n\n LoadShippingOptionsRequested = 'LOAD_SHIPPING_OPTIONS_REQUESTED',\n LoadShippingOptionsSucceeded = 'LOAD_SHIPPING_OPTIONS_SUCCEEDED',\n LoadShippingOptionsFailed = 'LOAD_SHIPPING_OPTIONS_FAILED',\n}\n\nexport type ConsignmentAction =\n CreateConsignmentsAction |\n UpdateConsignmentAction |\n DeleteConsignmentAction |\n UpdateShippingOptionAction |\n LoadShippingOptionsAction;\n\nexport type CreateConsignmentsAction =\n CreateConsignmentsRequestedAction |\n CreateConsignmentsSucceededAction |\n CreateConsignmentsFailedAction;\n\nexport type UpdateConsignmentAction =\n UpdateConsignmentRequestedAction |\n UpdateConsignmentSucceededAction |\n UpdateConsignmentFailedAction;\n\nexport type DeleteConsignmentAction =\n DeleteConsignmentRequestedAction |\n DeleteConsignmentSucceededAction |\n DeleteConsignmentFailedAction;\n\nexport type UpdateShippingOptionAction =\n UpdateShippingOptionRequestedAction |\n UpdateShippingOptionSucceededAction |\n UpdateShippingOptionFailedAction;\n\nexport type LoadShippingOptionsAction =\n LoadShippingOptionsRequestedAction |\n LoadShippingOptionsSucceededAction |\n LoadShippingOptionsFailedAction;\n\nexport interface CreateConsignmentsRequestedAction extends Action {\n type: ConsignmentActionType.CreateConsignmentsRequested;\n}\n\nexport interface CreateConsignmentsSucceededAction extends Action<Checkout> {\n type: ConsignmentActionType.CreateConsignmentsSucceeded;\n}\n\nexport interface CreateConsignmentsFailedAction extends Action<Error> {\n type: ConsignmentActionType.CreateConsignmentsFailed;\n}\n\nexport interface UpdateConsignmentRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentRequested;\n}\n\nexport interface UpdateConsignmentSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentSucceeded;\n}\n\nexport interface UpdateConsignmentFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentFailed;\n}\n\nexport interface DeleteConsignmentRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentRequested;\n}\n\nexport interface DeleteConsignmentSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentSucceeded;\n}\n\nexport interface DeleteConsignmentFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentFailed;\n}\n\nexport interface UpdateShippingOptionRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionRequested;\n}\n\nexport interface UpdateShippingOptionSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionSucceeded;\n}\n\nexport interface UpdateShippingOptionFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionFailed;\n}\n\nexport interface LoadShippingOptionsRequestedAction extends Action {\n type: ConsignmentActionType.LoadShippingOptionsRequested;\n}\n\nexport interface LoadShippingOptionsSucceededAction extends Action<Checkout> {\n type: ConsignmentActionType.LoadShippingOptionsSucceeded;\n}\n\nexport interface LoadShippingOptionsFailedAction extends Action<Error> {\n type: ConsignmentActionType.LoadShippingOptionsFailed;\n}\n","import Cart from './cart';\n\nexport default interface CartState {\n data?: Cart;\n errors: CartErrorsState;\n statuses: CartStatusesState;\n}\n\nexport interface CartErrorsState {\n loadError?: Error;\n}\n\nexport interface CartStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: CartState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadPaymentMethodAction } from '../payment';\n\nimport { CheckoutButtonMethodType } from './strategies';\n\nexport enum CheckoutButtonActionType {\n InitializeButtonFailed = 'INITIALIZE_BUTTON_FAILED',\n InitializeButtonRequested = 'INITIALIZE_BUTTON_REQUESTED',\n InitializeButtonSucceeded = 'INITIALIZE_BUTTON_SUCCEEDED',\n\n DeinitializeButtonFailed = 'DEINITIALIZE_BUTTON_FAILED',\n DeinitializeButtonRequested = 'DEINITIALIZE_BUTTON_REQUESTED',\n DeinitializeButtonSucceeded = 'DEINITIALIZE_BUTTON_SUCCEEDED',\n}\n\nexport type CheckoutButtonAction = InitializeButtonAction | DeinitializeButtonAction;\n\nexport type InitializeButtonAction =\n InitializeButtonRequestedAction |\n InitializeButtonSucceededAction |\n InitializeButtonFailedAction |\n LoadPaymentMethodAction;\n\nexport type DeinitializeButtonAction =\n DeinitializeButtonRequestedAction |\n DeinitializeButtonSucceededAction |\n DeinitializeButtonFailedAction;\n\nexport interface CheckoutButtonActionMeta {\n methodId: CheckoutButtonMethodType;\n}\n\nexport interface InitializeButtonActionMeta extends CheckoutButtonActionMeta {\n containerId: string;\n}\n\nexport interface InitializeButtonRequestedAction extends Action<undefined, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonRequested;\n}\n\nexport interface InitializeButtonSucceededAction extends Action<undefined, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonSucceeded;\n}\n\nexport interface InitializeButtonFailedAction extends Action<Error, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonFailed;\n}\n\nexport interface DeinitializeButtonRequestedAction extends Action<undefined, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonRequested;\n}\n\nexport interface DeinitializeButtonSucceededAction extends Action<undefined, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonSucceeded;\n}\n\nexport interface DeinitializeButtonFailedAction extends Action<Error, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { BillingAddressAction, BillingAddressActionType } from '../billing';\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType, GiftCertificateAction, GiftCertificateActionType } from '../coupon';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport Cart from './cart';\nimport CartState, { CartErrorsState, CartStatusesState, DEFAULT_STATE } from './cart-state';\n\nexport default function cartReducer(\n state: CartState = DEFAULT_STATE,\n action: Action\n): CartState {\n const reducer = combineReducers<CartState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Cart | undefined,\n action: BillingAddressAction | CheckoutAction | ConsignmentAction | CouponAction | GiftCertificateAction\n): Cart | undefined {\n switch (action.type) {\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return objectMerge(data, action.payload && action.payload.cart);\n\n default:\n return data;\n }\n}\n\nfunction statusesReducer(\n statuses: CartStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction\n): CartStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n\nfunction errorsReducer(\n errors: CartErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction\n): CartErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n","import { CheckoutButtonMethodType } from './strategies';\n\nexport default interface CheckoutButtonState {\n data: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonDataState | undefined\n };\n errors: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonErrorsState | undefined\n };\n statuses: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonStatusesState | undefined\n };\n}\n\nexport interface CheckoutButtonDataState {\n initializedContainers: {\n [key: string]: boolean;\n };\n}\n\nexport interface CheckoutButtonErrorsState {\n initializeError?: Error;\n deinitializeError?: Error;\n}\n\nexport interface CheckoutButtonStatusesState {\n isInitializing?: boolean;\n isDeinitializing?: boolean;\n}\n\nexport const DEFAULT_STATE: CheckoutButtonState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport Config from './config';\n\nexport enum ConfigActionType {\n LoadConfigRequested = 'LOAD_CONFIG_REQUESTED',\n LoadConfigSucceeded = 'LOAD_CONFIG_SUCCEEDED',\n LoadConfigFailed = 'LOAD_CONFIG_FAILED',\n}\n\nexport type LoadConfigAction =\n LoadConfigRequestedAction |\n LoadConfigSucceededAction |\n LoadConfigFailedAction;\n\nexport interface LoadConfigRequestedAction extends Action {\n type: ConfigActionType.LoadConfigRequested;\n}\n\nexport interface LoadConfigSucceededAction extends Action<Config> {\n type: ConfigActionType.LoadConfigSucceeded;\n}\n\nexport interface LoadConfigFailedAction extends Action<Error> {\n type: ConfigActionType.LoadConfigFailed;\n}\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { CheckoutButtonAction, CheckoutButtonActionType } from './checkout-button-actions';\nimport CheckoutButtonState, { CheckoutButtonDataState, CheckoutButtonErrorsState, CheckoutButtonStatusesState, DEFAULT_STATE } from './checkout-button-state';\n\nconst DEFAULT_DATA_STATE: CheckoutButtonDataState = { initializedContainers: {} };\nconst DEFAULT_ERROR_STATE: CheckoutButtonErrorsState = {};\nconst DEFAULT_STATUS_STATE: CheckoutButtonStatusesState = {};\n\nexport default function checkoutButtonReducer(\n state: CheckoutButtonState = DEFAULT_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonState {\n if (!action.meta || !action.meta.methodId) {\n return state;\n }\n\n const reducer = combineReducers<CheckoutButtonState>({\n data: combineReducers({\n [action.meta.methodId]: dataReducer,\n }),\n errors: combineReducers({\n [action.meta.methodId]: errorsReducer,\n }),\n statuses: combineReducers({\n [action.meta.methodId]: statusesReducer,\n }),\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CheckoutButtonDataState = DEFAULT_DATA_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonDataState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n if (!action.meta || !action.meta.containerId) {\n return data;\n }\n\n return objectMerge(data, {\n initializedContainers: {\n [action.meta.containerId]: true,\n },\n });\n\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(data, 'initializedContainers', {});\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: CheckoutButtonErrorsState = DEFAULT_ERROR_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonErrorsState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonRequested:\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n return objectSet(errors, 'initializeError', undefined);\n\n case CheckoutButtonActionType.InitializeButtonFailed:\n return objectSet(errors, 'initializeError', action.payload);\n\n case CheckoutButtonActionType.DeinitializeButtonRequested:\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(errors, 'deinitializeError', undefined);\n\n case CheckoutButtonActionType.DeinitializeButtonFailed:\n return objectSet(errors, 'deinitializeError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CheckoutButtonStatusesState = DEFAULT_STATUS_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonStatusesState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonRequested:\n return objectSet(statuses, 'isInitializing', true);\n\n case CheckoutButtonActionType.InitializeButtonFailed:\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n return objectSet(statuses, 'isInitializing', false);\n\n case CheckoutButtonActionType.DeinitializeButtonRequested:\n return objectSet(statuses, 'isDeinitializing', true);\n\n case CheckoutButtonActionType.DeinitializeButtonFailed:\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(statuses, 'isDeinitializing', false);\n\n default:\n return statuses;\n }\n}\n","import Config from './config';\n\nexport default interface ConfigState {\n data?: Config;\n meta?: ConfigMetaState;\n errors: ConfigErrorsState;\n statuses: ConfigStatusesState;\n}\n\nexport interface ConfigMetaState {\n externalSource?: string;\n variantIdentificationToken?: string;\n}\n\nexport interface ConfigErrorsState {\n loadError?: Error;\n}\n\nexport interface ConfigStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: ConfigState = {\n meta: {},\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport Config from './config';\nimport { ConfigActionType, LoadConfigAction } from './config-actions';\nimport ConfigState, { ConfigErrorsState, ConfigStatusesState, DEFAULT_STATE } from './config-state';\n\nexport default function configReducer(\n state: ConfigState = DEFAULT_STATE,\n action: Action\n): ConfigState {\n const reducer = combineReducers<ConfigState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Config | undefined,\n action: LoadConfigAction\n): Config | undefined {\n switch (action.type) {\n case ConfigActionType.LoadConfigSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ConfigErrorsState = DEFAULT_STATE.errors,\n action: LoadConfigAction\n): ConfigErrorsState {\n switch (action.type) {\n case ConfigActionType.LoadConfigSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case ConfigActionType.LoadConfigFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ConfigStatusesState = DEFAULT_STATE.statuses,\n action: LoadConfigAction\n): ConfigStatusesState {\n switch (action.type) {\n case ConfigActionType.LoadConfigRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ConfigActionType.LoadConfigSucceeded:\n case ConfigActionType.LoadConfigFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nimport Coupon from './coupon';\n\nexport default interface CouponState {\n data?: Coupon[];\n errors: CouponErrorsState;\n statuses: CouponStatusesState;\n}\n\nexport interface CouponErrorsState {\n applyCouponError?: RequestError<StorefrontErrorResponseBody>;\n removeCouponError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface CouponStatusesState {\n isApplyingCoupon?: boolean;\n isRemovingCoupon?: boolean;\n}\n\nexport const DEFAULT_STATE: CouponState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { OrderAction, OrderActionType } from '../order';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport Coupon from './coupon';\nimport { CouponAction, CouponActionType } from './coupon-actions';\nimport CouponState, { CouponErrorsState, CouponStatusesState, DEFAULT_STATE } from './coupon-state';\n\nexport default function couponReducer(\n state: CouponState = DEFAULT_STATE,\n action: Action\n): CouponState {\n const reducer = combineReducers<CouponState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Coupon[] | undefined,\n action: CouponAction | CheckoutAction | OrderAction | ConsignmentAction\n): Coupon[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case OrderActionType.LoadOrderSucceeded:\n return arrayReplace(data, action.payload && action.payload.coupons);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CouponErrorsState = {},\n action: CouponAction\n): CouponErrorsState {\n switch (action.type) {\n case CouponActionType.ApplyCouponRequested:\n case CouponActionType.ApplyCouponSucceeded:\n return objectSet(errors, 'applyCouponError', undefined);\n\n case CouponActionType.ApplyCouponFailed:\n return objectSet(errors, 'applyCouponError', action.payload);\n\n case CouponActionType.RemoveCouponRequested:\n case CouponActionType.RemoveCouponSucceeded:\n return objectSet(errors, 'removeCouponError', undefined);\n\n case CouponActionType.RemoveCouponFailed:\n return objectSet(errors, 'removeCouponError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CouponStatusesState = {},\n action: CouponAction\n): CouponStatusesState {\n switch (action.type) {\n case CouponActionType.ApplyCouponRequested:\n return objectSet(statuses, 'isApplyingCoupon', true);\n\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.ApplyCouponFailed:\n return objectSet(statuses, 'isApplyingCoupon', false);\n\n case CouponActionType.RemoveCouponRequested:\n return objectSet(statuses, 'isRemovingCoupon', true);\n\n case CouponActionType.RemoveCouponSucceeded:\n case CouponActionType.RemoveCouponFailed:\n return objectSet(statuses, 'isRemovingCoupon', false);\n\n default:\n return statuses;\n }\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nimport GiftCertificate from './gift-certificate';\n\nexport default interface GiftCertificateState {\n data?: GiftCertificate[];\n errors: GiftCertificateErrorsState;\n statuses: GiftCertificateStatusesState;\n}\n\nexport interface GiftCertificateErrorsState {\n applyGiftCertificateError?: RequestError<StorefrontErrorResponseBody>;\n removeGiftCertificateError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface GiftCertificateStatusesState {\n isApplyingGiftCertificate?: boolean;\n isRemovingGiftCertificate?: boolean;\n}\n\nexport const DEFAULT_STATE: GiftCertificateState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadCheckoutAction } from '../checkout';\nimport { SpamProtectionAction } from '../spam-protection';\n\nimport Customer from './customer';\nimport { InternalCustomerResponseData } from './internal-customer-responses';\n\nexport enum CustomerActionType {\n SignInCustomerRequested = 'SIGN_IN_CUSTOMER_REQUESTED',\n SignInCustomerSucceeded = 'SIGN_IN_CUSTOMER_SUCCEEDED',\n SignInCustomerFailed = 'SIGN_IN_CUSTOMER_FAILED',\n\n SignOutCustomerRequested = 'SIGN_OUT_CUSTOMER_REQUESTED',\n SignOutCustomerSucceeded = 'SIGN_OUT_CUSTOMER_SUCCEEDED',\n SignOutCustomerFailed = 'SIGN_OUT_CUSTOMER_FAILED',\n\n CreateCustomerRequested = 'CREATE_CUSTOMER_REQUESTED',\n CreateCustomerSucceeded = 'CREATE_CUSTOMER_SUCCEEDED',\n CreateCustomerFailed = 'CREATE_CUSTOMER_FAILED',\n\n CreateCustomerAddressRequested = 'CREATE_CUSTOMER_ADDRESS_REQUESTED',\n CreateCustomerAddressSucceeded = 'CREATE_CUSTOMER_ADDRESS_SUCCEEDED',\n CreateCustomerAddressFailed = 'CREATE_CUSTOMER_ADDRESS_FAILED',\n}\n\nexport type CustomerAction =\n SignInCustomerAction |\n SignOutCustomerAction |\n CreateCustomerAddressAction |\n CreateCustomerAction;\n\nexport type CreateCustomerAction =\n CreateCustomerRequestedAction |\n CreateCustomerSucceededAction |\n CreateCustomerFailedAction |\n SpamProtectionAction |\n LoadCheckoutAction;\n\nexport type CreateCustomerAddressAction =\n CreateCustomerAddressRequestedAction |\n CreateCustomerAddressSucceededAction |\n CreateCustomerAddressFailedAction |\n LoadCheckoutAction;\n\nexport type SignInCustomerAction =\n SignInCustomerRequestedAction |\n SignInCustomerSucceededAction |\n SignInCustomerFailedAction |\n LoadCheckoutAction;\n\nexport type SignOutCustomerAction =\n SignOutCustomerRequestedAction |\n SignOutCustomerSucceededAction |\n SignOutCustomerFailedAction |\n LoadCheckoutAction;\n\nexport interface SignInCustomerRequestedAction extends Action {\n type: CustomerActionType.SignInCustomerRequested;\n}\n\nexport interface SignInCustomerSucceededAction extends Action<InternalCustomerResponseData> {\n type: CustomerActionType.SignInCustomerSucceeded;\n}\n\nexport interface SignInCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.SignInCustomerFailed;\n}\n\nexport interface SignOutCustomerRequestedAction extends Action {\n type: CustomerActionType.SignOutCustomerRequested;\n}\n\nexport interface SignOutCustomerSucceededAction extends Action<InternalCustomerResponseData> {\n type: CustomerActionType.SignOutCustomerSucceeded;\n}\n\nexport interface SignOutCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.SignOutCustomerFailed;\n}\n\nexport interface CreateCustomerRequestedAction extends Action {\n type: CustomerActionType.CreateCustomerRequested;\n}\n\nexport interface CreateCustomerSucceededAction extends Action {\n type: CustomerActionType.CreateCustomerSucceeded;\n}\n\nexport interface CreateCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.CreateCustomerFailed;\n}\n\nexport interface CreateCustomerAddressRequestedAction extends Action {\n type: CustomerActionType.CreateCustomerAddressRequested;\n}\n\nexport interface CreateCustomerAddressSucceededAction extends Action<Customer> {\n type: CustomerActionType.CreateCustomerAddressSucceeded;\n}\n\nexport interface CreateCustomerAddressFailedAction extends Action<Error> {\n type: CustomerActionType.CreateCustomerAddressFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport { CouponAction, CouponActionType } from './coupon-actions';\nimport GiftCertificate from './gift-certificate';\nimport { GiftCertificateAction, GiftCertificateActionType } from './gift-certificate-actions';\nimport GiftCertificateState, { DEFAULT_STATE, GiftCertificateErrorsState, GiftCertificateStatusesState } from './gift-certificate-state';\n\nexport default function giftCertificateReducer(\n state: GiftCertificateState = DEFAULT_STATE,\n action: Action\n): GiftCertificateState {\n const reducer = combineReducers<GiftCertificateState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: GiftCertificate[] | undefined,\n action: CheckoutAction | GiftCertificateAction | ConsignmentAction | CouponAction\n): GiftCertificate[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return arrayReplace(data, action.payload && action.payload.giftCertificates);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: GiftCertificateErrorsState = DEFAULT_STATE.errors,\n action: GiftCertificateAction\n): GiftCertificateErrorsState {\n switch (action.type) {\n case GiftCertificateActionType.ApplyGiftCertificateRequested:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n return objectSet(errors, 'applyGiftCertificateError', undefined);\n\n case GiftCertificateActionType.ApplyGiftCertificateFailed:\n return objectSet(errors, 'applyGiftCertificateError', action.payload);\n\n case GiftCertificateActionType.RemoveGiftCertificateRequested:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return objectSet(errors, 'removeGiftCertificateError', undefined);\n\n case GiftCertificateActionType.RemoveGiftCertificateFailed:\n return objectSet(errors, 'removeGiftCertificateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: GiftCertificateStatusesState = DEFAULT_STATE.statuses,\n action: GiftCertificateAction\n): GiftCertificateStatusesState {\n switch (action.type) {\n case GiftCertificateActionType.ApplyGiftCertificateRequested:\n return objectSet(statuses, 'isApplyingGiftCertificate', true);\n\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateFailed:\n return objectSet(statuses, 'isApplyingGiftCertificate', false);\n\n case GiftCertificateActionType.RemoveGiftCertificateRequested:\n return objectSet(statuses, 'isRemovingGiftCertificate', true);\n\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateFailed:\n return objectSet(statuses, 'isRemovingGiftCertificate', false);\n\n default:\n return statuses;\n }\n}\n","import Customer from './customer';\n\nexport default interface CustomerState {\n data?: Customer;\n statuses: CustomerStatusesState;\n errors: CustomerErrorsState;\n}\n\nexport interface CustomerErrorsState {\n createError?: Error;\n createAddressError?: Error;\n}\n\nexport interface CustomerStatusesState {\n isCreating?: boolean;\n isCreatingAddress?: boolean;\n}\n\nexport const DEFAULT_STATE: CustomerState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum CustomerStrategyActionType {\n SignInFailed = 'CUSTOMER_STRATEGY_SIGN_IN_FAILED',\n SignInRequested = 'CUSTOMER_STRATEGY_SIGN_IN_REQUESTED',\n SignInSucceeded = 'CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED',\n SignOutFailed = 'CUSTOMER_STRATEGY_SIGN_OUT_FAILED',\n SignOutRequested = 'CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED',\n SignOutSucceeded = 'CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED',\n ExecutePaymentMethodCheckoutFailed = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED',\n ExecutePaymentMethodCheckoutRequested = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED',\n ExecutePaymentMethodCheckoutSucceeded = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED',\n InitializeFailed = 'CUSTOMER_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'CUSTOMER_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'CUSTOMER_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type CustomerStrategyAction =\n CustomerStrategySignInAction |\n CustomerStrategySignOutAction |\n CustomerStrategyExecutePaymentMethodCheckoutAction |\n CustomerStrategyInitializeAction |\n CustomerStrategyDeinitializeAction |\n CustomerStrategyWidgetAction;\n\nexport type CustomerStrategySignInAction =\n SignInRequestedAction |\n SignInSucceededAction |\n SignInFailedAction;\n\nexport type CustomerStrategySignOutAction =\n SignOutRequestedAction |\n SignOutSucceededAction |\n SignOutFailedAction;\n\nexport type CustomerStrategyExecutePaymentMethodCheckoutAction =\n ExecutePaymentMethodCheckoutRequestedAction |\n ExecutePaymentMethodCheckoutSucceededAction |\n ExecutePaymentMethodCheckoutFailedAction;\n\nexport type CustomerStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type CustomerStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type CustomerStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface SignInRequestedAction extends Action {\n type: CustomerStrategyActionType.SignInRequested;\n}\n\nexport interface SignInSucceededAction extends Action {\n type: CustomerStrategyActionType.SignInSucceeded;\n}\n\nexport interface SignInFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.SignInFailed;\n}\n\nexport interface SignOutRequestedAction extends Action {\n type: CustomerStrategyActionType.SignOutRequested;\n}\n\nexport interface SignOutSucceededAction extends Action {\n type: CustomerStrategyActionType.SignOutSucceeded;\n}\n\nexport interface SignOutFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.SignOutFailed;\n}\n\nexport interface ExecutePaymentMethodCheckoutRequestedAction extends Action {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested;\n}\n\nexport interface ExecutePaymentMethodCheckoutSucceededAction extends Action {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded;\n}\n\nexport interface ExecutePaymentMethodCheckoutFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: CustomerStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: CustomerStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: CustomerStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: CustomerStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: CustomerStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: CustomerStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers } from '@bigcommerce/data-store';\n\nimport { BillingAddressActionType, ContinueAsGuestAction } from '../billing';\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport Customer from './customer';\nimport { CustomerAction, CustomerActionType } from './customer-actions';\nimport CustomerState, { CustomerErrorsState, CustomerStatusesState, DEFAULT_STATE } from './customer-state';\n\nexport default function customerReducer(\n state: CustomerState = DEFAULT_STATE,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerState {\n const reducer = combineReducers<CustomerState, CheckoutAction | CustomerAction | ContinueAsGuestAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Customer | undefined,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): Customer | undefined {\n switch (action.type) {\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectMerge(data, action.payload && action.payload.customer);\n\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CustomerErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerErrorsState {\n switch (action.type) {\n case CustomerActionType.CreateCustomerRequested:\n case CustomerActionType.CreateCustomerSucceeded:\n return objectSet(errors, 'createError', undefined);\n\n case CustomerActionType.CreateCustomerFailed:\n return objectSet(errors, 'createError', action.payload);\n\n case CustomerActionType.CreateCustomerAddressRequested:\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectSet(errors, 'createAddressError', undefined);\n\n case CustomerActionType.CreateCustomerAddressFailed:\n return objectSet(errors, 'createAddressError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CustomerStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerStatusesState {\n switch (action.type) {\n case CustomerActionType.CreateCustomerRequested:\n return objectSet(statuses, 'isCreating', true);\n\n case CustomerActionType.CreateCustomerFailed:\n case CustomerActionType.CreateCustomerSucceeded:\n return objectSet(statuses, 'isCreating', false);\n\n case CustomerActionType.CreateCustomerAddressRequested:\n return objectSet(statuses, 'isCreatingAddress', true);\n\n case CustomerActionType.CreateCustomerAddressFailed:\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectSet(statuses, 'isCreatingAddress', false);\n default:\n return statuses;\n }\n}\n","export default interface CustomerStrategyState {\n data: CustomerStrategyDataState;\n errors: CustomerStrategyErrorsState;\n statuses: CustomerStrategyStatusesState;\n}\n\nexport interface CustomerStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface CustomerStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n signInError?: Error;\n signInMethodId?: string;\n signOutError?: Error;\n signOutMethodId?: string;\n executePaymentMethodCheckoutError?: Error;\n executePaymentMethodCheckoutMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface CustomerStrategyStatusesState {\n deinitializeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isInitializing?: boolean;\n isSigningIn?: boolean;\n isSigningOut?: boolean;\n signInMethodId?: string;\n signOutMethodId?: string;\n isExecutingPaymentMethodCheckout?: boolean;\n executePaymentMethodCheckoutMethodId?: string;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: CustomerStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { FormFields } from './form-field';\n\nexport enum FormFieldsActionType {\n LoadFormFieldsRequested = 'LOAD_FORM_FIELDS_REQUESTED',\n LoadFormFieldsSucceeded = 'LOAD_FORM_FIELDS_SUCCEEDED',\n LoadFormFieldsFailed = 'LOAD_FORM_FIELDS_FAILED',\n}\n\nexport type LoadFormFieldsAction =\n LoadFormFieldsRequestedAction |\n LoadFormFieldsSucceededAction |\n LoadFormFieldsFailedAction;\n\nexport interface LoadFormFieldsRequestedAction extends Action {\n type: FormFieldsActionType.LoadFormFieldsRequested;\n}\n\nexport interface LoadFormFieldsSucceededAction extends Action<FormFields> {\n type: FormFieldsActionType.LoadFormFieldsSucceeded;\n}\n\nexport interface LoadFormFieldsFailedAction extends Action<Error> {\n type: FormFieldsActionType.LoadFormFieldsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { CustomerStrategyAction, CustomerStrategyActionType } from './customer-strategy-actions';\nimport CustomerStrategyState, { CustomerStrategyDataState, CustomerStrategyErrorsState, CustomerStrategyStatusesState, DEFAULT_STATE } from './customer-strategy-state';\n\nexport default function customerStrategyReducer(\n state: CustomerStrategyState = DEFAULT_STATE,\n action: Action\n): CustomerStrategyState {\n const reducer = combineReducers<CustomerStrategyState, CustomerStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CustomerStrategyDataState = DEFAULT_STATE.data,\n action: CustomerStrategyAction\n): CustomerStrategyDataState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: CustomerStrategyErrorsState = DEFAULT_STATE.errors,\n action: CustomerStrategyAction\n): CustomerStrategyErrorsState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeRequested:\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.DeinitializeRequested:\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignInRequested:\n case CustomerStrategyActionType.SignInSucceeded:\n return objectMerge(errors, {\n signInError: undefined,\n signInMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignInFailed:\n return objectMerge(errors, {\n signInError: action.payload,\n signInMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignOutRequested:\n case CustomerStrategyActionType.SignOutSucceeded:\n return objectMerge(errors, {\n signOutError: undefined,\n signOutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignOutFailed:\n return objectMerge(errors, {\n signOutError: action.payload,\n signOutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested:\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded:\n return objectMerge(errors, {\n executePaymentMethodCheckoutError: undefined,\n executePaymentMethodCheckoutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed:\n return objectMerge(errors, {\n executePaymentMethodCheckoutError: action.payload,\n executePaymentMethodCheckoutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.WidgetInteractionStarted:\n case CustomerStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case CustomerStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CustomerStrategyStatusesState = DEFAULT_STATE.statuses,\n action: CustomerStrategyAction\n): CustomerStrategyStatusesState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.InitializeFailed:\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.DeinitializeFailed:\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignInRequested:\n return objectMerge(statuses, {\n isSigningIn: true,\n signInMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignInFailed:\n case CustomerStrategyActionType.SignInSucceeded:\n return objectMerge(statuses, {\n isSigningIn: false,\n signInMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignOutRequested:\n return objectMerge(statuses, {\n isSigningOut: true,\n signOutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignOutFailed:\n case CustomerStrategyActionType.SignOutSucceeded:\n return objectMerge(statuses, {\n isSigningOut: false,\n signOutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested:\n return objectMerge(statuses, {\n isExecutingPaymentMethodCheckout: true,\n executePaymentMethodCheckoutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed:\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded:\n return objectMerge(statuses, {\n isExecutingPaymentMethodCheckout: false,\n executePaymentMethodCheckoutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n case CustomerStrategyActionType.WidgetInteractionFinished:\n case CustomerStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { FormFields } from './form-field';\n\nexport default interface FormFieldsState {\n data?: FormFields;\n errors: FormFieldsErrorState;\n statuses: FormFieldsStatusesState;\n}\n\nexport interface FormFieldsErrorState {\n loadError?: Error;\n}\n\nexport interface FormFieldsStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: FormFieldsState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport Country from './country';\n\nexport enum CountryActionType {\n LoadCountriesRequested = 'LOAD_COUNTRIES_REQUESTED',\n LoadCountriesSucceeded = 'LOAD_COUNTRIES_SUCCEEDED',\n LoadCountriesFailed = 'LOAD_COUNTRIES_FAILED',\n}\n\nexport type LoadCountriesAction =\n LoadCountriesRequestedAction |\n LoadCountriesSucceededAction |\n LoadCountriesFailedAction;\n\nexport interface LoadCountriesRequestedAction extends Action {\n type: CountryActionType.LoadCountriesRequested;\n}\n\nexport interface LoadCountriesSucceededAction extends Action<Country[]> {\n type: CountryActionType.LoadCountriesSucceeded;\n}\n\nexport interface LoadCountriesFailedAction extends Action<Error> {\n type: CountryActionType.LoadCountriesFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { FormFields } from './form-field';\nimport { FormFieldsActionType, LoadFormFieldsAction } from './form-fields-actions';\nimport FormFieldsState, { DEFAULT_STATE, FormFieldsErrorState, FormFieldsStatusesState } from './form-fields-state';\n\nexport default function formFieldsReducer(\n state: FormFieldsState = DEFAULT_STATE,\n action: Action\n): FormFieldsState {\n const reducer = combineReducers<FormFieldsState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: FormFields | undefined,\n action: LoadFormFieldsAction\n): FormFields | undefined {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: FormFieldsErrorState = DEFAULT_STATE.errors,\n action: LoadFormFieldsAction\n): FormFieldsErrorState {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case FormFieldsActionType.LoadFormFieldsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: FormFieldsStatusesState = DEFAULT_STATE.statuses,\n action: LoadFormFieldsAction\n): FormFieldsStatusesState {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n case FormFieldsActionType.LoadFormFieldsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import Country from './country';\n\nexport default interface CountryState {\n data?: Country[];\n errors: CountryErrorsState;\n statuses: CountryStatusesState;\n}\n\nexport interface CountryErrorsState {\n loadError?: Error;\n}\n\nexport interface CountryStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: CountryState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\n\nimport Country from './country';\nimport { CountryActionType, LoadCountriesAction } from './country-actions';\nimport CountryState, { CountryErrorsState, CountryStatusesState, DEFAULT_STATE } from './country-state';\n\nexport default function countryReducer(\n state: CountryState = DEFAULT_STATE,\n action: Action\n): CountryState {\n const reducer = combineReducers<CountryState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Country[] | undefined,\n action: LoadCountriesAction\n): Country[] | undefined {\n switch (action.type) {\n case CountryActionType.LoadCountriesSucceeded:\n return arrayReplace(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CountryErrorsState = DEFAULT_STATE.errors,\n action: LoadCountriesAction\n): CountryErrorsState {\n switch (action.type) {\n case CountryActionType.LoadCountriesRequested:\n case CountryActionType.LoadCountriesSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CountryActionType.LoadCountriesFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CountryStatusesState = DEFAULT_STATE.statuses,\n action: LoadCountriesAction\n): CountryStatusesState {\n switch (action.type) {\n case CountryActionType.LoadCountriesRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CountryActionType.LoadCountriesSucceeded:\n case CountryActionType.LoadCountriesFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { Omit } from '../common/types';\n\nimport { InternalOrderMeta, InternalOrderPayment } from './internal-order';\nimport Order from './order';\n\nexport default interface OrderState {\n data?: OrderDataState;\n meta?: OrderMetaState;\n errors: OrderErrorsState;\n statuses: OrderStatusesState;\n}\n\nexport type OrderDataState = Omit<Order, 'billingAddress' | 'coupons'>;\n\nexport interface OrderMetaState extends InternalOrderMeta {\n token?: string;\n orderToken?: string;\n callbackUrl?: string;\n payment?: InternalOrderPayment;\n}\n\nexport interface OrderErrorsState {\n loadError?: Error;\n submitError?: Error;\n finalizeError?: Error;\n}\n\nexport interface OrderStatusesState {\n isLoading?: boolean;\n isSubmitting?: boolean;\n isFinalizing?: boolean;\n}\n\nexport const DEFAULT_STATE: OrderState = {\n errors: {},\n meta: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadOrderAction } from '../order';\n\nimport PaymentResponseBody from './payment-response-body';\n\nexport enum PaymentActionType {\n SubmitPaymentRequested = 'SUBMIT_PAYMENT_REQUESTED',\n SubmitPaymentSucceeded = 'SUBMIT_PAYMENT_SUCCEEDED',\n SubmitPaymentFailed = 'SUBMIT_PAYMENT_FAILED',\n\n InitializeOffsitePaymentRequested = 'INITIALIZE_OFFSITE_PAYMENT_REQUESTED',\n InitializeOffsitePaymentSucceeded = 'INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED',\n InitializeOffsitePaymentFailed = 'INITIALIZE_OFFSITE_PAYMENT_FAILED',\n}\n\nexport type PaymentAction = SubmitPaymentAction |\n InitializeOffsitePaymentAction;\n\nexport type SubmitPaymentAction =\n SubmitPaymentRequestedAction |\n SubmitPaymentSucceededAction |\n SubmitPaymentFailedAction |\n LoadOrderAction;\n\nexport type InitializeOffsitePaymentAction =\n InitializeOffsitePaymentRequestedAction |\n InitializeOffsitePaymentSucceededAction |\n InitializeOffsitePaymentFailedAction;\n\nexport interface SubmitPaymentRequestedAction extends Action {\n type: PaymentActionType.SubmitPaymentRequested;\n}\n\nexport interface SubmitPaymentSucceededAction extends Action<PaymentResponseBody> {\n type: PaymentActionType.SubmitPaymentSucceeded;\n}\n\nexport interface SubmitPaymentFailedAction extends Action<Error> {\n type: PaymentActionType.SubmitPaymentFailed;\n}\n\nexport interface InitializeOffsitePaymentRequestedAction extends Action {\n type: PaymentActionType.InitializeOffsitePaymentRequested;\n}\n\nexport interface InitializeOffsitePaymentSucceededAction extends Action {\n type: PaymentActionType.InitializeOffsitePaymentSucceeded;\n}\n\nexport interface InitializeOffsitePaymentFailedAction extends Action<Error> {\n type: PaymentActionType.InitializeOffsitePaymentFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\n\nexport enum PaymentMethodActionType {\n LoadPaymentMethodRequested = 'LOAD_PAYMENT_METHOD_REQUESTED',\n LoadPaymentMethodSucceeded = 'LOAD_PAYMENT_METHOD_SUCCEEDED',\n LoadPaymentMethodFailed = 'LOAD_PAYMENT_METHOD_FAILED',\n\n LoadPaymentMethodsRequested = 'LOAD_PAYMENT_METHODS_REQUESTED',\n LoadPaymentMethodsSucceeded = 'LOAD_PAYMENT_METHODS_SUCCEEDED',\n LoadPaymentMethodsFailed = 'LOAD_PAYMENT_METHODS_FAILED',\n}\n\nexport type PaymentMethodAction = LoadPaymentMethodAction | LoadPaymentMethodsAction;\n\nexport type LoadPaymentMethodAction =\n LoadPaymentMethodRequestedAction |\n LoadPaymentMethodSucceededAction |\n LoadPaymentMethodFailedAction;\n\nexport type LoadPaymentMethodsAction =\n LoadPaymentMethodsRequestedAction |\n LoadPaymentMethodsSucceededAction |\n LoadPaymentMethodsFailedAction;\n\nexport interface LoadPaymentMethodRequestedAction extends Action {\n type: PaymentMethodActionType.LoadPaymentMethodRequested;\n}\n\nexport interface LoadPaymentMethodSucceededAction extends Action<PaymentMethod> {\n type: PaymentMethodActionType.LoadPaymentMethodSucceeded;\n}\n\nexport interface LoadPaymentMethodFailedAction extends Action<Error> {\n type: PaymentMethodActionType.LoadPaymentMethodFailed;\n}\n\nexport interface LoadPaymentMethodsRequestedAction extends Action {\n type: PaymentMethodActionType.LoadPaymentMethodsRequested;\n}\n\nexport interface LoadPaymentMethodsSucceededAction extends Action<PaymentMethod[], PaymentMethodMeta> {\n type: PaymentMethodActionType.LoadPaymentMethodsSucceeded;\n}\n\nexport interface LoadPaymentMethodsFailedAction extends Action<Error> {\n type: PaymentMethodActionType.LoadPaymentMethodsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\nimport { omit } from 'lodash';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { OrderAction, OrderActionType } from './order-actions';\nimport OrderState, { DEFAULT_STATE, OrderDataState, OrderErrorsState, OrderMetaState, OrderStatusesState } from './order-state';\n\nexport default function orderReducer(\n state: OrderState = DEFAULT_STATE,\n action: Action\n): OrderState {\n const reducer = combineReducers<OrderState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: OrderDataState | undefined,\n action: OrderAction\n): OrderDataState | undefined {\n switch (action.type) {\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n return objectMerge(data, omit(action.payload, ['billingAddress', 'coupons'])) as OrderDataState;\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: OrderMetaState | undefined,\n action: OrderAction\n): OrderMetaState | undefined {\n switch (action.type) {\n case OrderActionType.FinalizeOrderSucceeded:\n case OrderActionType.SubmitOrderSucceeded:\n return objectMerge(meta, {\n ...action.meta,\n callbackUrl: action.payload && action.payload.order.callbackUrl,\n orderToken: action.payload && action.payload.order.token,\n payment: action.payload && action.payload.order && action.payload.order.payment,\n });\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: OrderErrorsState = DEFAULT_STATE.errors,\n action: OrderAction\n): OrderErrorsState {\n switch (action.type) {\n case OrderActionType.LoadOrderRequested:\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n case OrderActionType.LoadOrderPaymentsRequested:\n return objectSet(errors, 'loadError', undefined);\n\n case OrderActionType.LoadOrderFailed:\n case OrderActionType.LoadOrderPaymentsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: OrderStatusesState = DEFAULT_STATE.statuses,\n action: OrderAction\n): OrderStatusesState {\n switch (action.type) {\n case OrderActionType.LoadOrderRequested:\n case OrderActionType.LoadOrderPaymentsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderFailed:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n case OrderActionType.LoadOrderPaymentsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { PaymentAction, PaymentActionType } from './payment-actions';\nimport PaymentResponseBody from './payment-response-body';\nimport PaymentState from './payment-state';\n\nexport default function paymentReducer(state: PaymentState = {}, action: PaymentAction): PaymentState {\n const reducer = combineReducers<PaymentState, PaymentAction>({\n data: dataReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(data: PaymentResponseBody | undefined, action: PaymentAction): PaymentResponseBody | undefined {\n switch (action.type) {\n case PaymentActionType.SubmitPaymentSucceeded:\n return action.payload;\n\n default:\n return data;\n }\n}\n","import PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\n\nexport default interface PaymentMethodState {\n data?: PaymentMethod[];\n meta?: PaymentMethodMeta;\n errors: PaymentMethodErrorsState;\n statuses: PaymentMethodStatusesState;\n}\n\nexport interface PaymentMethodErrorsState {\n loadMethodId?: string;\n loadError?: Error;\n loadMethodError?: Error;\n}\n\nexport interface PaymentMethodStatusesState {\n loadMethodId?: string;\n isLoading?: boolean;\n isLoadingMethod?: boolean;\n}\n\nexport const DEFAULT_STATE: PaymentMethodState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadOrderPaymentsAction } from '../order';\n\nexport enum PaymentStrategyActionType {\n ExecuteFailed = 'PAYMENT_STRATEGY_EXECUTE_FAILED',\n ExecuteRequested = 'PAYMENT_STRATEGY_EXECUTE_REQUESTED',\n ExecuteSucceeded = 'PAYMENT_STRATEGY_EXECUTE_SUCCEEDED',\n FinalizeFailed = 'PAYMENT_STRATEGY_FINALIZE_FAILED',\n FinalizeRequested = 'PAYMENT_STRATEGY_FINALIZE_REQUESTED',\n FinalizeSucceeded = 'PAYMENT_STRATEGY_FINALIZE_SUCCEEDED',\n InitializeFailed = 'PAYMENT_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'PAYMENT_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'PAYMENT_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type PaymentStrategyAction =\n PaymentStrategyExecuteAction |\n PaymentStrategyFinalizeAction |\n PaymentStrategyInitializeAction |\n PaymentStrategyDeinitializeAction |\n PaymentStrategyWidgetAction;\n\nexport type PaymentStrategyExecuteAction =\n ExecuteRequestedAction |\n ExecuteSucceededAction |\n ExecuteFailedAction |\n LoadOrderPaymentsAction;\n\nexport type PaymentStrategyFinalizeAction =\n FinalizeRequestedAction |\n FinalizeSucceededAction |\n FinalizeFailedAction |\n LoadOrderPaymentsAction;\n\nexport type PaymentStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type PaymentStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type PaymentStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface ExecuteRequestedAction extends Action {\n type: PaymentStrategyActionType.ExecuteRequested;\n}\n\nexport interface ExecuteSucceededAction extends Action {\n type: PaymentStrategyActionType.ExecuteSucceeded;\n}\n\nexport interface ExecuteFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.ExecuteFailed;\n}\n\nexport interface FinalizeRequestedAction extends Action {\n type: PaymentStrategyActionType.FinalizeRequested;\n}\n\nexport interface FinalizeSucceededAction extends Action {\n type: PaymentStrategyActionType.FinalizeSucceeded;\n}\n\nexport interface FinalizeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.FinalizeFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: PaymentStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: PaymentStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: PaymentStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: PaymentStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: PaymentStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: PaymentStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, mergeOrPush, objectMerge, objectSet } from '../common/utility';\n\nimport PaymentMethod from './payment-method';\nimport { PaymentMethodAction, PaymentMethodActionType } from './payment-method-actions';\nimport PaymentMethodMeta from './payment-method-meta';\nimport PaymentMethodState, { DEFAULT_STATE, PaymentMethodErrorsState, PaymentMethodStatusesState } from './payment-method-state';\n\nexport default function paymentMethodReducer(\n state: PaymentMethodState = DEFAULT_STATE,\n action: Action\n): PaymentMethodState {\n const reducer = combineReducers<PaymentMethodState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentMethod[] | undefined,\n action: PaymentMethodAction\n): PaymentMethod[] | undefined {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n return mergeOrPush(data || [], action.payload, action.payload && {\n id: action.payload.id,\n gateway: action.payload.gateway,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return arrayReplace(data, action.payload, {\n matchObject: (methodA, methodB) => (\n methodA.id === methodB.id && methodA.gateway === methodB.gateway\n ),\n });\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: PaymentMethodMeta | undefined,\n action: PaymentMethodAction\n): PaymentMethodMeta | undefined {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return objectMerge(meta, action.meta);\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: PaymentMethodErrorsState = DEFAULT_STATE.errors,\n action: PaymentMethodAction\n): PaymentMethodErrorsState {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsRequested:\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case PaymentMethodActionType.LoadPaymentMethodsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case PaymentMethodActionType.LoadPaymentMethodRequested:\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n return objectMerge(errors, {\n loadMethodId: undefined,\n loadMethodError: undefined,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodFailed:\n return objectMerge(errors, {\n loadMethodId: action.meta.methodId,\n loadMethodError: action.payload,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PaymentMethodStatusesState = DEFAULT_STATE.statuses,\n action: PaymentMethodAction\n): PaymentMethodStatusesState {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n case PaymentMethodActionType.LoadPaymentMethodsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case PaymentMethodActionType.LoadPaymentMethodRequested:\n return objectMerge(statuses, {\n isLoadingMethod: true,\n loadMethodId: action.meta.methodId,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n case PaymentMethodActionType.LoadPaymentMethodFailed:\n return objectMerge(statuses, {\n isLoadingMethod: false,\n loadMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { findIndex, pick, pickBy, ValueKeyIteratee } from 'lodash';\n\nimport isPlainObject from './is-plain-object';\nimport objectMerge from './object-merge';\n\n/**\n * Push an item to an array if it doesn't exist in the array. Otherwise, merge\n * with the existing item in the array. This function always returns a new array.\n */\nexport default function mergeOrPush<T>(\n array: T[],\n item?: T,\n predicate?: ValueKeyIteratee<T>\n): T[] {\n if (!item) {\n return array;\n }\n\n const defaultPredicate = pick(item, 'id');\n const index = findIndex(array, typeof predicate === 'object' ? pickBy(predicate) : (predicate || defaultPredicate));\n const newArray = [...array];\n\n if (index === -1) {\n newArray.push(item);\n } else {\n const existingItem = array[index];\n\n newArray[index] = isPlainObject(existingItem) && isPlainObject(item) ?\n objectMerge(existingItem, item) :\n item;\n }\n\n return newArray;\n}\n","export default interface PaymentStrategyState {\n data: PaymentStrategyDataState;\n errors: PaymentStrategyErrorsState;\n statuses: PaymentStrategyStatusesState;\n}\n\nexport interface PaymentStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface PaymentStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n executeError?: Error;\n executeMethodId?: string;\n finalizeError?: Error;\n finalizeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface PaymentStrategyStatusesState {\n deinitializeMethodId?: string;\n executeMethodId?: string;\n finalizeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isExecuting?: boolean;\n isFinalizing?: boolean;\n isInitializing?: boolean;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: PaymentStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { VaultAccessToken } from './instrument';\nimport { InstrumentsResponseBody } from './instrument-response-body';\n\nexport enum InstrumentActionType {\n LoadInstrumentsRequested = 'LOAD_INSTRUMENTS_REQUESTED',\n LoadInstrumentsSucceeded = 'LOAD_INSTRUMENTS_SUCCEEDED',\n LoadInstrumentsFailed = 'LOAD_INSTRUMENTS_FAILED',\n\n DeleteInstrumentRequested = 'DELETE_INSTRUMENT_REQUESTED',\n DeleteInstrumentSucceeded = 'DELETE_INSTRUMENT_SUCCEEDED',\n DeleteInstrumentFailed = 'DELETE_INSTRUMENT_FAILED',\n}\n\nexport type InstrumentAction =\n LoadInstrumentsAction |\n DeleteInstrumentAction;\n\nexport type LoadInstrumentsAction =\n LoadInstrumentsRequestedAction |\n LoadInstrumentsSucceededAction |\n LoadInstrumentsFailedAction;\n\nexport type DeleteInstrumentAction =\n DeleteInstrumentRequestedAction |\n DeleteInstrumentSucceededAction |\n DeleteInstrumentFailedAction;\n\nexport interface LoadInstrumentsRequestedAction extends Action {\n type: InstrumentActionType.LoadInstrumentsRequested;\n}\n\nexport interface LoadInstrumentsSucceededAction extends Action<InstrumentsResponseBody, VaultAccessToken> {\n type: InstrumentActionType.LoadInstrumentsSucceeded;\n}\n\nexport interface LoadInstrumentsFailedAction extends Action<Error> {\n type: InstrumentActionType.LoadInstrumentsFailed;\n}\n\nexport interface DeleteInstrumentRequestedAction extends Action {\n type: InstrumentActionType.DeleteInstrumentRequested;\n}\n\nexport interface DeleteInstrumentSucceededAction extends Action<InstrumentsResponseBody, VaultAccessToken & { instrumentId: string }> {\n type: InstrumentActionType.DeleteInstrumentSucceeded;\n}\n\nexport interface DeleteInstrumentFailedAction extends Action<Error> {\n type: InstrumentActionType.DeleteInstrumentFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { PaymentStrategyAction, PaymentStrategyActionType } from './payment-strategy-actions';\nimport PaymentStrategyState, { DEFAULT_STATE, PaymentStrategyDataState, PaymentStrategyErrorsState, PaymentStrategyStatusesState } from './payment-strategy-state';\n\nexport default function paymentStrategyReducer(\n state: PaymentStrategyState = DEFAULT_STATE,\n action: Action\n): PaymentStrategyState {\n const reducer = combineReducers<PaymentStrategyState, PaymentStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentStrategyDataState = DEFAULT_STATE.data,\n action: PaymentStrategyAction\n): PaymentStrategyDataState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: PaymentStrategyErrorsState = DEFAULT_STATE.errors,\n action: PaymentStrategyAction\n): PaymentStrategyErrorsState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeRequested:\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.DeinitializeRequested:\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.ExecuteRequested:\n case PaymentStrategyActionType.ExecuteSucceeded:\n return objectMerge(errors, {\n executeError: undefined,\n executeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.ExecuteFailed:\n return objectMerge(errors, {\n executeError: action.payload,\n executeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.FinalizeRequested:\n case PaymentStrategyActionType.FinalizeSucceeded:\n return objectMerge(errors, {\n finalizeError: undefined,\n finalizeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.FinalizeFailed:\n return objectMerge(errors, {\n finalizeError: action.payload,\n finalizeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.WidgetInteractionStarted:\n case PaymentStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case PaymentStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PaymentStrategyStatusesState = DEFAULT_STATE.statuses,\n action: PaymentStrategyAction\n): PaymentStrategyStatusesState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.InitializeFailed:\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.DeinitializeFailed:\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.ExecuteRequested:\n return objectMerge(statuses, {\n isExecuting: true,\n executeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.ExecuteFailed:\n case PaymentStrategyActionType.ExecuteSucceeded:\n return objectMerge(statuses, {\n isExecuting: false,\n executeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.FinalizeRequested:\n return objectMerge(statuses, {\n isFinalizing: true,\n finalizeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.FinalizeFailed:\n case PaymentStrategyActionType.FinalizeSucceeded:\n return objectMerge(statuses, {\n isFinalizing: false,\n finalizeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n case PaymentStrategyActionType.WidgetInteractionFinished:\n case PaymentStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import PaymentInstrument, { VaultAccessToken } from './instrument';\n\nexport default interface InstrumentState {\n data?: PaymentInstrument[];\n meta?: InstrumentMeta;\n errors: InstrumentErrorState;\n statuses: InstrumentStatusState;\n}\n\nexport interface InstrumentErrorState {\n deleteError?: Error;\n failedInstrument?: string;\n loadError?: Error;\n vaultError?: Error;\n}\n\nexport interface InstrumentStatusState {\n isDeleting?: boolean;\n isLoading?: boolean;\n isVaulting?: boolean;\n deletingInstrument?: string;\n}\n\nexport type InstrumentMeta = VaultAccessToken;\n\nexport const DEFAULT_STATE = {\n data: [],\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { AmazonPayRemoteCheckout } from './methods';\n\nexport enum RemoteCheckoutActionType {\n ForgetCheckoutRemoteCustomerRequested = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED',\n ForgetCheckoutRemoteCustomerSucceeded = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED',\n ForgetCheckoutRemoteCustomerFailed = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED',\n\n InitializeRemoteBillingRequested = 'INITIALIZE_REMOTE_BILLING_REQUESTED',\n InitializeRemoteBillingSucceeded = 'INITIALIZE_REMOTE_BILLING_SUCCEEDED',\n InitializeRemoteBillingFailed = 'INITIALIZE_REMOTE_BILLING_FAILED',\n\n InitializeRemoteShippingRequested = 'INITIALIZE_REMOTE_SHIPPING_REQUESTED',\n InitializeRemoteShippingSucceeded = 'INITIALIZE_REMOTE_SHIPPING_SUCCEEDED',\n InitializeRemoteShippingFailed = 'INITIALIZE_REMOTE_SHIPPING_FAILED',\n\n InitializeRemotePaymentRequested = 'INITIALIZE_REMOTE_PAYMENT_REQUESTED',\n InitializeRemotePaymentSucceeded = 'INITIALIZE_REMOTE_PAYMENT_SUCCEEDED',\n InitializeRemotePaymentFailed = 'INITIALIZE_REMOTE_PAYMENT_FAILED',\n\n LoadRemoteSettingsRequested = 'LOAD_REMOTE_SETTINGS_REQUESTED',\n LoadRemoteSettingsSucceeded = 'LOAD_REMOTE_SETTINGS_SUCCEEDED',\n LoadRemoteSettingsFailed = 'LOAD_REMOTE_SETTINGS_FAILED',\n\n SignOutRemoteCustomerRequested = 'SIGN_OUT_REMOTE_CUSTOMER_REQUESTED',\n SignOutRemoteCustomerSucceeded = 'SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED',\n SignOutRemoteCustomerFailed = 'SIGN_OUT_REMOTE_CUSTOMER_FAILED',\n\n UpdateRemoteCheckout = 'UPDATE_REMOTE_CHECKOUT',\n}\n\nexport type RemoteCheckoutAction = ForgetCheckoutRemoteCustomerAction |\n InitializeRemoteBillingAction |\n InitializeRemoteShippingAction |\n InitializeRemotePaymentAction |\n SignOutRemoteCustomerAction |\n LoadRemoteSettingsAction |\n UpdateRemoteCheckoutAction;\n\nexport type ForgetCheckoutRemoteCustomerAction = ForgetCheckoutRemoteCustomerRequestedAction |\n ForgetCheckoutRemoteCustomerSucceededAction |\n ForgetCheckoutRemoteCustomerFailedAction;\n\nexport interface ForgetCheckoutRemoteCustomerRequestedAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerRequested;\n}\n\nexport interface ForgetCheckoutRemoteCustomerSucceededAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerSucceeded;\n}\n\nexport interface ForgetCheckoutRemoteCustomerFailedAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerFailed;\n}\n\nexport type InitializeRemoteBillingAction = InitializeRemoteBillingSucceededAction |\n InitializeRemoteBillingFailedAction |\n InitializeRemoteBillingRequestedAction;\n\nexport interface InitializeRemoteBillingSucceededAction extends Action<AmazonPayRemoteCheckout> {\n type: RemoteCheckoutActionType.InitializeRemoteBillingSucceeded;\n}\n\nexport interface InitializeRemoteBillingFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteBillingFailed;\n}\n\nexport interface InitializeRemoteBillingRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteBillingRequested;\n}\n\nexport type InitializeRemoteShippingAction = InitializeRemoteShippingSucceededAction |\n InitializeRemoteShippingFailedAction |\n InitializeRemoteShippingRequestedAction;\n\nexport interface InitializeRemoteShippingSucceededAction extends Action<AmazonPayRemoteCheckout> {\n type: RemoteCheckoutActionType.InitializeRemoteShippingSucceeded;\n}\n\nexport interface InitializeRemoteShippingFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteShippingFailed;\n}\n\nexport interface InitializeRemoteShippingRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteShippingRequested;\n}\n\nexport type InitializeRemotePaymentAction = InitializeRemotePaymentSucceededAction |\n InitializeRemotePaymentFailedAction |\n InitializeRemotePaymentRequestedAction;\n\nexport interface InitializeRemotePaymentSucceededAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentSucceeded;\n}\n\nexport interface InitializeRemotePaymentFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentFailed;\n}\n\nexport interface InitializeRemotePaymentRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentRequested;\n}\n\nexport type SignOutRemoteCustomerAction = SignOutRemoteCustomerSucceededAction |\n SignOutRemoteCustomerFailedAction |\n SignOutRemoteCustomerRequestedAction;\n\nexport interface SignOutRemoteCustomerSucceededAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerSucceeded;\n}\n\nexport interface SignOutRemoteCustomerFailedAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerFailed;\n}\n\nexport interface SignOutRemoteCustomerRequestedAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerRequested;\n}\n\nexport type LoadRemoteSettingsAction = LoadRemoteSettingsSucceededAction |\n LoadRemoteSettingsRequestedAction |\n LoadRemoteSettingsFailedAction;\n\nexport interface LoadRemoteSettingsSucceededAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsSucceeded;\n}\n\nexport interface LoadRemoteSettingsRequestedAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsRequested;\n}\n\nexport interface LoadRemoteSettingsFailedAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsFailed;\n}\n\nexport interface UpdateRemoteCheckoutAction extends Action {\n type: RemoteCheckoutActionType.UpdateRemoteCheckout;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../../common/error';\nimport { arrayReplace, objectMerge, objectSet } from '../../common/utility';\n\nimport PaymentInstrument from './instrument';\nimport { InstrumentAction, InstrumentActionType } from './instrument-actions';\nimport InstrumentState, { DEFAULT_STATE, InstrumentErrorState, InstrumentMeta, InstrumentStatusState } from './instrument-state';\n\nexport default function instrumentReducer(\n state: InstrumentState = DEFAULT_STATE,\n action: Action\n): InstrumentState {\n const reducer = combineReducers<InstrumentState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentInstrument[] = DEFAULT_STATE.data,\n action: InstrumentAction\n): PaymentInstrument[] {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsSucceeded:\n return arrayReplace(data, action.payload && action.payload.vaultedInstruments || []);\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: InstrumentMeta | undefined,\n action: InstrumentAction\n): InstrumentMeta | undefined {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsSucceeded:\n case InstrumentActionType.DeleteInstrumentSucceeded:\n return objectMerge(meta, action.meta);\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: InstrumentErrorState = DEFAULT_STATE.errors,\n action: InstrumentAction\n): InstrumentErrorState {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsRequested:\n case InstrumentActionType.LoadInstrumentsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case InstrumentActionType.DeleteInstrumentRequested:\n case InstrumentActionType.DeleteInstrumentSucceeded:\n return objectMerge(errors, {\n deleteError: undefined,\n failedInstrument: undefined,\n });\n\n case InstrumentActionType.LoadInstrumentsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case InstrumentActionType.DeleteInstrumentFailed:\n return objectMerge(errors, {\n deleteError: action.payload,\n failedInstrument: action.meta.instrumentId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: InstrumentStatusState = DEFAULT_STATE.statuses,\n action: InstrumentAction\n): InstrumentStatusState {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case InstrumentActionType.DeleteInstrumentRequested:\n return objectMerge(statuses, {\n isDeleting: true,\n deletingInstrument: action.meta.instrumentId,\n });\n\n case InstrumentActionType.LoadInstrumentsSucceeded:\n case InstrumentActionType.LoadInstrumentsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case InstrumentActionType.DeleteInstrumentSucceeded:\n case InstrumentActionType.DeleteInstrumentFailed:\n return objectMerge(statuses, {\n isDeleting: false,\n deletingInstrument: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { AmazonPayRemoteCheckout } from './methods';\n\nexport default interface RemoteCheckoutState {\n data: RemoteCheckoutStateData;\n}\n\nexport interface RemoteCheckoutStateData {\n amazon?: AmazonPayRemoteCheckout;\n}\n\nexport const DEFAULT_STATE: RemoteCheckoutState = {\n data: {},\n};\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport RemoteCheckout from './remote-checkout';\nimport { RemoteCheckoutAction, RemoteCheckoutActionType } from './remote-checkout-actions';\nimport RemoteCheckoutState, { DEFAULT_STATE, RemoteCheckoutStateData } from './remote-checkout-state';\n\nexport default function remoteCheckoutReducer(\n state: RemoteCheckoutState = DEFAULT_STATE,\n action: RemoteCheckoutAction\n): RemoteCheckoutState {\n if (!action.meta || !action.meta.methodId) {\n return state;\n }\n\n const reducer = combineReducers<RemoteCheckoutState>({\n data: combineReducers<RemoteCheckoutStateData>({\n [action.meta.methodId]: dataReducer,\n }),\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: RemoteCheckout,\n action: RemoteCheckoutAction\n): RemoteCheckout {\n switch (action.type) {\n case RemoteCheckoutActionType.InitializeRemoteBillingSucceeded:\n return objectSet(data, 'billing' as any, action.payload && action.payload.billing);\n\n case RemoteCheckoutActionType.InitializeRemoteShippingSucceeded:\n return objectSet(data, 'shipping' as any, action.payload && action.payload.shipping);\n\n case RemoteCheckoutActionType.LoadRemoteSettingsSucceeded:\n return objectSet(data, 'settings', action.payload);\n\n case RemoteCheckoutActionType.UpdateRemoteCheckout:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n","import Consignment from './consignment';\n\nexport default interface ConsignmentState {\n data?: Consignment[];\n errors: ConsignmentErrorsState;\n statuses: ConsignmentStatusesState;\n}\n\nexport interface ConsignmentErrorsState {\n loadError?: Error;\n loadShippingOptionsError?: Error;\n createError?: Error;\n updateError: { [key: string]: Error | undefined };\n deleteError: { [key: string]: Error | undefined };\n updateShippingOptionError: { [key: string]: Error | undefined };\n}\n\nexport interface ConsignmentStatusesState {\n isLoading?: boolean;\n isLoadingShippingOptions?: boolean;\n isCreating?: boolean;\n isUpdating: { [key: string]: boolean };\n isDeleting: { [key: string]: boolean };\n isUpdatingShippingOption: { [key: string]: boolean };\n}\n\nexport const DEFAULT_STATE: ConsignmentState = {\n errors: {\n updateShippingOptionError: {},\n updateError: {},\n deleteError: {},\n },\n statuses: {\n isUpdating: {},\n isUpdatingShippingOption: {},\n isDeleting: {},\n },\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { PickupOptionMeta, PickupOptionResult } from './pickup-option';\n\nexport enum PickupOptionActionType {\n LoadPickupOptionsRequested = 'LOAD_PICKUP_OPTIONS_REQUESTED',\n LoadPickupOptionsSucceeded = 'LOAD_PICKUP_OPTIONS_SUCCEEDED',\n LoadPickupOptionsFailed = 'LOAD_PICKUP_OPTIONS_FAILED',\n}\n\nexport type LoadPickupOptionsAction =\n PickupOptionRequestedAction |\n LoadPickupOptionsSucceededAction |\n LoadPickupOptionsFailedAction;\n\nexport interface PickupOptionRequestedAction extends Action {\n type: PickupOptionActionType.LoadPickupOptionsRequested;\n}\n\nexport interface LoadPickupOptionsSucceededAction extends Action<PickupOptionResult[], PickupOptionMeta> {\n type: PickupOptionActionType.LoadPickupOptionsSucceeded;\n}\n\nexport interface LoadPickupOptionsFailedAction extends Action<Error> {\n type: PickupOptionActionType.LoadPickupOptionsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType } from '../coupon';\nimport { CustomerAction, CustomerActionType } from '../customer';\n\nimport Consignment from './consignment';\nimport { ConsignmentAction, ConsignmentActionType } from './consignment-actions';\nimport ConsignmentState, { ConsignmentErrorsState, ConsignmentStatusesState, DEFAULT_STATE } from './consignment-state';\n\nexport default function consignmentReducer(\n state: ConsignmentState = DEFAULT_STATE,\n action: Action\n): ConsignmentState {\n const reducer = combineReducers<ConsignmentState, ConsignmentAction | CheckoutAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Consignment[] | undefined,\n action: ConsignmentAction | CheckoutAction | CouponAction | CustomerAction\n): Consignment[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n return arrayReplace(data, action.payload && action.payload.consignments);\n\n case CustomerActionType.SignOutCustomerSucceeded:\n return arrayReplace(data, []);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ConsignmentErrorsState = DEFAULT_STATE.errors,\n action: ConsignmentAction | CheckoutAction\n): ConsignmentErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.LoadShippingOptionsRequested:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case ConsignmentActionType.LoadShippingOptionsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case ConsignmentActionType.CreateConsignmentsRequested:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n return objectSet(errors, 'createError', undefined);\n\n case ConsignmentActionType.CreateConsignmentsFailed:\n return objectSet(errors, 'createError', action.payload);\n\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentRequested:\n if (action.meta) {\n return objectMerge(errors, {\n updateError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateConsignmentFailed:\n if (action.meta) {\n return objectMerge(errors, {\n updateError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentRequested:\n if (action.meta) {\n return objectMerge(errors, {\n deleteError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.DeleteConsignmentFailed:\n if (action.meta) {\n return objectMerge(errors, {\n deleteError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateShippingOptionRequested:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n if (action.meta) {\n return objectMerge(errors, {\n updateShippingOptionError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateShippingOptionFailed:\n if (action.meta) {\n return objectMerge(errors, {\n updateShippingOptionError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ConsignmentStatusesState = DEFAULT_STATE.statuses,\n action: ConsignmentAction | CheckoutAction\n): ConsignmentStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ConsignmentActionType.LoadShippingOptionsRequested:\n return objectSet(statuses, 'isLoadingShippingOptions', true);\n\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.LoadShippingOptionsFailed:\n return objectSet(statuses, 'isLoadingShippingOptions', false);\n\n case ConsignmentActionType.CreateConsignmentsRequested:\n return objectSet(statuses, 'isCreating', true);\n\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.CreateConsignmentsFailed:\n return objectSet(statuses, 'isCreating', false);\n\n case ConsignmentActionType.UpdateConsignmentRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdating: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdating: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.DeleteConsignmentRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isDeleting: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isDeleting: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateShippingOptionRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdatingShippingOption: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.UpdateShippingOptionFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdatingShippingOption: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n default:\n return statuses;\n }\n}\n","/**\n * Takes a nested object and flattens it.\n */\nexport default function objectFlatten(\n object: { [ key: string ]: any },\n parent?: string\n): { [ key: string ]: any } {\n const flattened: {[key: string]: any} = {};\n Object.keys(object).forEach((key: string) => {\n const value = object[key];\n const keyString = parent ? parent + '.' + key : key;\n if (typeof value === 'object') {\n Object.assign(flattened, objectFlatten(value, keyString));\n } else {\n flattened[keyString] = value;\n }\n });\n\n return flattened;\n}\n","export default function objectWithSortedKeys(\n object: { [ key: string ]: any }\n) {\n const keys = Object.keys(object);\n const sortedKeys = keys.sort();\n\n const sortedArray = sortedKeys.reduce((previous, current) => ({\n ...previous,\n [current]: object[current],\n }), {});\n\n return sortedArray;\n}\n","import { PickupOptionQueryMap } from './pickup-option';\n\nexport default interface PickupOptionState {\n data?: PickupOptionQueryMap;\n errors: PickupOptionErrorsState;\n statuses: PickupOptionStatusesState;\n}\n\nexport interface PickupOptionErrorsState {\n loadError?: Error;\n}\n\nexport interface PickupOptionStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: PickupOptionState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Country } from '../geography';\n\nexport enum ShippingCountryActionType {\n LoadShippingCountriesRequested = 'LOAD_SHIPPING_COUNTRIES_REQUESTED',\n LoadShippingCountriesSucceeded = 'LOAD_SHIPPING_COUNTRIES_SUCCEEDED',\n LoadShippingCountriesFailed = 'LOAD_SHIPPING_COUNTRIES_FAILED',\n}\n\nexport type LoadShippingCountriesAction = LoadShippingCountriesRequestedAction |\n LoadShippingCountriesSucceededAction |\n LoadShippingCountriesFailedAction;\n\nexport interface LoadShippingCountriesRequestedAction extends Action {\n type: ShippingCountryActionType.LoadShippingCountriesRequested;\n}\n\nexport interface LoadShippingCountriesSucceededAction extends Action<Country[]> {\n type: ShippingCountryActionType.LoadShippingCountriesSucceeded;\n}\n\nexport interface LoadShippingCountriesFailedAction extends Action<Error> {\n type: ShippingCountryActionType.LoadShippingCountriesFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectFlatten, objectSet, objectWithSortedKeys } from '../common/utility';\n\nimport { PickupOptionQueryMap } from './pickup-option';\nimport { LoadPickupOptionsAction, PickupOptionActionType } from './pickup-option-actions';\nimport PickupOptionState, { DEFAULT_STATE, PickupOptionErrorsState, PickupOptionStatusesState } from './pickup-option-state';\n\nexport default function pickupOptionReducer(\n state: PickupOptionState = DEFAULT_STATE,\n action: Action\n): PickupOptionState {\n const reducer = combineReducers<PickupOptionState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PickupOptionQueryMap | undefined,\n action: LoadPickupOptionsAction\n): PickupOptionQueryMap | undefined {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n if (action.meta) {\n const optionQuery = {\n consignmentId: action.meta.consignmentId,\n searchArea: action.meta.searchArea,\n };\n const flattenedMeta = objectFlatten(optionQuery);\n const sortedflattenedMeta = objectWithSortedKeys(flattenedMeta);\n const keyString = btoa(`${JSON.stringify(sortedflattenedMeta)}`);\n\n return objectSet(data, keyString , action.payload);\n }\n break;\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: PickupOptionErrorsState = DEFAULT_STATE.errors,\n action: Action\n) {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsRequested:\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case PickupOptionActionType.LoadPickupOptionsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PickupOptionStatusesState = DEFAULT_STATE.statuses,\n action: Action\n) {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsRequested:\n return objectSet(statuses, 'isLoading', true);\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n case PickupOptionActionType.LoadPickupOptionsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { Country } from '../geography';\n\nexport default interface ShippingCountryState {\n data?: Country[];\n errors: ShippingCountryErrorsState;\n statuses: ShippingCountryStatusesState;\n}\n\nexport interface ShippingCountryErrorsState {\n loadError?: Error;\n}\n\nexport interface ShippingCountryStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: ShippingCountryState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum ShippingStrategyActionType {\n UpdateAddressFailed = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED',\n UpdateAddressRequested = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED',\n UpdateAddressSucceeded = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED',\n SelectOptionFailed = 'SHIPPING_STRATEGY_SELECT_OPTION_FAILED',\n SelectOptionRequested = 'SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED',\n SelectOptionSucceeded = 'SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED',\n InitializeFailed = 'SHIPPING_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'SHIPPING_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'SHIPPING_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type ShippingStrategyAction =\n ShippingStrategyUpdateAddressAction |\n ShippingStrategySelectOptionAction |\n ShippingStrategyInitializeAction |\n ShippingStrategyDeinitializeAction |\n ShippingStrategyWidgetAction;\n\nexport type ShippingStrategyUpdateAddressAction =\n UpdateAddressRequestedAction |\n UpdateAddressSucceededAction |\n UpdateAddressFailedAction;\n\nexport type ShippingStrategySelectOptionAction =\n SelectOptionRequestedAction |\n SelectOptionSucceededAction |\n SelectOptionFailedAction;\n\nexport type ShippingStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type ShippingStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type ShippingStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface UpdateAddressRequestedAction extends Action {\n type: ShippingStrategyActionType.UpdateAddressRequested;\n}\n\nexport interface UpdateAddressSucceededAction extends Action {\n type: ShippingStrategyActionType.UpdateAddressSucceeded;\n}\n\nexport interface UpdateAddressFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.UpdateAddressFailed;\n}\n\nexport interface SelectOptionRequestedAction extends Action {\n type: ShippingStrategyActionType.SelectOptionRequested;\n}\n\nexport interface SelectOptionSucceededAction extends Action {\n type: ShippingStrategyActionType.SelectOptionSucceeded;\n}\n\nexport interface SelectOptionFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.SelectOptionFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: ShippingStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: ShippingStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: ShippingStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: ShippingStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: ShippingStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: ShippingStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { Country } from '../geography';\n\nimport { LoadShippingCountriesAction, ShippingCountryActionType } from './shipping-country-actions';\nimport ShippingCountryState, { DEFAULT_STATE, ShippingCountryErrorsState, ShippingCountryStatusesState } from './shipping-country-state';\n\nexport default function shippingCountryReducer(\n state: ShippingCountryState = DEFAULT_STATE,\n action: Action\n): ShippingCountryState {\n const reducer = combineReducers<ShippingCountryState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Country[] | undefined,\n action: LoadShippingCountriesAction\n): Country[] | undefined {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n return arrayReplace(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ShippingCountryErrorsState = DEFAULT_STATE.errors,\n action: LoadShippingCountriesAction\n): ShippingCountryErrorsState {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesRequested:\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case ShippingCountryActionType.LoadShippingCountriesFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ShippingCountryStatusesState = DEFAULT_STATE.statuses,\n action: LoadShippingCountriesAction\n): ShippingCountryStatusesState {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n case ShippingCountryActionType.LoadShippingCountriesFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","export default interface ShippingStrategyState {\n data: ShippingStrategyDataState;\n errors: ShippingStrategyErrorsState;\n statuses: ShippingStrategyStatusesState;\n}\n\nexport interface ShippingStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface ShippingStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n updateAddressError?: Error;\n updateAddressMethodId?: string;\n selectOptionError?: Error;\n selectOptionMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface ShippingStrategyStatusesState {\n deinitializeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isInitializing?: boolean;\n isUpdatingAddress?: boolean;\n isSelectingOption?: boolean;\n updateAddressMethodId?: string;\n selectOptionMethodId?: string;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: ShippingStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { SignInEmail } from './signin-email';\n\nexport enum SignInEmailActionType {\n SendSignInEmailRequested = 'SEND_SIGNIN_EMAIL_REQUESTED',\n SendSignInEmailSucceeded = 'SEND_SIGNIN_EMAIL_SUCCEEDED',\n SendSignInEmailFailed = 'SEND_SIGNIN_EMAIL_FAILED',\n}\nexport type SendSignInEmailAction =\n SendSignInEmailRequestedAction |\n SendSignInEmailSucceededAction |\n SendSignInEmailFailedAction;\n\nexport interface SendSignInEmailRequestedAction extends Action {\n type: SignInEmailActionType.SendSignInEmailRequested;\n}\n\nexport interface SendSignInEmailSucceededAction extends Action<SignInEmail> {\n type: SignInEmailActionType.SendSignInEmailSucceeded;\n}\n\nexport interface SendSignInEmailFailedAction extends Action<Error> {\n type: SignInEmailActionType.SendSignInEmailFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { ShippingStrategyAction, ShippingStrategyActionType } from './shipping-strategy-actions';\nimport ShippingStrategyState, { DEFAULT_STATE, ShippingStrategyDataState, ShippingStrategyErrorsState, ShippingStrategyStatusesState } from './shipping-strategy-state';\n\nexport default function shippingStrategyReducer(\n state: ShippingStrategyState = DEFAULT_STATE,\n action: Action\n): ShippingStrategyState {\n const reducer = combineReducers<ShippingStrategyState, ShippingStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: ShippingStrategyDataState = DEFAULT_STATE.data,\n action: ShippingStrategyAction\n): ShippingStrategyDataState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: ShippingStrategyErrorsState = DEFAULT_STATE.errors,\n action: ShippingStrategyAction\n): ShippingStrategyErrorsState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeRequested:\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.DeinitializeRequested:\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.UpdateAddressRequested:\n case ShippingStrategyActionType.UpdateAddressSucceeded:\n return objectMerge(errors, {\n updateAddressError: undefined,\n updateAddressMethodId: undefined,\n });\n\n case ShippingStrategyActionType.UpdateAddressFailed:\n return objectMerge(errors, {\n updateAddressError: action.payload,\n updateAddressMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.SelectOptionRequested:\n case ShippingStrategyActionType.SelectOptionSucceeded:\n return objectMerge(errors, {\n selectOptionError: undefined,\n selectOptionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.SelectOptionFailed:\n return objectMerge(errors, {\n selectOptionError: action.payload,\n selectOptionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.WidgetInteractionStarted:\n case ShippingStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta && action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ShippingStrategyStatusesState = DEFAULT_STATE.statuses,\n action: ShippingStrategyAction\n): ShippingStrategyStatusesState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.InitializeFailed:\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.DeinitializeFailed:\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.UpdateAddressRequested:\n return objectMerge(statuses, {\n isUpdatingAddress: true,\n updateAddressMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.UpdateAddressFailed:\n case ShippingStrategyActionType.UpdateAddressSucceeded:\n return objectMerge(statuses, {\n isUpdatingAddress: false,\n updateAddressMethodId: undefined,\n });\n\n case ShippingStrategyActionType.SelectOptionRequested:\n return objectMerge(statuses, {\n isSelectingOption: true,\n selectOptionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.SelectOptionFailed:\n case ShippingStrategyActionType.SelectOptionSucceeded:\n return objectMerge(statuses, {\n isSelectingOption: false,\n selectOptionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.WidgetInteractionFinished:\n case ShippingStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { SignInEmail } from './signin-email';\n\nexport default interface SignInEmailState {\n data?: SignInEmail;\n errors: SignInEmailErrorsState;\n statuses: SignInEmailStatusesState;\n}\n\nexport interface SignInEmailErrorsState {\n sendError?: Error;\n}\n\nexport interface SignInEmailStatusesState {\n isSending?: boolean;\n}\n\nexport const DEFAULT_STATE: SignInEmailState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum StoreCreditActionType {\n ApplyStoreCreditRequested = 'APPLY_STORE_CREDIT_REQUESTED',\n ApplyStoreCreditSucceeded = 'APPLY_STORE_CREDIT_SUCCEEDED',\n ApplyStoreCreditFailed = 'APPLY_STORE_CREDIT_FAILED',\n}\n\nexport type StoreCreditAction =\n ApplyStoreCreditAction;\n\nexport type ApplyStoreCreditAction =\n ApplyStoreCreditRequestedAction |\n ApplyStoreCreditSucceededAction |\n ApplyStoreCreditFailedAction;\n\nexport interface ApplyStoreCreditRequestedAction extends Action {\n type: StoreCreditActionType.ApplyStoreCreditRequested;\n}\n\nexport interface ApplyStoreCreditSucceededAction extends Action<Checkout> {\n type: StoreCreditActionType.ApplyStoreCreditSucceeded;\n}\n\nexport interface ApplyStoreCreditFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: StoreCreditActionType.ApplyStoreCreditFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { SignInEmail } from './signin-email';\nimport { SendSignInEmailAction, SignInEmailActionType } from './signin-email-actions';\nimport SignInEmailState, { DEFAULT_STATE, SignInEmailErrorsState, SignInEmailStatusesState } from './signin-email-state';\n\nexport default function signInEmailReducer(\n state: SignInEmailState = DEFAULT_STATE,\n action: Action\n): SignInEmailState {\n const reducer = combineReducers<SignInEmailState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: SignInEmail | undefined,\n action: SendSignInEmailAction\n): SignInEmail | undefined {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: SignInEmailErrorsState = DEFAULT_STATE.errors,\n action: SendSignInEmailAction\n): SignInEmailErrorsState {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailRequested:\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectSet(errors, 'sendError', undefined);\n\n case SignInEmailActionType.SendSignInEmailFailed:\n return objectSet(errors, 'sendError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: SignInEmailStatusesState = DEFAULT_STATE.statuses,\n action: SendSignInEmailAction\n): SignInEmailStatusesState {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailRequested:\n return objectSet(statuses, 'isSending', true);\n\n case SignInEmailActionType.SendSignInEmailFailed:\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectSet(statuses, 'isSending', false);\n default:\n return statuses;\n }\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet } from '../common/utility';\n\nimport { StoreCreditAction, StoreCreditActionType } from './store-credit-actions';\nimport StoreCreditState, { StoreCreditErrorsState, StoreCreditStatusesState } from './store-credit-state';\n\nconst DEFAULT_STATE: StoreCreditState = {\n errors: {},\n statuses: {},\n};\n\nexport default function storeCreditReducer(\n state: StoreCreditState = DEFAULT_STATE,\n action: Action\n): StoreCreditState {\n const reducer = combineReducers<StoreCreditState>({\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction errorsReducer(\n errors: StoreCreditErrorsState = DEFAULT_STATE.errors,\n action: StoreCreditAction\n): StoreCreditErrorsState {\n switch (action.type) {\n case StoreCreditActionType.ApplyStoreCreditRequested:\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n return objectSet(errors, 'applyError', undefined);\n\n case StoreCreditActionType.ApplyStoreCreditFailed:\n return objectSet(errors, 'applyError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: StoreCreditStatusesState = DEFAULT_STATE.statuses,\n action: StoreCreditAction\n): StoreCreditStatusesState {\n switch (action.type) {\n case StoreCreditActionType.ApplyStoreCreditRequested:\n return objectSet(statuses, 'isApplying', true);\n\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n case StoreCreditActionType.ApplyStoreCreditFailed:\n return objectSet(statuses, 'isApplying', false);\n\n default:\n return statuses;\n }\n}\n","export default interface SubscriptionsState {\n errors: SubscriptionsErrorsState;\n statuses: SubscriptionsStatusesState;\n}\n\nexport interface SubscriptionsErrorsState {\n updateError?: Error;\n}\n\nexport interface SubscriptionsStatusesState {\n isUpdating?: boolean;\n}\n\nexport const DEFAULT_STATE: SubscriptionsState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nexport enum SpamProtectionActionType {\n InitializeFailed = 'SPAM_PROTECTION_INITIALIZE_FAILED',\n InitializeSucceeded = 'SPAM_PROTECTION_INITIALIZE_SUCCEEDED',\n InitializeRequested = 'SPAM_PROTECTION_INITIALIZE_REQUESTED',\n VerifyCheckoutRequested = 'SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED',\n VerifyCheckoutSucceeded = 'SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED',\n VerifyCheckoutFailed = 'SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED',\n ExecuteRequested = 'SPAM_PROTECTION_EXECUTE_REQUESTED',\n ExecuteSucceeded = 'SPAM_PROTECTION_EXECUTE_SUCCEEDED',\n ExecuteFailed = 'SPAM_PROTECTION_EXECUTE_FAILED',\n}\n\nexport type SpamProtectionAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction |\n ExecuteRequestedAction |\n ExecuteSucceededAction |\n ExecuteFailedAction |\n CheckoutVerifyRequestedAction |\n CheckoutVerifyFailedAction |\n CheckoutVerifySucceededAction;\n\nexport interface InitializeRequestedAction extends Action {\n type: SpamProtectionActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: SpamProtectionActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: SpamProtectionActionType.InitializeFailed;\n}\n\nexport interface ExecuteRequestedAction extends Action {\n type: SpamProtectionActionType.ExecuteRequested;\n}\n\nexport interface ExecuteSucceededAction extends Action<{ token: string }> {\n type: SpamProtectionActionType.ExecuteSucceeded;\n}\n\nexport interface ExecuteFailedAction extends Action {\n type: SpamProtectionActionType.ExecuteFailed;\n}\n\nexport interface CheckoutVerifyRequestedAction extends Action {\n type: SpamProtectionActionType.VerifyCheckoutRequested;\n}\n\nexport interface CheckoutVerifyFailedAction extends Action<Error> {\n type: SpamProtectionActionType.VerifyCheckoutFailed;\n}\n\nexport interface CheckoutVerifySucceededAction extends Action<Checkout> {\n type: SpamProtectionActionType.VerifyCheckoutSucceeded;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet } from '../common/utility';\nimport { SubscriptionsActionType, UpdateSubscriptionsAction } from '../subscription';\n\nimport SubscriptionsState, { DEFAULT_STATE, SubscriptionsErrorsState, SubscriptionsStatusesState } from './subscriptions-state';\n\nexport default function subscriptionsReducer(\n state: SubscriptionsState = DEFAULT_STATE,\n action: Action\n): SubscriptionsState {\n const reducer = combineReducers<SubscriptionsState>({\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction errorsReducer(\n errors: SubscriptionsErrorsState = DEFAULT_STATE.errors,\n action: UpdateSubscriptionsAction\n): SubscriptionsErrorsState {\n switch (action.type) {\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: SubscriptionsStatusesState = DEFAULT_STATE.statuses,\n action: UpdateSubscriptionsAction\n): SubscriptionsStatusesState {\n switch (action.type) {\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n default:\n return statuses;\n }\n}\n","import { Omit } from '../common/types';\n\nimport Checkout from './checkout';\n\nexport default interface CheckoutState {\n data?: CheckoutDataState;\n errors: CheckoutErrorsState;\n statuses: CheckoutStatusesState;\n}\n\nexport type CheckoutDataState = Omit<Checkout, 'billingAddress' | 'cart' | 'consignments' | 'coupons' | 'giftCertificates'>;\n\nexport interface CheckoutErrorsState {\n loadError?: Error;\n updateError?: Error;\n}\n\nexport interface CheckoutStatusesState {\n isExecutingSpamCheck?: boolean;\n isLoading?: boolean;\n isUpdating?: boolean;\n}\n\nexport const DEFAULT_STATE: CheckoutState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\nimport { omit } from 'lodash';\n\nimport { BillingAddressAction, BillingAddressActionType } from '../billing';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType, GiftCertificateAction, GiftCertificateActionType } from '../coupon';\nimport { OrderAction, OrderActionType } from '../order';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\nimport { SpamProtectionAction, SpamProtectionActionType } from '../spam-protection';\nimport { StoreCreditAction, StoreCreditActionType } from '../store-credit';\n\nimport { CheckoutAction, CheckoutActionType } from './checkout-actions';\nimport CheckoutState, { CheckoutDataState, CheckoutErrorsState, CheckoutStatusesState, DEFAULT_STATE } from './checkout-state';\n\nexport default function checkoutReducer(\n state: CheckoutState = DEFAULT_STATE,\n action: Action\n): CheckoutState {\n const reducer = combineReducers<CheckoutState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CheckoutDataState | undefined,\n action: CheckoutAction | BillingAddressAction | ConsignmentAction | CouponAction |\n GiftCertificateAction | OrderAction | SpamProtectionAction | StoreCreditAction\n): CheckoutDataState | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n case SpamProtectionActionType.VerifyCheckoutSucceeded:\n return objectMerge(data, omit(action.payload, [\n 'billingAddress',\n 'cart',\n 'consignments',\n 'customer',\n 'coupons',\n 'giftCertificates',\n ])) as CheckoutDataState;\n\n case OrderActionType.SubmitOrderSucceeded:\n return objectSet(data, 'orderId', action.payload && action.payload.order.orderId) ;\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CheckoutErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | OrderAction\n): CheckoutErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case CheckoutActionType.UpdateCheckoutRequested:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case CheckoutActionType.UpdateCheckoutFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CheckoutStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | OrderAction | SpamProtectionAction\n): CheckoutStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(statuses, 'isLoading', false);\n\n case CheckoutActionType.UpdateCheckoutRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case CheckoutActionType.UpdateCheckoutFailed:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n\n case SpamProtectionActionType.ExecuteRequested:\n return objectSet(statuses, 'isExecutingSpamCheck', true);\n\n case SpamProtectionActionType.ExecuteFailed:\n case SpamProtectionActionType.ExecuteSucceeded:\n return objectSet(statuses, 'isExecutingSpamCheck', false);\n\n default:\n return statuses;\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/memoize\");","import StandardError from './standard-error';\n\nexport enum MissingDataErrorType {\n MissingBillingAddress,\n MissingCart,\n MissingCheckout,\n MissingConsignments,\n MissingCustomer,\n MissingCheckoutConfig,\n MissingOrder,\n MissingOrderConfig,\n MissingOrderId,\n MissingPayment,\n MissingPaymentId,\n MissingPaymentInstrument,\n MissingPaymentMethod,\n MissingPaymentRedirectUrl,\n MissingPaymentStatus,\n MissingPaymentToken,\n MissingShippingAddress,\n}\n\n/**\n * Throw this error when data that is expected to exist is missing. Usually it\n * is due to the fact that certain data has not been retrieved from or saved to\n * the server yet. And such data is required to perform certain actions.\n */\nexport default class MissingDataError extends StandardError {\n constructor(\n public subtype: MissingDataErrorType\n ) {\n super(getErrorMessage(subtype));\n\n this.name = 'MissingDataError';\n this.type = 'missing_data';\n }\n}\n\nfunction getErrorMessage(type: MissingDataErrorType): string {\n switch (type) {\n case MissingDataErrorType.MissingBillingAddress:\n return 'Unable to proceed because billing address data is unavailable.';\n\n case MissingDataErrorType.MissingCart:\n return 'Unable to proceed because cart data is unavailable.';\n\n case MissingDataErrorType.MissingConsignments:\n return 'Unable to proceed because consignments data is unavailable.';\n\n case MissingDataErrorType.MissingCheckout:\n return 'Unable to proceed because checkout data is unavailable.';\n\n case MissingDataErrorType.MissingCustomer:\n return 'Unable to proceed because customer data is unavailable.';\n\n case MissingDataErrorType.MissingCheckoutConfig:\n case MissingDataErrorType.MissingOrderConfig:\n return 'Unable to proceed because configuration data is unavailable.';\n\n case MissingDataErrorType.MissingOrder:\n return 'Unable to proceed because order data is unavailable.';\n\n case MissingDataErrorType.MissingOrderId:\n return 'Unable to proceed because order ID is unavailable or not generated yet.';\n\n case MissingDataErrorType.MissingPayment:\n return 'Unable to proceed because payment data is unavailable.';\n\n case MissingDataErrorType.MissingPaymentToken:\n return 'Unable to proceed because the token required to submit a payment is missing.';\n\n case MissingDataErrorType.MissingPaymentMethod:\n return 'Unable to proceed because payment method data is unavailable or not properly configured.';\n\n case MissingDataErrorType.MissingShippingAddress:\n return 'Unable to proceed because shipping address data is unavailable.';\n\n default:\n return 'Unable to proceed because the required data is unavailable.';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"reselect\");","import { createSelector as defaultSelectorCreator } from 'reselect';\n\nimport withMemoizedCombiner from './with-memoized-combiner';\n\n/**\n * This is a decorated version of Reselect's default `createSelector` function.\n * If the return value of the combiner function is a function, it will create a\n * memorized version of that function and return it instead.\n */\nexport default withMemoizedCombiner(defaultSelectorCreator);\n","import { memoize } from '@bigcommerce/memoize';\nimport { createSelector as defaultSelectorCreator } from 'reselect';\n\n/**\n * Decorate selector creators with the ability to memoize the return value of\n * their combiner if it is a function (which effectively works as a partially\n * applied combiner).\n */\nexport default function withMemoizedCombiner<T extends typeof defaultSelectorCreator>(\n creator: T\n): T {\n return ((...args: any[]) => {\n const combiner = args.pop();\n\n // Reselect's default `createSelector` has many overloads. To avoid having\n // to redefine all of them, we're using `any` to bypass the typechecker.\n return (creator as any)(...args, (...combinerArgs: any[]) => {\n // Although there are many overloads, all of them have the last argument\n // as the combiner.\n const result = combiner(...combinerArgs);\n\n if (typeof result === 'function') {\n return memoize(result);\n }\n\n return result;\n });\n }) as T;\n}\n","export default function guard<T>(value: T, errorFactory?: () => Error): NonNullable<T> {\n if (value === undefined || value === null) {\n throw errorFactory ? errorFactory() : new Error('An unexpected error has occurred.');\n }\n\n return value as NonNullable<T>;\n}\n","import { deepFreeze } from '@bigcommerce/data-store';\n\n// tslint:disable-next-line:ban-types\ntype FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? T[K] : never };\n\nexport default function createFreezeProxy<T extends object>(target: T): T {\n return createProxy(target, (target, name) =>\n (...args: any[]) => deepFreeze(target[name].call(target, ...args))\n );\n}\n\nexport function createFreezeProxies<T extends object, TMap extends { [key: string]: T }>(map: TMap): TMap {\n return Object.keys(map)\n .reduce((result, key) => {\n result[key] = createFreezeProxy(map[key]);\n\n return result;\n }, {} as { [key: string]: T }) as TMap;\n}\n\nfunction createProxy<T extends object>(target: T, trap: (target: FunctionProperties<T>, name: keyof FunctionProperties<T>, proxy: T) => any): T {\n const proxy = Object.create(target);\n\n traversePrototypeOf(target, prototype => {\n Object.getOwnPropertyNames(prototype)\n .forEach(name => {\n if (name === 'constructor' || typeof proxy[name] !== 'function' || name.charAt(0) === '_') {\n return;\n }\n\n proxy[name] = trap(target as FunctionProperties<T>, name as keyof T, proxy);\n });\n });\n\n return proxy;\n}\n\nfunction traversePrototypeOf(target: object, iteratee: (prototype: object) => void): void {\n let prototype = Object.getPrototypeOf(target);\n\n while (prototype) {\n iteratee(prototype);\n\n prototype = Object.getPrototypeOf(prototype);\n }\n}\n","import PaymentInstrument from './instrument';\n\ninterface SupportedInstruments {\n [key: string]: Pick<PaymentInstrument, 'method' | 'provider'>;\n}\n\nconst supportedInstruments: SupportedInstruments = {\n 'mollie.credit_card': {\n provider: 'mollie',\n method: 'credit_card',\n },\n 'adyenv2.scheme': {\n provider: 'adyenv2',\n method: 'scheme',\n },\n 'adyenv3.scheme': {\n provider: 'adyenv3',\n method: 'scheme',\n },\n 'adyenv2.bcmc': {\n provider: 'adyenv2',\n method: 'bcmc',\n },\n 'adyenv2.ideal': {\n provider: 'adyenv2',\n method: 'ideal',\n },\n 'adyenv2.sepadirectdebit': {\n provider: 'adyenv2',\n method: 'sepadirectdebit',\n },\n 'adyenv2.directEbanking': {\n provider: 'adyenv2',\n method: 'directEbanking',\n },\n 'adyenv2.giropay': {\n provider: 'adyenv2',\n method: 'giropay',\n },\n barclays: {\n provider: 'barclays',\n method: 'credit_card',\n },\n braintree: {\n provider: 'braintree',\n method: 'credit_card',\n },\n braintreepaypal: {\n provider: 'braintree',\n method: 'paypal',\n },\n authorizenet: {\n provider: 'authorizenet',\n method: 'credit_card',\n },\n elavon: {\n provider: 'elavon',\n method: 'credit_card',\n },\n checkoutcom: {\n provider: 'checkoutcom',\n method: 'credit_card',\n },\n 'checkoutcom.credit_card': {\n provider: 'checkoutcom',\n method: 'credit_card',\n },\n 'checkoutcom.card': {\n provider: 'checkoutcom',\n method: 'card',\n },\n sagepay: {\n provider: 'sagepay',\n method: 'credit_card',\n },\n stripe: {\n provider: 'stripe',\n method: 'credit_card',\n },\n 'stripev3.card': {\n provider: 'stripev3',\n method: 'card',\n },\n 'stripeupe.card': {\n provider: 'stripeupe',\n method: 'card',\n },\n cybersource: {\n provider: 'cybersource',\n method: 'credit_card',\n },\n cybersourcev2: {\n provider: 'cybersourcev2',\n method: 'credit_card',\n },\n converge: {\n provider: 'converge',\n method: 'credit_card',\n },\n bluesnapv2: {\n provider: 'bluesnapv2',\n method: 'credit_card',\n },\n orbital: {\n provider: 'orbital',\n method: 'credit_card',\n },\n paymetric: {\n provider: 'paymetric',\n method: 'credit_card',\n },\n bolt: {\n provider: 'bolt',\n method: 'credit_card',\n },\n 'barclaycard.credit_card': {\n provider: 'barclaycard',\n method: 'credit_card',\n },\n digitalriver: {\n provider: 'digitalriver',\n method: 'credit_card',\n },\n moneris: {\n provider: 'moneris',\n method: 'credit_card',\n },\n cba_mpgs: {\n provider: 'cba_mpgs',\n method: 'credit_card',\n },\n};\n\nexport default supportedInstruments;\n","import { identity, isEqual, pickBy } from 'lodash';\n\nimport Address from './address';\n\nexport default function isAddressEqual(addressA: Partial<Address>, addressB: Partial<Address>): boolean {\n return isEqual(normalize(addressA), normalize(addressB));\n}\n\nfunction normalize(address: Partial<Address>): Partial<Address> {\n return pickBy({\n firstName: address.firstName,\n lastName: address.lastName,\n company: address.company,\n address1: address.address1,\n address2: address.address2,\n city: address.city,\n stateOrProvince: address.stateOrProvince,\n countryCode: address.countryCode,\n postalCode: address.postalCode,\n phone: address.phone,\n customFields: address.customFields,\n }, identity);\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport default interface StoreCreditState {\n errors: StoreCreditErrorsState;\n statuses: StoreCreditStatusesState;\n}\n\nexport interface StoreCreditErrorsState {\n applyError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface StoreCreditStatusesState {\n isApplying?: boolean;\n}\n\nexport const DEFAULT_STATE: StoreCreditState = {\n errors: {},\n statuses: {},\n};\n","import { createBillingAddressSelectorFactory } from '../billing';\nimport { createCartSelectorFactory } from '../cart';\nimport { createCheckoutButtonSelectorFactory } from '../checkout-buttons';\nimport { createFreezeProxies } from '../common/utility';\nimport { createConfigSelectorFactory } from '../config';\nimport { createCouponSelectorFactory, createGiftCertificateSelectorFactory } from '../coupon';\nimport { createCustomerSelectorFactory, createCustomerStrategySelectorFactory } from '../customer';\nimport { createFormSelectorFactory } from '../form';\nimport { createCountrySelectorFactory } from '../geography';\nimport { createOrderSelectorFactory } from '../order';\nimport { createPaymentMethodSelectorFactory, createPaymentSelectorFactory, createPaymentStrategySelectorFactory } from '../payment';\nimport { createInstrumentSelectorFactory } from '../payment/instrument';\nimport { createRemoteCheckoutSelectorFactory } from '../remote-checkout';\nimport { createConsignmentSelectorFactory, createPickupOptionSelectorFactory, createShippingAddressSelectorFactory, createShippingCountrySelectorFactory, createShippingStrategySelectorFactory } from '../shipping';\nimport { createSignInEmailSelectorFactory } from '../signin-email';\nimport { createStoreCreditSelectorFactory } from '../store-credit';\nimport { createSubscriptionsSelectorFactory } from '../subscription';\n\nimport { createCheckoutSelectorFactory } from './checkout-selector';\nimport { CheckoutStoreOptions } from './checkout-store';\nimport CheckoutStoreState from './checkout-store-state';\nimport InternalCheckoutSelectors from './internal-checkout-selectors';\n\nexport type InternalCheckoutSelectorsFactory = (\n state: CheckoutStoreState,\n options?: CheckoutStoreOptions\n) => InternalCheckoutSelectors;\n\nexport function createInternalCheckoutSelectorsFactory(): InternalCheckoutSelectorsFactory {\n const createBillingAddressSelector = createBillingAddressSelectorFactory();\n const createCartSelector = createCartSelectorFactory();\n const createCheckoutButtonSelector = createCheckoutButtonSelectorFactory();\n const createConfigSelector = createConfigSelectorFactory();\n const createCountrySelector = createCountrySelectorFactory();\n const createCouponSelector = createCouponSelectorFactory();\n const createCustomerSelector = createCustomerSelectorFactory();\n const createCustomerStrategySelector = createCustomerStrategySelectorFactory();\n const createGiftCertificateSelector = createGiftCertificateSelectorFactory();\n const createInstrumentSelector = createInstrumentSelectorFactory();\n const createFormSelector = createFormSelectorFactory();\n const createPaymentMethodSelector = createPaymentMethodSelectorFactory();\n const createPaymentStrategySelector = createPaymentStrategySelectorFactory();\n const createPickupOptionSelector = createPickupOptionSelectorFactory();\n const createRemoteCheckoutSelector = createRemoteCheckoutSelectorFactory();\n const createShippingAddressSelector = createShippingAddressSelectorFactory();\n const createShippingCountrySelector = createShippingCountrySelectorFactory();\n const createShippingStrategySelector = createShippingStrategySelectorFactory();\n const createConsignmentSelector = createConsignmentSelectorFactory();\n const createCheckoutSelector = createCheckoutSelectorFactory();\n const createOrderSelector = createOrderSelectorFactory();\n const createPaymentSelector = createPaymentSelectorFactory();\n const createStoreCreditSelector = createStoreCreditSelectorFactory();\n const createSubscriptionsSelector = createSubscriptionsSelectorFactory();\n const createSignInEmailSelector = createSignInEmailSelectorFactory();\n\n return (state, options = {}) => {\n const billingAddress = createBillingAddressSelector(state.billingAddress);\n const cart = createCartSelector(state.cart);\n const checkoutButton = createCheckoutButtonSelector(state.checkoutButton);\n const countries = createCountrySelector(state.countries);\n const coupons = createCouponSelector(state.coupons);\n const customer = createCustomerSelector(state.customer);\n const customerStrategies = createCustomerStrategySelector(state.customerStrategies);\n const form = createFormSelector(state.formFields);\n const giftCertificates = createGiftCertificateSelector(state.giftCertificates);\n const instruments = createInstrumentSelector(state.instruments);\n const paymentMethods = createPaymentMethodSelector(state.paymentMethods);\n const paymentStrategies = createPaymentStrategySelector(state.paymentStrategies);\n const pickupOptions = createPickupOptionSelector(state.pickupOptions);\n const remoteCheckout = createRemoteCheckoutSelector(state.remoteCheckout);\n const shippingAddress = createShippingAddressSelector(state.consignments);\n const shippingCountries = createShippingCountrySelector(state.shippingCountries);\n const shippingStrategies = createShippingStrategySelector(state.shippingStrategies);\n const subscriptions = createSubscriptionsSelector(state.subscriptions);\n const storeCredit = createStoreCreditSelector(state.storeCredit);\n const signInEmail = createSignInEmailSelector(state.signInEmail);\n\n // Compose selectors\n const consignments = createConsignmentSelector(state.consignments, cart);\n const checkout = createCheckoutSelector(state.checkout, billingAddress, cart, consignments, coupons, customer, giftCertificates);\n const order = createOrderSelector(state.order, billingAddress, coupons);\n const payment = createPaymentSelector(checkout, order);\n const config = createConfigSelector(state.config, state.formFields);\n\n const selectors = {\n billingAddress,\n cart,\n checkout,\n checkoutButton,\n config,\n consignments,\n countries,\n coupons,\n customer,\n customerStrategies,\n form,\n giftCertificates,\n instruments,\n order,\n payment,\n paymentMethods,\n paymentStrategies,\n pickupOptions,\n remoteCheckout,\n shippingAddress,\n shippingCountries,\n shippingStrategies,\n signInEmail,\n subscriptions,\n storeCredit,\n };\n\n return options.shouldWarnMutation ? createFreezeProxies(selectors) : selectors;\n };\n}\n\nexport default function createInternalCheckoutSelectors(\n state: CheckoutStoreState,\n options?: CheckoutStoreOptions\n): InternalCheckoutSelectors {\n return createInternalCheckoutSelectorsFactory()(state, options);\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport BillingAddress from './billing-address';\nimport BillingAddressState, { DEFAULT_STATE } from './billing-address-state';\n\nexport default interface BillingAddressSelector {\n getBillingAddress(): BillingAddress | undefined;\n getBillingAddressOrThrow(): BillingAddress;\n getUpdateError(): Error | undefined;\n getContinueAsGuestError(): Error | undefined;\n getLoadError(): Error | undefined;\n isUpdating(): boolean;\n isContinuingAsGuest(): boolean;\n isLoading(): boolean;\n}\n\nexport type BillingAddressSelectorFactory = (state: BillingAddressState) => BillingAddressSelector;\n\nexport function createBillingAddressSelectorFactory(): BillingAddressSelectorFactory {\n const getBillingAddress = createSelector(\n (state: BillingAddressState) => state.data,\n data => () => data\n );\n\n const getBillingAddressOrThrow = createSelector(\n getBillingAddress,\n getBillingAddress => () => {\n return guard(getBillingAddress(), () => new MissingDataError(MissingDataErrorType.MissingBillingAddress));\n }\n );\n\n const getUpdateError = createSelector(\n (state: BillingAddressState) => state.errors.updateError,\n error => () => error\n );\n\n const getContinueAsGuestError = createSelector(\n (state: BillingAddressState) => state.errors.continueAsGuestError,\n error => () => error\n );\n\n const getLoadError = createSelector(\n (state: BillingAddressState) => state.errors.loadError,\n error => () => error\n );\n\n const isUpdating = createSelector(\n (state: BillingAddressState) => !!state.statuses.isUpdating,\n status => () => status\n );\n\n const isContinuingAsGuest = createSelector(\n (state: BillingAddressState) => !!state.statuses.isContinuingAsGuest,\n status => () => status\n );\n\n const isLoading = createSelector(\n (state: BillingAddressState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: BillingAddressState = DEFAULT_STATE\n ): BillingAddressSelector => {\n return {\n getBillingAddress: getBillingAddress(state),\n getBillingAddressOrThrow: getBillingAddressOrThrow(state),\n getUpdateError: getUpdateError(state),\n getContinueAsGuestError: getContinueAsGuestError(state),\n getLoadError: getLoadError(state),\n isUpdating: isUpdating(state),\n isContinuingAsGuest: isContinuingAsGuest(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoize, memoizeOne } from '@bigcommerce/memoize';\nimport { find, some, values } from 'lodash';\n\nimport { createSelector } from '../common/selector';\n\nimport CheckoutButtonState, { DEFAULT_STATE } from './checkout-button-state';\nimport { CheckoutButtonMethodType } from './strategies';\n\nexport default interface CheckoutButtonSelector {\n getState(): CheckoutButtonState;\n isInitializing(methodId?: CheckoutButtonMethodType): boolean;\n isInitialized(methodId: CheckoutButtonMethodType, containerId?: string): boolean;\n isDeinitializing(methodId?: CheckoutButtonMethodType): boolean;\n getInitializeError(methodId?: CheckoutButtonMethodType): Error | undefined;\n getDeinitializeError(methodId?: CheckoutButtonMethodType): Error | undefined;\n}\n\nexport type CheckoutButtonSelectorFactory = (state: CheckoutButtonState) => CheckoutButtonSelector;\n\nexport function createCheckoutButtonSelectorFactory(): CheckoutButtonSelectorFactory {\n const getState = createSelector(\n (state: CheckoutButtonState) => state,\n state => () => state\n );\n\n const isInitializing = createSelector(\n (state: CheckoutButtonState) => state.statuses,\n statuses => memoize((methodId?: CheckoutButtonMethodType) => {\n if (methodId) {\n const method = statuses[methodId];\n\n return (method && method.isInitializing) === true;\n }\n\n return some(statuses, { isInitializing: true });\n })\n );\n\n const isInitialized = createSelector(\n (state: CheckoutButtonState) => state.data,\n data => memoize((methodId: CheckoutButtonMethodType, containerId?: string) => {\n const method = data[methodId];\n\n if (!method) {\n return false;\n }\n\n if (!containerId) {\n return some(method.initializedContainers, isInitialized => isInitialized === true);\n }\n\n return method.initializedContainers[containerId] === true;\n })\n );\n\n const isDeinitializing = createSelector(\n (state: CheckoutButtonState) => state.statuses,\n statuses => memoize((methodId?: CheckoutButtonMethodType) => {\n if (methodId) {\n const method = statuses[methodId];\n\n return (method && method.isDeinitializing) === true;\n }\n\n return some(statuses, { isDeinitializing: true });\n })\n );\n\n const getInitializeError = createSelector(\n (state: CheckoutButtonState) => state.errors,\n errors => memoize((methodId?: CheckoutButtonMethodType) => {\n const method = methodId ?\n errors[methodId] :\n find(values(errors), method => !!(method && method.initializeError));\n\n return method && method.initializeError;\n })\n );\n\n const getDeinitializeError = createSelector(\n (state: CheckoutButtonState) => state.errors,\n errors => memoize((methodId?: CheckoutButtonMethodType) => {\n const method = methodId ?\n errors[methodId] :\n find(values(errors), method => !!(method && method.deinitializeError));\n\n return method && method.deinitializeError;\n })\n );\n\n return memoizeOne((\n state: CheckoutButtonState = DEFAULT_STATE\n ): CheckoutButtonSelector => {\n return {\n getState: getState(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isDeinitializing: isDeinitializing(state),\n getInitializeError: getInitializeError(state),\n getDeinitializeError: getDeinitializeError(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport Coupon from './coupon';\nimport CouponState, { DEFAULT_STATE } from './coupon-state';\n\nexport default interface CouponSelector {\n getCoupons(): Coupon[] | undefined;\n getRemoveError(): RequestError | undefined;\n getApplyError(): RequestError | undefined;\n isApplying(): boolean;\n isRemoving(): boolean;\n}\n\nexport type CouponSelectorFactory = (state: CouponState) => CouponSelector;\n\nexport function createCouponSelectorFactory(): CouponSelectorFactory {\n const getCoupons = createSelector(\n (state: CouponState) => state.data,\n data => () => data\n );\n\n const getRemoveError = createSelector(\n (state: CouponState) => state.errors.removeCouponError,\n error => () => error\n );\n\n const getApplyError = createSelector(\n (state: CouponState) => state.errors.applyCouponError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: CouponState) => !!state.statuses.isApplyingCoupon,\n status => () => status\n );\n\n const isRemoving = createSelector(\n (state: CouponState) => !!state.statuses.isRemovingCoupon,\n status => () => status\n );\n\n return memoizeOne((\n state: CouponState = DEFAULT_STATE\n ): CouponSelector => {\n return {\n getCoupons: getCoupons(state),\n getRemoveError: getRemoveError(state),\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n isRemoving: isRemoving(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Customer from './customer';\nimport CustomerState, { DEFAULT_STATE } from './customer-state';\n\nexport default interface CustomerSelector {\n getCustomer(): Customer | undefined;\n getCustomerOrThrow(): Customer;\n getCreateAccountError(): Error | undefined;\n isCreatingCustomerAccount(): boolean;\n getCreateAddressError(): Error | undefined;\n isCreatingCustomerAddress(): boolean;\n}\n\nexport type CustomerSelectorFactory = (state: CustomerState) => CustomerSelector;\n\nexport function createCustomerSelectorFactory(): CustomerSelectorFactory {\n const getCustomer = createSelector(\n (state: CustomerState) => state.data,\n customer => () => customer\n );\n\n const getCustomerOrThrow = createSelector(\n getCustomer,\n getCustomer => () => {\n return guard(getCustomer(), () => new MissingDataError(MissingDataErrorType.MissingCustomer));\n }\n );\n\n const getCreateAccountError = createSelector(\n (state: CustomerState) => state.errors.createError,\n error => () => error\n );\n\n const isCreatingCustomerAccount = createSelector(\n (state: CustomerState) => !!state.statuses.isCreating,\n status => () => status\n );\n\n const getCreateAddressError = createSelector(\n (state: CustomerState) => state.errors.createAddressError,\n error => () => error\n );\n\n const isCreatingCustomerAddress = createSelector(\n (state: CustomerState) => !!state.statuses.isCreatingAddress,\n status => () => status\n );\n\n return memoizeOne((\n state: CustomerState = DEFAULT_STATE\n ): CustomerSelector => {\n return {\n getCustomer: getCustomer(state),\n getCustomerOrThrow: getCustomerOrThrow(state),\n getCreateAccountError: getCreateAccountError(state),\n isCreatingCustomerAccount: isCreatingCustomerAccount(state),\n getCreateAddressError: getCreateAddressError(state),\n isCreatingCustomerAddress: isCreatingCustomerAddress(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport RemoteCheckoutState, { DEFAULT_STATE, RemoteCheckoutStateData } from './remote-checkout-state';\n\nexport default interface RemoteCheckoutSelector {\n getCheckout<TMethodId extends keyof RemoteCheckoutStateData>(\n methodId: TMethodId\n ): RemoteCheckoutStateData[TMethodId] | undefined;\n}\n\nexport type RemoteCheckoutSelectorFactory = (state: RemoteCheckoutState) => RemoteCheckoutSelector;\n\nexport function createRemoteCheckoutSelectorFactory(): RemoteCheckoutSelectorFactory {\n const getCheckout = createSelector(\n (state: RemoteCheckoutState) => state.data,\n data => <TMethodId extends keyof RemoteCheckoutStateData>(methodId: TMethodId) => {\n return data[methodId];\n }\n );\n\n return memoizeOne((\n state: RemoteCheckoutState = DEFAULT_STATE\n ): RemoteCheckoutSelector => {\n return {\n getCheckout: getCheckout(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { Address } from '../address';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\n\nexport default interface ShippingAddressSelector {\n getShippingAddress(): Address | undefined;\n getShippingAddressOrThrow(): Address;\n}\n\nexport type ShippingAddressSelectorFactory = (state: ConsignmentState) => ShippingAddressSelector;\n\nexport function createShippingAddressSelectorFactory(): ShippingAddressSelectorFactory {\n const getShippingAddress = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => {\n const shippingConsignment = consignments?.find(consignment => !consignment.selectedPickupOption);\n\n return shippingConsignment?.shippingAddress;\n }\n );\n\n const getShippingAddressOrThrow = createSelector(\n getShippingAddress,\n getShippingAddress => () => {\n return guard(getShippingAddress(), () => new MissingDataError(MissingDataErrorType.MissingShippingAddress));\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE\n ): ShippingAddressSelector => {\n return {\n getShippingAddress: getShippingAddress(state),\n getShippingAddressOrThrow: getShippingAddressOrThrow(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { CheckoutSelector } from '../checkout';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { GatewayOrderPayment, OrderSelector } from '../order';\n\nimport PaymentMethod from './payment-method';\nimport { HOSTED } from './payment-method-types';\nimport { ACKNOWLEDGE, FINALIZE } from './payment-status-types';\n\nexport default interface PaymentSelector {\n getPaymentId(): { providerId: string; gatewayId?: string } | undefined;\n getPaymentIdOrThrow(): { providerId: string; gatewayId?: string };\n getPaymentStatus(): string | undefined;\n getPaymentStatusOrThrow(): string;\n getPaymentToken(): string | undefined;\n getPaymentTokenOrThrow(): string;\n getPaymentRedirectUrl(): string | undefined;\n getPaymentRedirectUrlOrThrow(): string;\n isPaymentDataRequired(useStoreCredit?: boolean): boolean;\n isPaymentDataSubmitted(paymentMethod?: PaymentMethod): boolean;\n}\n\nexport type PaymentSelectorFactory = (\n checkout: CheckoutSelector,\n order: OrderSelector\n) => PaymentSelector;\n\ninterface PaymentSelectorDependencies {\n checkout: CheckoutSelector;\n order: OrderSelector;\n}\n\nexport function createPaymentSelectorFactory(): PaymentSelectorFactory {\n const getInternalPayment = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.payment;\n }\n );\n\n const getGatewayPayment = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrder,\n getOrder => () => {\n const order = getOrder();\n\n return find(order && order.payments, ({ providerId }) =>\n providerId !== 'giftcertificate' && providerId !== 'storecredit'\n ) as GatewayOrderPayment;\n }\n );\n\n const getHostedPayment = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getCheckout,\n getCheckout => () => {\n const checkout = getCheckout();\n\n return find(checkout && checkout.payments, ({ providerType }) =>\n providerType === HOSTED\n );\n }\n );\n\n const getPaymentId = createSelector(\n getInternalPayment,\n getHostedPayment,\n getGatewayPayment,\n (getInternalPayment, getHostedPayment, getGatewayPayment) => () => {\n const internalPayment = getInternalPayment();\n\n if (internalPayment && internalPayment.id) {\n return {\n providerId: internalPayment.id,\n gatewayId: internalPayment.gateway,\n };\n }\n\n const payment = getHostedPayment() || getGatewayPayment();\n\n if (payment && payment.providerId) {\n return {\n providerId: payment.providerId,\n gatewayId: payment.gatewayId,\n };\n }\n }\n );\n\n const getPaymentIdOrThrow = createSelector(\n getPaymentId,\n getPaymentId => () => {\n return guard(getPaymentId(), () => new MissingDataError(MissingDataErrorType.MissingPaymentId));\n }\n );\n\n const getPaymentStatus = createSelector(\n getInternalPayment,\n getHostedPayment,\n getGatewayPayment,\n (getInternalPayment, getHostedPayment, getGatewayPayment) => () => {\n const internalPayment = getInternalPayment();\n\n if (internalPayment && internalPayment.status) {\n return internalPayment.status.replace('PAYMENT_STATUS_', '');\n }\n\n const payment = getHostedPayment() || getGatewayPayment();\n\n if (payment) {\n return payment.detail.step;\n }\n }\n );\n\n const getPaymentStatusOrThrow = createSelector(\n getPaymentStatus,\n getPaymentStatus => () => {\n return guard(getPaymentStatus(), () => new MissingDataError(MissingDataErrorType.MissingPaymentStatus));\n }\n );\n\n const getPaymentToken = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.token;\n }\n );\n\n const getPaymentTokenOrThrow = createSelector(\n getPaymentToken,\n getPaymentToken => () => {\n return guard(getPaymentToken(), () => new MissingDataError(MissingDataErrorType.MissingPaymentToken));\n }\n );\n\n const getPaymentRedirectUrl = createSelector(\n getInternalPayment,\n getInternalPayment => () => {\n const payment = getInternalPayment();\n\n return payment && payment.redirectUrl;\n }\n );\n\n const getPaymentRedirectUrlOrThrow = createSelector(\n getPaymentRedirectUrl,\n getPaymentRedirectUrl => () => {\n return guard(getPaymentRedirectUrl(), () => new MissingDataError(MissingDataErrorType.MissingPaymentRedirectUrl));\n }\n );\n\n const isPaymentDataRequired = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getOutstandingBalance,\n getOutstandingBalance => (useStoreCredit = false) => {\n const grandTotal = getOutstandingBalance(useStoreCredit);\n\n return grandTotal ? grandTotal > 0 : false;\n }\n );\n\n const isPaymentDataSubmitted = createSelector(\n getPaymentStatus,\n getPaymentStatus => (paymentMethod?: PaymentMethod) => {\n if (paymentMethod && paymentMethod.nonce) {\n return true;\n }\n\n return getPaymentStatus() === ACKNOWLEDGE || getPaymentStatus() === FINALIZE;\n }\n );\n\n return memoizeOne((\n checkout: CheckoutSelector,\n order: OrderSelector\n ): PaymentSelector => {\n return {\n getPaymentId: getPaymentId({ checkout, order }),\n getPaymentIdOrThrow: getPaymentIdOrThrow({ checkout, order }),\n getPaymentStatus: getPaymentStatus({ checkout, order }),\n getPaymentStatusOrThrow: getPaymentStatusOrThrow({ checkout, order }),\n getPaymentToken: getPaymentToken({ checkout, order }),\n getPaymentTokenOrThrow: getPaymentTokenOrThrow({ checkout, order }),\n getPaymentRedirectUrl: getPaymentRedirectUrl({ checkout, order }),\n getPaymentRedirectUrlOrThrow: getPaymentRedirectUrlOrThrow({ checkout, order }),\n isPaymentDataRequired: isPaymentDataRequired({ checkout, order }),\n isPaymentDataSubmitted: isPaymentDataSubmitted({ checkout, order }),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport { SignInEmail } from './signin-email';\nimport SignInEmailState, { DEFAULT_STATE } from './signin-email-state';\n\nexport default interface SignInEmailSelector {\n getEmail(): SignInEmail | undefined;\n getSendError(): Error | undefined;\n isSending(): boolean;\n}\n\nexport type SignInEmailSelectorFactory = (state: SignInEmailState) => SignInEmailSelector;\n\nexport function createSignInEmailSelectorFactory(): SignInEmailSelectorFactory {\n const getEmail = createSelector(\n (state: SignInEmailState) => state.data,\n signInEmail => () => signInEmail\n );\n\n const getSendError = createSelector(\n (state: SignInEmailState) => state.errors.sendError,\n error => () => error\n );\n\n const isSending = createSelector(\n (state: SignInEmailState) => !!state.statuses.isSending,\n status => () => status\n );\n\n return memoizeOne((\n state: SignInEmailState = DEFAULT_STATE\n ): SignInEmailSelector => {\n return {\n getEmail: getEmail(state),\n getSendError: getSendError(state),\n isSending: isSending(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Cart from './cart';\nimport CartState, { DEFAULT_STATE } from './cart-state';\n\nexport default interface CartSelector {\n getCart(): Cart | undefined;\n getCartOrThrow(): Cart;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type CartSelectorFactory = (state: CartState) => CartSelector;\n\nexport function createCartSelectorFactory() {\n const getCart = createSelector(\n (state: CartState) => state.data,\n cart => () => cart\n );\n\n const getCartOrThrow = createSelector(\n getCart,\n getCart => () => {\n return guard(getCart(), () => new MissingDataError(MissingDataErrorType.MissingCart));\n }\n );\n\n const getLoadError = createSelector(\n (state: CartState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: CartState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: CartState = DEFAULT_STATE\n ): CartSelector => {\n return {\n getCart: getCart(state),\n getCartOrThrow: getCartOrThrow(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { FormFieldsState } from '../form';\n\nimport Config, { ContextConfig, FlashMessage, FlashMessageType, StoreConfig } from './config';\nimport ConfigState, { DEFAULT_STATE } from './config-state';\n\nexport default interface ConfigSelector {\n getConfig(): Config | undefined;\n getFlashMessages(type?: FlashMessageType): FlashMessage[] | undefined;\n getStoreConfig(): StoreConfig | undefined;\n getStoreConfigOrThrow(): StoreConfig;\n getContextConfig(): ContextConfig | undefined;\n getExternalSource(): string | undefined;\n getVariantIdentificationToken(): string | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type ConfigSelectorFactory = (\n state: ConfigState,\n formState: FormFieldsState\n) => ConfigSelector;\n\ninterface ConfigSelectorDependencies {\n formState: FormFieldsState;\n}\n\nexport function createConfigSelectorFactory(): ConfigSelectorFactory {\n\n const getConfig = createSelector(\n (state: ConfigState) => state.data,\n data => () => data\n );\n\n const getFlashMessages = createSelector(\n (state: ConfigState) => state.data,\n data => (filterType?: FlashMessageType) => {\n if (!data) {\n return;\n }\n\n const { flashMessages } = data.context;\n\n if (!flashMessages) {\n return;\n }\n\n return filterType !== undefined ?\n flashMessages.filter(({ type }) => filterType === type) :\n flashMessages;\n }\n );\n\n const getStoreConfig = createSelector(\n (state: ConfigState) => state.data,\n (_: ConfigState, { formState }: ConfigSelectorDependencies) => formState && formState.data,\n (data, formFields) => () => data && formFields ? ({\n ...data.storeConfig,\n formFields,\n }) : undefined\n );\n\n const getStoreConfigOrThrow = createSelector(\n getStoreConfig,\n getStoreConfig => () => {\n return guard(getStoreConfig(), () => new MissingDataError(MissingDataErrorType.MissingCheckoutConfig));\n }\n );\n\n const getContextConfig = createSelector(\n (state: ConfigState) => state.data && state.data.context,\n data => () => data\n );\n\n const getExternalSource = createSelector(\n (state: ConfigState) => state.meta && state.meta.externalSource,\n data => () => data\n );\n\n const getVariantIdentificationToken = createSelector(\n (state: ConfigState) => state.meta && state.meta.variantIdentificationToken,\n data => () => data\n );\n\n const getLoadError = createSelector(\n (state: ConfigState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: ConfigState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: ConfigState = DEFAULT_STATE,\n formState: FormFieldsState\n ): ConfigSelector => {\n return {\n getConfig: getConfig(state),\n getFlashMessages: getFlashMessages(state),\n getStoreConfig: getStoreConfig(state, { formState }),\n getStoreConfigOrThrow: getStoreConfigOrThrow(state, { formState }),\n getContextConfig: getContextConfig(state),\n getExternalSource: getExternalSource(state),\n getVariantIdentificationToken: getVariantIdentificationToken(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport Country from './country';\nimport CountryState, { DEFAULT_STATE } from './country-state';\n\nexport default interface CountrySelector {\n getCountries(): Country[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type CountrySelectorFactory = (state: CountryState) => CountrySelector;\n\nexport function createCountrySelectorFactory(): CountrySelectorFactory {\n const getCountries = createSelector(\n (state: CountryState) => state.data,\n countries => () => countries\n );\n\n const getLoadError = createSelector(\n (state: CountryState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: CountryState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: CountryState = DEFAULT_STATE\n ): CountrySelector => {\n return {\n getCountries: getCountries(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport CustomerStrategyState, { DEFAULT_STATE } from './customer-strategy-state';\n\nexport default interface CustomerStrategySelector {\n getSignInError(methodId?: string): Error | undefined;\n getSignOutError(methodId?: string): Error | undefined;\n getExecutePaymentMethodCheckoutError(methodId?: string): Error | undefined;\n getInitializeError(methodId?: string): Error | undefined;\n getWidgetInteractionError(methodId?: string): Error | undefined;\n isSigningIn(methodId?: string): boolean;\n isSigningOut(methodId?: string): boolean;\n isExecutingPaymentMethodCheckout(methodId?: string): boolean;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type CustomerStrategySelectorFactory = (state: CustomerStrategyState) => CustomerStrategySelector;\n\nexport function createCustomerStrategySelectorFactory(): CustomerStrategySelectorFactory {\n const getSignInError = createSelector(\n (state: CustomerStrategyState) => state.errors.signInMethodId,\n (state: CustomerStrategyState) => state.errors.signInError,\n (signInMethodId, signInError) => (methodId?: string) => {\n if (methodId && signInMethodId !== methodId) {\n return;\n }\n\n return signInError;\n }\n );\n\n const getSignOutError = createSelector(\n (state: CustomerStrategyState) => state.errors.signOutMethodId,\n (state: CustomerStrategyState) => state.errors.signOutError,\n (signOutMethodId, signOutError) => (methodId?: string) => {\n if (methodId && signOutMethodId !== methodId) {\n return;\n }\n\n return signOutError;\n }\n );\n\n const getExecutePaymentMethodCheckoutError = createSelector(\n (state: CustomerStrategyState) => state.errors.executePaymentMethodCheckoutMethodId,\n (state: CustomerStrategyState) => state.errors.executePaymentMethodCheckoutError,\n (executePaymentMethodCheckoutMethodId, executePaymentMethodCheckoutError) => (methodId?: string) => {\n if (methodId && executePaymentMethodCheckoutMethodId !== methodId) {\n return;\n }\n\n return executePaymentMethodCheckoutError;\n }\n );\n\n const getInitializeError = createSelector(\n (state: CustomerStrategyState) => state.errors.initializeMethodId,\n (state: CustomerStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getWidgetInteractionError = createSelector(\n (state: CustomerStrategyState) => state.errors.widgetInteractionMethodId,\n (state: CustomerStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isSigningIn = createSelector(\n (state: CustomerStrategyState) => state.statuses.signInMethodId,\n (state: CustomerStrategyState) => state.statuses.isSigningIn,\n (signInMethodId, isSigningIn) => (methodId?: string) => {\n if (methodId && signInMethodId !== methodId) {\n return false;\n }\n\n return !!isSigningIn;\n }\n );\n\n const isSigningOut = createSelector(\n (state: CustomerStrategyState) => state.statuses.signOutMethodId,\n (state: CustomerStrategyState) => state.statuses.isSigningOut,\n (signOutMethodId, isSigningOut) => (methodId?: string) => {\n if (methodId && signOutMethodId !== methodId) {\n return false;\n }\n\n return !!isSigningOut;\n }\n );\n\n const isExecutingPaymentMethodCheckout = createSelector(\n (state: CustomerStrategyState) => state.statuses.executePaymentMethodCheckoutMethodId,\n (state: CustomerStrategyState) => state.statuses.isExecutingPaymentMethodCheckout,\n (executePaymentMethodCheckoutMethodId, isExecutingPaymentMethodCheckout) => (methodId?: string) => {\n if (methodId && executePaymentMethodCheckoutMethodId !== methodId) {\n return false;\n }\n\n return !!isExecutingPaymentMethodCheckout;\n }\n );\n\n const isInitializing = createSelector(\n (state: CustomerStrategyState) => state.statuses.initializeMethodId,\n (state: CustomerStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: CustomerStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: CustomerStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: CustomerStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: CustomerStrategyState = DEFAULT_STATE\n ): CustomerStrategySelector => {\n return {\n getSignInError: getSignInError(state),\n getSignOutError: getSignOutError(state),\n getExecutePaymentMethodCheckoutError: getExecutePaymentMethodCheckoutError(state),\n getInitializeError: getInitializeError(state),\n getWidgetInteractionError: getWidgetInteractionError(state),\n isSigningIn: isSigningIn(state),\n isSigningOut: isSigningOut(state),\n isExecutingPaymentMethodCheckout: isExecutingPaymentMethodCheckout(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport GiftCertificate from './gift-certificate';\nimport GiftCertificateState, { DEFAULT_STATE } from './gift-certificate-state';\n\nexport default interface GiftCertificateSelector {\n getGiftCertificates(): GiftCertificate[] | undefined;\n getRemoveError(): RequestError<StorefrontErrorResponseBody> | undefined;\n getApplyError(): RequestError<StorefrontErrorResponseBody> | undefined;\n isApplying(): boolean;\n isRemoving(): boolean;\n}\n\nexport type GiftCertificateSelectorFactory = (state: GiftCertificateState) => GiftCertificateSelector;\n\nexport function createGiftCertificateSelectorFactory(): GiftCertificateSelectorFactory {\n const getGiftCertificates = createSelector(\n (state: GiftCertificateState) => state.data,\n data => () => data\n );\n\n const getRemoveError = createSelector(\n (state: GiftCertificateState) => state.errors.removeGiftCertificateError,\n error => () => error\n );\n\n const getApplyError = createSelector(\n (state: GiftCertificateState) => state.errors.applyGiftCertificateError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: GiftCertificateState) => !!state.statuses.isApplyingGiftCertificate,\n status => () => status\n );\n\n const isRemoving = createSelector(\n (state: GiftCertificateState) => !!state.statuses.isRemovingGiftCertificate,\n status => () => status\n );\n\n return memoizeOne((\n state: GiftCertificateState = DEFAULT_STATE\n ): GiftCertificateSelector => {\n return {\n getGiftCertificates: getGiftCertificates(state),\n getRemoveError: getRemoveError(state),\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n isRemoving: isRemoving(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { filter, flatMap, isMatch, values } from 'lodash';\n\nimport { MissingDataError, MissingDataErrorType } from '../../common/error/errors';\nimport { createSelector } from '../../common/selector';\nimport { guard } from '../../common/utility';\nimport PaymentMethod from '../payment-method';\n\nimport PaymentInstrument, { CardInstrument } from './instrument';\nimport InstrumentState, { DEFAULT_STATE, InstrumentMeta } from './instrument-state';\nimport supportedInstruments from './supported-payment-instruments';\n\nexport default interface InstrumentSelector {\n getCardInstrument(instrumentId: string): CardInstrument | undefined;\n getCardInstrumentOrThrow(instrumentId: string): CardInstrument;\n getInstruments(): PaymentInstrument[] | undefined;\n getInstrumentsByPaymentMethod(paymentMethod: PaymentMethod): PaymentInstrument[] | undefined;\n getInstrumentsMeta(): InstrumentMeta | undefined;\n getLoadError(): Error | undefined;\n getDeleteError(instrumentId?: string): Error | undefined;\n isLoading(): boolean;\n isDeleting(instrumentId?: string): boolean;\n}\n\nexport type InstrumentSelectorFactory = (state: InstrumentState) => InstrumentSelector;\n\nexport function createInstrumentSelectorFactory(): InstrumentSelectorFactory {\n const getInstrumentsByPaymentMethod = createSelector(\n (state: InstrumentState) => state.data,\n instruments => (paymentMethod: PaymentMethod) => {\n if (!instruments) {\n return;\n }\n\n const paymentMethodKey = paymentMethod.gateway ? `${paymentMethod.gateway}.${paymentMethod.id}` : paymentMethod.id;\n\n const currentMethod = supportedInstruments[paymentMethodKey];\n\n if (!currentMethod) {\n return [];\n }\n\n return filter<PaymentInstrument>(instruments, currentMethod);\n }\n );\n\n const getCardInstrument = createSelector(\n (state: InstrumentState) => state.data,\n (instruments = []) => (instrumentId: string) => {\n const cards = values(supportedInstruments);\n\n return instruments?.find((instrument): instrument is CardInstrument =>\n instrument.bigpayToken === instrumentId &&\n instrument.type === 'card' &&\n cards.some(card => isMatch(instrument, card))\n );\n }\n );\n\n const getCardInstrumentOrThrow = createSelector(\n getCardInstrument,\n getCardInstrument => (instrumentId: string) => {\n return guard(getCardInstrument(instrumentId), () => new MissingDataError(MissingDataErrorType.MissingPaymentInstrument));\n }\n );\n\n const getInstruments = createSelector(\n (state: InstrumentState) => state.data,\n instruments => () => {\n if (!instruments) {\n return;\n }\n\n const allSupportedInstruments = flatMap(supportedInstruments, supportedProvider =>\n filter(instruments, (instrument: PaymentInstrument): instrument is PaymentInstrument => {\n return isMatch(instrument, supportedProvider);\n })\n );\n\n return allSupportedInstruments;\n }\n );\n\n const getInstrumentsMeta = createSelector(\n (state: InstrumentState) => state.meta,\n meta => () => meta\n );\n\n const getLoadError = createSelector(\n (state: InstrumentState) => state.errors.loadError,\n loadError => () => loadError\n );\n\n const getDeleteError = createSelector(\n (state: InstrumentState) => state.errors.failedInstrument,\n (state: InstrumentState) => state.errors.deleteError,\n (failedInstrument, deleteError) => (instrumentId?: string) => {\n if (instrumentId && failedInstrument !== instrumentId) {\n return;\n }\n\n return deleteError;\n }\n );\n\n const isLoading = createSelector(\n (state: InstrumentState) => state.statuses.isLoading,\n isLoading => () => !!isLoading\n );\n\n const isDeleting = createSelector(\n (state: InstrumentState) => state.statuses.deletingInstrument,\n (state: InstrumentState) => state.statuses.isDeleting,\n (deletingInstrument, isDeleting) => (instrumentId?: string) => {\n if (instrumentId && deletingInstrument !== instrumentId) {\n return false;\n }\n\n return !!isDeleting;\n }\n );\n\n return memoizeOne((\n state: InstrumentState = DEFAULT_STATE\n ): InstrumentSelector => {\n return {\n getCardInstrument: getCardInstrument(state),\n getCardInstrumentOrThrow: getCardInstrumentOrThrow(state),\n getInstruments: getInstruments(state),\n getInstrumentsByPaymentMethod: getInstrumentsByPaymentMethod(state),\n getInstrumentsMeta: getInstrumentsMeta(state),\n getLoadError: getLoadError(state),\n getDeleteError: getDeleteError(state),\n isLoading: isLoading(state),\n isDeleting: isDeleting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { createSelector } from '../common/selector';\nimport { Country } from '../geography';\n\nimport FormField from './form-field';\nimport FormFieldsState, { DEFAULT_STATE } from './form-fields-state';\n\nexport default interface FormSelector {\n getShippingAddressFields(countries: Country[] | undefined, countryCode: string): FormField[];\n getBillingAddressFields(countries: Country[] | undefined, countryCode: string): FormField[];\n getCustomerAccountFields(): FormField[];\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type FormSelectorFactory = (state: FormFieldsState) => FormSelector;\n\nexport function createFormSelectorFactory(): FormSelectorFactory {\n const getShippingAddressFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => (countries: Country[] = [], countryCode: string) => {\n const selectedCountry = find(countries, { code: countryCode });\n const fields = formFields ? formFields.shippingAddress : [];\n\n return fields.map((field: any) => processField(field, countries, selectedCountry));\n }\n );\n\n const getBillingAddressFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => (countries: Country[] = [], countryCode: string) => {\n const selectedCountry = find(countries, { code: countryCode });\n const fields = formFields ? formFields.billingAddress : [];\n\n return fields.map((field: any) => processField(field, countries, selectedCountry));\n }\n );\n\n const getCustomerAccountFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => () => formFields ? formFields.customerAccount : []\n );\n\n const getLoadError = createSelector(\n (state: FormFieldsState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: FormFieldsState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n function processField(field: FormField, countries: Country[], selectedCountry?: Country): FormField {\n if (field.name === 'countryCode') {\n return processCountry(field, countries, selectedCountry);\n }\n\n if (field.name === 'stateOrProvince') {\n return processProvince(field, selectedCountry);\n }\n\n if (field.name === 'postalCode') {\n return processsPostCode(field, selectedCountry);\n }\n\n return field;\n }\n\n function processCountry(field: FormField, countries: Country[] = [], country?: Country): FormField {\n if (!countries.length) {\n return field;\n }\n\n const { code = '' } = country || {};\n const items = countries.map(({ code, name }: any) => ({\n value: code,\n label: name,\n }));\n\n return {\n ...field,\n options: { items },\n default: code,\n type: 'array',\n fieldType: 'dropdown',\n itemtype: 'string',\n };\n }\n\n function processProvince(field: FormField, country?: Country): FormField {\n const { subdivisions = [], requiresState } = country || {};\n\n if (!subdivisions.length) {\n return {\n ...field,\n required: requiresState == null ? false : requiresState,\n };\n }\n\n const items = subdivisions.map(({ code, name }: any) => ({\n value: code,\n label: name,\n }));\n\n return {\n ...field,\n name: 'stateOrProvinceCode',\n options: { items },\n required: requiresState == null ? true : requiresState,\n type: 'array',\n fieldType: 'dropdown',\n itemtype: 'string',\n };\n }\n\n function processsPostCode(field: FormField, country?: Country): FormField {\n const { hasPostalCodes = [] } = country || {};\n\n if (hasPostalCodes === undefined) {\n return field;\n }\n\n return { ...field, required: Boolean(hasPostalCodes) };\n }\n\n return memoizeOne((\n state: FormFieldsState = DEFAULT_STATE\n ): FormSelector => {\n return {\n getShippingAddressFields: getShippingAddressFields(state),\n getBillingAddressFields: getBillingAddressFields(state),\n getCustomerAccountFields: getCustomerAccountFields(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\nimport PaymentMethodState, { DEFAULT_STATE } from './payment-method-state';\n\nexport default interface PaymentMethodSelector {\n getPaymentMethods(): PaymentMethod[] | undefined;\n getPaymentMethodsMeta(): PaymentMethodMeta | undefined;\n getPaymentMethod(methodId: string, gatewayId?: string): PaymentMethod | undefined;\n getPaymentMethodOrThrow(methodId: string, gatewayId ?: string): PaymentMethod;\n getLoadError(): Error | undefined;\n getLoadMethodError(methodId?: string): Error | undefined;\n isLoading(): boolean;\n isLoadingMethod(methodId?: string): boolean;\n}\n\nexport type PaymentMethodSelectorFactory = (state: PaymentMethodState) => PaymentMethodSelector;\n\nexport function createPaymentMethodSelectorFactory(): PaymentMethodSelectorFactory {\n const getPaymentMethods = createSelector(\n (state: PaymentMethodState) => state.data,\n paymentMethods => () => paymentMethods\n );\n\n const getPaymentMethodsMeta = createSelector(\n (state: PaymentMethodState) => state.meta,\n meta => () => meta\n );\n\n const getPaymentMethod = createSelector(\n (state: PaymentMethodState) => state.data,\n paymentMethods => (methodId: string, gatewayId?: string) => {\n return gatewayId ?\n find(paymentMethods, { id: methodId, gateway: gatewayId }) :\n find(paymentMethods, { id: methodId });\n }\n );\n\n const getPaymentMethodOrThrow = createSelector(\n getPaymentMethod,\n getPaymentMethod => (methodId: string, gatewayId?: string) => {\n return guard(getPaymentMethod(methodId, gatewayId), () => new MissingDataError(MissingDataErrorType.MissingPaymentMethod));\n }\n );\n\n const getLoadError = createSelector(\n (state: PaymentMethodState) => state.errors.loadError,\n loadError => () => loadError\n );\n\n const getLoadMethodError = createSelector(\n (state: PaymentMethodState) => state.errors.loadMethodId,\n (state: PaymentMethodState) => state.errors.loadMethodError,\n (loadMethodId, loadMethodError) => (methodId?: string) => {\n if (methodId && loadMethodId !== methodId) {\n return;\n }\n\n return loadMethodError;\n }\n );\n\n const isLoading = createSelector(\n (state: PaymentMethodState) => state.statuses.isLoading,\n isLoading => () => !!isLoading\n );\n\n const isLoadingMethod = createSelector(\n (state: PaymentMethodState) => state.statuses.loadMethodId,\n (state: PaymentMethodState) => state.statuses.isLoadingMethod,\n (loadMethodId, isLoadingMethod) => (methodId?: string) => {\n if (methodId && loadMethodId !== methodId) {\n return false;\n }\n\n return !!isLoadingMethod;\n }\n );\n\n return memoizeOne((\n state: PaymentMethodState = DEFAULT_STATE\n ): PaymentMethodSelector => {\n return {\n getPaymentMethods: getPaymentMethods(state),\n getPaymentMethodsMeta: getPaymentMethodsMeta(state),\n getPaymentMethod: getPaymentMethod(state),\n getPaymentMethodOrThrow: getPaymentMethodOrThrow(state),\n getLoadError: getLoadError(state),\n getLoadMethodError: getLoadMethodError(state),\n isLoading: isLoading(state),\n isLoadingMethod: isLoadingMethod(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport PaymentStrategyState, { DEFAULT_STATE } from './payment-strategy-state';\n\nexport default interface PaymentStrategySelector {\n getInitializeError(methodId?: string): Error | undefined;\n getExecuteError(methodId?: string): Error | undefined;\n getFinalizeError(methodId?: string): Error | undefined;\n getWidgetInteractingError(methodId?: string): Error | undefined;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isExecuting(methodId?: string): boolean;\n isFinalizing(methodId?: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type PaymentStrategySelectorFactory = (state: PaymentStrategyState) => PaymentStrategySelector;\n\nexport function createPaymentStrategySelectorFactory(): PaymentStrategySelectorFactory {\n const getInitializeError = createSelector(\n (state: PaymentStrategyState) => state.errors.initializeMethodId,\n (state: PaymentStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getExecuteError = createSelector(\n (state: PaymentStrategyState) => state.errors.executeMethodId,\n (state: PaymentStrategyState) => state.errors.executeError,\n (executeMethodId, executeError) => (methodId?: string) => {\n if (methodId && executeMethodId !== methodId) {\n return;\n }\n\n return executeError;\n }\n );\n\n const getFinalizeError = createSelector(\n (state: PaymentStrategyState) => state.errors.finalizeMethodId,\n (state: PaymentStrategyState) => state.errors.finalizeError,\n (finalizeMethodId, finalizeError) => (methodId?: string) => {\n if (methodId && finalizeMethodId !== methodId) {\n return;\n }\n\n return finalizeError;\n }\n );\n\n const getWidgetInteractingError = createSelector(\n (state: PaymentStrategyState) => state.errors.widgetInteractionMethodId,\n (state: PaymentStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isInitializing = createSelector(\n (state: PaymentStrategyState) => state.statuses.initializeMethodId,\n (state: PaymentStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: PaymentStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isExecuting = createSelector(\n (state: PaymentStrategyState) => state.statuses.executeMethodId,\n (state: PaymentStrategyState) => state.statuses.isExecuting,\n (executeMethodId, isExecuting) => (methodId?: string) => {\n if (methodId && executeMethodId !== methodId) {\n return false;\n }\n\n return !!isExecuting;\n }\n );\n\n const isFinalizing = createSelector(\n (state: PaymentStrategyState) => state.statuses.finalizeMethodId,\n (state: PaymentStrategyState) => state.statuses.isFinalizing,\n (finalizeMethodId, isFinalizing) => (methodId?: string) => {\n if (methodId && finalizeMethodId !== methodId) {\n return false;\n }\n\n return !!isFinalizing;\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: PaymentStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: PaymentStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: PaymentStrategyState = DEFAULT_STATE\n ): PaymentStrategySelector => {\n return {\n getInitializeError: getInitializeError(state),\n getExecuteError: getExecuteError(state),\n getFinalizeError: getFinalizeError(state),\n getWidgetInteractingError: getWidgetInteractingError(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isExecuting: isExecuting(state),\n isFinalizing: isFinalizing(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\nimport { objectFlatten, objectWithSortedKeys } from '../common/utility';\n\nimport { PickupOptionResult, SearchArea } from './pickup-option';\nimport PickupOptionState, { DEFAULT_STATE } from './pickup-option-state';\n\nexport default interface PickupOptionSelector {\n getPickupOptions(consignmentId: string, searchArea: SearchArea): PickupOptionResult[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type PickupOptionSelectorFactory = (state: PickupOptionState) => PickupOptionSelector;\n\nexport function createPickupOptionSelectorFactory(): PickupOptionSelectorFactory {\n const getPickupOptions = createSelector(\n (state: PickupOptionState) => state.data,\n pickupOptions => (consignmentId: string, searchArea: SearchArea) => {\n if (!pickupOptions) {\n return;\n }\n const flattenedParams = objectFlatten({ consignmentId, searchArea });\n const sortedFlattenedParams = objectWithSortedKeys(flattenedParams);\n const keyString = btoa(`${JSON.stringify(sortedFlattenedParams)}`);\n\n return pickupOptions[keyString];\n }\n );\n\n const getLoadError = createSelector(\n (state: PickupOptionState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: PickupOptionState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: PickupOptionState = DEFAULT_STATE\n ): PickupOptionSelector => {\n return {\n getPickupOptions: getPickupOptions(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\nimport { Country } from '../geography';\n\nimport ShippingCountryState, { DEFAULT_STATE } from './shipping-country-state';\n\nexport default interface ShippingCountrySelector {\n getShippingCountries(): Country[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type ShippingCountrySelectorFactory = (state: ShippingCountryState) => ShippingCountrySelector;\n\nexport function createShippingCountrySelectorFactory(): ShippingCountrySelectorFactory {\n const getShippingCountries = createSelector(\n (state: ShippingCountryState) => state.data,\n data => () => data\n );\n\n const getLoadError = createSelector(\n (state: ShippingCountryState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: ShippingCountryState) => state.statuses.isLoading,\n status => () => !!status\n );\n\n return memoizeOne((\n state: ShippingCountryState = DEFAULT_STATE\n ): ShippingCountrySelector => {\n return {\n getShippingCountries: getShippingCountries(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport ShippingStrategyState, { DEFAULT_STATE } from './shipping-strategy-state';\n\nexport default interface ShippingStrategySelector {\n getUpdateAddressError(methodId?: string): Error | undefined;\n getSelectOptionError(methodId?: string): Error | undefined;\n getInitializeError(methodId?: string): Error | undefined;\n getWidgetInteractionError(methodId?: string): Error | undefined;\n isUpdatingAddress(methodId?: string): boolean;\n isSelectingOption(methodId?: string): boolean;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type ShippingStrategySelectorFactory = (state: ShippingStrategyState) => ShippingStrategySelector;\n\nexport function createShippingStrategySelectorFactory(): ShippingStrategySelectorFactory {\n const getUpdateAddressError = createSelector(\n (state: ShippingStrategyState) => state.errors.updateAddressMethodId,\n (state: ShippingStrategyState) => state.errors.updateAddressError,\n (updateAddressMethodId, updateAddressError) => (methodId?: string) => {\n if (methodId && updateAddressMethodId !== methodId) {\n return;\n }\n\n return updateAddressError;\n }\n );\n\n const getSelectOptionError = createSelector(\n (state: ShippingStrategyState) => state.errors.selectOptionMethodId,\n (state: ShippingStrategyState) => state.errors.selectOptionError,\n (selectOptionMethodId, selectOptionError) => (methodId?: string) => {\n if (methodId && selectOptionMethodId !== methodId) {\n return;\n }\n\n return selectOptionError;\n }\n );\n\n const getInitializeError = createSelector(\n (state: ShippingStrategyState) => state.errors.initializeMethodId,\n (state: ShippingStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getWidgetInteractionError = createSelector(\n (state: ShippingStrategyState) => state.errors.widgetInteractionMethodId,\n (state: ShippingStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isUpdatingAddress = createSelector(\n (state: ShippingStrategyState) => state.statuses.updateAddressMethodId,\n (state: ShippingStrategyState) => state.statuses.isUpdatingAddress,\n (updateAddressMethodId, isUpdatingAddress) => (methodId?: string) => {\n if (methodId && updateAddressMethodId !== methodId) {\n return false;\n }\n\n return !!isUpdatingAddress;\n }\n );\n\n const isSelectingOption = createSelector(\n (state: ShippingStrategyState) => state.statuses.selectOptionMethodId,\n (state: ShippingStrategyState) => state.statuses.isSelectingOption,\n (selectOptionMethodId, isSelectingOption) => (methodId?: string) => {\n if (methodId && selectOptionMethodId !== methodId) {\n return false;\n }\n\n return !!isSelectingOption;\n }\n );\n\n const isInitializing = createSelector(\n (state: ShippingStrategyState) => state.statuses.initializeMethodId,\n (state: ShippingStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: ShippingStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: ShippingStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: ShippingStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: ShippingStrategyState = DEFAULT_STATE\n ): ShippingStrategySelector => {\n return {\n getUpdateAddressError: getUpdateAddressError(state),\n getSelectOptionError: getSelectOptionError(state),\n getInitializeError: getInitializeError(state),\n getWidgetInteractionError: getWidgetInteractionError(state),\n isUpdatingAddress: isUpdatingAddress(state),\n isSelectingOption: isSelectingOption(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { isAddressEqual, AddressRequestBody } from '../address';\nimport { CartSelector, PhysicalItem } from '../cart';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Consignment from './consignment';\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\nimport ShippingOption from './shipping-option';\n\nexport default interface ConsignmentSelector {\n getConsignments(): Consignment[] | undefined;\n getConsignmentsOrThrow(): Consignment[];\n getConsignmentById(id: string): Consignment | undefined;\n getConsignmentByAddress(address: AddressRequestBody): Consignment | undefined;\n getShippingOption(): ShippingOption | undefined;\n getLoadError(): Error | undefined;\n getCreateError(): Error | undefined;\n getLoadShippingOptionsError(): Error | undefined;\n getUnassignedItems(): PhysicalItem[];\n getUpdateError(consignmentId?: string): Error | undefined;\n getDeleteError(consignmentId?: string): Error | undefined;\n getItemAssignmentError(address: AddressRequestBody): Error | undefined;\n getUpdateShippingOptionError(consignmentId?: string): Error | undefined;\n isLoading(): boolean;\n isLoadingShippingOptions(): boolean;\n isCreating(): boolean;\n isUpdating(consignmentId?: string): boolean;\n isDeleting(consignmentId?: string): boolean;\n isAssigningItems(address: AddressRequestBody): boolean;\n isUpdatingShippingOption(consignmentId?: string): boolean;\n}\n\nexport type ConsignmentSelectorFactory = (\n state: ConsignmentState,\n cart: CartSelector\n) => ConsignmentSelector;\n\ninterface ConsignmentSelectorDependencies {\n cart: CartSelector;\n}\n\nexport function createConsignmentSelectorFactory(): ConsignmentSelectorFactory {\n const getConsignments = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => consignments\n );\n\n const getConsignmentsOrThrow = createSelector(\n getConsignments,\n getConsignments => () => {\n return guard(getConsignments(), () => new MissingDataError(MissingDataErrorType.MissingConsignments));\n }\n );\n\n const getConsignmentById = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => (id: string) => {\n if (!consignments || !consignments.length) {\n return;\n }\n\n return find(consignments, { id });\n }\n );\n\n const getConsignmentByAddress = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => (address: AddressRequestBody) => {\n if (!consignments || !consignments.length) {\n return;\n }\n\n return find(consignments, consignment =>\n isAddressEqual(consignment.shippingAddress, address)\n );\n }\n );\n\n const getShippingOption = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => {\n if (consignments && consignments.length) {\n return consignments[0].selectedShippingOption;\n }\n }\n );\n\n const getLoadError = createSelector(\n (state: ConsignmentState) => state.errors.loadError,\n error => () => error\n );\n\n const getCreateError = createSelector(\n (state: ConsignmentState) => state.errors.createError,\n error => () => error\n );\n\n const getLoadShippingOptionsError = createSelector(\n (state: ConsignmentState) => state.errors.loadShippingOptionsError,\n error => () => error\n );\n\n const getUnassignedItems = createSelector(\n getConsignments,\n (_: ConsignmentState, { cart }: ConsignmentSelectorDependencies) => cart.getCart,\n (getConsignments, getCart) => () => {\n const cart = getCart();\n\n if (!cart) {\n return [];\n }\n\n const assignedLineItemIds = (getConsignments() || []).reduce(\n (itemIds, consignment) => itemIds.concat(consignment.lineItemIds),\n [] as string[]\n );\n\n return (cart.lineItems.physicalItems || []).filter(\n item => assignedLineItemIds.indexOf(item.id as string) < 0\n );\n }\n );\n\n const getUpdateError = createSelector(\n (state: ConsignmentState) => state.errors.updateError,\n updateError => (consignmentId?: string) => {\n if (consignmentId) {\n return updateError[consignmentId];\n }\n\n return find(updateError);\n }\n );\n\n const getDeleteError = createSelector(\n (state: ConsignmentState) => state.errors.deleteError,\n deleteError => (consignmentId?: string) => {\n if (consignmentId) {\n return deleteError[consignmentId];\n }\n\n return find(deleteError);\n }\n );\n\n const getItemAssignmentError = createSelector(\n getConsignmentByAddress,\n getUpdateError,\n getCreateError,\n (getConsignmentByAddress, getUpdateError, getCreateError) => (address: AddressRequestBody) => {\n const consignment = getConsignmentByAddress(address);\n\n return consignment ? getUpdateError(consignment.id) : getCreateError();\n }\n );\n\n const getUpdateShippingOptionError = createSelector(\n (state: ConsignmentState) => state.errors.updateShippingOptionError,\n updateShippingOptionError => (consignmentId?: string) => {\n if (consignmentId) {\n return updateShippingOptionError[consignmentId];\n }\n\n return find(updateShippingOptionError);\n }\n );\n\n const isLoading = createSelector(\n (state: ConsignmentState) => state.statuses.isLoading,\n isLoading => () => isLoading === true\n );\n\n const isLoadingShippingOptions = createSelector(\n (state: ConsignmentState) => state.statuses.isLoadingShippingOptions,\n isLoadingShippingOptions => () => isLoadingShippingOptions === true\n );\n\n const isCreating = createSelector(\n (state: ConsignmentState) => state.statuses.isCreating,\n isCreating => () => isCreating === true\n );\n\n const isUpdating = createSelector(\n (state: ConsignmentState) => state.statuses.isUpdating,\n isUpdating => (consignmentId?: string) => {\n if (consignmentId) {\n return isUpdating[consignmentId] === true;\n }\n\n return find(isUpdating) === true;\n }\n );\n\n const isDeleting = createSelector(\n (state: ConsignmentState) => state.statuses.isDeleting,\n isDeleting => (consignmentId?: string) => {\n if (consignmentId) {\n return isDeleting[consignmentId] === true;\n }\n\n return find(isDeleting) === true;\n }\n );\n\n const isAssigningItems = createSelector(\n getConsignmentByAddress,\n isUpdating,\n isCreating,\n (getConsignmentByAddress, isUpdating, isCreating) => (address: AddressRequestBody) => {\n const consignment = getConsignmentByAddress(address);\n\n return consignment ? isUpdating(consignment.id) : isCreating();\n }\n );\n\n const isUpdatingShippingOption = createSelector(\n (state: ConsignmentState) => state.statuses.isUpdatingShippingOption,\n isUpdatingShippingOption => (consignmentId?: string) => {\n if (consignmentId) {\n return isUpdatingShippingOption[consignmentId] === true;\n }\n\n return find(isUpdatingShippingOption) === true;\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE,\n cart: CartSelector\n ): ConsignmentSelector => {\n return {\n getConsignments: getConsignments(state),\n getConsignmentsOrThrow: getConsignmentsOrThrow(state),\n getConsignmentById: getConsignmentById(state),\n getConsignmentByAddress: getConsignmentByAddress(state),\n getShippingOption: getShippingOption(state),\n getLoadError: getLoadError(state),\n getCreateError: getCreateError(state),\n getLoadShippingOptionsError: getLoadShippingOptionsError(state),\n getUnassignedItems: getUnassignedItems(state, { cart }),\n getUpdateError: getUpdateError(state),\n getDeleteError: getDeleteError(state),\n getItemAssignmentError: getItemAssignmentError(state),\n getUpdateShippingOptionError: getUpdateShippingOptionError(state),\n isLoading: isLoading(state),\n isLoadingShippingOptions: isLoadingShippingOptions(state),\n isCreating: isCreating(state),\n isUpdating: isUpdating(state),\n isDeleting: isDeleting(state),\n isAssigningItems: isAssigningItems(state),\n isUpdatingShippingOption: isUpdatingShippingOption(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { BillingAddressSelector } from '../billing';\nimport { CartSelector } from '../cart';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { CouponSelector, GiftCertificateSelector } from '../coupon';\nimport { CustomerSelector } from '../customer';\nimport { ConsignmentSelector } from '../shipping';\n\nimport Checkout from './checkout';\nimport CheckoutState, { DEFAULT_STATE } from './checkout-state';\n\nexport default interface CheckoutSelector {\n getCheckout(): Checkout | undefined;\n getCheckoutOrThrow(): Checkout;\n getOutstandingBalance(useStoreCredit?: boolean): number | undefined;\n getLoadError(): Error | undefined;\n getUpdateError(): Error | undefined;\n isExecutingSpamCheck(): boolean;\n isLoading(): boolean;\n isUpdating(): boolean;\n}\n\nexport type CheckoutSelectorFactory = (\n state: CheckoutState,\n billingAddress: BillingAddressSelector,\n cart: CartSelector,\n consignments: ConsignmentSelector,\n coupons: CouponSelector,\n customer: CustomerSelector,\n giftCertificates: GiftCertificateSelector\n) => CheckoutSelector;\n\ninterface CheckoutSelectorDependencies {\n billingAddress: BillingAddressSelector;\n cart: CartSelector;\n consignments: ConsignmentSelector;\n coupons: CouponSelector;\n customer: CustomerSelector;\n giftCertificates: GiftCertificateSelector;\n}\n\nexport function createCheckoutSelectorFactory(): CheckoutSelectorFactory {\n const getCheckout = createSelector(\n (state: CheckoutState) => state.data,\n (_: CheckoutState, { billingAddress }: CheckoutSelectorDependencies) => billingAddress.getBillingAddress,\n (_: CheckoutState, { cart }: CheckoutSelectorDependencies) => cart.getCart,\n (_: CheckoutState, { customer }: CheckoutSelectorDependencies) => customer.getCustomer,\n (_: CheckoutState, { consignments }: CheckoutSelectorDependencies) => consignments.getConsignments,\n (_: CheckoutState, { coupons }: CheckoutSelectorDependencies) => coupons.getCoupons,\n (_: CheckoutState, { giftCertificates }: CheckoutSelectorDependencies) => giftCertificates.getGiftCertificates,\n (data, getBillingAddress, getCart, getCustomer, getConsignments, getCoupons, getGiftCertificates) => () => {\n const billingAddress = getBillingAddress();\n const cart = getCart();\n const customer = getCustomer();\n const consignments = getConsignments() || [];\n const coupons = getCoupons() || [];\n const giftCertificates = getGiftCertificates() || [];\n\n if (!data || !cart || !customer) {\n return;\n }\n\n return {\n ...data,\n billingAddress,\n cart,\n customer,\n consignments,\n coupons,\n giftCertificates,\n };\n }\n );\n\n const getCheckoutOrThrow = createSelector(\n getCheckout,\n getCheckout => () => {\n return guard(getCheckout(), () => new MissingDataError(MissingDataErrorType.MissingCheckout));\n }\n );\n\n const getOutstandingBalance = createSelector(\n getCheckout,\n getCheckout => (useStoreCredit?: boolean) => {\n const checkout = getCheckout();\n\n if (!checkout) {\n return;\n }\n\n const grandTotal = checkout.grandTotal || 0;\n const storeCredit = checkout.customer.storeCredit || 0;\n\n return useStoreCredit ? Math.max(grandTotal - storeCredit, 0) : checkout.outstandingBalance;\n }\n );\n\n const getLoadError = createSelector(\n (state: CheckoutState) => state.errors.loadError,\n error => () => error\n );\n\n const getUpdateError = createSelector(\n (state: CheckoutState) => state.errors.updateError,\n error => () => error\n );\n\n const isExecutingSpamCheck = createSelector(\n (state: CheckoutState) => state.statuses.isExecutingSpamCheck,\n isExecutingSpamCheck => () => isExecutingSpamCheck === true\n );\n\n const isLoading = createSelector(\n (state: CheckoutState) => state.statuses.isLoading,\n isLoading => () => isLoading === true\n );\n\n const isUpdating = createSelector(\n (state: CheckoutState) => state.statuses.isUpdating,\n isUpdating => () => isUpdating === true\n );\n\n return memoizeOne((\n state: CheckoutState = DEFAULT_STATE,\n billingAddress: BillingAddressSelector,\n cart: CartSelector,\n consignments: ConsignmentSelector,\n coupons: CouponSelector,\n customer: CustomerSelector,\n giftCertificates: GiftCertificateSelector\n ): CheckoutSelector => {\n return {\n getCheckout: getCheckout(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getCheckoutOrThrow: getCheckoutOrThrow(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getOutstandingBalance: getOutstandingBalance(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getLoadError: getLoadError(state),\n getUpdateError: getUpdateError(state),\n isExecutingSpamCheck: isExecutingSpamCheck(state),\n isLoading: isLoading(state),\n isUpdating: isUpdating(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { BillingAddressSelector } from '../billing';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { CouponSelector } from '../coupon';\n\nimport Order from './order';\nimport OrderState, { DEFAULT_STATE, OrderMetaState } from './order-state';\n\nexport default interface OrderSelector {\n getOrder(): Order | undefined;\n getOrderOrThrow(): Order;\n getOrderMeta(): OrderMetaState | undefined;\n getLoadError(): Error | undefined;\n getPaymentId(methodId: string): string | undefined;\n isLoading(): boolean;\n}\n\nexport type OrderSelectorFactory = (\n state: OrderState,\n billingAddress: BillingAddressSelector,\n coupons: CouponSelector\n) => OrderSelector;\n\ninterface OrderSelectorDependencies {\n billingAddress: BillingAddressSelector;\n coupons: CouponSelector;\n}\n\nexport function createOrderSelectorFactory(): OrderSelectorFactory {\n const getOrder = createSelector(\n (state: OrderState) => state.data,\n (_: OrderState, { billingAddress }: OrderSelectorDependencies) => billingAddress.getBillingAddress(),\n (_: OrderState, { coupons }: OrderSelectorDependencies) => coupons.getCoupons(),\n (data, billingAddress, coupons = []) => () => {\n if (!data || !billingAddress) {\n return;\n }\n\n return {\n ...data,\n billingAddress,\n coupons,\n };\n }\n );\n\n const getOrderOrThrow = createSelector(\n getOrder,\n getOrder => () => {\n return guard(getOrder(), () => new MissingDataError(MissingDataErrorType.MissingOrder));\n }\n );\n\n const getOrderMeta = createSelector(\n (state: OrderState) => state.meta,\n meta => () => meta\n );\n\n const getLoadError = createSelector(\n (state: OrderState) => state.errors.loadError,\n error => () => error\n );\n\n const getPaymentId = createSelector(\n (state: OrderState) => state.data?.payments,\n (payments = []) => (methodId: string) => {\n const currentPayment = payments.find(({ providerId }) => providerId === methodId);\n\n return currentPayment?.paymentId;\n }\n );\n\n const isLoading = createSelector(\n (state: OrderState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: OrderState = DEFAULT_STATE,\n billingAddress: BillingAddressSelector,\n coupons: CouponSelector\n ): OrderSelector => {\n return {\n getOrder: getOrder(state, { billingAddress, coupons }),\n getOrderOrThrow: getOrderOrThrow(state, { billingAddress, coupons }),\n getOrderMeta: getOrderMeta(state),\n getLoadError: getLoadError(state),\n getPaymentId: getPaymentId(state),\n isLoading: isLoading(state),\n };\n });\n}\n","export const HOSTED = 'PAYMENT_TYPE_HOSTED';\nexport const OFFLINE = 'PAYMENT_TYPE_OFFLINE';\n","export const ACKNOWLEDGE = 'ACKNOWLEDGE';\nexport const FINALIZE = 'FINALIZE';\nexport const INITIALIZE = 'INITIALIZE';\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport StoreCreditState, { DEFAULT_STATE } from './store-credit-state';\n\nexport default interface StoreCreditSelector {\n getApplyError(): RequestError | undefined;\n isApplying(): boolean;\n}\n\nexport type StoreCreditSelectorFactory = (state: StoreCreditState) => StoreCreditSelector;\n\nexport function createStoreCreditSelectorFactory(): StoreCreditSelectorFactory {\n const getApplyError = createSelector(\n (state: StoreCreditState) => state.errors.applyError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: StoreCreditState) => !!state.statuses.isApplying,\n status => () => status\n );\n\n return memoizeOne((\n state: StoreCreditState = DEFAULT_STATE\n ): StoreCreditSelector => {\n return {\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport SubscriptionsState, { DEFAULT_STATE } from './subscriptions-state';\n\nexport default interface SubscriptionsSelector {\n getUpdateError(): Error | undefined;\n isUpdating(): boolean;\n}\n\nexport type SubscriptionsSelectorFactory = (state: SubscriptionsState) => SubscriptionsSelector;\n\nexport function createSubscriptionsSelectorFactory(): SubscriptionsSelectorFactory {\n const getUpdateError = createSelector(\n (state: SubscriptionsState) => state.errors.updateError,\n error => () => error\n );\n\n const isUpdating = createSelector(\n (state: SubscriptionsState) => !!state.statuses.isUpdating,\n status => () => status\n );\n\n return memoizeOne((\n state: SubscriptionsState = DEFAULT_STATE\n ): SubscriptionsSelector => {\n return {\n getUpdateError: getUpdateError(state),\n isUpdating: isUpdating(state),\n };\n });\n}\n","import { createDataStore } from '@bigcommerce/data-store';\n\nimport { createRequestErrorFactory } from '../common/error';\n\nimport CheckoutStore, { CheckoutStoreOptions } from './checkout-store';\nimport CheckoutStoreState from './checkout-store-state';\nimport createActionTransformer from './create-action-transformer';\nimport createCheckoutStoreReducer from './create-checkout-store-reducer';\nimport { createInternalCheckoutSelectorsFactory } from './create-internal-checkout-selectors';\n\nexport default function createCheckoutStore(\n initialState: Partial<CheckoutStoreState> = {},\n options?: CheckoutStoreOptions\n): CheckoutStore {\n const actionTransformer = createActionTransformer(createRequestErrorFactory());\n const createInternalCheckoutSelectors = createInternalCheckoutSelectorsFactory();\n const stateTransformer = (state: CheckoutStoreState) => createInternalCheckoutSelectors(state);\n\n return createDataStore(\n createCheckoutStoreReducer(),\n initialState,\n { actionTransformer, stateTransformer, ...options }\n );\n}\n","import { PaymentMethodInvalidError } from '../../payment/errors';\n\nimport { UnrecoverableError } from './errors';\nimport RequestErrorFactory from './request-error-factory';\n\nexport default function createRequestErrorFactory(): RequestErrorFactory {\n const factory = new RequestErrorFactory();\n\n const unrecoverableErrorTypes = [\n 'catalog_only',\n 'empty_cart',\n 'invalid_order_id',\n 'invalid_order_token',\n 'missing_order_token',\n 'missing_provider_token',\n 'missing_shipping_method',\n 'order_completion_error',\n 'order_could_not_be_finalized_error',\n 'order_create_failed',\n 'provider_fatal_error',\n 'provider_setup_error',\n 'stock_too_low',\n ];\n\n unrecoverableErrorTypes.forEach(type => {\n factory.register(type, (response, message) => new UnrecoverableError(response, message));\n });\n\n factory.register('invalid_payment_provider', response => new PaymentMethodInvalidError(response));\n factory.register('payment_config_not_found', response => new PaymentMethodInvalidError(response));\n\n return factory;\n}\n","import { Action } from '@bigcommerce/data-store';\nimport { from, Observable, Subscribable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { RequestErrorFactory } from '../common/error';\n\nexport default function createActionTransformer(\n requestErrorFactory: RequestErrorFactory\n): (action: Subscribable<Action>) => Observable<Action> {\n return action$ => from(action$).pipe(catchError<Action, never>(action => {\n if (action instanceof Error || action.payload instanceof Error) {\n throw action;\n }\n\n if (isResponse(action.payload)) {\n const message = action.payload.body && action.payload.body.detail;\n\n throw { ...action, payload: requestErrorFactory.createError(action.payload, message) };\n }\n\n throw action;\n }));\n}\n\nfunction isResponse(object: any) {\n if (!object || typeof object !== 'object') {\n return false;\n }\n\n return ['body', 'headers', 'status', 'statusText'].every(key =>\n Object.prototype.hasOwnProperty.call(object, key)\n );\n}\n","import { combineReducers, Action, Reducer } from '@bigcommerce/data-store';\n\nimport { billingAddressReducer } from '../billing';\nimport { cartReducer } from '../cart';\nimport { checkoutButtonReducer } from '../checkout-buttons';\nimport { configReducer } from '../config';\nimport { couponReducer, giftCertificateReducer } from '../coupon';\nimport { customerReducer, customerStrategyReducer } from '../customer';\nimport { formFieldsReducer } from '../form';\nimport { countryReducer } from '../geography';\nimport { orderReducer } from '../order';\nimport { paymentMethodReducer, paymentReducer, paymentStrategyReducer } from '../payment';\nimport { instrumentReducer } from '../payment/instrument';\nimport { remoteCheckoutReducer } from '../remote-checkout';\nimport { consignmentReducer, pickupOptionReducer, shippingCountryReducer, shippingStrategyReducer } from '../shipping';\nimport { signInEmailReducer } from '../signin-email';\nimport { storeCreditReducer } from '../store-credit';\nimport { subscriptionsReducer } from '../subscription';\n\nimport checkoutReducer from './checkout-reducer';\nimport CheckoutStoreState from './checkout-store-state';\n\nexport default function createCheckoutStoreReducer(): Reducer<CheckoutStoreState, Action> {\n return combineReducers({\n billingAddress: billingAddressReducer,\n cart: cartReducer,\n checkout: checkoutReducer,\n checkoutButton: checkoutButtonReducer,\n config: configReducer,\n consignments: consignmentReducer,\n countries: countryReducer,\n coupons: couponReducer,\n customer: customerReducer,\n customerStrategies: customerStrategyReducer,\n formFields: formFieldsReducer,\n giftCertificates: giftCertificateReducer,\n instruments: instrumentReducer,\n order: orderReducer,\n payment: paymentReducer,\n paymentMethods: paymentMethodReducer,\n paymentStrategies: paymentStrategyReducer,\n pickupOptions: pickupOptionReducer,\n remoteCheckout: remoteCheckoutReducer,\n shippingCountries: shippingCountryReducer,\n shippingStrategies: shippingStrategyReducer,\n signInEmail: signInEmailReducer,\n subscriptions: subscriptionsReducer,\n storeCredit: storeCreditReducer,\n });\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/bigpay-client\");","import { Action, ThunkAction } from '@bigcommerce/data-store';\nimport { memoize } from '@bigcommerce/memoize';\nimport { from, Observable } from 'rxjs';\nimport { shareReplay } from 'rxjs/operators';\n\nexport default function cacheAction<TFunction extends CreateActionFn>(\n fn: TFunction\n): TFunction {\n function decoratedFn(this: any, ...args: any[]) {\n const action = fn.call(this, ...args);\n\n if (action instanceof Observable) {\n return from(action).pipe(shareReplay());\n }\n\n if (typeof action === 'function') {\n return memoize(store => from(action(store)).pipe(shareReplay()));\n }\n\n return action;\n }\n\n return memoize(decoratedFn as TFunction);\n}\n\ntype CreateActionFn = (...args: any[]) => Observable<Action> | ThunkAction<Action> | Action;\n","import ActionOptions from './action-options';\n\nexport default function isActionOptions(param: any): param is ActionOptions {\n return param && typeof param.useCache === 'boolean';\n}\n","import cacheAction from './cache-action';\nimport isActionOptions from './is-action-options';\n\nexport default function cachableActionDecorator<TMethod extends (...args: any[]) => any>(\n _: object,\n key: string,\n descriptor: TypedPropertyDescriptor<TMethod>\n): TypedPropertyDescriptor<TMethod> {\n const memoizedMethods = new WeakMap<object, { [key: string]: TMethod }>();\n\n function decorateMethod(this: object, method: TMethod): TMethod {\n return ((...args: any[]) => {\n const lastArg = args[args.length - 1];\n const { useCache } = isActionOptions(lastArg) ? lastArg : { useCache: false };\n\n if (!useCache) {\n return method.call(this, ...args);\n }\n\n const instanceMethods = memoizedMethods.get(this) || {};\n\n if (!memoizedMethods.get(this)) {\n memoizedMethods.set(this, instanceMethods);\n }\n\n if (!instanceMethods[key]) {\n instanceMethods[key] = cacheAction(method);\n }\n\n return instanceMethods[key].call(this, ...args);\n }) as TMethod;\n }\n\n return {\n get() {\n if (typeof descriptor.value !== 'function') {\n throw new Error('Decorator should be used in functions');\n }\n\n const value = decorateMethod.call(this, descriptor.value);\n\n Object.defineProperty(this, key, { ...descriptor, value });\n\n return value;\n },\n };\n}\n","export interface ApplePayWindow extends Window {\n ApplePaySession: ApplePaySession;\n}\n\nexport default function isApplePayWindow(window: Window): window is ApplePayWindow {\n return 'ApplePaySession' in window;\n}\n\nexport function assertApplePayWindow(window: Window): asserts window is ApplePayWindow {\n if (!isApplePayWindow(window)) {\n throw new Error('Apple pay is not supported');\n }\n}\n","import { createAction, createErrorAction } from '@bigcommerce/data-store';\nimport { filter } from 'lodash';\nimport { Observable, Observer } from 'rxjs';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { RequestOptions } from '../common/http-request';\n\nimport { PaymentMethod } from '.';\nimport { LoadPaymentMethodsAction, LoadPaymentMethodAction, PaymentMethodActionType } from './payment-method-actions';\nimport PaymentMethodRequestSender from './payment-method-request-sender';\nimport { isApplePayWindow } from './strategies/apple-pay';\n\nconst APPLEPAYID = 'applepay';\n\nexport default class PaymentMethodActionCreator {\n constructor(\n private _requestSender: PaymentMethodRequestSender\n ) {}\n\n loadPaymentMethods(options?: RequestOptions): Observable<LoadPaymentMethodsAction> {\n return Observable.create((observer: Observer<LoadPaymentMethodsAction>) => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsRequested));\n\n this._requestSender.loadPaymentMethods(options)\n .then(response => {\n const meta = {\n deviceSessionId: response.headers['x-device-session-id'],\n sessionHash: response.headers['x-session-hash'],\n };\n const methods = response.body;\n const filteredMethods = Array.isArray(methods) ? this._filterApplePay(methods) : methods;\n\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsSucceeded, filteredMethods, meta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(PaymentMethodActionType.LoadPaymentMethodsFailed, response));\n });\n });\n }\n\n @cachableAction\n loadPaymentMethod(methodId: string, options?: RequestOptions & ActionOptions): Observable<LoadPaymentMethodAction> {\n return Observable.create((observer: Observer<LoadPaymentMethodAction>) => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodRequested, undefined, { methodId }));\n\n this._requestSender.loadPaymentMethod(methodId, options)\n .then(response => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodSucceeded, response.body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(PaymentMethodActionType.LoadPaymentMethodFailed, response, { methodId }));\n });\n });\n }\n\n private _filterApplePay(methods: PaymentMethod[]): PaymentMethod[] {\n\n return filter(methods, method => {\n if (method.id === APPLEPAYID && !isApplePayWindow(window)) {\n return false;\n }\n\n return true;\n });\n }\n}\n","enum ContentType {\n Json = 'application/json',\n JsonV1 = 'application/vnd.bc.v1+json',\n}\n\nexport default ContentType;\n","export const INTERNAL_USE_ONLY = 'This API endpoint is for internal use only and may change in the future';\n","export const SDK_VERSION_HEADERS = { 'X-Checkout-SDK-Version': LIBRARY_VERSION };\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport PaymentMethod from './payment-method';\n\nexport default class PaymentMethodRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadPaymentMethods({ timeout }: RequestOptions = {}): Promise<Response<PaymentMethod[]>> {\n const url = '/api/storefront/payments';\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n\n loadPaymentMethod(methodId: string, { timeout, params }: RequestOptions = {}): Promise<Response<PaymentMethod>> {\n const url = `/api/storefront/payments/${methodId}`;\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n params,\n });\n }\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","/**\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>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\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)\n .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>(_: object, key: string, descriptor: TypedPropertyDescriptor<T>): 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 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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"shallowequal\");","export interface RootCacheKeyMap {\n maps: ChildCacheKeyMap[];\n}\n\nexport interface IntermediateCacheKeyMap {\n maps: ChildCacheKeyMap[];\n parentMap: RootCacheKeyMap | IntermediateCacheKeyMap;\n usedCount: number;\n value: any;\n}\n\nexport interface TerminalCacheKeyMap extends IntermediateCacheKeyMap {\n cacheKey: string;\n}\n\nexport type ChildCacheKeyMap = IntermediateCacheKeyMap | TerminalCacheKeyMap;\n\nexport function isTerminalCacheKeyMap(map: ChildCacheKeyMap): map is TerminalCacheKeyMap {\n return Object.prototype.hasOwnProperty.call(map, 'cacheKey');\n}\n\nexport function isRootCacheKeyMap(map: RootCacheKeyMap | ChildCacheKeyMap): map is RootCacheKeyMap {\n return Object.prototype.hasOwnProperty.call(map, 'parentMap');\n}\n","import { noop } from 'lodash';\nimport shallowEqual from 'shallowequal';\n\nimport { isRootCacheKeyMap, isTerminalCacheKeyMap, ChildCacheKeyMap, IntermediateCacheKeyMap, RootCacheKeyMap, TerminalCacheKeyMap } from './cache-key-maps';\n\nexport interface CacheKeyResolverOptions {\n maxSize?: number;\n onExpire?(key: string): void;\n isEqual?(valueA: any, valueB: any): boolean;\n}\n\ninterface ResolveResult {\n index: number;\n parentMap: RootCacheKeyMap | IntermediateCacheKeyMap;\n map?: TerminalCacheKeyMap;\n}\n\nexport default class CacheKeyResolver {\n private _lastId = 0;\n private _map: RootCacheKeyMap = { maps: [] };\n private _usedMaps: TerminalCacheKeyMap[] = [];\n private _options: Required<CacheKeyResolverOptions>;\n\n constructor(options?: CacheKeyResolverOptions) {\n this._options = {\n maxSize: 0,\n isEqual: shallowEqual,\n onExpire: noop,\n ...options,\n };\n }\n\n getKey(...args: any[]): string {\n const result = this._resolveMap(...args);\n const { index, parentMap } = result;\n let { map } = result;\n\n if (map && map.cacheKey) {\n map.usedCount++;\n } else {\n map = this._generateMap(parentMap, args.slice(index));\n }\n\n // Keep track of the least used map so we can remove it if the size of\n // the stack exceeds the maximum size.\n this._removeLeastUsedMap(map);\n\n return map.cacheKey;\n }\n\n getUsedCount(...args: any[]): number {\n const { map } = this._resolveMap(...args);\n\n return map ? map.usedCount : 0;\n }\n\n private _resolveMap(...args: any[]): ResolveResult {\n let index = 0;\n let parentMap = this._map;\n\n // Traverse the tree to find the linked list of maps that match the\n // arguments of the call. Each intermediate or terminal map contains a\n // value that could be used to match with the arguments. The last map in\n // the list (the terminal) should contain a cache key. If it can does\n // not exist, we will return a falsy value so that the caller could\n // handle and generate a new cache key.\n while (parentMap.maps.length) {\n let isMatched = false;\n\n for (let mapIndex = 0; mapIndex < parentMap.maps.length; mapIndex++) {\n const map = parentMap.maps[mapIndex];\n\n if (!this._options.isEqual(map.value, args[index])) {\n continue;\n }\n\n // Move the most recently used map to the top of the stack for\n // quicker access\n parentMap.maps.unshift(...parentMap.maps.splice(mapIndex, 1));\n\n if ((args.length === 0 || index === args.length - 1) && isTerminalCacheKeyMap(map)) {\n return { index, map, parentMap };\n }\n\n isMatched = true;\n parentMap = map;\n index++;\n\n break;\n }\n\n if (!isMatched) {\n break;\n }\n }\n\n return { index, parentMap };\n }\n\n private _generateMap(parent: RootCacheKeyMap | IntermediateCacheKeyMap, args: any[]): TerminalCacheKeyMap {\n let index = 0;\n let parentMap = parent;\n let map: IntermediateCacheKeyMap;\n\n do {\n map = {\n maps: [],\n parentMap,\n usedCount: 1,\n value: args[index],\n };\n\n // Continue to build the tree of maps so that it could be resolved\n // next time when the function is called with the same set of\n // arguments.\n parentMap.maps.unshift(map);\n\n parentMap = map;\n index++;\n } while (index < args.length);\n\n const terminalMap = map as TerminalCacheKeyMap;\n\n terminalMap.cacheKey = `${++this._lastId}`;\n\n return terminalMap;\n }\n\n private _removeLeastUsedMap(recentlyUsedMap: TerminalCacheKeyMap): void {\n if (!this._options.maxSize) {\n return;\n }\n\n const index = this._usedMaps.indexOf(recentlyUsedMap);\n\n this._usedMaps.splice(\n index === -1 ? 0 : index,\n index === -1 ? 0 : 1,\n recentlyUsedMap\n );\n\n if (this._usedMaps.length <= this._options.maxSize) {\n return;\n }\n\n const map = this._usedMaps.pop();\n\n if (!map) {\n return;\n }\n\n this._removeMap(map);\n this._options.onExpire(map.cacheKey);\n }\n\n private _removeMap(map: ChildCacheKeyMap): void {\n if (!map.parentMap) {\n return;\n }\n\n map.parentMap.maps.splice(map.parentMap.maps.indexOf(map), 1);\n\n if (isRootCacheKeyMap(map.parentMap)) {\n return;\n }\n\n this._removeMap(map.parentMap);\n }\n}\n","export default function isPrivate(key: string): boolean {\n return `${key}`.indexOf('$$') === 0 || `${key}`.indexOf('_') === 0;\n}\n","import { memoize } from '@bigcommerce/memoize';\n\nimport { bindDecorator, isEqual, isPrivate, CacheKeyResolver } from '../utility';\n\n/**\n * Decorates a class by patching all of its methods to cache their return values\n * and return them if they are called again with the same set of parameters. The\n * decorator also binds all the methods to the calling instance so it can be\n * destructed.\n */\nexport default function selectorDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype)\n .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 selectorMethodDecorator(target.prototype, key, descriptor)\n );\n });\n\n return decoratedTarget;\n}\n\nfunction selectorMethodDecorator<T extends Method>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let resolver = new CacheKeyResolver();\n let method = descriptor.value;\n let memoizedMethod = memoize(method);\n\n return bindDecorator(target, key, {\n get() {\n const value = ((...args: any[]) => {\n const cachedValue = memoizedMethod.call(this, ...args);\n\n if (resolver.getUsedCount(...args) === 1) {\n return cachedValue;\n }\n\n const newValue = method.call(this, ...args);\n\n if (isEqual(newValue, cachedValue, { keyFilter: key => !isPrivate(key) })) {\n return cachedValue;\n }\n\n memoizedMethod.cache.set(resolver.getKey(...args), newValue);\n\n return newValue;\n }) as T;\n\n Object.defineProperty(this, key, { ...descriptor, value });\n\n return value;\n },\n set(value) {\n resolver = new CacheKeyResolver();\n method = value;\n memoizedMethod = memoize(method);\n },\n });\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\ntype Method = (...args: any[]) => any;\n","import { InternalCheckoutSelectors } from '../checkout';\nimport { selector } from '../common/selector';\n\nimport CheckoutButtonSelector from './checkout-button-selector';\nimport { CheckoutButtonMethodType } from './strategies';\n\n@selector\nexport default class CheckoutButtonErrorSelector {\n private _checkoutButton: CheckoutButtonSelector;\n\n /**\n * @internal\n */\n constructor(selectors: InternalCheckoutSelectors) {\n this._checkoutButton = selectors.checkoutButton;\n }\n\n getInitializeButtonError(methodId?: CheckoutButtonMethodType): Error | undefined {\n return this._checkoutButton.getInitializeError(methodId);\n }\n\n getDeinitializeButtonError(methodId?: CheckoutButtonMethodType): Error | undefined {\n return this._checkoutButton.getDeinitializeError(methodId);\n }\n}\n","import { InternalCheckoutSelectors } from '../checkout';\nimport { selector } from '../common/selector';\n\nimport CheckoutButtonSelector from './checkout-button-selector';\nimport { CheckoutButtonMethodType } from './strategies';\n\n@selector\nexport default class CheckoutButtonStatusSelector {\n private _checkoutButton: CheckoutButtonSelector;\n\n /**\n * @internal\n */\n constructor(selectors: InternalCheckoutSelectors) {\n this._checkoutButton = selectors.checkoutButton;\n }\n\n isInitializingButton(methodId?: CheckoutButtonMethodType): boolean {\n return this._checkoutButton.isInitializing(methodId);\n }\n\n isDeinitializingButton(methodId?: CheckoutButtonMethodType): boolean {\n return this._checkoutButton.isDeinitializing(methodId);\n }\n}\n","import { InternalCheckoutSelectors } from '../checkout';\n\nimport CheckoutButtonErrorSelector from './checkout-button-error-selector';\nimport CheckoutButtonSelectors from './checkout-button-selectors';\nimport CheckoutButtonStatusSelector from './checkout-button-status-selector';\n\nexport default function createCheckoutButtonSelectors(selectors: InternalCheckoutSelectors): CheckoutButtonSelectors {\n const errors = new CheckoutButtonErrorSelector(selectors);\n const statuses = new CheckoutButtonStatusSelector(selectors);\n\n return {\n errors,\n statuses,\n };\n}\n","import { CheckoutStore, InternalCheckoutSelectors } from '../checkout';\nimport { isElementId, setUniqueElementId } from '../common/dom';\nimport { bindDecorator as bind } from '../common/utility';\n\nimport { CheckoutButtonInitializeOptions, CheckoutButtonOptions } from './checkout-button-options';\nimport CheckoutButtonSelectors from './checkout-button-selectors';\nimport CheckoutButtonStrategyActionCreator from './checkout-button-strategy-action-creator';\nimport createCheckoutButtonSelectors from './create-checkout-button-selectors';\n\n@bind\nexport default class CheckoutButtonInitializer {\n private _state: CheckoutButtonSelectors;\n\n /**\n * @internal\n */\n constructor(\n private _store: CheckoutStore,\n private _buttonStrategyActionCreator: CheckoutButtonStrategyActionCreator\n ) {\n this._state = createCheckoutButtonSelectors(this._store.getState());\n\n this._store.subscribe(state => {\n this._state = createCheckoutButtonSelectors(state);\n });\n }\n\n /**\n * Returns a snapshot of the current state.\n *\n * The method returns a new instance every time there is a change in the\n * state. You can query the state by calling any of its getter methods.\n *\n * ```js\n * const state = service.getState();\n *\n * console.log(state.errors.getInitializeButtonError());\n * console.log(state.statuses.isInitializingButton());\n * ```\n *\n * @returns The current customer's checkout state\n */\n getState(): CheckoutButtonSelectors {\n return this._state;\n }\n\n /**\n * Subscribes to any changes to the current state.\n *\n * The method registers a callback function and executes it every time there\n * is a change in the current state.\n *\n * ```js\n * service.subscribe(state => {\n * console.log(state.statuses.isInitializingButton());\n * });\n * ```\n *\n * The method can be configured to notify subscribers only regarding\n * relevant changes, by providing a filter function.\n *\n * ```js\n * const filter = state => state.errors.getInitializeButtonError();\n *\n * // Only trigger the subscriber when the cart changes.\n * service.subscribe(state => {\n * console.log(state.errors.getInitializeButtonError())\n * }, filter);\n * ```\n *\n * @param subscriber - The function to subscribe to state changes.\n * @param filters - One or more functions to filter out irrelevant state\n * changes. If more than one function is provided, the subscriber will only\n * be triggered if all conditions are met.\n * @returns A function, if called, will unsubscribe the subscriber.\n */\n subscribe(\n subscriber: (state: CheckoutButtonSelectors) => void,\n ...filters: Array<(state: CheckoutButtonSelectors) => any>\n ): () => void {\n return this._store.subscribe(\n () => subscriber(this.getState()),\n state => state.checkoutButton.getState(),\n ...filters.map(filter => (state: InternalCheckoutSelectors) => filter(createCheckoutButtonSelectors(state)))\n );\n }\n\n /**\n * Initializes the checkout button of a payment method.\n *\n * When the checkout button is initialized, it will be inserted into the DOM,\n * ready to be interacted with by the customer.\n *\n * ```js\n * initializer.initializeButton({\n * methodId: 'braintreepaypal',\n * containerId: 'checkoutButton',\n * braintreepaypal: {\n * },\n * });\n * ```\n *\n * @param options - Options for initializing the checkout button.\n * @returns A promise that resolves to the current state.\n */\n initializeButton(options: CheckoutButtonInitializeOptions): Promise<CheckoutButtonSelectors> {\n const containerIds = isElementId(options.containerId) ?\n [options.containerId] :\n setUniqueElementId(options.containerId, `${options.methodId}-container`);\n\n return Promise.all(\n containerIds.map(containerId => {\n const action = this._buttonStrategyActionCreator.initialize({ ...options, containerId });\n const queueId = `checkoutButtonStrategy:${options.methodId}:${containerId}`;\n\n return this._store.dispatch(action, { queueId });\n })\n )\n .then(() => this.getState());\n }\n\n /**\n * De-initializes the checkout button by performing any necessary clean-ups.\n *\n * ```js\n * await service.deinitializeButton({\n * methodId: 'braintreepaypal',\n * });\n * ```\n *\n * @param options - Options for deinitializing the checkout button.\n * @returns A promise that resolves to the current state.\n */\n deinitializeButton(options: CheckoutButtonOptions): Promise<CheckoutButtonSelectors> {\n const action = this._buttonStrategyActionCreator.deinitialize(options);\n const queueId = `checkoutButtonStrategy:${options.methodId}`;\n\n return this._store.dispatch(action, { queueId })\n .then(() => this.getState());\n }\n}\n","/* eslint-disable no-useless-escape */\nexport default function isElementId(id: string): boolean {\n return /^\\w[\\w\\-\\:\\.]*$/.test(id);\n}\n","import { uniqueId } from 'lodash';\n\nimport { InvalidArgumentError } from '../error/errors';\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(`Unable to find any element with the specified selector: ${selector}`);\n }\n\n return Array.prototype.slice.call(containers)\n .map((container: HTMLElement) => {\n if (!container.id) {\n container.id = uniqueId(idPrefix);\n }\n\n return container.id;\n });\n}\n","import { createErrorAction, Action } from '@bigcommerce/data-store';\nimport { concat, of, throwError, Observable } from 'rxjs';\n\nexport default function throwErrorAction<TPayload, TMeta, TType extends string>(\n type: TType,\n error?: TPayload,\n meta?: TMeta\n): Observable<Action<TPayload, TMeta, TType>> {\n if (isErrorAction(error)) {\n return concat(of(error), throwError(createErrorAction(type, error.payload, meta)));\n }\n\n return throwError(createErrorAction(type, error, meta));\n}\n\nfunction isErrorAction(action: any): action is Action {\n return action && action.type && action.error;\n}\n","enum CheckoutButtonMethodType {\n APPLEPAY = 'applepay',\n AMAZON_PAY_V2 = 'amazonpay',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_PAYPALV2 = 'braintreepaypalv2',\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n BRAINTREE_PAYPAL_CREDITV2 = 'braintreepaypalcreditv2',\n GOOGLEPAY_ADYENV2 = 'googlepayadyenv2',\n GOOGLEPAY_ADYENV3 = 'googlepayadyenv3',\n GOOGLEPAY_AUTHORIZENET = 'googlepayauthorizenet',\n GOOGLEPAY_BRAINTREE = 'googlepaybraintree',\n GOOGLEPAY_CHECKOUTCOM = 'googlepaycheckoutcom',\n GOOGLEPAY_CYBERSOURCEV2 = 'googlepaycybersourcev2',\n GOOGLEPAY_ORBITAL = 'googlepayorbital',\n GOOGLEPAY_STRIPE = 'googlepaystripe',\n GOOGLEPAY_STRIPEUPE = 'googlepaystripeupe',\n MASTERPASS = 'masterpass',\n PAYPALEXPRESS = 'paypalexpress',\n PAYPALCOMMERCE = 'paypalcommerce',\n}\n\nexport default CheckoutButtonMethodType;\n","import { createAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, empty, of } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { Registry } from '../common/registry';\nimport { PaymentMethodActionCreator } from '../payment';\n\nimport { CheckoutButtonActionType, DeinitializeButtonAction, InitializeButtonAction } from './checkout-button-actions';\nimport { CheckoutButtonInitializeOptions, CheckoutButtonOptions } from './checkout-button-options';\nimport { CheckoutButtonMethodType, CheckoutButtonStrategy } from './strategies';\n\nconst methodMap: { [key: string]: CheckoutButtonMethodType | undefined } = {\n [CheckoutButtonMethodType.BRAINTREE_PAYPALV2]: CheckoutButtonMethodType.BRAINTREE_PAYPAL, // TODO: should be removed when BRAINTREE_PAYPALV2 registries will be removed\n [CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDITV2]: CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, // TODO: should be removed when BRAINTREE_PAYPAL_CREDITV2 registries will be removed\n};\n\nconst mapCheckoutButtonMethodId = (methodId: CheckoutButtonMethodType) => {\n return methodMap[methodId] || methodId;\n};\n\nexport default class CheckoutButtonStrategyActionCreator {\n constructor(\n private _registry: Registry<CheckoutButtonStrategy>,\n private _paymentMethodActionCreator: PaymentMethodActionCreator\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): ThunkAction<InitializeButtonAction, InternalCheckoutSelectors> {\n return store => {\n const meta = { methodId: options.methodId, containerId: options.containerId };\n\n if (store.getState().checkoutButton.isInitialized(options.methodId, options.containerId)) {\n return empty();\n }\n\n return concat(\n of(createAction(CheckoutButtonActionType.InitializeButtonRequested, undefined, meta)),\n this._paymentMethodActionCreator.loadPaymentMethod(mapCheckoutButtonMethodId(options.methodId), { timeout: options.timeout, useCache: true }),\n defer(() => this._registry.get(options.methodId).initialize(options)\n .then(() => createAction(CheckoutButtonActionType.InitializeButtonSucceeded, undefined, meta)))\n ).pipe(\n catchError(error => throwErrorAction(CheckoutButtonActionType.InitializeButtonFailed, error, meta))\n );\n };\n }\n\n deinitialize(options: CheckoutButtonOptions): ThunkAction<DeinitializeButtonAction, InternalCheckoutSelectors> {\n return store => {\n const meta = { methodId: options.methodId };\n\n if (!store.getState().checkoutButton.isInitialized(options.methodId)) {\n return empty();\n }\n\n return concat(\n of(createAction(CheckoutButtonActionType.DeinitializeButtonRequested, undefined, meta)),\n defer(() => this._registry.get(options.methodId).deinitialize()\n .then(() => createAction(CheckoutButtonActionType.DeinitializeButtonSucceeded, undefined, meta)))\n ).pipe(\n catchError(error => throwErrorAction(CheckoutButtonActionType.DeinitializeButtonFailed, error, meta))\n );\n };\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/script-loader\");","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when a shopper tries to sign in as a guest but\n * they are already signed in as a registered customer.\n */\nexport default class UnableToContinueAsGuestError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to continue as a guest because the customer is already signed in.');\n\n this.name = 'UnableToContinueAsGuestError';\n this.type = 'unable_to_continue_as_guest';\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { Response } from '@bigcommerce/request-sender';\nimport { concat, defer, empty, merge, of, Observable, Observer } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { Checkout, InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { GuestCredentials } from '../customer';\nimport { SubscriptionsActionCreator, UpdateSubscriptionsAction } from '../subscription';\n\nimport { BillingAddressRequestSender } from '.';\nimport { BillingAddressUpdateRequestBody } from './billing-address';\nimport { BillingAddressActionType, ContinueAsGuestAction, UpdateBillingAddressAction } from './billing-address-actions';\nimport { UnableToContinueAsGuestError } from './errors';\n\nexport default class BillingAddressActionCreator {\n constructor(\n private _requestSender: BillingAddressRequestSender,\n private _subscriptionActionCreator: SubscriptionsActionCreator\n ) {}\n\n continueAsGuest(\n credentials: GuestCredentials,\n options?: RequestOptions\n ): ThunkAction<ContinueAsGuestAction | UpdateSubscriptionsAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const customer = state.customer.getCustomer();\n\n if (customer && !customer.isGuest) {\n throw new UnableToContinueAsGuestError();\n }\n\n const billingAddress = state.billingAddress.getBillingAddress();\n\n let billingAddressRequestBody: Partial<BillingAddressUpdateRequestBody>;\n\n if (!billingAddress) {\n billingAddressRequestBody = credentials;\n } else {\n const { country, ...existingBillingAddressRequestBody } = billingAddress;\n\n billingAddressRequestBody = {\n ...existingBillingAddressRequestBody,\n ...credentials,\n };\n }\n\n return merge(\n concat(\n of(createAction(BillingAddressActionType.ContinueAsGuestRequested)),\n defer(async () => {\n const { body } = await this._createOrUpdateBillingAddress(\n checkout.id,\n billingAddressRequestBody,\n options\n );\n\n return createAction(BillingAddressActionType.ContinueAsGuestSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(BillingAddressActionType.ContinueAsGuestFailed, error))\n ),\n this._updateCustomerConsent(credentials, options)\n );\n };\n }\n\n updateAddress(\n address: Partial<BillingAddressUpdateRequestBody>,\n options?: RequestOptions\n ): ThunkAction<UpdateBillingAddressAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateBillingAddressAction>) => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(BillingAddressActionType.UpdateBillingAddressRequested));\n\n const billingAddress = state.billingAddress.getBillingAddress();\n\n // If email is not present in the address provided by the client, then\n // fall back to the stored email as it could have been set separately\n // using a convenience method. We can't rely on billingAddress having\n // an ID to consider that there's a preexisting email, as billingAddress\n // object from Order doesn't have an ID.\n const billingAddressRequestBody = {\n ...address,\n email: typeof address.email === 'undefined' && billingAddress ? billingAddress.email : address.email,\n };\n\n if (billingAddress && billingAddress.id) {\n billingAddressRequestBody.id = billingAddress.id;\n }\n\n this._createOrUpdateBillingAddress(checkout.id, billingAddressRequestBody, options)\n .then(({ body }) => {\n observer.next(createAction(BillingAddressActionType.UpdateBillingAddressSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(BillingAddressActionType.UpdateBillingAddressFailed, response));\n });\n });\n }\n\n private _updateCustomerConsent(\n {\n email,\n acceptsAbandonedCartEmails,\n acceptsMarketingNewsletter,\n }: GuestCredentials,\n options?: RequestOptions\n ): Observable<UpdateSubscriptionsAction> {\n if ((acceptsAbandonedCartEmails === undefined || acceptsAbandonedCartEmails === null) &&\n (acceptsMarketingNewsletter === undefined || acceptsMarketingNewsletter === null)) {\n return empty();\n }\n\n return this._subscriptionActionCreator.updateSubscriptions({\n email,\n acceptsMarketingNewsletter: acceptsMarketingNewsletter || false,\n acceptsAbandonedCartEmails: acceptsAbandonedCartEmails || false,\n }, options);\n }\n\n private _createOrUpdateBillingAddress(\n checkoutId: string,\n address: Partial<BillingAddressUpdateRequestBody>,\n options?: RequestOptions\n ): Promise<Response<Checkout>> {\n if (!address.id) {\n return this._requestSender.createAddress(checkoutId, address, options);\n }\n\n return this._requestSender.updateAddress(checkoutId, address, options);\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { AddressRequestBody } from '../address';\nimport { Checkout } from '../checkout';\nimport { ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { BillingAddressUpdateRequestBody } from './billing-address';\n\nconst DEFAULT_PARAMS = {\n include: [\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'promotions.banners',\n ].join(','),\n};\n\nexport default class BillingAddressRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n createAddress(checkoutId: string, address: Partial<AddressRequestBody>, { timeout }: RequestOptions = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/billing-address`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, { body: address, params: DEFAULT_PARAMS, headers, timeout });\n }\n\n updateAddress(checkoutId: string, address: Partial<BillingAddressUpdateRequestBody>, { timeout }: RequestOptions = {}): Promise<Response<Checkout>> {\n const { id, ...body } = address;\n const url = `/api/storefront/checkouts/${checkoutId}/billing-address/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, { params: DEFAULT_PARAMS, body, headers, timeout });\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, merge, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { ConfigActionCreator } from '../config';\nimport { FormFieldsActionCreator } from '../form';\n\nimport { CheckoutRequestBody } from './checkout';\nimport { CheckoutActionType, LoadCheckoutAction, UpdateCheckoutAction } from './checkout-actions';\nimport CheckoutRequestSender from './checkout-request-sender';\nimport InternalCheckoutSelectors from './internal-checkout-selectors';\n\nexport default class CheckoutActionCreator {\n constructor(\n private _checkoutRequestSender: CheckoutRequestSender,\n private _configActionCreator: ConfigActionCreator,\n private _formFieldsActionCreator: FormFieldsActionCreator\n ) {}\n\n loadCheckout(id: string, options?: RequestOptions): Observable<LoadCheckoutAction> {\n return concat(\n of(createAction(CheckoutActionType.LoadCheckoutRequested)),\n merge(\n this._configActionCreator.loadConfig({ ...options, useCache: true }),\n this._formFieldsActionCreator.loadFormFields({ ...options, useCache: true }),\n defer(() => this._checkoutRequestSender.loadCheckout(id, options)\n .then(({ body }) => createAction(CheckoutActionType.LoadCheckoutSucceeded, body)))\n )\n ).pipe(\n catchError(error => throwErrorAction(CheckoutActionType.LoadCheckoutFailed, error))\n );\n }\n\n loadDefaultCheckout(options?: RequestOptions): ThunkAction<LoadCheckoutAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(CheckoutActionType.LoadCheckoutRequested)),\n merge(\n this._configActionCreator.loadConfig(),\n this._formFieldsActionCreator.loadFormFields({ ...options, useCache: true })\n ),\n defer(async () => {\n const state = store.getState();\n const context = state.config.getContextConfig();\n\n if (!context || !context.checkoutId) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckoutConfig);\n }\n\n const { body } = await this._checkoutRequestSender.loadCheckout(context.checkoutId, options);\n\n return createAction(CheckoutActionType.LoadCheckoutSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(CheckoutActionType.LoadCheckoutFailed, error))\n );\n }\n\n updateCheckout(\n body: CheckoutRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateCheckoutAction, InternalCheckoutSelectors> {\n return store => new Observable(observer => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(CheckoutActionType.UpdateCheckoutRequested));\n\n this._checkoutRequestSender.updateCheckout(checkout.id, body, options)\n .then(({ body }) => {\n observer.next(createAction(CheckoutActionType.UpdateCheckoutSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(CheckoutActionType.UpdateCheckoutFailed, response));\n });\n });\n }\n\n loadCurrentCheckout(options?: RequestOptions): ThunkAction<LoadCheckoutAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n return this.loadCheckout(checkout.id, options);\n };\n }\n}\n","import { uniq } from 'lodash';\n\nexport default function joinIncludes<T>(includes: T[]): string {\n return uniq(includes).join(',');\n}\n","import joinIncludes from './join-includes';\nimport mergeIncludes from './merge-includes';\n\n/**\n * Joins or merges a base list of includes with a set of additional includes.\n */\nexport default function joinOrMergeIncludes<T extends string>(\n baseIncludes: T[],\n includeDictionaryOrList: { [key in T]?: boolean } | T[] = []\n): string {\n return Array.isArray(includeDictionaryOrList) ?\n joinIncludes([\n ...baseIncludes,\n ...includeDictionaryOrList,\n ]) :\n mergeIncludes(baseIncludes, includeDictionaryOrList);\n}\n","import { difference, filter, keys, pickBy } from 'lodash';\n\nimport joinIncludes from './join-includes';\n\n/**\n * Merges includes given a list of base includes and a dictionary\n * of includes\n */\nexport default function mergeIncludes<T extends string>(\n baseIncludes: T[],\n includesDictionary?: { [key in T]?: boolean }\n): string {\n const deletions = keys(pickBy(includesDictionary, on => !on));\n const additions = keys(filter(includesDictionary));\n\n return joinIncludes([\n ...difference(baseIncludes, deletions),\n ...additions,\n ]);\n}\n","const CHECKOUT_DEFAULT_INCLUDES = [\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'customer.customerGroup',\n 'payments',\n 'promotions.banners',\n];\n\nexport default CHECKOUT_DEFAULT_INCLUDES;\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../../common/error';\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error when we are unable to retrieve a checkout object from the\n * server using the provided ID. It could be because the shopper does not have\n * permission to view the object, or the ID itself is invalid.\n */\nexport default class CheckoutNotAvailableError extends RequestError {\n constructor(response: Response<InternalErrorResponseBody>) {\n super(response, { message: response.body.title });\n\n this.name = 'CheckoutNotAvailableError';\n this.type = 'checkout_not_available';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { joinOrMergeIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport Checkout, { CheckoutRequestBody } from './checkout';\nimport CHECKOUT_DEFAULT_INCLUDES from './checkout-default-includes';\nimport CheckoutParams from './checkout-params';\nimport { CheckoutNotAvailableError } from './errors';\n\nexport default class CheckoutRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadCheckout(id: string, { params: { include } = {}, timeout }: RequestOptions<CheckoutParams> = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkout/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.get<Checkout>(url, {\n params: {\n include: joinOrMergeIncludes(CHECKOUT_DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n }).catch(error => {\n if (error.status >= 400 && error.status < 500) {\n throw new CheckoutNotAvailableError(error);\n }\n\n throw error;\n });\n }\n\n updateCheckout(id: string, body: CheckoutRequestBody, { params: { include } = {}, timeout }: RequestOptions<CheckoutParams> = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkout/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, {\n params: {\n include: joinOrMergeIncludes(CHECKOUT_DEFAULT_INCLUDES, include),\n },\n body,\n headers,\n timeout,\n });\n }\n}\n","import { isEqual } from 'lodash';\n\nimport { PartialDeep } from '../common/types';\n\nimport Cart from './cart';\n\nexport default class CartComparator {\n isEqual(cartA: Cart, cartB: Cart): boolean {\n return isEqual(\n this._normalize(cartA),\n this._normalize(cartB)\n );\n }\n\n private _normalize(cart: Cart): PartialDeep<Cart> {\n return {\n cartAmount: cart.cartAmount,\n currency: cart.currency,\n id: cart.id,\n lineItems: {\n digitalItems: cart.lineItems.digitalItems\n .slice()\n .sort((itemA, itemB) =>\n `${itemA.productId}${itemA.variantId}`.localeCompare(`${itemB.productId}${itemB.variantId}`)\n )\n .map(item => ({\n extendedSalePrice: item.extendedSalePrice,\n productId: item.productId,\n quantity: item.quantity,\n variantId: item.variantId,\n })),\n giftCertificates: cart.lineItems.giftCertificates\n .slice()\n .sort((itemA, itemB) => `${itemA.id}`.localeCompare(`${itemB.id}`))\n .map(item => ({\n amount: item.amount,\n recipient: item.recipient,\n })),\n physicalItems: cart.lineItems.physicalItems\n .slice()\n .sort((itemA, itemB) =>\n `${itemA.productId}${itemA.variantId}`.localeCompare(`${itemB.productId}${itemB.variantId}`)\n )\n .map(item => ({\n extendedSalePrice: item.extendedSalePrice,\n productId: item.productId,\n quantity: item.quantity,\n variantId: item.variantId,\n giftWrapping: item.giftWrapping,\n })),\n },\n };\n }\n}\n","import { ComparableCheckout } from '../../checkout';\nimport { StandardError } from '../../common/error/errors';\n\nexport default class CartChangedError extends StandardError {\n /**\n * @alpha\n * Please note that this option is currently in an early stage of\n * development. Therefore the API is unstable and not ready for public\n * consumption.\n */\n data: { previous: ComparableCheckout; updated: ComparableCheckout };\n\n constructor(\n previous: ComparableCheckout,\n updated: ComparableCheckout\n ) {\n super('An update to your shopping cart has been detected and your available shipping costs have been updated.');\n\n this.name = 'CartChangedError';\n this.type = 'cart_changed';\n this.data = {\n previous,\n updated,\n };\n }\n}\n","import { isEqual, map } from 'lodash';\n\nimport { Cart, CartComparator } from '../cart';\nimport { CartChangedError } from '../cart/errors';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { Coupon, GiftCertificate } from '../coupon';\n\nimport Checkout from './checkout';\nimport CheckoutRequestSender from './checkout-request-sender';\nexport type ComparableCheckout = Pick<Checkout, 'outstandingBalance' | 'coupons' | 'giftCertificates'>\n & {\n cart: Partial<Cart>;\n };\n\nexport default class CheckoutValidator {\n constructor(\n private _checkoutRequestSender: CheckoutRequestSender\n ) {}\n\n validate(checkout?: Checkout, options?: RequestOptions): Promise<void> {\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n return this._checkoutRequestSender.loadCheckout(checkout.id, options)\n .then(response => {\n const comparator = new CartComparator();\n\n if (checkout.outstandingBalance === response.body.outstandingBalance\n && this._compareCoupons(checkout.coupons, response.body.coupons)\n && this._compareGiftCertificates(checkout.giftCertificates, response.body.giftCertificates)\n && comparator.isEqual(checkout.cart, response.body.cart)\n ) {\n return;\n }\n\n throw new CartChangedError(\n this._getComparableCheckout(checkout),\n this._getComparableCheckout(response.body)\n );\n });\n }\n\n private _compareCoupons(couponsA: Coupon[], couponsB: Coupon[]): boolean {\n return isEqual(map(couponsA, 'code'), map(couponsB, 'code'));\n }\n\n private _compareGiftCertificates(giftCertificatesA: GiftCertificate[], giftCertificatesB: GiftCertificate[]): boolean {\n return isEqual(map(giftCertificatesA, 'code'), map(giftCertificatesB, 'code'));\n }\n\n private _getComparableCheckout(\n checkout: Checkout\n ): ComparableCheckout {\n const { cart, coupons, giftCertificates, outstandingBalance } = checkout;\n\n return {\n cart: {\n cartAmount: cart.cartAmount,\n currency: cart.currency,\n lineItems: cart.lineItems,\n },\n coupons,\n giftCertificates,\n outstandingBalance,\n };\n }\n}\n","import { InvalidArgumentError } from '../error/errors';\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 _options: RegistryOptions;\n\n constructor(options?: RegistryOptions) {\n this._factories = {};\n this._instances = {};\n this._options = { defaultToken: 'default', ...options };\n }\n\n get(token?: K, cacheToken?: string): T {\n try {\n return this._getInstance(\n token || this._options.defaultToken,\n cacheToken || token || this._options.defaultToken\n );\n } catch (error) {\n return this._getInstance(\n this._options.defaultToken,\n cacheToken || this._options.defaultToken\n );\n }\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._factories[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 type Factory<T> = () => T;\n\nexport interface RegistryOptions {\n defaultToken: string;\n}\n","import { createAction, createErrorAction } from '@bigcommerce/data-store';\nimport { Observable, Observer } from 'rxjs';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { RequestOptions } from '../common/http-request';\n\nimport { ConfigRequestSender } from '.';\nimport { ConfigActionType, LoadConfigAction } from './config-actions';\n\nexport default class ConfigActionCreator {\n constructor(\n private _configRequestSender: ConfigRequestSender\n ) {}\n\n @cachableAction\n loadConfig(options?: RequestOptions & ActionOptions): Observable<LoadConfigAction> {\n return Observable.create((observer: Observer<LoadConfigAction>) => {\n observer.next(createAction(ConfigActionType.LoadConfigRequested));\n\n this._configRequestSender.loadConfig(options)\n .then(response => {\n observer.next(createAction(ConfigActionType.LoadConfigSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConfigActionType.LoadConfigFailed, response));\n });\n });\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { CheckoutNotAvailableError } from '../checkout/errors';\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport Config from './config';\n\nexport default class ConfigRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadConfig({ timeout }: RequestOptions = {}): Promise<Response<Config>> {\n const url = '/api/storefront/checkout-settings';\n\n return this._requestSender.get<Config>(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n }).catch(error => {\n if (error.status >= 400 && error.status < 500) {\n throw new CheckoutNotAvailableError(error);\n }\n throw error;\n });\n }\n}\n","import { createAction } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\n\nimport { FormFieldsActionType, LoadFormFieldsAction } from './form-fields-actions';\nimport FormFieldsRequestSender from './form-fields-request-sender';\n\nexport default class FormFieldsActionCreator {\n constructor(\n private _formFieldsRequestSender: FormFieldsRequestSender\n ) {}\n\n @cachableAction\n loadFormFields(options?: RequestOptions & ActionOptions): Observable<LoadFormFieldsAction> {\n return concat(\n of(createAction(FormFieldsActionType.LoadFormFieldsRequested)),\n defer(async () => {\n const { body } = await this._formFieldsRequestSender.loadFields(options);\n\n return createAction(FormFieldsActionType.LoadFormFieldsSucceeded, body);\n })\n ).pipe(\n catchError(response => throwErrorAction(FormFieldsActionType.LoadFormFieldsFailed, response))\n );\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { FormFields } from './form-field';\n\nexport default class FormFieldsRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadFields({ timeout }: RequestOptions = {}): Promise<Response<FormFields>> {\n const url = '/api/storefront/form-fields';\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam check.\n */\nexport default class SpamProtectionNotCompletedError extends StandardError {\n constructor() {\n super('You haven\\'t complete our spam check. Please try again.');\n\n this.name = 'SpamProtectionNotCompletedError';\n this.type = 'spam_protection_not_completed';\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, from, of, Observable, Observer } from 'rxjs';\nimport { catchError, switchMap } from 'rxjs/operators';\n\nimport { CheckoutValidator, InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { SpamProtectionNotCompletedError } from '../spam-protection/errors';\n\nimport InternalOrderRequestBody from './internal-order-request-body';\nimport { FinalizeOrderAction, LoadOrderAction, LoadOrderPaymentsAction, OrderActionType, SubmitOrderAction } from './order-actions';\nimport OrderRequestBody from './order-request-body';\nimport OrderRequestSender from './order-request-sender';\n\nexport default class OrderActionCreator {\n constructor(\n private _orderRequestSender: OrderRequestSender,\n private _checkoutValidator: CheckoutValidator\n ) {}\n\n loadOrder(orderId: number, options?: RequestOptions): Observable<LoadOrderAction> {\n return new Observable((observer: Observer<LoadOrderAction>) => {\n observer.next(createAction(OrderActionType.LoadOrderRequested));\n\n this._orderRequestSender.loadOrder(orderId, options)\n .then(response => {\n observer.next(createAction(OrderActionType.LoadOrderSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(OrderActionType.LoadOrderFailed, response));\n });\n });\n }\n\n // TODO: Remove when checkout does not contain unrelated order data.\n loadOrderPayments(orderId: number, options?: RequestOptions): Observable<LoadOrderPaymentsAction> {\n return new Observable((observer: Observer<LoadOrderPaymentsAction>) => {\n observer.next(createAction(OrderActionType.LoadOrderPaymentsRequested));\n\n this._orderRequestSender.loadOrder(orderId, options)\n .then(response => {\n observer.next(createAction(OrderActionType.LoadOrderPaymentsSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(OrderActionType.LoadOrderPaymentsFailed, response));\n });\n });\n }\n\n loadCurrentOrder(options?: RequestOptions): ThunkAction<LoadOrderAction, InternalCheckoutSelectors> {\n return store => defer(() => {\n const orderId = this._getCurrentOrderId(store.getState());\n\n if (!orderId) {\n throw new MissingDataError(MissingDataErrorType.MissingOrderId);\n }\n\n return this.loadOrder(orderId, options);\n });\n }\n\n submitOrder(payload?: OrderRequestBody, options?: RequestOptions): ThunkAction<SubmitOrderAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(OrderActionType.SubmitOrderRequested)),\n defer(() => {\n const state = store.getState();\n const externalSource = state.config.getExternalSource();\n const variantIdentificationToken = state.config.getVariantIdentificationToken();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (checkout.shouldExecuteSpamCheck) {\n throw new SpamProtectionNotCompletedError();\n }\n\n return from(\n this._checkoutValidator.validate(checkout, options)\n .then(() => this._orderRequestSender.submitOrder(\n this._mapToOrderRequestBody(\n payload ?? {},\n checkout.id,\n checkout.customerMessage,\n externalSource\n ),\n {\n ...options,\n headers: {\n checkoutVariant: variantIdentificationToken,\n },\n }))\n ).pipe(\n switchMap(response => concat(\n // TODO: Remove once we can submit orders using storefront API\n this.loadOrder(response.body.data.order.orderId, options),\n of(createAction(OrderActionType.SubmitOrderSucceeded, response.body.data, { ...response.body.meta, token: response.headers.token }))\n ))\n );\n }).pipe(\n catchError(error => throwErrorAction(OrderActionType.SubmitOrderFailed, error))\n )\n );\n }\n\n finalizeOrder(orderId: number, options?: RequestOptions): Observable<FinalizeOrderAction | LoadOrderAction> {\n return concat(\n of(createAction(OrderActionType.FinalizeOrderRequested)),\n from(this._orderRequestSender.finalizeOrder(orderId, options))\n .pipe(\n switchMap(response => concat(\n this.loadOrder(orderId, options),\n of(createAction(OrderActionType.FinalizeOrderSucceeded, response.body.data))\n ))\n )\n ).pipe(\n catchError(error => throwErrorAction(OrderActionType.FinalizeOrderFailed, error))\n );\n }\n\n private _getCurrentOrderId(state: InternalCheckoutSelectors): number | undefined {\n const order = state.order.getOrder();\n const checkout = state.checkout.getCheckout();\n\n return (order && order.orderId) || (checkout && checkout.orderId);\n }\n\n private _mapToOrderRequestBody(\n payload: OrderRequestBody,\n cartId: string,\n customerMessage: string,\n externalSource?: string\n ): InternalOrderRequestBody {\n const { payment, ...order } = payload;\n\n if (!payment) {\n return {\n ...order,\n cartId,\n customerMessage,\n externalSource,\n };\n }\n\n return {\n ...order,\n cartId,\n customerMessage,\n externalSource,\n payment: {\n paymentData: payment.paymentData,\n name: payment.methodId,\n gateway: payment.gatewayId,\n },\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Checkout prevents consumers from placing their orders when a merchant wishes\n * to be able to block transactions if the automated tax provider cannot be reached.\n */\nexport default class OrderTaxProviderUnavailableError extends StandardError {\n constructor(message?: string) {\n super(message || 'The tax provider is unavailable.');\n\n this.name = 'OrderTaxProviderUnavailableError';\n this.type = 'tax_provider_unavailable';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\nimport { isNil, omitBy } from 'lodash';\n\nimport { joinIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { OrderTaxProviderUnavailableError } from './errors';\nimport InternalOrderRequestBody from './internal-order-request-body';\nimport { InternalOrderResponseBody } from './internal-order-responses';\nimport Order from './order';\nimport OrderParams from './order-params';\n\nexport interface SubmitOrderRequestOptions extends RequestOptions {\n headers?: {\n checkoutVariant?: string;\n };\n}\n\nexport default class OrderRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadOrder(orderId: number, { timeout, params }: RequestOptions<OrderParams> = {}): Promise<Response<Order>> {\n const url = `/api/storefront/orders/${orderId}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n const include = [\n 'payments',\n 'lineItems.physicalItems.socialMedia',\n 'lineItems.physicalItems.options',\n 'lineItems.digitalItems.socialMedia',\n 'lineItems.digitalItems.options',\n ];\n\n return this._requestSender.get(url, {\n params: {\n include: joinIncludes([\n ...include,\n ...(params && params.include || []),\n ]),\n },\n headers,\n timeout,\n });\n }\n\n submitOrder(body?: InternalOrderRequestBody, { headers, timeout }: SubmitOrderRequestOptions = {}): Promise<Response<InternalOrderResponseBody>> {\n const url = '/internalapi/v1/checkout/order';\n\n return this._requestSender.post<InternalOrderResponseBody>(url, {\n body,\n headers: omitBy({\n 'X-Checkout-Variant': headers && headers.checkoutVariant,\n ...SDK_VERSION_HEADERS,\n }, isNil),\n timeout,\n }).catch(error => {\n if (error.body.type === 'tax_provider_unavailable') {\n throw new OrderTaxProviderUnavailableError();\n }\n\n throw error;\n });\n }\n\n finalizeOrder(orderId: number, { timeout }: RequestOptions = {}): Promise<Response<InternalOrderResponseBody>> {\n const url = `/internalapi/v1/checkout/order/${orderId}`;\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport PaymentRequestBody from './payment-request-body';\n\n/**\n * @todo Convert this file into TypeScript properly\n */\nexport default class PaymentRequestSender {\n /**\n * @constructor\n * @param {BigpayClient} client\n */\n constructor(\n private _client: any\n ) {}\n\n submitPayment(payload: PaymentRequestBody): Promise<Response<any>> {\n return new Promise((resolve, reject) => {\n this._client.submitPayment(payload, (error: any, response: any) => {\n if (error) {\n reject(this._transformResponse(error));\n } else {\n resolve(this._transformResponse(response));\n }\n });\n });\n }\n\n initializeOffsitePayment(payload: PaymentRequestBody, target?: string): Promise<void> {\n return new Promise(() => {\n this._client.initializeOffsitePayment(payload, null, target);\n });\n }\n\n private _transformResponse(response: any): Response<any> {\n return {\n headers: response.headers,\n body: response.data,\n status: response.status,\n statusText: response.statusText,\n };\n }\n}\n","import { isBillingAddressLike, BillingAddress } from '../billing';\nimport { Consignment } from '../shipping';\n\nimport Address from './address';\nimport InternalAddress from './internal-address';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalAddress(\n address: Address | BillingAddress,\n consignments?: Consignment[]\n): InternalAddress<any> {\n let addressId;\n\n if (isBillingAddressLike(address)) {\n addressId = address.id;\n } else if (consignments && consignments.length) {\n addressId = consignments[0].id;\n }\n\n return {\n id: addressId,\n firstName: address.firstName,\n lastName: address.lastName,\n company: address.company,\n addressLine1: address.address1,\n addressLine2: address.address2,\n city: address.city,\n province: address.stateOrProvince,\n provinceCode: address.stateOrProvinceCode,\n postCode: address.postalCode,\n country: address.country,\n countryCode: address.countryCode,\n phone: address.phone,\n customFields: address.customFields,\n };\n}\n","import { Address } from '../address';\n\nimport BillingAddress from './billing-address';\n\nexport default function isBillingAddressLike(address: Address): address is BillingAddress {\n const billingAddress = address as BillingAddress;\n\n return typeof billingAddress.id !== 'undefined';\n}\n","export default class AmountTransformer {\n constructor(private _decimalPlaces: number) {}\n\n toInteger(amount: number): number {\n return Math.round(amount * Math.pow(10, this._decimalPlaces));\n }\n}\n","import Coupon from './coupon';\nimport InternalCoupon from './internal-coupon';\n\nconst couponTypes = [\n 'per_item_discount',\n 'percentage_discount',\n 'per_total_discount',\n 'shipping_discount',\n 'free_shipping',\n];\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCoupon(coupon: Coupon): InternalCoupon {\n return {\n code: coupon.code,\n discount: coupon.displayName,\n discountType: couponTypes.indexOf(coupon.couponType),\n };\n}\n","import GiftCertificate from './gift-certificate';\nimport InternalGiftCertificate from './internal-gift-certificate';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalGiftCertificate(giftCertificate: GiftCertificate): InternalGiftCertificate {\n return {\n code: giftCertificate.code,\n discountedAmount: giftCertificate.used,\n remainingBalance: giftCertificate.remaining,\n giftCertificate: {\n balance: giftCertificate.balance,\n code: giftCertificate.code,\n purchaseDate: giftCertificate.purchaseDate,\n },\n };\n}\n","import InternalLineItem from './internal-line-item';\nimport { LineItem } from './line-item';\nimport LineItemMap from './line-item-map';\nimport mapGiftCertificateToInternalLineItem from './map-gift-certificate-to-internal-line-item';\nimport mapToInternalLineItem from './map-to-internal-line-item';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalLineItems(\n itemMap: LineItemMap,\n decimalPlaces: number,\n idKey: keyof LineItem = 'id'\n): InternalLineItem[] {\n return (Object.keys(itemMap) as Array<keyof LineItemMap>)\n .reduce((result, key) => [\n ...result,\n ...(itemMap[key] as LineItem[]).map((item: any) => {\n if (key === 'giftCertificates') {\n return mapGiftCertificateToInternalLineItem(item, decimalPlaces);\n }\n\n return mapToInternalLineItem(\n item,\n mapToInternalLineItemType(key),\n decimalPlaces,\n idKey\n );\n }),\n ], [] as InternalLineItem[]);\n}\n\nfunction mapToInternalLineItemType(type: string): string {\n switch (type) {\n case 'physicalItems':\n return 'ItemPhysicalEntity';\n\n case 'digitalItems':\n return 'ItemDigitalEntity';\n\n case 'giftCertificates':\n return 'ItemGiftCertificateEntity';\n\n default:\n return '';\n }\n}\n","import { AmountTransformer } from '../common/utility';\n\nimport InternalLineItem from './internal-line-item';\nimport { GiftCertificateItem } from './line-item';\n\nexport default function mapGiftCertificateToInternalLineItem(\n item: GiftCertificateItem,\n decimalPlaces: number\n): InternalLineItem {\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: item.id,\n imageUrl: '',\n name: item.name,\n amount: item.amount,\n amountAfterDiscount: item.amount,\n discount: 0,\n integerAmount: amountTransformer.toInteger(item.amount),\n integerAmountAfterDiscount: amountTransformer.toInteger(item.amount),\n integerUnitPrice: amountTransformer.toInteger(item.amount),\n integerUnitPriceAfterDiscount: amountTransformer.toInteger(item.amount),\n integerDiscount: 0,\n quantity: 1,\n sender: item.sender,\n recipient: item.recipient,\n type: 'ItemGiftCertificateEntity',\n attributes: [],\n variantId: null,\n };\n}\n","import { AmountTransformer } from '../common/utility';\n\nimport InternalLineItem from './internal-line-item';\nimport { DigitalItem, LineItem } from './line-item';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalLineItem(\n item: LineItem,\n type: string,\n decimalPlaces: number,\n idKey: keyof LineItem = 'id'\n): InternalLineItem {\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: (item[idKey] as string | number),\n imageUrl: item.imageUrl,\n amount: item.extendedListPrice,\n amountAfterDiscount: item.extendedSalePrice,\n discount: item.discountAmount,\n integerAmount: amountTransformer.toInteger(item.extendedListPrice),\n integerAmountAfterDiscount: amountTransformer.toInteger(item.extendedSalePrice),\n integerDiscount: amountTransformer.toInteger(item.discountAmount),\n integerUnitPrice: amountTransformer.toInteger(item.listPrice),\n integerUnitPriceAfterDiscount: amountTransformer.toInteger(item.salePrice),\n downloadsPageUrl: (item as DigitalItem).downloadPageUrl,\n name: item.name,\n quantity: item.quantity,\n brand: item.brand,\n sku: item.sku,\n categoryNames: item.categoryNames,\n variantId: item.variantId,\n productId: item.productId,\n attributes: (item.options || []).map(option => ({\n name: option.name,\n value: option.value,\n })),\n addedByPromotion: item.addedByPromotion,\n type,\n };\n}\n","import { keyBy, reduce, some } from 'lodash';\n\nimport { Checkout } from '../checkout';\nimport { AmountTransformer } from '../common/utility';\nimport { mapToInternalCoupon, mapToInternalGiftCertificate } from '../coupon';\nimport { mapToDiscountNotifications } from '../promotion';\n\nimport InternalCart from './internal-cart';\nimport mapToInternalLineItems from './map-to-internal-line-items';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCart(checkout: Checkout): InternalCart {\n const decimalPlaces = checkout.cart.currency.decimalPlaces;\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: checkout.cart.id,\n items: mapToInternalLineItems(checkout.cart.lineItems, decimalPlaces),\n currency: checkout.cart.currency.code,\n coupon: {\n discountedAmount: reduce(checkout.cart.coupons, (sum, coupon) => {\n return sum + coupon.discountedAmount;\n }, 0),\n coupons: checkout.cart.coupons.map(mapToInternalCoupon),\n },\n discount: {\n amount: checkout.cart.discountAmount,\n integerAmount: amountTransformer.toInteger(checkout.cart.discountAmount),\n },\n discountNotifications: mapToDiscountNotifications(checkout.promotions),\n giftCertificate: {\n totalDiscountedAmount: reduce(checkout.giftCertificates, (sum, certificate) => {\n return sum + certificate.used;\n }, 0),\n appliedGiftCertificates: keyBy(checkout.giftCertificates.map(mapToInternalGiftCertificate), 'code'),\n },\n shipping: {\n amount: checkout.shippingCostTotal,\n integerAmount: amountTransformer.toInteger(checkout.shippingCostTotal),\n amountBeforeDiscount: checkout.shippingCostBeforeDiscount,\n integerAmountBeforeDiscount: amountTransformer.toInteger(checkout.shippingCostBeforeDiscount),\n required: some(checkout.cart.lineItems.physicalItems, lineItem => lineItem.isShippingRequired),\n },\n subtotal: {\n amount: checkout.subtotal,\n integerAmount: amountTransformer.toInteger(checkout.subtotal),\n },\n storeCredit: {\n amount: checkout.customer ? checkout.customer.storeCredit : 0,\n },\n taxSubtotal: {\n amount: checkout.taxTotal,\n integerAmount: amountTransformer.toInteger(checkout.taxTotal),\n },\n taxes: checkout.taxes,\n taxTotal: {\n amount: checkout.taxTotal,\n integerAmount: amountTransformer.toInteger(checkout.taxTotal),\n },\n handling: {\n amount: checkout.handlingCostTotal,\n integerAmount: amountTransformer.toInteger(checkout.handlingCostTotal),\n },\n grandTotal: {\n amount: checkout.grandTotal,\n integerAmount: amountTransformer.toInteger(checkout.grandTotal),\n },\n };\n}\n","import { DiscountNotification } from '../discount';\n\nimport { Promotion } from '.';\n\nexport default function mapToDiscountNotifications(promotions?: Promotion[]): DiscountNotification[] {\n const notifications: DiscountNotification[] = [];\n\n (promotions || []).forEach(promotion => {\n (promotion.banners || []).forEach(banner => {\n notifications.push({\n placeholders: [],\n discountType: null,\n message: '',\n messageHtml: banner.text,\n });\n });\n });\n\n return notifications;\n}\n","import { mapToInternalAddress } from '../address';\nimport { BillingAddress } from '../billing';\n\nimport { Customer } from '.';\nimport InternalCustomer from './internal-customer';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCustomer(customer: Customer, billingAddress: BillingAddress): InternalCustomer {\n const firstName = customer.firstName || billingAddress.firstName || '';\n const lastName = customer.lastName || billingAddress.lastName || '';\n\n return {\n addresses: (customer.addresses || []).map(address => mapToInternalAddress(address)),\n customerId: customer.id,\n isGuest: customer.isGuest,\n storeCredit: customer.storeCredit,\n email: customer.email || billingAddress.email || '',\n firstName,\n lastName,\n name: customer.fullName || [firstName, lastName].join(' '),\n customerGroupName: customer.customerGroup && customer.customerGroup.name,\n };\n}\n","import CardExpiryDate from './card-expiry-date';\n\nconst NUMBER_SEPARATOR = '/';\n\nexport default class CardExpiryFormatter {\n format(value: string): string {\n const [month = '', year = ''] = value.split(new RegExp(`\\\\s*${NUMBER_SEPARATOR}\\\\s*`));\n const trimmedMonth = month.slice(0, 2);\n const trimmedYear = year.length === 4 ? year.slice(-2) : (year ? year.slice(0, 2) : month.slice(2));\n\n // i.e.: '1'\n if (value.length < 2) {\n return month;\n }\n\n // ie.: '10 /' (without trailing space)\n if (value.length > 3 && !trimmedYear) {\n return trimmedMonth;\n }\n\n return `${trimmedMonth} ${NUMBER_SEPARATOR} ${trimmedYear}`;\n }\n\n toObject(value: string): CardExpiryDate {\n const [month = '', year = ''] = value.split(new RegExp(`\\\\s*${NUMBER_SEPARATOR}\\\\s*`));\n\n if (!/^\\d+$/.test(month) || !/^\\d+$/.test(year)) {\n return { month: '', year: '' };\n }\n\n return {\n month: month.length === 1 ? `0${month}` : month.slice(0, 2),\n year: year.length === 2 ? `20${year}` : year.slice(0, 4),\n };\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"card-validator\");","import { creditCardType, number } from 'card-validator';\nimport { max } from 'lodash';\n\nconst NUMBER_SEPARATOR = ' ';\n\nexport default class CardNumberFormatter {\n format(value: string): string {\n const { card } = number(value);\n\n if (!card) {\n return value;\n }\n\n const maxLength = max(creditCardType(value).map(info => max(info.lengths)));\n const unformattedValue = this.unformat(value).slice(0, maxLength);\n\n return card.gaps\n .filter(gapIndex => unformattedValue.length > gapIndex)\n .reduce((output, gapIndex, index) => (\n [\n output.slice(0, gapIndex + index),\n output.slice(gapIndex + index),\n ].join(NUMBER_SEPARATOR)\n ), unformattedValue);\n }\n\n unformat(value: string): string {\n const { card } = number(value);\n\n if (!card) {\n return value;\n }\n\n return value.replace(new RegExp(NUMBER_SEPARATOR, 'g'), '');\n }\n}\n","import { filter, find, keyBy, reduce } from 'lodash';\n\nimport { mapToInternalLineItems, LineItem } from '../cart';\nimport { Checkout } from '../checkout';\nimport { AmountTransformer } from '../common/utility';\nimport { mapToInternalCoupon } from '../coupon';\nimport { HOSTED } from '../payment';\n\nimport InternalOrder, { InternalGiftCertificateList, InternalIncompleteOrder, InternalOrderPayment, InternalSocialDataList } from './internal-order';\nimport Order, { GatewayOrderPayment, GiftCertificateOrderPayment, OrderPayment, OrderPayments } from './order';\nimport { OrderMetaState } from './order-state';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalOrder(order: Order, orderMeta: OrderMetaState = {}): InternalOrder {\n const decimalPlaces = order.currency.decimalPlaces;\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: order.orderId,\n items: mapToInternalLineItems(order.lineItems, order.currency.decimalPlaces, 'productId'),\n orderId: order.orderId,\n currency: order.currency.code,\n customerCanBeCreated: order.customerCanBeCreated,\n payment: mapToInternalOrderPayment(order.payments, orderMeta.payment),\n subtotal: {\n amount: order.baseAmount,\n integerAmount: amountTransformer.toInteger(order.baseAmount),\n },\n coupon: {\n discountedAmount: reduce(order.coupons, (sum, coupon) => {\n return sum + coupon.discountedAmount;\n }, 0),\n coupons: order.coupons.map(mapToInternalCoupon),\n },\n discount: {\n amount: order.discountAmount,\n integerAmount: amountTransformer.toInteger(order.discountAmount),\n },\n token: orderMeta.orderToken,\n callbackUrl: orderMeta.callbackUrl,\n discountNotifications: [],\n giftCertificate: mapToGiftCertificates(order.payments),\n socialData: mapToInternalSocialDataList(order),\n status: order.status,\n hasDigitalItems: order.hasDigitalItems,\n isDownloadable: order.isDownloadable,\n isComplete: order.isComplete,\n shipping: {\n amount: order.shippingCostTotal,\n integerAmount: amountTransformer.toInteger(order.shippingCostTotal),\n amountBeforeDiscount: order.shippingCostBeforeDiscount,\n integerAmountBeforeDiscount: amountTransformer.toInteger(order.shippingCostBeforeDiscount),\n },\n storeCredit: {\n amount: mapToStoreCredit(order.payments),\n },\n taxes: order.taxes,\n taxTotal: {\n amount: order.taxTotal,\n integerAmount: amountTransformer.toInteger(order.taxTotal),\n },\n handling: {\n amount: order.handlingCostTotal,\n integerAmount: amountTransformer.toInteger(order.handlingCostTotal),\n },\n grandTotal: {\n amount: order.orderAmount,\n integerAmount: order.orderAmountAsInteger,\n },\n };\n}\n\nexport function mapToInternalIncompleteOrder(checkout: Checkout): InternalIncompleteOrder {\n const payment = find(checkout.payments, { providerType: HOSTED });\n\n return {\n orderId: null,\n isComplete: false,\n payment: !payment ? {} : {\n id: payment.providerId,\n gateway: payment.gatewayId,\n status: mapToInternalPaymentStatus(payment.detail.step),\n },\n };\n}\n\nfunction mapToInternalPaymentStatus(status: string): string {\n return `PAYMENT_STATUS_${status}`;\n}\n\nfunction mapToStoreCredit(payments?: OrderPayments): number {\n const item = find(payments, { providerId: 'storecredit' });\n\n return item ? item.amount : 0;\n}\n\nfunction mapToGiftCertificates(payments?: OrderPayments): InternalGiftCertificateList {\n const items = filter(payments, { providerId: 'giftcertificate' }) as GiftCertificateOrderPayment[];\n\n return {\n totalDiscountedAmount: reduce(items, (sum, item) => item.amount + sum, 0),\n appliedGiftCertificates: keyBy(items.map(item => ({\n code: item.detail.code,\n discountedAmount: item.amount,\n remainingBalance: item.detail.remaining,\n giftCertificate: {\n balance: item.amount + item.detail.remaining,\n code: item.detail.code,\n purchaseDate: '',\n },\n })), 'code'),\n };\n}\n\nfunction mapToInternalOrderPayment(payments?: OrderPayments, payment: InternalOrderPayment = {}): InternalOrderPayment {\n const item = find(payments, isDefaultOrderPayment) as GatewayOrderPayment;\n\n if (!item) {\n return {};\n }\n\n return {\n id: item.providerId,\n status: mapToInternalPaymentStatus(item.detail.step),\n helpText: item.detail.instructions,\n returnUrl: payment.returnUrl,\n };\n}\n\nfunction isDefaultOrderPayment(payment: OrderPayment): payment is GatewayOrderPayment {\n return payment.providerId !== 'giftcertificate' && payment.providerId !== 'storecredit';\n}\n\nfunction mapToInternalSocialDataList(order: Order): { [itemId: string]: InternalSocialDataList } | undefined {\n const socialDataObject: { [itemId: string]: InternalSocialDataList } = {};\n const items = [\n ...order.lineItems.physicalItems,\n ...order.lineItems.digitalItems,\n ];\n\n items.forEach(item => {\n socialDataObject[item.id] = mapToInternalSocialData(item);\n });\n\n return socialDataObject;\n}\n\nfunction mapToInternalSocialData(lineItem: LineItem): InternalSocialDataList {\n const codes = ['fb', 'tw', 'gp'];\n\n return codes.reduce((socialData, code) => {\n const item = lineItem.socialMedia && find(lineItem.socialMedia, item => item.code === code);\n\n if (!item) {\n return socialData;\n }\n\n socialData[code] = {\n name: lineItem.name,\n description: lineItem.name,\n image: lineItem.imageUrl,\n url: item.link,\n shareText: item.text,\n sharingLink: item.link,\n channelName: item.channel,\n channelCode: item.code,\n };\n\n return socialData;\n }, {} as InternalSocialDataList);\n}\n","import InternalShippingOption from './internal-shipping-option';\nimport ShippingOption from './shipping-option';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalShippingOption(option: ShippingOption, isSelected: boolean): InternalShippingOption {\n return {\n description: option.description,\n module: option.type,\n price: option.cost,\n id: option.id,\n selected: isSelected,\n isRecommended: option.isRecommended,\n imageUrl: option.imageUrl,\n transitTime: option.transitTime,\n };\n}\n","import { pick } from 'lodash';\n\nimport { mapToInternalAddress } from '../address';\nimport { mapToInternalCart } from '../cart';\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { CheckoutButtonMethodType } from '../checkout-buttons/strategies';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { mapToInternalCustomer } from '../customer';\nimport { HostedFormOrderData } from '../hosted-form';\nimport { CardExpiryFormatter, CardNumberFormatter, HostedInputValues } from '../hosted-form/iframe-content';\nimport { mapToInternalOrder } from '../order';\nimport { mapToInternalShippingOption } from '../shipping';\n\nimport isVaultedInstrument, { isFormattedVaultedInstrument } from './is-vaulted-instrument';\nimport Payment, { HostedCreditCardInstrument, HostedVaultedInstrument, PaymentInstrument } from './payment';\nimport PaymentMethod from './payment-method';\nimport PaymentRequestBody from './payment-request-body';\n\nexport default class PaymentRequestTransformer {\n private _cardExpiryFormatter = new CardExpiryFormatter();\n private _cardNumberFormatter = new CardNumberFormatter();\n\n transform(payment: Payment, checkoutState: InternalCheckoutSelectors): PaymentRequestBody {\n const billingAddress = checkoutState.billingAddress.getBillingAddress();\n const checkout = checkoutState.checkout.getCheckout();\n const customer = checkoutState.customer.getCustomer();\n const order = checkoutState.order.getOrder();\n const paymentMethod = checkoutState.paymentMethods.getPaymentMethod(payment.methodId, payment.gatewayId);\n const shippingAddress = checkoutState.shippingAddress.getShippingAddress();\n const consignments = checkoutState.consignments.getConsignments();\n const shippingOption = checkoutState.consignments.getShippingOption();\n const storeConfig = checkoutState.config.getStoreConfig();\n const contextConfig = checkoutState.config.getContextConfig();\n const instrumentMeta = checkoutState.instruments.getInstrumentsMeta();\n const paymentMeta = checkoutState.paymentMethods.getPaymentMethodsMeta();\n const orderMeta = checkoutState.order.getOrderMeta();\n const internalCustomer = customer && billingAddress && mapToInternalCustomer(customer, billingAddress);\n\n const authToken = instrumentMeta && payment.paymentData &&\n (isVaultedInstrument(payment.paymentData) || isFormattedVaultedInstrument(payment.paymentData)) ?\n `${checkoutState.payment.getPaymentToken()}, ${instrumentMeta.vaultAccessToken}` :\n checkoutState.payment.getPaymentToken();\n\n if (!authToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentToken);\n }\n\n return {\n additionalAction: payment.additionalAction,\n authToken,\n customer: internalCustomer,\n billingAddress: billingAddress && mapToInternalAddress(billingAddress),\n shippingAddress: shippingAddress && mapToInternalAddress(shippingAddress, consignments),\n shippingOption: shippingOption && mapToInternalShippingOption(shippingOption, true),\n cart: checkout && mapToInternalCart(checkout),\n order: order && mapToInternalOrder(order, orderMeta),\n orderMeta,\n payment: payment.paymentData,\n paymentMethod: paymentMethod && this._transformPaymentMethod(paymentMethod),\n quoteMeta: {\n request: {\n ...paymentMeta,\n geoCountryCode: contextConfig && contextConfig.geoCountryCode,\n },\n },\n source: 'bigcommerce-checkout-js-sdk',\n store: pick(storeConfig && storeConfig.storeProfile, [\n 'storeHash',\n 'storeId',\n 'storeLanguage',\n 'storeName',\n ]),\n };\n }\n\n transformWithHostedFormData(values: HostedInputValues, data: HostedFormOrderData, nonce: string): PaymentRequestBody {\n const { additionalAction, authToken, checkout, config, order, orderMeta, payment = {}, paymentMethod, paymentMethodMeta } = data;\n const consignment = checkout && checkout.consignments[0];\n const shippingAddress = consignment && consignment.shippingAddress;\n const shippingOption = consignment && consignment.selectedShippingOption;\n\n return {\n additionalAction,\n authToken,\n paymentMethod: paymentMethod && this._transformPaymentMethod(paymentMethod),\n customer: order && order.billingAddress && checkout && mapToInternalCustomer(checkout.customer, order.billingAddress),\n billingAddress: order && order.billingAddress && mapToInternalAddress(order.billingAddress),\n shippingAddress: shippingAddress && checkout && mapToInternalAddress(shippingAddress, checkout.consignments),\n shippingOption: shippingOption && mapToInternalShippingOption(shippingOption, true),\n cart: checkout && mapToInternalCart(checkout),\n order: order && mapToInternalOrder(order, orderMeta),\n orderMeta,\n payment: this._transformHostedInputValues(values, payment, nonce),\n quoteMeta: {\n request: {\n ...paymentMethodMeta,\n geoCountryCode: config && config.context.geoCountryCode,\n },\n },\n source: 'bigcommerce-checkout-js-sdk',\n store: config && pick(config.storeConfig.storeProfile, [\n 'storeHash',\n 'storeId',\n 'storeLanguage',\n 'storeName',\n ]),\n };\n }\n\n private _transformPaymentMethod(paymentMethod: PaymentMethod): PaymentMethod {\n if (paymentMethod.method === 'multi-option' && !paymentMethod.gateway) {\n return { ...paymentMethod, gateway: paymentMethod.id };\n }\n\n if (paymentMethod.initializationData && paymentMethod.initializationData.gateway) {\n return { ...paymentMethod, id: paymentMethod.initializationData.gateway };\n }\n\n if (paymentMethod.id === CheckoutButtonMethodType.BRAINTREE_VENMO) {\n return { ...paymentMethod, id: CheckoutButtonMethodType.BRAINTREE_PAYPAL };\n }\n\n return paymentMethod;\n }\n\n private _transformHostedInputValues(\n values: HostedInputValues,\n payment: HostedCreditCardInstrument | HostedVaultedInstrument,\n nonce: string\n ): PaymentInstrument {\n return 'instrumentId' in payment ?\n {\n ...payment,\n ccCvv: values.cardCodeVerification,\n ccNumber: values.cardNumberVerification && this._cardNumberFormatter.unformat(values.cardNumberVerification),\n hostedFormNonce: nonce,\n } :\n {\n ...payment,\n ccCvv: values.cardCode,\n ccExpiry: this._cardExpiryFormatter.toObject(values.cardExpiry || ''),\n ccName: values.cardName || '',\n ccNumber: this._cardNumberFormatter.unformat(values.cardNumber || ''),\n hostedFormNonce: nonce,\n };\n }\n}\n","import { FormattedPayload, FormattedVaultedInstrument, HostedVaultedInstrument, PaymentInstrument, VaultedInstrument } from './payment';\n\nexport default function isVaultedInstrument(instrument: PaymentInstrument): instrument is VaultedInstrument {\n return Boolean((instrument as VaultedInstrument).instrumentId);\n}\n\nexport function isHostedVaultedInstrument(instrument: PaymentInstrument): instrument is HostedVaultedInstrument {\n return (\n Boolean((instrument as HostedVaultedInstrument).instrumentId) &&\n !Object.prototype.hasOwnProperty.call(instrument, 'ccNumber') &&\n !Object.prototype.hasOwnProperty.call(instrument, 'ccCvv')\n );\n}\n\nexport function isFormattedVaultedInstrument(instrument: PaymentInstrument): instrument is FormattedPayload<FormattedVaultedInstrument> {\n const formattedInstrument = (instrument as FormattedPayload<FormattedVaultedInstrument>).formattedPayload;\n\n if (!formattedInstrument) {\n return false;\n }\n\n return typeof formattedInstrument.bigpay_token === 'string' ||\n Boolean(formattedInstrument.bigpay_token && formattedInstrument.bigpay_token.token);\n}\n","import { createAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, of } from 'rxjs';\nimport { catchError, switchMap } from 'rxjs/operators';\n\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { OrderActionCreator } from '../order';\nimport { PaymentHumanVerificationHandler } from '../spam-protection';\n\nimport Payment, { FormattedHostedInstrument, FormattedPayload, FormattedVaultedInstrument } from './payment';\nimport { InitializeOffsitePaymentAction, PaymentActionType, SubmitPaymentAction } from './payment-actions';\nimport PaymentRequestSender from './payment-request-sender';\nimport PaymentRequestTransformer from './payment-request-transformer';\n\ninterface InitializeOffsitePaymentSettings {\n methodId: string;\n gatewayId?: string;\n instrumentId?: string;\n target?: string;\n promise?: Promise<undefined>;\n shouldSaveInstrument?: boolean;\n shouldSetAsDefaultInstrument?: boolean;\n}\n\ntype InitializeOffsitePayment = (settings: InitializeOffsitePaymentSettings)\n => ThunkAction<InitializeOffsitePaymentAction, InternalCheckoutSelectors>;\n\nexport default class PaymentActionCreator {\n constructor(\n private _paymentRequestSender: PaymentRequestSender,\n private _orderActionCreator: OrderActionCreator,\n private _paymentRequestTransformer: PaymentRequestTransformer,\n private _paymentHumanVerificationHandler: PaymentHumanVerificationHandler\n ) {}\n\n submitPayment(payment: Payment): ThunkAction<SubmitPaymentAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(PaymentActionType.SubmitPaymentRequested)),\n defer(async () => {\n try {\n return await this._paymentRequestSender.submitPayment(\n this._paymentRequestTransformer.transform(payment, store.getState())\n );\n } catch (error) {\n const additionalAction = await this._paymentHumanVerificationHandler.handle(error);\n\n return await this._paymentRequestSender.submitPayment(\n this._paymentRequestTransformer.transform({ ...payment, additionalAction }, store.getState())\n );\n }\n })\n .pipe(\n switchMap(({ body }) => concat(\n this._orderActionCreator.loadCurrentOrder()(store),\n of(createAction(PaymentActionType.SubmitPaymentSucceeded, body))\n ))\n )\n ).pipe(\n catchError(error => throwErrorAction(PaymentActionType.SubmitPaymentFailed, error))\n );\n }\n\n initializeOffsitePayment: InitializeOffsitePayment = ({\n methodId,\n gatewayId,\n instrumentId,\n target,\n promise,\n shouldSaveInstrument,\n shouldSetAsDefaultInstrument,\n }) => {\n return store => {\n let paymentData: FormattedPayload<FormattedHostedInstrument | FormattedVaultedInstrument> | undefined;\n\n if (instrumentId) {\n paymentData = { formattedPayload: { bigpay_token: instrumentId } };\n } else if (shouldSaveInstrument) {\n paymentData = {\n formattedPayload: {\n vault_payment_instrument: shouldSaveInstrument,\n set_as_default_stored_instrument: shouldSetAsDefaultInstrument || null,\n },\n };\n }\n\n const payload = this._paymentRequestTransformer.transform({ gatewayId, methodId, paymentData }, store.getState());\n\n return concat(\n of(createAction(PaymentActionType.InitializeOffsitePaymentRequested)),\n Promise.race([this._paymentRequestSender.initializeOffsitePayment(payload, target), promise].filter(Boolean))\n .then(() => createAction(PaymentActionType.InitializeOffsitePaymentSucceeded))\n ).pipe(\n catchError(error => throwErrorAction(PaymentActionType.InitializeOffsitePaymentFailed, error))\n );\n };\n };\n}\n","import StandardError from './standard-error';\n\nexport enum NotInitializedErrorType {\n CheckoutButtonNotInitialized,\n CustomerNotInitialized,\n PaymentNotInitialized,\n ShippingNotInitialized,\n SpamProtectionNotInitialized,\n}\n\n/**\n * Throw this error if a method requires a certain initialization call to be\n * made first. Some objects can be constructed but they cannot be used until a\n * separate initialization call is made.\n */\nexport default class NotInitializedError extends StandardError {\n constructor(\n public subtype: NotInitializedErrorType\n ) {\n super(getErrorMessage(subtype));\n\n this.name = 'NotInitializedError';\n this.type = 'not_initialized';\n }\n}\n\nfunction getErrorMessage(type: NotInitializedErrorType): string {\n switch (type) {\n case NotInitializedErrorType.CustomerNotInitialized:\n return 'Unable to proceed because the customer step of checkout has not been initialized.';\n\n case NotInitializedErrorType.PaymentNotInitialized:\n return 'Unable to proceed because the payment step of checkout has not been initialized.';\n\n case NotInitializedErrorType.ShippingNotInitialized:\n return 'Unable to proceed because the shipping step of checkout has not been initialized.';\n\n case NotInitializedErrorType.SpamProtectionNotInitialized:\n return 'Unable to proceed because the checkout spam protection has not been initialized.';\n\n default:\n return 'Unable to proceed because the required component has not been initialized.';\n }\n}\n","import { PaymentMethod } from '../..';\nimport { AmazonPayV2ButtonInitializeOptions } from '../../../checkout-buttons/strategies/amazon-pay-v2';\nimport { NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\n\nimport { AmazonPayV2ChangeActionType, AmazonPayV2SDK } from './amazon-pay-v2';\nimport AmazonPayV2ScriptLoader from './amazon-pay-v2-script-loader';\n\nexport default class AmazonPayV2PaymentProcessor {\n private _amazonPayV2SDK?: AmazonPayV2SDK;\n\n constructor(\n private _amazonPayV2ScriptLoader: AmazonPayV2ScriptLoader\n ) { }\n\n async initialize(paymentMethod: PaymentMethod): Promise<void> {\n this._amazonPayV2SDK = await this._amazonPayV2ScriptLoader.load(paymentMethod);\n }\n\n deinitialize(): Promise<void> {\n this._amazonPayV2SDK = undefined;\n\n return Promise.resolve();\n }\n\n bindButton(buttonId: string, sessionId: string, changeAction: AmazonPayV2ChangeActionType): void {\n this._getAmazonPayV2SDK().Pay.bindChangeAction(`#${buttonId}`, {\n amazonCheckoutSessionId: sessionId,\n changeAction,\n });\n }\n\n createButton(containerId: string, options: AmazonPayV2ButtonInitializeOptions): HTMLElement {\n return this._getAmazonPayV2SDK().Pay.renderButton(containerId, options);\n }\n\n async signout(): Promise<void> {\n if (this._amazonPayV2SDK) {\n this._amazonPayV2SDK.Pay.signout();\n }\n\n return Promise.resolve();\n }\n\n private _getAmazonPayV2SDK(): AmazonPayV2SDK {\n if (!this._amazonPayV2SDK) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._amazonPayV2SDK;\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when the client library of a payment method fails\n * to load, or for some reason, it is inaccessible.\n */\nexport default class PaymentMethodClientUnavailableError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to proceed because the client library of a payment method is not loaded or ready to be used.');\n\n this.name = 'PaymentMethodClientUnavailableError';\n this.type = 'payment_method_client_unavailable';\n }\n}\n","export type EnvironmentType = 'PRODUCTION' | 'TEST';\n\nexport interface AmazonPayV2Options {\n environment: EnvironmentType;\n}\n\nexport interface AmazonPayV2SDK {\n Pay: AmazonPayV2Client;\n}\n\nexport interface AmazonPayV2Client {\n /**\n * Render the Amazon Pay button to a HTML container element.\n *\n * @param containerId - HTML element id.\n * @param params - Button rendering params.\n */\n renderButton(containerId: string, params: AmazonPayV2ButtonParams): HTMLElement;\n\n /**\n * Bind click events to HTML elements, so that when the element is clicked, the buyer can select a different shipping address or payment method.\n *\n * @param buttonId - HTML element id.\n * @param options - Element binding options.\n */\n bindChangeAction(buttonId: string, options: AmazonPayV2ChangeActionOptions): void;\n\n /**\n * Allow buyers to sign out from their Amazon account.\n */\n signout(): void;\n}\n\nexport interface AmazonPayV2HostWindow extends Window {\n amazon?: AmazonPayV2SDK;\n}\n\nexport interface AmazonPayV2ButtonParams {\n /**\n * Amazon Pay merchant account identifier.\n */\n merchantId: string;\n\n /**\n * Configuration for calling the endpoint to Create Checkout Session.\n */\n createCheckoutSession: AmazonPayV2CheckoutSession;\n\n /**\n * Placement of the Amazon Pay button on your website.\n */\n placement: AmazonPayV2Placement;\n\n /**\n * Ledger currency provided during registration for the given merchant identifier.\n */\n ledgerCurrency: AmazonPayV2LedgerCurrency;\n\n /**\n * Product type selected for checkout. Default is 'PayAndShip'.\n */\n productType?: AmazonPayV2PayOptions;\n\n /**\n * Language used to render the button and text on Amazon Pay hosted pages.\n */\n checkoutLanguage?: AmazonPayV2CheckoutLanguage;\n\n /**\n * Sets button to Sandbox environment. Default is false.\n */\n sandbox?: boolean;\n}\n\nexport interface AmazonPayV2CheckoutSession {\n /**\n * Endpoint URL to Create Checkout Session.\n */\n url: string;\n\n /**\n * HTTP request method. Default is 'POST'.\n */\n method?: 'GET' | 'POST';\n\n /**\n * Checkout Session ID parameter in the response. Default is 'checkoutSessionId'.\n */\n extractAmazonCheckoutSessionId?: string;\n}\n\nexport type AmazonPayV2ChangeActionType = 'changeAddress' | 'changePayment';\n\nexport interface AmazonPayV2ChangeActionOptions {\n /**\n * Amazon Pay Checkout Session identifier.\n */\n amazonCheckoutSessionId: string;\n\n /**\n * Update requested by the buyer.\n */\n changeAction: AmazonPayV2ChangeActionType;\n}\n\nexport enum AmazonPayV2Regions {\n de = 'eu',\n jp = 'fe',\n uk = 'eu',\n us = 'na',\n}\n\nexport enum AmazonPayV2CheckoutLanguage {\n en_US = 'en_US',\n en_GB = 'en_GB',\n de_DE = 'de_DE',\n fr_FR = 'fr_FR',\n it_IT = 'it_IT',\n es_ES = 'es_ES',\n ja_JP = 'ja_JP',\n}\n\nexport enum AmazonPayV2Placement {\n /** Initial or main page. */\n Home = 'Home',\n\n /** Product details page. */\n Product = 'Product',\n\n /** Cart review page before buyer starts checkout. */\n Cart = 'Cart',\n\n /** Any page after buyer starts checkout. */\n Checkout = 'Checkout',\n\n /** Any page that doesn't fit the previous descriptions. */\n Other = 'Other',\n}\n\nexport enum AmazonPayV2LedgerCurrency {\n USD = 'USD',\n EUR = 'EUR',\n GBP = 'GBP',\n JPY = 'JPY',\n}\n\nexport enum AmazonPayV2PayOptions {\n /** Select this product type if you need the buyer's shipping details. */\n PayAndShip = 'PayAndShip',\n\n /** Select this product type if you do not need the buyer's shipping details. */\n PayOnly = 'PayOnly',\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { AmazonPayV2HostWindow, AmazonPayV2Regions, AmazonPayV2SDK } from './amazon-pay-v2';\n\nexport default class AmazonPayV2ScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: AmazonPayV2HostWindow = window\n ) {}\n\n async load(method: PaymentMethod): Promise<AmazonPayV2SDK> {\n const {\n initializationData: { region = 'us' } = {},\n } = method;\n\n const amazonPayV2Region = (AmazonPayV2Regions as any)[region];\n\n await this._scriptLoader.loadScript(`https://static-${amazonPayV2Region}.payments-amazon.com/checkout.js`);\n if (!this._window.amazon) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.amazon;\n }\n}\n","import { assertApplePayWindow } from './is-apple-pay-window';\n\nexport default class ApplePaySessionFactory {\n create(request: ApplePayJS.ApplePayPaymentRequest): ApplePaySession {\n assertApplePayWindow(window);\n\n return new ApplePaySession(1, request);\n }\n}\n","import StandardError from './standard-error';\n\n/**\n * Throw this error if the shopper is using a browser version that is not\n * supported by us or any third party provider we use.\n */\nexport default class UnsupportedBrowserError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unsupported browser error');\n\n this.name = 'UnsupportedBrowserError';\n this.type = 'unsupported_browser';\n }\n}\n","import { GooglePaymentData, GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1, GooglePayCreator, TokenizePayload } from '../googlepay';\nimport { PaypalAuthorizeData, PaypalButtonOptions, PaypalButtonRender, PaypalSDK } from '../paypal';\n\nimport { VisaCheckoutInitOptions, VisaCheckoutPaymentSuccessPayload, VisaCheckoutTokenizedPayload } from './visacheckout';\n\n/**\n *\n * Constants\n *\n */\nexport const PAYPAL_COMPONENTS = ['buttons', 'messages'];\n\n/**\n *\n * Common\n *\n */\nexport interface BraintreeModuleCreator<TInstance, TOptions = BraintreeModuleCreatorConfig, TError = BraintreeError> {\n create(config: TOptions, callback?: (error: TError, instance: TInstance) => void): Promise<TInstance>;\n}\n\nexport interface BraintreeModuleCreatorConfig {\n client?: BraintreeClient;\n authorization?: string;\n}\n\nexport interface BraintreeModule {\n teardown(): Promise<void>;\n}\n\nexport interface BraintreeSDK {\n client?: BraintreeClientCreator;\n dataCollector?: BraintreeDataCollectorCreator;\n googlePayment?: GooglePayCreator;\n hostedFields?: BraintreeHostedFieldsCreator;\n paypal?: BraintreePaypalCreator;\n paypalCheckout?: BraintreePaypalCheckoutCreator;\n threeDSecure?: BraintreeThreeDSecureCreator;\n venmo?: BraintreeVenmoCheckoutCreator;\n visaCheckout?: BraintreeVisaCheckoutCreator;\n}\n\nexport interface BraintreePaypalRequest {\n amount: string | number;\n billingAgreementDescription?: string;\n currency?: string;\n displayName?: string;\n enableShippingAddress: true;\n flow: 'checkout' | 'vault';\n intent?: 'authorize' | 'order' | 'sale';\n landingPageType?: 'login' | 'billing';\n locale?: string;\n offerCredit?: boolean;\n shippingAddressEditable?: boolean;\n shippingAddressOverride?: BraintreeShippingAddressOverride;\n useraction?: 'commit';\n}\n\nexport interface BraintreeShippingAddressOverride {\n line1: string;\n line2?: string;\n city: string;\n state: string;\n postalCode: string;\n countryCode: string;\n phone?: string;\n recipientName?: string;\n}\n\nexport interface BraintreeTokenizePayload {\n nonce: string;\n type: 'PaypalAccount' | 'VenmoAccount';\n details: BraintreeDetails;\n creditFinancingOffered?: {\n totalCost: {\n value: string;\n currency: string;\n };\n term: number;\n monthlyPayment: {\n value: string;\n currency: string;\n };\n totalInsterest: {\n value: string;\n currency: string;\n };\n payerAcceptance: boolean;\n cartAmountImmutable: boolean;\n };\n}\n\nexport interface BraintreeDetails {\n username?: string;\n email?: string;\n payerId?: string;\n firstName?: string;\n lastName?: string;\n countryCode?: string;\n phone?: string;\n shippingAddress?: BraintreeShippingAddress;\n billingAddress?: BraintreeAddress;\n}\n\nexport interface BraintreeAddress {\n line1: string;\n line2: string;\n city: string;\n state: string;\n postalCode: string;\n countryCode: string;\n}\n\nexport interface BraintreeShippingAddress extends BraintreeAddress {\n recipientName: string;\n}\n\nexport interface BraintreeVerifyPayload {\n nonce: string;\n details: {\n cardType: string;\n lastFour: string;\n lastTwo: string;\n };\n description: string;\n liabilityShiftPossible: boolean;\n liabilityShifted: boolean;\n}\n\nexport interface BraintreeError extends Error {\n type: 'CUSTOMER' | 'MERCHANT' | 'NETWORK' | 'INTERNAL' | 'UNKNOWN';\n code: string;\n details?: unknown;\n}\n\n/**\n *\n * Braintree Client\n *\n */\nexport type BraintreeClientCreator = BraintreeModuleCreator<BraintreeClient>;\n\nexport interface BraintreeClient {\n request(payload: BraintreeRequestData): Promise<BraintreeTokenizeResponse>;\n getVersion(): string | void;\n}\n\nexport interface BraintreeRequestData {\n data: {\n creditCard: {\n billingAddress?: {\n countryCodeAlpha2: string;\n locality: string;\n countryName: string;\n postalCode: string;\n streetAddress: string;\n };\n cardholderName: string;\n cvv?: string;\n expirationDate: string;\n number: string;\n options: {\n validate: boolean;\n };\n };\n };\n endpoint: string;\n method: string;\n}\n\nexport interface BraintreeTokenizeResponse {\n creditCards: Array<{ nonce: string }>;\n}\n\n/**\n *\n * Braintree Data Collector\n *\n */\nexport type BraintreeDataCollectorCreator = BraintreeModuleCreator<BraintreeDataCollector, BraintreeDataCollectorCreatorConfig>;\n\nexport interface BraintreeDataCollectorCreatorConfig extends BraintreeModuleCreatorConfig {\n kount?: boolean;\n paypal?: boolean;\n}\n\nexport interface BraintreeDataCollector extends BraintreeModule {\n deviceData?: string;\n}\n\n/**\n *\n * Braintree Google Pay\n *\n */\nexport interface BraintreeGooglePayThreeDSecure {\n verifyCard(options: BraintreeGooglePayThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeGooglePayThreeDSecureOptions {\n nonce: string;\n amount: number;\n showLoader?: boolean;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\n}\n\nexport interface GooglePayBraintreeSDK extends BraintreeModule {\n createPaymentDataRequest(request?: GooglePayBraintreeDataRequest): GooglePayBraintreePaymentDataRequestV1;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\n/**\n *\n * Braintree Hosted Fields\n *\n */\nexport type BraintreeHostedFieldsCreator = BraintreeModuleCreator<BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig>;\n\nexport interface BraintreeHostedFields {\n teardown(): Promise<void>;\n tokenize(options?: BraintreeHostedFieldsTokenizeOptions): Promise<BraintreeHostedFieldsTokenizePayload>;\n on(eventName: string, callback: (event: BraintreeHostedFieldsState) => void): void;\n}\n\nexport interface BraintreeHostedFieldsCreatorConfig extends BraintreeModuleCreatorConfig {\n fields: {\n number?: BraintreeHostedFieldOption;\n expirationDate?: BraintreeHostedFieldOption;\n expirationMonth?: BraintreeHostedFieldOption;\n expirationYear?: BraintreeHostedFieldOption;\n cvv?: BraintreeHostedFieldOption;\n postalCode?: BraintreeHostedFieldOption;\n };\n styles?: {\n input?: { [key: string]: string };\n '.invalid'?: { [key: string]: string };\n '.valid'?: { [key: string]: string };\n ':focus'?: { [key: string]: string };\n };\n}\n\nexport interface BraintreeHostedFieldOption {\n container: string | HTMLElement;\n placeholder?: string;\n type?: string;\n formatInput?: boolean;\n maskInput?: boolean | { character?: string; showLastFour?: string };\n select?: boolean | { options?: string[] };\n maxCardLength?: number;\n maxlength?: number;\n minlength?: number;\n prefill?: string;\n rejectUnsupportedCards?: boolean;\n supportedCardBrands?: { [key: string]: boolean };\n}\n\nexport interface BraintreeHostedFieldsState {\n cards: BraintreeHostedFieldsCard[];\n emittedBy: string;\n fields: {\n number?: BraintreeHostedFieldsFieldData;\n expirationDate?: BraintreeHostedFieldsFieldData;\n expirationMonth?: BraintreeHostedFieldsFieldData;\n expirationYear?: BraintreeHostedFieldsFieldData;\n cvv?: BraintreeHostedFieldsFieldData;\n postalCode?: BraintreeHostedFieldsFieldData;\n };\n}\n\nexport interface BraintreeHostedFieldsCard {\n type: string;\n niceType: string;\n code: { name: string; size: number };\n}\n\nexport interface BraintreeHostedFieldsFieldData {\n container: HTMLElement;\n isFocused: boolean;\n isEmpty: boolean;\n isPotentiallyValid: boolean;\n isValid: boolean;\n}\n\nexport interface BraintreeHostedFieldsTokenizeOptions {\n vault?: boolean;\n fieldsToTokenize?: string[];\n cardholderName?: string;\n billingAddress?: BraintreeBillingAddressRequestData;\n}\n\nexport interface BraintreeHostedFieldsTokenizePayload {\n nonce: string;\n details: {\n bin: string;\n cardType: string;\n expirationMonth: string;\n expirationYear: string;\n lastFour: string;\n lastTwo: string;\n };\n description: string;\n type: string;\n binData: {\n commercial: string;\n countryOfIssuance: string;\n debit: string;\n durbinRegulated: string;\n healthcare: string;\n issuingBank: string;\n payroll: string;\n prepaid: string;\n productId: string;\n };\n}\n\nexport interface BraintreeBillingAddressRequestData {\n postalCode?: string;\n firstName?: string;\n lastName?: string;\n company?: string;\n streetAddress?: string;\n extendedAddress?: string;\n locality?: string;\n region?: string;\n countryCodeNumeric?: string;\n countryCodeAlpha2?: string;\n countryCodeAlpha3?: string;\n countryName?: string;\n}\n\nexport interface BraintreeHostedFormError extends BraintreeError {\n details?: {\n invalidFieldKeys?: string[];\n };\n}\n\n/**\n *\n * Braintree 3D Secure\n *\n */\nexport type BraintreeThreeDSecureCreator = BraintreeModuleCreator<BraintreeThreeDSecure, BraintreeThreeDSecureCreatorConfig>;\n\nexport interface BraintreeThreeDSecure extends BraintreeModule {\n verifyCard(options: BraintreeThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n cancelVerifyCard(): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeThreeDSecureCreatorConfig extends BraintreeModuleCreatorConfig {\n version?: number;\n}\n\nexport interface BraintreeThreeDSecureOptions {\n nonce: string;\n amount: number;\n challengeRequested: boolean;\n showLoader?: boolean;\n addFrame(error: Error | undefined, iframe: HTMLIFrameElement): void;\n removeFrame(): void;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\n}\n\ninterface BraintreeThreeDSecureVerificationData {\n lookup: {\n threeDSecureVersion: string;\n };\n paymentMethod: BraintreeVerifyPayload;\n requiresUserAuthentication: boolean;\n threeDSecureInfo: {\n liabilityShiftPossible: boolean;\n liabilityShifted: boolean;\n };\n}\n\n/**\n *\n * Braintree PayPal\n *\n */\nexport type BraintreePaypalCreator = BraintreeModuleCreator<BraintreePaypal>;\n\nexport interface BraintreePaypal {\n closeWindow(): void;\n focusWindow(): void;\n tokenize(options: BraintreePaypalRequest): Promise<BraintreeTokenizePayload>;\n Buttons?(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\n/**\n *\n * Braintree PayPal Checkout\n *\n */\nexport type BraintreePaypalCheckoutCreator = BraintreeModuleCreator<BraintreePaypalCheckout>;\n\nexport interface BraintreePaypalCheckout {\n loadPayPalSDK(config: BraintreePaypalSdkCreatorConfig, callback: (instance: BraintreePaypalCheckout) => void): void;\n createPayment(options: BraintreePaypalRequest): Promise<string>;\n teardown(): Promise<void>;\n tokenizePayment(options: PaypalAuthorizeData): Promise<BraintreeTokenizePayload>;\n}\n\nexport interface BraintreePaypalSdkCreatorConfig {\n components?: string;\n currency?: string;\n}\n\n/**\n *\n * Braintree Venmo\n *\n */\nexport type BraintreeVenmoCheckoutCreator = BraintreeModuleCreator<BraintreeVenmoCheckout, BraintreeVenmoCreatorConfig>;\n\nexport interface BraintreeVenmoCheckout extends BraintreeModule {\n tokenize(callback: (error: BraintreeError, payload: BraintreeTokenizePayload) => void): void;\n isBrowserSupported(): boolean;\n}\n\nexport interface BraintreeVenmoCreatorConfig extends BraintreeModuleCreatorConfig {\n allowDesktop: boolean;\n paymentMethodUsage: string;\n}\n\n/**\n *\n * Braintree Visa Checkout\n *\n */\nexport type BraintreeVisaCheckoutCreator = BraintreeModuleCreator<BraintreeVisaCheckout>;\n\nexport interface BraintreeVisaCheckout extends BraintreeModule {\n tokenize(payment: VisaCheckoutPaymentSuccessPayload): Promise<VisaCheckoutTokenizedPayload>;\n createInitOptions(options: Partial<VisaCheckoutInitOptions>): VisaCheckoutInitOptions;\n}\n\n/**\n *\n * Other\n *\n */\nexport interface BraintreeHostWindow extends Window {\n braintree?: BraintreeSDK;\n paypal?: PaypalSDK;\n}\n","import { NotInitializedError, NotInitializedErrorType, UnsupportedBrowserError } from '../../../common/error/errors';\nimport { PaypalHostWindow } from '../paypal';\n\nimport { BraintreeClient, BraintreeDataCollector, BraintreeError, BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig, BraintreeModule, BraintreePaypal, BraintreePaypalCheckout, BraintreeThreeDSecure, BraintreeVenmoCheckout, BraintreeVisaCheckout, GooglePayBraintreeSDK, PAYPAL_COMPONENTS } from './braintree';\nimport BraintreeScriptLoader from './braintree-script-loader';\n\nexport default class BraintreeSDKCreator {\n private _client?: Promise<BraintreeClient>;\n private _3ds?: Promise<BraintreeThreeDSecure>;\n private _paypal?: Promise<BraintreePaypal>;\n private _paypalCheckout?: Promise<BraintreePaypalCheckout>;\n private _clientToken?: string;\n private _visaCheckout?: Promise<BraintreeVisaCheckout>;\n private _venmoCheckout?: Promise<BraintreeVenmoCheckout>;\n private _dataCollectors: {\n default?: Promise<BraintreeDataCollector>;\n paypal?: Promise<BraintreeDataCollector>;\n } = {};\n private _googlePay?: Promise<GooglePayBraintreeSDK>;\n private _window: PaypalHostWindow;\n\n constructor(\n private _braintreeScriptLoader: BraintreeScriptLoader\n ) {\n this._window = window;\n }\n\n initialize(clientToken: string) {\n this._clientToken = clientToken;\n }\n\n getClient(): Promise<BraintreeClient> {\n if (!this._clientToken) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n if (!this._client) {\n this._client = this._braintreeScriptLoader.loadClient()\n .then(client => client.create({ authorization: this._clientToken }));\n }\n\n return this._client;\n }\n\n getPaypal(): Promise<BraintreePaypal> {\n if (!this._paypal) {\n this._paypal = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadPaypal(),\n ])\n .then(([client, paypal]) => paypal.create({ client }));\n }\n\n return this._paypal;\n }\n\n async getPaypalCheckout(\n config: { currency: string },\n onSuccess: (instance: BraintreePaypalCheckout) => void,\n onError: (error: BraintreeError) => void\n ): Promise<BraintreePaypalCheckout> {\n const client = await this.getClient();\n const paypalCheckout = await this._braintreeScriptLoader.loadPaypalCheckout();\n\n const paypalCheckoutConfig = { client };\n const paypalCheckoutCallback = (error: BraintreeError, braintreePaypalCheckout: BraintreePaypalCheckout) => {\n if (error) {\n return onError(error);\n }\n\n const paypalSdkLoadCallback = () => onSuccess(braintreePaypalCheckout);\n const paypalSdkLoadConfig = {\n currency: config.currency,\n components: PAYPAL_COMPONENTS.toString(),\n };\n\n if (!this._window.paypal) {\n braintreePaypalCheckout.loadPayPalSDK(paypalSdkLoadConfig, paypalSdkLoadCallback);\n } else {\n onSuccess(braintreePaypalCheckout);\n }\n };\n\n this._paypalCheckout = paypalCheckout.create(paypalCheckoutConfig, paypalCheckoutCallback);\n\n return this._paypalCheckout;\n }\n\n async getVenmoCheckout(\n onSuccess: (braintreeVenmoCheckout: BraintreeVenmoCheckout) => void,\n onError: (error: BraintreeError | UnsupportedBrowserError) => void\n ): Promise<BraintreeVenmoCheckout> {\n if (!this._venmoCheckout) {\n const client = await this.getClient();\n\n const venmoCheckout = await this._braintreeScriptLoader.loadVenmoCheckout();\n\n const venmoCheckoutConfig = {\n client,\n allowDesktop: true,\n paymentMethodUsage: 'multi_use',\n };\n\n const venmoCheckoutCallback = (error: BraintreeError, braintreeVenmoCheckout: BraintreeVenmoCheckout): void => {\n if (error) {\n return onError(error);\n }\n\n if (!braintreeVenmoCheckout.isBrowserSupported()) {\n return onError(new UnsupportedBrowserError());\n }\n\n onSuccess(braintreeVenmoCheckout);\n };\n\n this._venmoCheckout = venmoCheckout.create(venmoCheckoutConfig, venmoCheckoutCallback);\n }\n\n return this._venmoCheckout;\n }\n\n get3DS(): Promise<BraintreeThreeDSecure> {\n if (!this._3ds) {\n this._3ds = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.load3DS(),\n ])\n .then(([client, threeDSecure]) => threeDSecure.create({ client, version: 2}));\n }\n\n return this._3ds;\n }\n\n getDataCollector(options?: { paypal: boolean }): Promise<BraintreeDataCollector> {\n const cacheKey = options && options.paypal ? 'paypal' : 'default';\n let cached = this._dataCollectors[cacheKey];\n\n if (!cached) {\n cached = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadDataCollector(),\n ])\n .then(([client, dataCollector]) => dataCollector.create({ client, kount: true, ...options }))\n .catch(error => {\n if (error && error.code === 'DATA_COLLECTOR_KOUNT_NOT_ENABLED') {\n return { deviceData: undefined, teardown: () => Promise.resolve() };\n }\n\n throw error;\n });\n\n this._dataCollectors[cacheKey] = cached;\n }\n\n return cached;\n }\n\n getVisaCheckout(): Promise<BraintreeVisaCheckout> {\n if (!this._visaCheckout) {\n this._visaCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadVisaCheckout(),\n ])\n .then(([client, visaCheckout]) => visaCheckout.create({ client }));\n }\n\n return this._visaCheckout;\n }\n\n getGooglePaymentComponent(): Promise<GooglePayBraintreeSDK> {\n if (!this._googlePay) {\n this._googlePay = Promise.all ([\n this.getClient(),\n this._braintreeScriptLoader.loadGooglePayment(),\n ])\n .then(([client, googlePay]) => googlePay.create({ client }));\n }\n\n return this._googlePay;\n }\n\n async createHostedFields(\n options: Pick<BraintreeHostedFieldsCreatorConfig, 'fields' | 'styles'>\n ): Promise<BraintreeHostedFields> {\n const [client, hostedFields] = await Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadHostedFields(),\n ]);\n\n return hostedFields.create({ ...options, client });\n }\n\n teardown(): Promise<void> {\n return Promise.all([\n this._teardown(this._3ds),\n this._teardown(this._dataCollectors.default),\n this._teardown(this._dataCollectors.paypal),\n this._teardown(this._googlePay),\n this._teardown(this._paypalCheckout),\n this._teardown(this._venmoCheckout),\n this._teardown(this._visaCheckout),\n ]).then(() => {\n this._3ds = undefined;\n this._dataCollectors = {};\n this._googlePay = undefined;\n this._paypalCheckout = undefined;\n this._venmoCheckout = undefined;\n this._visaCheckout = undefined;\n });\n }\n\n private _teardown(module?: Promise<BraintreeModule>) {\n return module ?\n module.then(mod => mod.teardown()) :\n Promise.resolve();\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport { GooglePayCreator } from '../googlepay';\n\nimport { BraintreeClientCreator, BraintreeDataCollectorCreator, BraintreeHostedFieldsCreator, BraintreeHostWindow, BraintreePaypalCheckoutCreator, BraintreePaypalCreator, BraintreeThreeDSecureCreator, BraintreeVenmoCheckoutCreator, BraintreeVisaCheckoutCreator } from './braintree';\n\nconst version = '3.81.0';\n\nexport default class BraintreeScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: BraintreeHostWindow = window\n ) {}\n\n loadClient(): Promise<BraintreeClientCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/client.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.client) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.client;\n });\n }\n\n load3DS(): Promise<BraintreeThreeDSecureCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/three-d-secure.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.threeDSecure) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.threeDSecure;\n });\n }\n\n loadDataCollector(): Promise<BraintreeDataCollectorCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/data-collector.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.dataCollector) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.dataCollector;\n });\n }\n\n loadPaypal(): Promise<BraintreePaypalCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/paypal.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.paypal;\n });\n }\n\n loadPaypalCheckout(): Promise<BraintreePaypalCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/paypal-checkout.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.paypalCheckout) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.paypalCheckout;\n });\n }\n\n loadVisaCheckout(): Promise<BraintreeVisaCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/visa-checkout.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.visaCheckout) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.visaCheckout;\n });\n }\n\n loadVenmoCheckout(): Promise<BraintreeVenmoCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/venmo.min.js`)\n .then(() => {\n if (!this._window.braintree?.venmo) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.venmo;\n });\n }\n\n loadGooglePayment(): Promise<GooglePayCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/google-payment.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.googlePayment) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.googlePayment;\n });\n }\n\n async loadHostedFields(): Promise<BraintreeHostedFieldsCreator> {\n await this._scriptLoader.loadScript(`//js.braintreegateway.com/web/${version}/js/hosted-fields.min.js`);\n\n if (!this._window.braintree || !this._window.braintree.hostedFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.hostedFields;\n }\n}\n","export enum CheckoutIncludes {\n AvailableShippingOptions = 'consignments.availableShippingOptions',\n PhysicalItemsCategoryNames = 'cart.lineItems.physicalItems.categoryNames',\n DigitalItemsCategoryNames = 'cart.lineItems.digitalItems.categoryNames',\n}\n\nexport default interface CheckoutParams {\n include?: CheckoutIncludes[] | CheckoutIncludeParam;\n}\n\nexport type CheckoutIncludeParam = {\n [key in CheckoutIncludes]?: boolean;\n};\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { find } from 'lodash';\nimport { Observable, Observer } from 'rxjs';\n\nimport { AddressRequestBody } from '../address';\nimport { Cart } from '../cart';\nimport { CheckoutIncludes, CheckoutParams, CheckoutRequestSender, InternalCheckoutSelectors, ReadableCheckoutStore } from '../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\n\nimport Consignment, { ConsignmentsRequestBody, ConsignmentAssignmentBaseRequestBodyWithAddress, ConsignmentAssignmentBaseRequestBodyWithShippingAddress, ConsignmentAssignmentRequestBody, ConsignmentCreateRequestBody, ConsignmentLineItem, ConsignmentRequestBody, ConsignmentShippingOptionRequestBody, ConsignmentUpdateRequestBody } from './consignment';\nimport { ConsignmentActionType, CreateConsignmentsAction, DeleteConsignmentAction, LoadShippingOptionsAction, UpdateConsignmentAction, UpdateShippingOptionAction } from './consignment-actions';\nimport ConsignmentRequestSender from './consignment-request-sender';\n\nexport default class ConsignmentActionCreator {\n constructor(\n private _consignmentRequestSender: ConsignmentRequestSender,\n private _checkoutRequestSender: CheckoutRequestSender\n ) {}\n\n unassignItemsByAddress(\n consignment: ConsignmentAssignmentRequestBody,\n options?: RequestOptions\n ): ThunkAction<DeleteConsignmentAction | UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const address = this._consignmentHasAddress(consignment) ? consignment.address : consignment.shippingAddress;\n\n const existingConsignment = state.consignments.getConsignmentByAddress(address);\n\n if (!existingConsignment) {\n throw new InvalidArgumentError('No consignment found for the specified address');\n }\n\n const lineItems = this._removeLineItems(\n consignment.lineItems,\n existingConsignment,\n state.cart.getCart()\n );\n\n if (!lineItems.length) {\n return this.deleteConsignment(existingConsignment.id, options)(store);\n }\n\n return this.updateConsignment({\n id: existingConsignment.id,\n address,\n lineItems,\n }, options)(store);\n };\n }\n\n assignItemsByAddress(\n consignment: ConsignmentAssignmentRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateConsignmentAction | CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const address = this._consignmentHasAddress(consignment) ? consignment.address : consignment.shippingAddress;\n const existingConsignment = state.consignments.getConsignmentByAddress(address);\n\n return this._createOrUpdateConsignment({\n id: existingConsignment && existingConsignment.id,\n address,\n lineItems: this._addLineItems(\n consignment.lineItems,\n existingConsignment,\n state.cart.getCart()\n ),\n }, options)(store);\n };\n }\n\n selectShippingOption(\n id: string,\n options?: RequestOptions\n ): ThunkAction<UpdateShippingOptionAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateShippingOptionAction>) => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n const consignments = state.consignments.getConsignments();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!consignments || !consignments.length) {\n throw new MissingDataError(MissingDataErrorType.MissingConsignments);\n }\n\n const consignmentUpdateBody = {\n id: consignments[0].id,\n shippingOptionId: id,\n };\n\n const consignmentMeta = {\n id: consignments[0].id,\n };\n\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignmentUpdateBody, options)\n .then(({ body }) => {\n observer.next(createAction(\n ConsignmentActionType.UpdateShippingOptionSucceeded,\n body,\n consignmentMeta\n ));\n\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(\n ConsignmentActionType.UpdateShippingOptionFailed,\n response,\n consignmentMeta\n ));\n });\n });\n }\n\n loadShippingOptions(options?: RequestOptions): ThunkAction<LoadShippingOptionsAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<LoadShippingOptionsAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.LoadShippingOptionsRequested));\n\n this._checkoutRequestSender.loadCheckout(checkout.id, {\n ...options,\n params: {\n include: [CheckoutIncludes.AvailableShippingOptions],\n },\n })\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.LoadShippingOptionsSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.LoadShippingOptionsFailed, response));\n });\n });\n }\n\n updateAddress(\n address: AddressRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<CreateConsignmentsAction | UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => {\n const consignment = this._getUpdateAddressRequestBody(address, store);\n const consignments = store.getState().consignments.getConsignments();\n\n if (consignments && consignments.length) {\n (consignment as ConsignmentUpdateRequestBody).id = consignments[0].id;\n }\n\n return this._createOrUpdateConsignment(consignment, options)(store);\n };\n }\n\n createConsignments(\n consignments: ConsignmentsRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<CreateConsignmentsAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.CreateConsignmentsRequested));\n\n this._consignmentRequestSender.createConsignments(checkout.id, consignments, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.CreateConsignmentsSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.CreateConsignmentsFailed, response));\n });\n });\n }\n\n updateConsignment(\n consignment: ConsignmentUpdateRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateConsignmentAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const consignmentMeta = { id: consignment.id };\n\n observer.next(createAction(ConsignmentActionType.UpdateConsignmentRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignment, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.UpdateConsignmentSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.UpdateConsignmentFailed, response, consignmentMeta));\n });\n });\n }\n\n deleteConsignment(\n consignmentId: string,\n options?: RequestOptions\n ): ThunkAction<DeleteConsignmentAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<DeleteConsignmentAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n const consignmentMeta = { id: consignmentId };\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.DeleteConsignmentRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.deleteConsignment(checkout.id, consignmentId, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.DeleteConsignmentSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.DeleteConsignmentFailed, response, consignmentMeta));\n });\n });\n }\n\n updateShippingOption(\n consignment: ConsignmentShippingOptionRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateShippingOptionAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateShippingOptionAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const consignmentMeta = { id: consignment.id };\n\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignment, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.UpdateShippingOptionFailed, response, consignmentMeta));\n });\n });\n }\n\n private _createOrUpdateConsignment(\n consignment: ConsignmentCreateRequestBody | ConsignmentUpdateRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<UpdateConsignmentAction | CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (this._isUpdateConsignmentRequest(consignment)) {\n return this.updateConsignment(consignment, options)(store);\n }\n\n return this.createConsignments([consignment], options)(store);\n };\n }\n\n private _getUpdateAddressRequestBody(\n address: AddressRequestBody,\n store: ReadableCheckoutStore\n ): ConsignmentRequestBody {\n const state = store.getState();\n const cart = state.cart.getCart();\n\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n const { physicalItems, customItems = [] } = cart.lineItems;\n\n return {\n address,\n lineItems: [ ...physicalItems, ...customItems ].map(item => ({\n itemId: item.id,\n quantity: item.quantity,\n })),\n };\n }\n\n private _removeLineItems(\n lineItems: ConsignmentLineItem[],\n consignment: Consignment,\n cart?: Cart\n ): ConsignmentLineItem[] {\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n\n return this._hydrateLineItems(consignment.lineItemIds, cart).map(existingItem => {\n const sharedItem = find(lineItems, lineItem => lineItem.itemId === existingItem.itemId);\n\n return {\n ...existingItem,\n quantity: sharedItem ? (existingItem.quantity - sharedItem.quantity) : existingItem.quantity,\n };\n }).filter(lineItem => lineItem.quantity > 0);\n }\n\n private _addLineItems(\n lineItems: ConsignmentLineItem[],\n consignment?: Consignment,\n cart?: Cart\n ): ConsignmentLineItem[] {\n if (!consignment) {\n return lineItems;\n }\n\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n\n return lineItems\n .concat(this._hydrateLineItems(consignment.lineItemIds, cart))\n .filter(lineItem => lineItem.quantity > 0);\n }\n\n private _hydrateLineItems(lineItemIds: string[], cart: Cart): ConsignmentLineItem[] {\n return lineItemIds.map(itemId => {\n const item = find(cart.lineItems.physicalItems, lineItem => lineItem.id === itemId);\n\n return {\n itemId,\n quantity: item ? item.quantity : 0,\n };\n });\n }\n\n private _isUpdateConsignmentRequest(\n request: ConsignmentRequestBody\n ): request is ConsignmentUpdateRequestBody {\n const updateRequest = request as ConsignmentUpdateRequestBody;\n\n return !!updateRequest.id;\n }\n\n private _consignmentHasAddress(\n consignment: ConsignmentAssignmentBaseRequestBodyWithAddress | ConsignmentAssignmentBaseRequestBodyWithShippingAddress\n ): consignment is ConsignmentAssignmentBaseRequestBodyWithAddress {\n return typeof consignment === 'object' && 'address' in consignment;\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { Checkout, CheckoutParams } from '../checkout';\nimport { joinIncludes, joinOrMergeIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { ConsignmentsRequestBody, ConsignmentUpdateRequestBody } from './consignment';\n\nconst DEFAULT_INCLUDES = [\n 'consignments.availableShippingOptions',\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'promotions.banners',\n];\n\nexport default class ConsignmentRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n createConsignments(\n checkoutId: string,\n consignments: ConsignmentsRequestBody,\n { timeout, params: { include } = {} }: RequestOptions<CheckoutParams> = {}\n ): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/consignments`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, {\n body: consignments,\n params: {\n include: joinOrMergeIncludes(DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n });\n }\n\n updateConsignment(\n checkoutId: string,\n consignment: ConsignmentUpdateRequestBody,\n { timeout, params: { include } = {} }: RequestOptions<CheckoutParams> = {}\n ): Promise<Response<Checkout>> {\n const { id, ...body } = consignment;\n const url = `/api/storefront/checkouts/${checkoutId}/consignments/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, {\n body,\n params: {\n include: joinOrMergeIncludes(DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n });\n }\n\n deleteConsignment(\n checkoutId: string,\n consignmentId: string,\n { timeout }: RequestOptions = {}\n ): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/consignments/${consignmentId}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n const include = joinIncludes(DEFAULT_INCLUDES);\n\n return this._requestSender.delete(url, { params: { include }, headers, timeout });\n }\n}\n","import { RequestError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when the subscriptions fails to be updated\n */\nexport default class UpdateSubscriptionsError extends RequestError {\n constructor(response?: Response) {\n super(response);\n\n this.name = 'UpdateSubscriptionsError';\n this.type = 'update_subscriptions';\n }\n}\n","import { createAction } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\nimport { Subscriptions, SubscriptionsActionType, SubscriptionsRequestSender, UpdateSubscriptionsAction } from '../subscription';\n\nimport { UpdateSubscriptionsError } from './errors';\n\nexport default class SubscriptionsActionCreator {\n constructor(\n private _subscriptionsRequestSender: SubscriptionsRequestSender\n ) {}\n\n updateSubscriptions(\n subscriptions: Subscriptions,\n options?: RequestOptions\n ): Observable<UpdateSubscriptionsAction> {\n return concat(\n of(createAction(SubscriptionsActionType.UpdateSubscriptionsRequested)),\n defer(async () => {\n const { body } = await this._subscriptionsRequestSender.updateSubscriptions(subscriptions, options);\n\n return createAction(SubscriptionsActionType.UpdateSubscriptionsSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(\n SubscriptionsActionType.UpdateSubscriptionsFailed,\n new UpdateSubscriptionsError(error)\n ))\n );\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { Subscriptions } from './subscriptions';\n\nexport default class SubscriptionsRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n updateSubscriptions(subscriptions: Subscriptions, { timeout }: RequestOptions = {}): Promise<Response<Subscriptions>> {\n const url = '/api/storefront/subscriptions';\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, { body: subscriptions, headers, timeout });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we are unable to synchronize the checkout details of a\n * shopper with a hosted / remote checkout provider (i.e.: Amazon).\n */\nexport default class RemoteCheckoutSynchronizationError extends StandardError {\n constructor(\n public error?: Error\n ) {\n super('Unable to synchronize your checkout details with a third party provider. Please try again later.');\n\n this.name = 'RemoteCheckoutSynchronizationError';\n this.type = 'remote_checkout_synchronization';\n }\n}\n","import { PaymentInitializeOptions } from '../..';\nimport { Checkout, InternalCheckoutSelectors } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\nimport { BraintreeModuleCreator, BraintreeVerifyPayload, GooglePayBraintreeSDK } from '../braintree';\n\nexport type EnvironmentType = 'PRODUCTION' | 'TEST';\nexport type TokenizeType = 'AndroidPayCard' | 'CreditCard' | 'CARD';\n\nexport interface GooglePayInitializer {\n initialize(checkout: Checkout, paymentMethod: PaymentMethod, hasShippingAddress: boolean, publishableKey?: string): Promise<GooglePayPaymentDataRequestV2>;\n teardown(): Promise<void>;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\nexport interface GooglePayProviderProcessor {\n initialize(options: PaymentInitializeOptions): Promise<void>;\n processAdditionalAction(error: unknown): Promise<InternalCheckoutSelectors>;\n}\n\nexport type GooglePayCreator = BraintreeModuleCreator<GooglePayBraintreeSDK>\n\nexport interface GooglePayPaymentOptions {\n environment: EnvironmentType;\n}\n\nexport type GooglePayVerifyPayload = BraintreeVerifyPayload | undefined;\n\nexport interface GooglePayIsReadyToPayResponse {\n result: boolean;\n paymentMethodPresend?: boolean;\n}\n\nexport interface GooglePaySDK {\n payments: {\n api: {\n PaymentsClient: new(options: GooglePayPaymentOptions) => GooglePayClient;\n };\n };\n}\n\nexport interface GooglePayClient {\n isReadyToPay(options: object): Promise<GooglePayIsReadyToPayResponse>;\n loadPaymentData(paymentDataRequest: GooglePayPaymentDataRequestV2): Promise<GooglePaymentData>;\n createButton(options: { [key: string]: string | object }): HTMLElement;\n}\n\nexport interface GooglePayHostWindow extends Window {\n google?: GooglePaySDK;\n}\n\nexport interface TokenizePayload {\n nonce: string;\n tokenFormat?: string;\n details: {\n cardType: string;\n lastFour: string;\n lastTwo?: string;\n };\n description?: string;\n type: TokenizeType;\n binData?: {\n commercial: string;\n countryOfIssuance: string;\n debit: string;\n durbinRegulated: string;\n healthcare: string;\n issuingBank: string;\n payroll: string;\n prepaid: string;\n productId: string;\n };\n}\n\nexport interface GooglePaymentData {\n apiVersion: number;\n apiVersionMinor: number;\n paymentMethodData: {\n description: string;\n info: {\n cardDetails: string;\n cardNetwork: string;\n billingAddress: GooglePayAddress;\n };\n tokenizationData: {\n token: string;\n type: string;\n };\n type: TokenizeType;\n };\n shippingAddress: GooglePayAddress;\n email: string;\n}\n\nexport interface GooglePayAddress {\n address1: string;\n address2: string;\n address3: string;\n administrativeArea: string;\n companyName: string;\n countryCode: string;\n locality: string;\n name: string;\n postalCode: string;\n sortingCode: string;\n phoneNumber: string;\n}\n\nexport interface GooglePaymentsError {\n statusCode: string;\n statusMessage?: string;\n}\n\nexport interface PaymentMethodData {\n methodId: string;\n paymentData: {\n method: string;\n nonce: string;\n cardInformation: {\n type: string;\n number: string;\n };\n };\n}\n\nexport enum ButtonType {\n Long = 'long',\n Short = 'short',\n}\nexport enum ButtonColor {\n Default = 'default',\n Black = 'black',\n White = 'white',\n}\n\nexport interface TokenizationSpecification {\n type: string;\n parameters: {\n gateway: string;\n gatewayMerchantId?: string;\n 'braintree:apiVersion'?: string;\n 'braintree:clientKey'?: string;\n 'braintree:merchantId'?: string;\n 'braintree:sdkVersion'?: string;\n 'braintree:authorizationFingerprint'?: string;\n 'stripe:version'?: string;\n 'stripe:publishableKey'?: string;\n };\n}\n\nexport enum BillingAddressFormat {\n /*\n * Name, country code, and postal code (default).\n */\n Min = 'MIN',\n /*\n * Name, street address, locality, region, country code, and postal code.\n */\n Full = 'FULL',\n}\n\nexport interface GooglePayPaymentDataRequestV2 {\n apiVersion: number;\n apiVersionMinor: number;\n merchantInfo: {\n authJwt?: string;\n merchantId?: string;\n merchantName?: string;\n };\n allowedPaymentMethods: [{\n type: string;\n parameters: {\n allowedAuthMethods: string[];\n allowedCardNetworks: string[];\n allowPrepaidCards?: boolean;\n billingAddressRequired?: boolean;\n billingAddressParameters?: {\n format?: BillingAddressFormat;\n phoneNumberRequired?: boolean;\n };\n };\n tokenizationSpecification?: TokenizationSpecification;\n }];\n transactionInfo: {\n currencyCode: string;\n countryCode?: string;\n totalPriceStatus: string;\n totalPrice?: string;\n checkoutOption?: string;\n };\n emailRequired?: boolean;\n shippingAddressRequired?: boolean;\n shippingAddressParameters?: {\n allowedCountryCodes?: string[];\n phoneNumberRequired?: boolean;\n };\n}\n","export function getFirstAndLastName(fullName: string): [string, string] {\n const nameParts = fullName.split(' ');\n\n if (nameParts.length === 1) {\n return [fullName, ''];\n }\n\n const firstName = nameParts.slice(0, -1).join(' ');\n const lastName = nameParts[nameParts.length - 1];\n\n return [firstName, lastName];\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { AddressRequestBody } from '../../../address';\nimport { BillingAddressActionCreator, BillingAddressUpdateRequestBody } from '../../../billing';\nimport { CheckoutStore, InternalCheckoutSelectors } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { RemoteCheckoutSynchronizationError } from '../../../remote-checkout/errors';\nimport { ConsignmentActionCreator } from '../../../shipping';\nimport { PaymentMethodInvalidError } from '../../errors';\nimport PaymentMethodActionCreator from '../../payment-method-action-creator';\n\nimport { ButtonColor, ButtonType, EnvironmentType, GooglePaymentData, GooglePayAddress, GooglePayClient, GooglePayInitializer, GooglePayPaymentDataRequestV2, GooglePaySDK, TokenizePayload } from './googlepay';\nimport { getFirstAndLastName } from './googlepay-get-first-and-last-name';\nimport GooglePayScriptLoader from './googlepay-script-loader';\n\nexport default class GooglePayPaymentProcessor {\n private _googlePayClient?: GooglePayClient;\n private _methodId?: string;\n private _paymentDataRequest?: GooglePayPaymentDataRequestV2;\n\n constructor(\n private _store: CheckoutStore,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _googlePayScriptLoader: GooglePayScriptLoader,\n private _googlePayInitializer: GooglePayInitializer,\n private _billingAddressActionCreator: BillingAddressActionCreator,\n private _consignmentActionCreator: ConsignmentActionCreator,\n private _requestSender: RequestSender\n ) {}\n\n initialize(methodId: string): Promise<void> {\n this._methodId = methodId;\n\n return this._configureWallet();\n }\n\n deinitialize(): Promise<void> {\n return this._googlePayInitializer.teardown();\n }\n\n createButton(\n onClick: (event: Event) => Promise<void>,\n buttonType: ButtonType = ButtonType.Short,\n buttonColor: ButtonColor = ButtonColor.Default\n ): HTMLElement {\n if (!this._googlePayClient) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._googlePayClient.createButton({\n buttonColor,\n buttonType,\n onClick,\n });\n }\n\n displayWallet(): Promise<GooglePaymentData> {\n if (!this._googlePayClient) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._googlePayClient.loadPaymentData(this._getPaymentDataRequest());\n }\n\n handleSuccess(paymentData: GooglePaymentData): Promise<InternalCheckoutSelectors> {\n return this._googlePayInitializer.parseResponse(paymentData)\n .then(tokenizePayload => this._postForm(tokenizePayload))\n .then(() => this._updateBillingAddress(paymentData));\n }\n\n updateShippingAddress(shippingAddress: GooglePayAddress): Promise<InternalCheckoutSelectors> {\n return this._store.dispatch(\n this._consignmentActionCreator.updateAddress(this._mapGooglePayAddressToShippingAddress(shippingAddress))\n );\n }\n\n private _configureWallet(): Promise<void> {\n const methodId = this._getMethodId();\n\n return this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId))\n .then(state => {\n const paymentMethod = state.paymentMethods.getPaymentMethod(methodId);\n const checkout = state.checkout.getCheckout();\n const hasShippingAddress = !!state.shippingAddress.getShippingAddress();\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const { testMode } = paymentMethod.config;\n\n return Promise.all([\n this._googlePayScriptLoader.load(),\n this._googlePayInitializer.initialize(checkout, paymentMethod, hasShippingAddress),\n ]).then(([googlePay, paymentDataRequest]) => {\n this._googlePayClient = this._getGooglePayClient(googlePay, testMode);\n this._paymentDataRequest = paymentDataRequest;\n\n return this._googlePayClient.isReadyToPay({\n allowedPaymentMethods: [\n {\n type: paymentDataRequest.allowedPaymentMethods[0].type,\n parameters: {\n allowedAuthMethods: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedAuthMethods,\n allowedCardNetworks: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedCardNetworks,\n },\n },\n ],\n apiVersion: paymentDataRequest.apiVersion,\n apiVersionMinor: paymentDataRequest.apiVersionMinor,\n }).then(response => {\n if (response.result) {\n return;\n }\n\n throw new PaymentMethodInvalidError();\n });\n });\n });\n }\n\n private _getCardInformation(cardInformation: { cardType: string; lastFour: string }) {\n return {\n type: cardInformation.cardType,\n number: cardInformation.lastFour,\n };\n }\n\n private _getPaymentDataRequest(): GooglePayPaymentDataRequestV2 {\n if (!this._paymentDataRequest) {\n throw new RemoteCheckoutSynchronizationError();\n }\n\n return this._paymentDataRequest;\n }\n\n private _getGooglePayClient(google: GooglePaySDK, testMode?: boolean): GooglePayClient {\n if (testMode === undefined) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const environment: EnvironmentType = testMode ? 'TEST' : 'PRODUCTION';\n\n return new google.payments.api.PaymentsClient({ environment });\n }\n\n private _getMethodId(): string {\n if (!this._methodId) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._methodId;\n }\n\n private _mapGooglePayAddressToBillingAddress(paymentData: GooglePaymentData, id: string, customerEmail?: string): BillingAddressUpdateRequestBody {\n const fullName = paymentData.paymentMethodData.info.billingAddress.name;\n const [firstName, lastName] = getFirstAndLastName(fullName);\n const address1 = paymentData.paymentMethodData.info.billingAddress.address1;\n const city = paymentData.paymentMethodData.info.billingAddress.locality;\n const postalCode = paymentData.paymentMethodData.info.billingAddress.postalCode;\n const countryCode = paymentData.paymentMethodData.info.billingAddress.countryCode;\n\n if (!firstName || !address1 || !city || !postalCode || !countryCode) {\n throw new MissingDataError(MissingDataErrorType.MissingBillingAddress);\n }\n\n return {\n id,\n firstName,\n lastName,\n company: paymentData.paymentMethodData.info.billingAddress.companyName,\n address1,\n address2: paymentData.paymentMethodData.info.billingAddress.address2 + paymentData.paymentMethodData.info.billingAddress.address3,\n city,\n stateOrProvince: paymentData.paymentMethodData.info.billingAddress.administrativeArea,\n stateOrProvinceCode: paymentData.paymentMethodData.info.billingAddress.administrativeArea,\n postalCode,\n countryCode,\n phone: paymentData.paymentMethodData.info.billingAddress.phoneNumber,\n customFields: [],\n email: customerEmail || paymentData.email,\n };\n }\n\n private _mapGooglePayAddressToShippingAddress(address: GooglePayAddress): AddressRequestBody {\n const [firstName, lastName] = getFirstAndLastName(address.name);\n\n return {\n firstName,\n lastName,\n company: address.companyName,\n address1: address.address1,\n address2: address.address2 + address.address3,\n city: address.locality,\n stateOrProvince: address.administrativeArea,\n stateOrProvinceCode: address.administrativeArea,\n postalCode: address.postalCode,\n countryCode: address.countryCode,\n phone: address.phoneNumber,\n customFields: [],\n };\n }\n\n private _postForm(postPaymentData: TokenizePayload): Promise<Response<void>> {\n const cardInformation = postPaymentData.details;\n\n return this._requestSender.post('/checkout.php', {\n headers: {\n Accept: 'text/html',\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...SDK_VERSION_HEADERS,\n },\n body: {\n payment_type: postPaymentData.type,\n nonce: postPaymentData.nonce,\n tokenFormat: postPaymentData.tokenFormat,\n provider: this._getMethodId(),\n action: 'set_external_checkout',\n card_information: this._getCardInformation(cardInformation),\n },\n });\n }\n\n private _updateBillingAddress(paymentData: GooglePaymentData): Promise<InternalCheckoutSelectors> {\n const remoteBillingAddress = this._store.getState().billingAddress.getBillingAddress();\n\n if (!remoteBillingAddress) {\n throw new MissingDataError(MissingDataErrorType.MissingBillingAddress);\n }\n\n const googlePayAddressMapped = this._mapGooglePayAddressToBillingAddress(paymentData, remoteBillingAddress.id, remoteBillingAddress.email);\n\n return this._store.dispatch(\n this._billingAddressActionCreator.updateAddress(googlePayAddressMapped)\n );\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { GooglePayHostWindow, GooglePaySDK } from './googlepay';\n\nexport default class GooglePayScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: GooglePayHostWindow = window\n ) {}\n\n load(): Promise<GooglePaySDK> {\n return this._scriptLoader\n .loadScript('https://pay.google.com/gp/p/js/pay.js')\n .then(() => {\n if (!this._window.google) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.google;\n });\n }\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\nimport { getScriptLoader } from '@bigcommerce/script-loader';\n\nimport { BillingAddressActionCreator, BillingAddressRequestSender } from '../../../billing';\nimport { CheckoutRequestSender, CheckoutStore } from '../../../checkout';\nimport { ConsignmentActionCreator, ConsignmentRequestSender } from '../../../shipping';\nimport { SubscriptionsActionCreator, SubscriptionsRequestSender } from '../../../subscription';\nimport PaymentMethodActionCreator from '../../payment-method-action-creator';\nimport PaymentMethodRequestSender from '../../payment-method-request-sender';\n\nimport { GooglePayInitializer } from './googlepay';\nimport GooglePayPaymentProcessor from './googlepay-payment-processor';\nimport GooglePayScriptLoader from './googlepay-script-loader';\n\nexport default function createGooglePayPaymentProcessor(store: CheckoutStore, initializer: GooglePayInitializer): GooglePayPaymentProcessor {\n const requestSender = createRequestSender();\n const scriptLoader = getScriptLoader();\n\n return new GooglePayPaymentProcessor(\n store,\n new PaymentMethodActionCreator(\n new PaymentMethodRequestSender(requestSender)\n ),\n new GooglePayScriptLoader(scriptLoader),\n initializer,\n new BillingAddressActionCreator(\n new BillingAddressRequestSender(requestSender),\n new SubscriptionsActionCreator(\n new SubscriptionsRequestSender(requestSender)\n )\n ),\n new ConsignmentActionCreator(\n new ConsignmentRequestSender(requestSender),\n new CheckoutRequestSender(requestSender)\n ),\n requestSender\n );\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayAdyenV2Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: token,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'adyen',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n countryCode,\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayAdyenV3Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: token,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'adyen',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n countryCode,\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { PaymentMethod } from '../..';\nimport { Checkout } from '../../../checkout';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizationSpecification, TokenizePayload } from './googlepay';\n\nconst baseRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n};\n\nexport default class GooglePayAuthorizeNetInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(\n this._getGooglePaymentDataRequest(checkout, paymentMethod, hasShippingAddress)\n );\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: btoa(token),\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePaymentDataRequest(checkout: Checkout, paymentMethod: PaymentMethod, hasShippingAddress: boolean): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n paymentGatewayId: gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n const paymentGatewaySpecification = this._getPaymentGatewaySpecification(gatewayMerchantId);\n const cardPaymentMethod = this._getCardPaymentMethod(paymentGatewaySpecification, supportedCards);\n\n return {\n ...baseRequest,\n allowedPaymentMethods: [cardPaymentMethod],\n transactionInfo: {\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n currencyCode,\n countryCode,\n },\n merchantInfo : {\n merchantName,\n merchantId,\n authJwt,\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n\n private _getPaymentGatewaySpecification(gatewayMerchantId: string) {\n return {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'authorizenet',\n gatewayMerchantId,\n },\n };\n }\n\n private _getCardPaymentMethod(tokenizationSpecification: TokenizationSpecification, supportedCards: string[]) {\n return {\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification,\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport PaymentMethod from '../../payment-method';\nimport { BraintreeSDKCreator, GooglePayBraintreeSDK } from '../braintree';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\nimport { GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1 } from './googlepay-braintree';\n\nexport default class GooglePayBraintreeInitializer implements GooglePayInitializer {\n private _googlePaymentInstance!: GooglePayBraintreeSDK;\n\n constructor(\n private _braintreeSDKCreator: BraintreeSDKCreator\n ) {}\n\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n\n return this._braintreeSDKCreator.getGooglePaymentComponent()\n .then(googleBraintreePaymentInstance => {\n this._googlePaymentInstance = googleBraintreePaymentInstance;\n\n return this._createGooglePayPayload(\n checkout,\n paymentMethod.initializationData,\n hasShippingAddress\n );\n });\n }\n\n teardown(): Promise<void> {\n return this._braintreeSDKCreator.teardown();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token).androidPayCards[0];\n\n return Promise.resolve({\n nonce: payload.nonce,\n type: payload.type,\n description: payload.description,\n details: {\n cardType: payload.details.cardType,\n lastFour: payload.details.lastFour,\n lastTwo: payload.details.lastTwo,\n },\n binData: payload.binData,\n });\n }\n\n private _createGooglePayPayload(\n checkout: Checkout,\n initializationData: any,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n if (!initializationData.platformToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const googlePayBraintreePaymentDataRequest: GooglePayBraintreeDataRequest = {\n merchantInfo: {\n authJwt: initializationData.platformToken,\n merchantName: initializationData.googleMerchantName,\n merchantId: initializationData.googleMerchantId,\n },\n transactionInfo: {\n currencyCode: checkout.cart.currency.code,\n totalPriceStatus: 'FINAL',\n totalPrice: round(checkout.outstandingBalance, 2).toFixed(2),\n },\n cardRequirements: {\n billingAddressRequired: true,\n billingAddressFormat: 'FULL',\n },\n shippingAddressRequired: !hasShippingAddress,\n emailRequired: true,\n phoneNumberRequired: true,\n };\n\n return this._mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2(\n this._googlePaymentInstance.createPaymentDataRequest(googlePayBraintreePaymentDataRequest)\n );\n }\n\n private _mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2(googlePayBraintreeDataRequestV1: GooglePayBraintreePaymentDataRequestV1): GooglePayPaymentDataRequestV2 {\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt: googlePayBraintreeDataRequestV1.merchantInfo.authJwt,\n merchantId: googlePayBraintreeDataRequestV1.merchantInfo.merchantId,\n merchantName: googlePayBraintreeDataRequestV1.merchantInfo.merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: googlePayBraintreeDataRequestV1.cardRequirements.allowedCardNetworks,\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'braintree',\n 'braintree:apiVersion': 'v1',\n 'braintree:authorizationFingerprint': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:authorizationFingerprint'],\n 'braintree:merchantId': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:merchantId'],\n 'braintree:sdkVersion': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:sdkVersion'],\n },\n },\n }],\n transactionInfo: googlePayBraintreeDataRequestV1.transactionInfo,\n emailRequired: true,\n shippingAddressRequired: googlePayBraintreeDataRequestV1.shippingAddressRequired,\n shippingAddressParameters: {\n phoneNumberRequired: googlePayBraintreeDataRequestV1.phoneNumberRequired,\n },\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when a payment method experiences some kind of\n * failure (i.e.: its client library returns a rejected promise). And there is\n * no other error type that is more specific than this one.\n */\nexport default class PaymentMethodFailedError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to proceed because the client library of a payment method has thrown an unexpected error.');\n\n this.name = 'PaymentMethodFailedError';\n this.type = 'payment_method_client_invalid';\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { ContentType } from '../../../common/http-request';\nimport { PaymentMethodFailedError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\nimport { CheckoutcomGooglePayToken, CheckoutcomToken } from '../checkoutcom';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayCheckoutcomInitializer implements GooglePayInitializer {\n private _publishableKey = '';\n private _testMode = true;\n private _errorMessage = 'Unable to parse response from GooglePay.';\n\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n async initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n this._publishableKey = paymentMethod.initializationData.checkoutcomkey;\n this._testMode = !!paymentMethod.config.testMode;\n\n return this._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(\n checkout,\n paymentMethod.initializationData,\n hasShippingAddress\n );\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n async parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n let token;\n try {\n token = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n } catch (err) {\n throw new InvalidArgumentError(this._errorMessage);\n }\n\n if (!token.signature || !token.protocolVersion || !token.signedMessage) {\n throw new PaymentMethodFailedError(this._errorMessage);\n }\n const finalToken = await this._convertToken(this._testMode, this._publishableKey, token);\n\n const payload: TokenizePayload = {\n nonce: finalToken.token,\n type: 'CreditCard',\n description: paymentData.paymentMethodData.description,\n details: {\n cardType: paymentData.paymentMethodData.info.cardNetwork,\n lastFour: paymentData.paymentMethodData.info.cardDetails,\n },\n };\n\n if (finalToken.token_format) {\n payload.tokenFormat = finalToken.token_format;\n }\n\n return payload;\n }\n\n private async _convertToken(testMode: boolean, checkoutcomkey: string, token: CheckoutcomGooglePayToken): Promise<CheckoutcomToken> {\n const checkoutcomToken: CheckoutcomToken = await this._requestCheckoutcomTokenize(testMode, checkoutcomkey, {\n type: 'googlepay',\n token_data: token,\n });\n\n if (!checkoutcomToken || !checkoutcomToken.token) {\n throw new PaymentMethodFailedError('Unable to parse response from Checkout.com');\n }\n\n return checkoutcomToken;\n }\n\n private async _requestCheckoutcomTokenize(testMode: boolean, checkoutcomKey: string, data = {}): Promise<CheckoutcomToken> {\n const TEST_URL = 'https://api.sandbox.checkout.com/tokens';\n const LIVE_URL = 'https://api.checkout.com/tokens';\n\n const url = testMode ? TEST_URL : LIVE_URL;\n\n const response = await this._requestSender.post(url, {\n credentials: false,\n body: data,\n headers: {\n 'Content-Type': ContentType.Json,\n Authorization: checkoutcomKey,\n 'X-XSRF-TOKEN': null,\n },\n });\n\n return response.body as CheckoutcomToken;\n }\n\n private _mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(\n checkout: Checkout,\n initializationData: any,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt: initializationData.platformToken,\n merchantId: initializationData.googleMerchantId,\n merchantName: initializationData.googleMerchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: ['AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA'],\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'checkoutltd',\n gatewayMerchantId: initializationData.checkoutcomkey,\n },\n },\n }],\n transactionInfo: {\n currencyCode: checkout.cart.currency.code,\n totalPriceStatus: 'FINAL',\n totalPrice: round(checkout.outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayCybersourceV2Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n nonce: btoa(token),\n type,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'cybersource',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayOrbitalInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n nonce: btoa(token),\n type,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'chase',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayStripeInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n try {\n const payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n\n return Promise.resolve({\n nonce: payload.id,\n type: payload.type,\n details: {\n cardType: payload.card.brand,\n lastFour: payload.card.last4,\n },\n });\n } catch (err) {\n throw new InvalidArgumentError('Unable to parse response from Google Pay.');\n }\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n stripeVersion,\n stripePublishableKey,\n stripeConnectedAccount,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'stripe',\n 'stripe:version': stripeVersion,\n 'stripe:publishableKey': `${stripePublishableKey}/${stripeConnectedAccount}`,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { PaymentMethodFailedError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayStripeUPEInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n let payload;\n try {\n payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n } catch (err) {\n throw new InvalidArgumentError('Unable to parse response from Google Pay.');\n }\n\n if (!payload.id || !payload.type || !payload.card || !payload.card.brand || !payload.card.last4) {\n throw new PaymentMethodFailedError('Unable to parse response from Google Pay.');\n }\n\n return Promise.resolve({\n nonce: payload.id,\n type: payload.type,\n details: {\n cardType: payload.card.brand,\n lastFour: payload.card.last4,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode, decimalPlaces: decimalPlaces },\n },\n } = checkout;\n\n const {\n initializationData: {\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n stripeVersion,\n stripePublishableKey,\n stripeConnectedAccount,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'stripe',\n 'stripe:version': stripeVersion,\n 'stripe:publishableKey': `${stripePublishableKey}/${stripeConnectedAccount}`,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, decimalPlaces).toFixed(decimalPlaces),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { Masterpass, MasterpassHostWindow } from './masterpass';\ninterface MasterpassScriptLoaderParams {\n useMasterpassSrc: boolean;\n language: string;\n testMode?: boolean;\n checkoutId?: string;\n }\nexport default class MasterpassScriptLoader {\n\n constructor(\n private _scriptLoader: ScriptLoader,\n public _window: MasterpassHostWindow = window\n ) {}\n\n async load({ useMasterpassSrc, language, testMode, checkoutId }: MasterpassScriptLoaderParams): Promise<Masterpass> {\n\n if (useMasterpassSrc) {\n const subdomain = testMode ? 'sandbox.' : '';\n const params = [\n `locale=${language}`,\n `checkoutid=${checkoutId}`,\n ];\n\n const sourceUrl = [\n `https://${subdomain}src.mastercard.com/srci/integration/merchant.js`,\n params.join('&'),\n ].join('?');\n\n await this._scriptLoader.loadScript(sourceUrl);\n\n if (!this._window.masterpass) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.masterpass;\n\n }\n\n await this._scriptLoader.loadScript(`//${testMode ? 'sandbox.' : ''}masterpass.com/integration/merchant.js`);\n\n if (!this._window.masterpass) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.masterpass;\n }\n}\n","import { LoadScriptOptions, ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { PaypalHostWindow, PaypalSDK } from './paypal-sdk';\n\nexport default class PaypalScriptLoader {\n private _window: PaypalHostWindow;\n\n constructor(\n private _scriptLoader: ScriptLoader\n ) {\n this._window = window;\n }\n\n async loadPaypal(merchantId = ''): Promise<PaypalSDK> {\n const scriptSrc = '//www.paypalobjects.com/api/checkout.min.js';\n const options: LoadScriptOptions = { async: true, attributes: { 'data-merchant-id': merchantId } };\n\n merchantId\n ? await this._scriptLoader.loadScript(scriptSrc, options)\n : await this._scriptLoader.loadScript(scriptSrc);\n\n if (!this._window.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.paypal;\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { PaypalCommerceHostWindow, PaypalCommerceScriptParams, PaypalCommerceSDK } from './paypal-commerce-sdk';\n\nexport default class PaypalCommerceScriptLoader {\n private _window: PaypalCommerceHostWindow;\n\n constructor(\n private _scriptLoader: ScriptLoader\n ) {\n this._window = window;\n }\n\n async loadPaypalCommerce(params: PaypalCommerceScriptParams, isProgressiveOnboardingAvailable?: boolean): Promise<PaypalCommerceSDK> {\n this._validateParams(params, isProgressiveOnboardingAvailable);\n\n if (!this._window.paypalLoadScript) {\n const scriptSrc = 'https://unpkg.com/@paypal/paypal-js@5.0.5/dist/iife/paypal-js.min.js';\n\n await this._scriptLoader.loadScript(scriptSrc, {async: true, attributes: {}});\n\n if (!this._window.paypalLoadScript) {\n throw new PaymentMethodClientUnavailableError();\n }\n }\n\n await this._window.paypalLoadScript(params);\n\n if (!this._window.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.paypal;\n }\n\n _validateParams(options: PaypalCommerceScriptParams, isProgressiveOnboardingAvailable?: boolean): void {\n const CLIENT_ID = 'client-id';\n const MERCHANT_ID = 'merchant-id';\n let param;\n\n if (!options) {\n param = 'options';\n } else if (!options[CLIENT_ID]) {\n param = CLIENT_ID;\n } else if (!options[MERCHANT_ID] && !isProgressiveOnboardingAvailable) {\n param = MERCHANT_ID;\n }\n\n if (param) {\n throw new InvalidArgumentError(`Unable to proceed because \"${param}\" argument in PayPal script is not provided.`);\n }\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, SDK_VERSION_HEADERS } from '../../../common/http-request';\n\nimport { OrderData, OrderStatus } from './paypal-commerce-sdk';\n\nexport interface ParamsForProvider {\n isCredit?: boolean;\n isCheckout?: boolean;\n isCreditCard?: boolean;\n isAPM?: boolean;\n isVenmo?: boolean;\n}\n\nexport default class PaypalCommerceRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n async setupPayment(cartId: string, params: ParamsForProvider = {}): Promise<OrderData> {\n const { isCredit, isCheckout, isCreditCard, isAPM, isVenmo} = params;\n let provider = 'paypalcommerce';\n\n if (isCreditCard) {\n provider = 'paypalcommercecreditcardscheckout';\n } else if (isCheckout) {\n provider = isCredit ? 'paypalcommercecreditcheckout' : 'paypalcommercecheckout';\n } else if (isCredit) {\n provider = 'paypalcommercecredit';\n }\n if (isVenmo && !isAPM) {\n provider = isCheckout ? 'paypalcommercevenmocheckout' : 'paypalcommercevenmo';\n }\n\n if (isAPM) {\n provider = 'paypalcommercealternativemethodscheckout';\n }\n\n const url = `/api/storefront/payment/${provider}`;\n const body = { cartId };\n const headers = {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n 'Content-Type': ContentType.Json,\n ...SDK_VERSION_HEADERS,\n };\n\n const res = await this._requestSender.post(url, { headers, body });\n\n return res.body as OrderData;\n }\n\n async getOrderStatus() {\n const url = '/api/storefront/initialization/paypalcommerce';\n const headers = {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n 'Content-Type': ContentType.Json,\n ...SDK_VERSION_HEADERS,\n };\n\n const res = await this._requestSender.get<OrderStatus>(url, {headers});\n\n return res.body;\n }\n}\n","import StandardError from './standard-error';\n\n/**\n * Throw this error if we try to call a method that is only a stub and has not\n * been fully implemented.\n */\nexport default class NotImplementedError extends StandardError {\n constructor(message?: string) {\n super(message || 'Not implemented.');\n\n this.name = 'NotImplementedError';\n this.type = 'not_implemented';\n }\n}\n","enum PaymentStrategyType {\n ADYENV2 = 'adyenv2',\n ADYENV2_GOOGLEPAY = 'googlepayadyenv2',\n ADYENV3 = 'adyenv3',\n ADYENV3_GOOGLEPAY = 'googlepayadyenv3',\n AFFIRM = 'affirm',\n AFTERPAY = 'afterpay',\n AMAZON = 'amazon',\n AUTHORIZENET_GOOGLE_PAY = 'googlepayauthorizenet',\n AMAZONPAYV2 = 'amazonpay',\n APPLEPAY = 'applepay',\n BARCLAYS = 'barclays',\n BLUESNAPV2 = 'bluesnapv2',\n BOLT = 'bolt',\n CBA_MPGS = 'cba_mpgs',\n CHECKOUTCOM = 'checkoutcom',\n CHECKOUTCOM_APM = 'checkoutcomapm',\n CHECKOUTCOM_FAWRY = 'checkoutcomfawry',\n CHECKOUTCOM_SEPA = 'checkoutcomsepa',\n CHECKOUTCOM_IDEAL = 'checkoutcomideal',\n CREDIT_CARD = 'creditcard',\n CHECKOUTCOM_GOOGLE_PAY = 'googlepaycheckoutcom',\n CLEARPAY = 'clearpay',\n CONVERGE = 'converge',\n CYBERSOURCE = 'cybersource',\n CYBERSOURCEV2 = 'cybersourcev2',\n DIGITALRIVER = 'digitalriver',\n CYBERSOURCEV2_GOOGLE_PAY = 'googlepaycybersourcev2',\n HUMM = 'humm',\n KLARNA = 'klarna',\n KLARNAV2 = 'klarnav2',\n LAYBUY = 'laybuy',\n LEGACY = 'legacy',\n MOLLIE = 'mollie',\n MONERIS = 'moneris',\n NO_PAYMENT_DATA_REQUIRED = 'nopaymentdatarequired',\n OFFLINE = 'offline',\n OFFSITE = 'offsite',\n OPY = 'opy',\n ORBITAL_GOOGLE_PAY = 'googlepayorbital',\n PAYPAL = 'paypal',\n PAYPAL_EXPRESS = 'paypalexpress',\n PAYPAL_EXPRESS_CREDIT = 'paypalexpresscredit',\n PAYPAL_COMMERCE = 'paypalcommerce',\n PAYPAL_COMMERCE_CREDIT = 'paypalcommercecredit',\n PAYPAL_COMMERCE_CREDIT_CARD = 'paypalcommercecreditcards',\n PAYPAL_COMMERCE_ALTERNATIVE_METHODS = 'paypalcommercealternativemethods',\n PAYPAL_COMMERCE_VENMO = 'paypalcommercevenmo',\n PPSDK = 'PAYMENT_TYPE_SDK',\n QUADPAY = 'quadpay',\n SAGE_PAY = 'sagepay',\n SQUARE = 'squarev2',\n STRIPEV3 = 'stripev3',\n STRIPE_UPE = 'stripeupe',\n STRIPE_UPE_GOOGLE_PAY = 'googlepaystripeupe',\n BRAINTREE = 'braintree',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n BRAINTREE_VISA_CHECKOUT = 'braintreevisacheckout',\n BRAINTREE_GOOGLE_PAY = 'googlepaybraintree',\n CHASE_PAY = 'chasepay',\n WE_PAY = 'wepay',\n MASTERPASS = 'masterpass',\n STRIPE_GOOGLE_PAY = 'googlepaystripe',\n SEZZLE = 'sezzle',\n ZIP = 'zip',\n}\n\nexport default PaymentStrategyType;\n","\nexport interface ApproveDataOptions {\n orderID?: string;\n}\n\nexport interface ClickDataOptions {\n fundingSource: string;\n}\n\nexport interface ClickActions {\n reject(): Promise<void>;\n resolve(): Promise<void>;\n}\n\nexport interface OrderData {\n orderId: string;\n approveUrl: string;\n}\n\nexport interface OrderStatus {\n status: 'APPROVED' | 'CREATED' | string;\n}\n\nexport enum StyleButtonLabel {\n paypal = 'paypal',\n checkout = 'checkout',\n buynow = 'buynow',\n pay = 'pay',\n installment = 'installment',\n}\n\nexport enum StyleButtonLayout {\n vertical = 'vertical',\n horizontal = 'horizontal',\n}\n\nexport enum StyleButtonColor {\n gold = 'gold',\n blue = 'blue',\n silver = 'silver',\n black = 'black',\n white = 'white',\n}\n\nexport enum StyleButtonShape {\n pill = 'pill',\n rect = 'rect' ,\n}\n\nexport interface PaypalButtonStyleOptions {\n layout?: StyleButtonLayout;\n color?: StyleButtonColor;\n shape?: StyleButtonShape;\n height?: 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55;\n label?: StyleButtonLabel;\n tagline?: boolean;\n}\n\nexport interface ButtonsOptions {\n style?: PaypalButtonStyleOptions;\n fundingSource?: string;\n createOrder?(): Promise<string>;\n onApprove?(data: ApproveDataOptions): void;\n onClick?(data: ClickDataOptions, actions: ClickActions): void;\n onCancel?(): void;\n onError?(error: Error): void;\n}\n\nexport interface PaypalFieldsStyleOptions {\n variables?: {\n fontFamily?: string;\n fontSizeBase?: string;\n fontSizeSm?: string;\n fontSizeM?: string;\n fontSizeLg?: string;\n textColor?: string;\n colorTextPlaceholder?: string;\n colorBackground?: string;\n colorInfo?: string;\n colorDanger?: string;\n borderRadius?: string;\n borderColor?: string;\n borderWidth?: string;\n borderFocusColor?: string;\n spacingUnit?: string;\n };\n rules?: {\n [key: string]: any;\n };\n}\n\nexport interface FieldsOptions {\n style?: PaypalFieldsStyleOptions;\n fundingSource: string;\n fields: { name?: { value?: string }; email?: { value?: string } };\n}\n\nexport interface MessagesOptions {\n amount: number;\n placement: string;\n style?: MessagesStyleOptions;\n fundingSource?: string;\n}\n\nexport interface MessagesStyleOptions {\n layout?: string;\n}\n\nexport interface PaypalCommerceHostedFieldOption {\n selector: string;\n placeholder?: string;\n}\n\nexport interface PaypalCommerceHostedFieldsRenderOptions {\n fields?: {\n number?: PaypalCommerceHostedFieldOption;\n cvv?: PaypalCommerceHostedFieldOption;\n expirationDate?: PaypalCommerceHostedFieldOption;\n };\n paymentsSDK?: boolean;\n styles?: {\n input?: { [key: string]: string };\n '.invalid'?: { [key: string]: string };\n '.valid'?: { [key: string]: string };\n ':focus'?: { [key: string]: string };\n };\n createOrder(): Promise<string>;\n}\n\nexport interface PaypalCommerceHostedFieldsSubmitOptions {\n contingencies?: Array<'3D_SECURE'>;\n cardholderName?: string;\n}\n\nexport interface PaypalCommerceHostedFieldsApprove {\n orderId: string;\n liabilityShift: 'POSSIBLE' | 'NO' | 'UNKNOWN';\n}\n\nexport interface PaypalCommerceHostedFields {\n submit(options?: PaypalCommerceHostedFieldsSubmitOptions): PaypalCommerceHostedFieldsApprove;\n getState(): PaypalCommerceHostedFieldsState;\n on(eventName: string, callback: (event: PaypalCommerceHostedFieldsState) => void): void;\n}\n\nexport interface PaypalCommerceHostedFieldsState {\n cards: PaypalCommerceHostedFieldsCard[];\n emittedBy: string;\n fields: {\n number?: PaypalCommerceHostedFieldsFieldData;\n expirationDate?: PaypalCommerceHostedFieldsFieldData;\n expirationMonth?: PaypalCommerceHostedFieldsFieldData;\n expirationYear?: PaypalCommerceHostedFieldsFieldData;\n cvv?: PaypalCommerceHostedFieldsFieldData;\n postalCode?: PaypalCommerceHostedFieldsFieldData;\n };\n}\n\nexport interface PaypalCommerceHostedFieldsCard {\n type: string;\n niceType: string;\n code: { name: string; size: number };\n}\n\nexport interface PaypalCommerceHostedFieldsFieldData {\n container: HTMLElement;\n isFocused: boolean;\n isEmpty: boolean;\n isPotentiallyValid: boolean;\n isValid: boolean;\n}\n\nexport interface PaypalCommerceButtons {\n render(id: string): void;\n close(): void;\n isEligible(): boolean;\n}\n\nexport interface PaypalCommerceFields {\n render(id: string): void;\n}\n\nexport interface PaypalCommerceMessages {\n render(id: string): void;\n}\n\nexport interface PaypalCommerceSDKFunding {\n PAYPAL: string;\n CREDIT: string;\n PAYLATER: string;\n BANCONTACT: string;\n GIROPAY: string;\n P24: string;\n EPS: string;\n IDEAL: string;\n MYBANK: string;\n OXXO: string;\n SOFORT: string;\n SEPA: string;\n BLIK: string;\n TRUSTLY: string;\n VERKKOPANKKI: string;\n VENMO: string;\n}\n\nexport const NON_INSTANT_PAYMENT_METHODS = ['oxxo'];\n\nexport interface PaypalCommerceSDK {\n FUNDING: PaypalCommerceSDKFunding;\n HostedFields: {\n isEligible(): boolean;\n render(data: PaypalCommerceHostedFieldsRenderOptions): Promise<PaypalCommerceHostedFields>;\n };\n Buttons(params: ButtonsOptions): PaypalCommerceButtons;\n PaymentFields(params: FieldsOptions): PaypalCommerceFields;\n Messages(params: MessagesOptions): PaypalCommerceMessages;\n}\n\nexport interface PaypalCommerceHostWindow extends Window {\n paypal?: PaypalCommerceSDK;\n paypalLoadScript?(options: PaypalCommerceScriptParams): Promise<{ paypal: PaypalCommerceSDK }>;\n}\n\nexport type FundingType = string[];\nexport type EnableFundingType = FundingType | string;\n\nexport interface PaypalCommerceInitializationData {\n clientId: string;\n merchantId?: string;\n buyerCountry?: string;\n isDeveloperModeApplicable?: boolean;\n intent?: 'capture' | 'authorize';\n isPayPalCreditAvailable?: boolean;\n availableAlternativePaymentMethods: FundingType;\n enabledAlternativePaymentMethods: FundingType;\n isProgressiveOnboardingAvailable?: boolean;\n clientToken?: string;\n attributionId?: string;\n isVenmoEnabled?: boolean;\n}\n\nexport type ComponentsScriptType = Array<'buttons' | 'messages' | 'hosted-fields' | 'payment-fields'>;\n\nexport interface PaypalCommerceScriptParams {\n 'client-id': string;\n 'merchant-id'?: string;\n 'buyer-country'?: string;\n 'disable-funding'?: FundingType;\n 'enable-funding'?: EnableFundingType;\n 'data-client-token'?: string;\n 'data-partner-attribution-id'?: string;\n currency?: string;\n commit?: boolean;\n intent?: 'capture' | 'authorize';\n components?: ComponentsScriptType;\n}\n","import { isNil, omitBy } from 'lodash';\n\nimport { CheckoutStore, InternalCheckoutSelectors } from '../../../checkout';\nimport { NotImplementedError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { OrderActionCreator } from '../../../order';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentActionCreator from '../../payment-action-creator';\nimport PaymentStrategyType from '../../payment-strategy-type';\n\nimport { ButtonsOptions, FieldsOptions, NON_INSTANT_PAYMENT_METHODS, ParamsForProvider, PaypalButtonStyleOptions, PaypalCommerceButtons, PaypalCommerceFields, PaypalCommerceHostedFields, PaypalCommerceHostedFieldsApprove, PaypalCommerceHostedFieldsRenderOptions, PaypalCommerceHostedFieldsState, PaypalCommerceHostedFieldsSubmitOptions, PaypalCommerceMessages, PaypalCommerceRequestSender, PaypalCommerceScriptLoader, PaypalCommerceScriptParams, PaypalCommerceSDK, PaypalCommerceSDKFunding, PaypalFieldsStyleOptions, StyleButtonColor, StyleButtonLabel, StyleButtonLayout, StyleButtonShape } from './index';\n\nexport interface OptionalParamsRenderButtons {\n paramsForProvider?: ParamsForProvider;\n fundingKey?: keyof PaypalCommerceSDKFunding;\n onRenderButton?(): void;\n}\n\nexport interface ParamsRenderHostedFields {\n fields: PaypalCommerceHostedFieldsRenderOptions['fields'];\n styles?: PaypalCommerceHostedFieldsRenderOptions['styles'];\n}\n\ninterface EventsHostedFields {\n blur?(event: PaypalCommerceHostedFieldsState): void;\n focus?(event: PaypalCommerceHostedFieldsState): void;\n cardTypeChange?(event: PaypalCommerceHostedFieldsState): void;\n validityChange?(event: PaypalCommerceHostedFieldsState): void;\n inputSubmitRequest?(event: PaypalCommerceHostedFieldsState): void;\n}\n\nexport interface RenderApmFieldsParams {\n apmFieldsContainer: string;\n fundingKey: keyof PaypalCommerceSDKFunding;\n apmFieldsStyles?: PaypalFieldsStyleOptions;\n fullName?: string;\n email?: string;\n}\n\nexport default class PaypalCommercePaymentProcessor {\n private _paypal?: PaypalCommerceSDK;\n private _paypalButtons?: PaypalCommerceButtons;\n private _paypalFields?: PaypalCommerceFields;\n private _paypalMessages?: PaypalCommerceMessages;\n private _hostedFields?: PaypalCommerceHostedFields;\n private _fundingSource?: string;\n private _orderId?: string;\n private _gatewayId?: string;\n private _isVenmoEnabled?: boolean;\n\n constructor(\n private _paypalScriptLoader: PaypalCommerceScriptLoader,\n private _paypalCommerceRequestSender: PaypalCommerceRequestSender,\n private _store: CheckoutStore,\n private _orderActionCreator: OrderActionCreator,\n private _paymentActionCreator: PaymentActionCreator\n ) {}\n\n async initialize(paramsScript: PaypalCommerceScriptParams, isProgressiveOnboardingAvailable?: boolean, gatewayId?: string, isVenmoEnabled?: boolean): Promise<PaypalCommerceSDK> {\n this._paypal = await this._paypalScriptLoader.loadPaypalCommerce(paramsScript, isProgressiveOnboardingAvailable);\n this._gatewayId = gatewayId;\n this._isVenmoEnabled = isVenmoEnabled;\n\n return this._paypal;\n }\n\n renderButtons(cartId: string, container: string, params: ButtonsOptions = {}, optionalParams: OptionalParamsRenderButtons = {}): PaypalCommerceButtons {\n if (!this._paypal || !this._paypal.Buttons) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const { paramsForProvider, fundingKey, onRenderButton } = optionalParams;\n\n const buttonParams: ButtonsOptions = {\n ...params,\n createOrder: () => this._setupPayment(cartId, paramsForProvider),\n\n onClick: async (data, actions) => {\n this._fundingSource = data.fundingSource;\n\n return params.onClick?.(data, actions);\n },\n };\n\n if (params.style) {\n buttonParams.style = this._validateStyleParams(params.style);\n }\n\n if (fundingKey) {\n this._fundingSource = this._paypal.FUNDING[fundingKey];\n buttonParams.fundingSource = this._fundingSource;\n }\n\n this._paypalButtons = this._paypal.Buttons(buttonParams);\n\n if (!this._paypalButtons.isEligible()) {\n this._processNotEligible(buttonParams, fundingKey);\n }\n\n onRenderButton?.();\n\n this._paypalButtons.render(container);\n\n return this._paypalButtons;\n }\n\n renderFields({\n apmFieldsContainer,\n fundingKey,\n apmFieldsStyles,\n fullName,\n email,\n }: RenderApmFieldsParams): PaypalCommerceFields {\n if (!this._paypal || !this._paypal.PaymentFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const fieldsParams: FieldsOptions = {\n fundingSource: this._paypal.FUNDING[fundingKey],\n style: apmFieldsStyles,\n fields: {\n name: {\n value: fullName,\n },\n email: {\n value: email,\n },\n },\n };\n\n this._paypalFields = this._paypal.PaymentFields(fieldsParams);\n\n const fieldContainerElement = document.querySelector(apmFieldsContainer);\n if (fieldContainerElement) {\n fieldContainerElement.innerHTML = '';\n }\n\n this._paypalFields.render(apmFieldsContainer);\n\n return this._paypalFields;\n }\n\n getOrderId() {\n return this._orderId;\n }\n\n renderMessages(cartTotal: number, container: string): PaypalCommerceMessages {\n if (!this._paypal || !this._paypal.Messages) {\n throw new PaymentMethodClientUnavailableError();\n }\n this._paypalMessages = this._paypal.Messages({\n amount: cartTotal,\n placement: 'cart',\n style: {\n layout: 'text',\n },\n });\n this._paypalMessages.render(container);\n\n return this._paypalMessages;\n }\n\n async renderHostedFields(cartId: string, params: ParamsRenderHostedFields, events?: EventsHostedFields): Promise<void> {\n if (!this._paypal || !this._paypal.HostedFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const { fields, styles } = params;\n\n if (!this._paypal.HostedFields.isEligible()) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n this._hostedFields = await this._paypal.HostedFields.render({\n fields,\n styles,\n paymentsSDK: true,\n createOrder: () => this._setupPayment(cartId, { isCreditCard: true }),\n });\n\n if (events) {\n (Object.keys(events) as Array<keyof EventsHostedFields>).forEach(key => {\n (this._hostedFields as PaypalCommerceHostedFields).on(key, events[key] as (event: PaypalCommerceHostedFieldsState) => void);\n });\n }\n }\n\n async submitHostedFields(options?: PaypalCommerceHostedFieldsSubmitOptions): Promise<PaypalCommerceHostedFieldsApprove> {\n if (!this._hostedFields) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._hostedFields.submit(omitBy(options, isNil));\n }\n\n getHostedFieldsValidationState(): { isValid: boolean; fields: PaypalCommerceHostedFieldsState['fields'] } {\n if (!this._hostedFields) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n const { fields } = this._hostedFields.getState();\n\n const isValid = (Object.keys(fields) as Array<keyof PaypalCommerceHostedFieldsState['fields']>)\n .every(key => fields[key]?.isValid);\n\n return { isValid, fields };\n }\n\n deinitialize() {\n this._paypalButtons?.close?.();\n this._paypal = undefined;\n this._paypalButtons = undefined;\n this._fundingSource = undefined;\n this._hostedFields = undefined;\n }\n\n private async _setupPayment(cartId: string, params: ParamsForProvider = {}): Promise<string> {\n const paramsForProvider = { ...params, isCredit: this._fundingSource === 'credit' || this._fundingSource === 'paylater' };\n const isAPM = this._gatewayId === PaymentStrategyType.PAYPAL_COMMERCE_ALTERNATIVE_METHODS;\n const isVenmo = this._fundingSource === 'venmo' && this._isVenmoEnabled;\n\n const { orderId } = await this._paypalCommerceRequestSender.setupPayment(cartId, {...paramsForProvider, isAPM, isVenmo});\n this._orderId = orderId;\n const methodId = this._fundingSource;\n\n if (methodId && NON_INSTANT_PAYMENT_METHODS.indexOf(methodId) > -1) {\n await this._patchNonInstantPaymentMethods(methodId);\n }\n\n return orderId;\n }\n\n private async _patchNonInstantPaymentMethods(methodId: string): Promise<InternalCheckoutSelectors> {\n const gatewayId = this._gatewayId;\n const paymentData = {\n formattedPayload: {\n vault_payment_instrument: null,\n set_as_default_stored_instrument: null,\n device_info: null,\n method_id: methodId,\n paypal_account: {\n order_id: this._orderId,\n },\n },\n };\n\n const order = { useStoreCredit: false };\n const paymentRequestOptions = {\n gatewayId,\n methodId,\n };\n\n await this._store.dispatch(this._orderActionCreator.submitOrder(\n order,\n { params: paymentRequestOptions }\n ));\n\n return this._store.dispatch(this._paymentActionCreator.submitPayment({\n gatewayId,\n methodId,\n paymentData,\n }));\n }\n\n private _validateStyleParams = (style: PaypalButtonStyleOptions): PaypalButtonStyleOptions => {\n const updatedStyle: PaypalButtonStyleOptions = { ...style };\n const { label, color, layout, shape, height, tagline } = style;\n\n if (label && !StyleButtonLabel[label]) {\n delete updatedStyle.label;\n }\n\n if (layout && !StyleButtonLayout[layout]) {\n delete updatedStyle.layout;\n }\n\n if (color && !StyleButtonColor[color]) {\n delete updatedStyle.color;\n }\n\n if (shape && !StyleButtonShape[shape]) {\n delete updatedStyle.shape;\n }\n\n if (typeof height === 'number') {\n updatedStyle.height = height < 25\n ? 25\n : (height > 55 ? 55 : height);\n } else {\n delete updatedStyle.height;\n }\n\n if (typeof tagline !== 'boolean' || (tagline && updatedStyle.layout !== StyleButtonLayout[StyleButtonLayout.horizontal])) {\n delete updatedStyle.tagline;\n }\n\n return updatedStyle;\n };\n\n private _processNotEligible(buttonParams: ButtonsOptions, fundingKey?: keyof PaypalCommerceSDKFunding): void {\n if (fundingKey?.toUpperCase() === this._paypal?.FUNDING.PAYLATER.toUpperCase()) {\n buttonParams.fundingSource = this._paypal?.FUNDING.CREDIT;\n\n this._paypalButtons = this._paypal?.Buttons(buttonParams);\n\n if (this._paypalButtons?.isEligible()) {\n return;\n }\n }\n\n throw new NotImplementedError(`PayPal ${this._fundingSource || ''} is not available for your region. Please use PayPal Checkout instead.`);\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\n/**\n * @todo Convert this file into TypeScript properly\n */\nexport default class RemoteCheckoutRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n initializeBilling(methodName: string, params?: { referenceId: string }, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/billing`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n initializeShipping(methodName: string, params?: { referenceId: string }, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/shipping`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n initializePayment(methodName: string, params?: InitializePaymentOptions, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/payment`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n loadSettings(methodName: string, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/settings`;\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n signOut(methodName: string, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/signout`;\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n generateToken({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = '/remote-checkout-token';\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n trackAuthorizationEvent({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = '/remote-checkout/events/shopper-checkout-service-provider-authorization-requested';\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n forgetCheckout({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/forget-checkout`;\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n}\n\nexport interface InitializePaymentOptions {\n authorizationToken?: string;\n customerMessage?: string;\n referenceId?: string;\n useStoreCredit?: boolean;\n}\n","import { createAction, createErrorAction, Action } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable, Observer } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { CheckoutActionCreator } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\n\nimport { RemoteCheckoutActionType } from './remote-checkout-actions';\nimport RemoteCheckoutRequestSender, { InitializePaymentOptions } from './remote-checkout-request-sender';\nimport { RemoteCheckoutStateData } from './remote-checkout-state';\n\n/**\n * @todo Convert this file into TypeScript properly\n * i.e.: Action<T>\n */\nexport default class RemoteCheckoutActionCreator {\n constructor(\n private _remoteCheckoutRequestSender: RemoteCheckoutRequestSender,\n private _checkoutActionCreator: CheckoutActionCreator\n ) {}\n\n initializeBilling(methodId: string, params?: { referenceId: string }, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteBillingRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializeBilling(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteBillingSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemoteBillingFailed, response, { methodId }));\n });\n });\n }\n\n initializeShipping(methodId: string, params?: { referenceId: string }, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteShippingRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializeShipping(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteShippingSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemoteShippingFailed, response, { methodId }));\n });\n });\n }\n\n initializePayment(methodId: string, params?: InitializePaymentOptions, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemotePaymentRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializePayment(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemotePaymentSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemotePaymentFailed, response, { methodId }));\n });\n });\n }\n\n loadSettings(methodId: string, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.LoadRemoteSettingsRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.loadSettings(methodId, options)\n .then(({ body }) => {\n observer.next(createAction(RemoteCheckoutActionType.LoadRemoteSettingsSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.LoadRemoteSettingsFailed, response, { methodId }));\n });\n });\n }\n\n signOut(methodId: string, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.SignOutRemoteCustomerRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.signOut(methodId, options)\n .then(() => {\n observer.next(createAction(RemoteCheckoutActionType.SignOutRemoteCustomerSucceeded, undefined, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.SignOutRemoteCustomerFailed, response, { methodId }));\n });\n });\n }\n\n forgetCheckout(methodId: string, options?: RequestOptions): Observable<Action> {\n return concat(\n of(createAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerRequested, undefined, {methodId})),\n defer(async () => {\n await this._remoteCheckoutRequestSender.forgetCheckout(options);\n await this._checkoutActionCreator.loadCurrentCheckout();\n\n return createAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerSucceeded, undefined, {methodId});\n })\n ).pipe(\n catchError(error => throwErrorAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerFailed, error, { methodId }))\n );\n }\n\n updateCheckout<K extends keyof RemoteCheckoutStateData>(methodId: K, data: Partial<RemoteCheckoutStateData[K]>): Action {\n return createAction(RemoteCheckoutActionType.UpdateRemoteCheckout, data, { methodId });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam protection\n * challenge (i.e.: they close the reCaptcha window).\n */\nexport default class SpamProtectionChallengeNotCompletedError extends StandardError {\n constructor() {\n super('You haven\\'t complete our spam protection challenge. Please try again.');\n\n this.name = 'SpamProtectionChallengeNotCompletedError';\n this.type = 'spam_protection_challenge_not_completed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam protection\n * challenge (i.e.: they close the reCaptcha window).\n */\nexport default class CardingProtectionChallengeNotCompletedError extends StandardError {\n constructor() {\n super('Please complete our human verification challenge and try again.');\n\n this.name = 'CardingProtectionChallengeNotCompletedError';\n this.type = 'carding_protection_challenge_not_completed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we fail to complete the required spam protection\n * verification due to an unknown reason.\n */\nexport default class CardingProtectionFailedError extends StandardError {\n constructor() {\n super('We were not able to verify that you are not a robot. Please try again.');\n\n this.name = 'CardingProtectionFailedError';\n this.type = 'carding_protection_failed';\n }\n}\n","import { switchMap, take } from 'rxjs/operators';\n\nimport { RequestError } from '../common/error/errors';\nimport { PaymentAdditionalAction } from '../payment';\n\nimport { CardingProtectionChallengeNotCompletedError, CardingProtectionFailedError, SpamProtectionChallengeNotCompletedError } from './errors';\nimport GoogleRecaptcha from './google-recaptcha';\n\nexport default class PaymentHumanVerificationHandler {\n\n constructor(\n private _googleRecaptcha: GoogleRecaptcha\n ) {}\n\n handle(error: Error): Promise<PaymentAdditionalAction>;\n handle(id: string, key: string): Promise<PaymentAdditionalAction>;\n async handle(errorOrId: Error | string, key?: string): Promise<PaymentAdditionalAction> {\n if (typeof errorOrId === 'string') {\n return this.handleWithRecaptchaSitekey(errorOrId, key);\n }\n\n return this.handleWithPaymentHumanVerificationRequestError(errorOrId);\n }\n\n private async handleWithPaymentHumanVerificationRequestError(error: Error): Promise<PaymentAdditionalAction> {\n if (!this._isPaymentHumanVerificationRequest(error)) {\n throw error;\n }\n\n await this._initialize(error.body.additional_action_required.data.key);\n\n return this._performRecaptcha();\n }\n\n private async handleWithRecaptchaSitekey(id: string, key?: string): Promise<PaymentAdditionalAction> {\n if (id !== 'recaptcha_v2') {\n throw Error('Human verification method is not supported.');\n }\n\n if (!key) {\n throw Error('Recaptcha site key is missing.');\n }\n\n await this._initialize(key);\n\n return this._performRecaptcha();\n }\n\n private _performRecaptcha(): Promise<PaymentAdditionalAction> {\n return this._googleRecaptcha.execute()\n .pipe(take(1))\n .pipe(switchMap(async ({ error, token }) => {\n if (error instanceof SpamProtectionChallengeNotCompletedError) {\n throw new CardingProtectionChallengeNotCompletedError();\n }\n\n if (error || !token) {\n throw new CardingProtectionFailedError();\n }\n\n return {\n type: 'recaptcha_v2_verification',\n data: {\n human_verification_token: token,\n },\n };\n })).toPromise();\n }\n\n private _initialize(recaptchaSitekey: string): Promise<void> {\n const cardingProtectionElementId = 'cardingProtectionContainer';\n\n let cardingProtectionElement = document.getElementById(cardingProtectionElementId);\n if (cardingProtectionElement && cardingProtectionElement.parentNode) {\n cardingProtectionElement.parentNode.removeChild(cardingProtectionElement);\n }\n\n cardingProtectionElement = document.createElement('div');\n cardingProtectionElement.setAttribute('id', cardingProtectionElementId);\n document.body.appendChild(cardingProtectionElement);\n\n return this._googleRecaptcha.load(cardingProtectionElementId, recaptchaSitekey);\n }\n\n private _isPaymentHumanVerificationRequest(error: Error): error is RequestError {\n const { additional_action_required, status } = (error as RequestError).body || {};\n\n return status === 'additional_action_required'\n && additional_action_required\n && additional_action_required.type === 'recaptcha_v2_verification';\n }\n}\n","export interface MutationObeserverCreator {\n prototype: MutationObserver;\n new(callback: MutationCallback): MutationObserver;\n}\n\nexport interface MutationObserverWindow extends Window {\n MutationObserver: MutationObeserverCreator;\n}\n\nexport class MutationObserverFactory {\n constructor(\n private _window: MutationObserverWindow = window as MutationObserverWindow\n ) {}\n\n create(callback: MutationCallback): MutationObserver {\n return new this._window.MutationObserver(callback);\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we fail to complete the required spam protection\n * verification due to an unknown reason.\n */\nexport default class SpamProtectionFailedError extends StandardError {\n constructor() {\n super('We were not able to complete your spam protection verification. Please try again.');\n\n this.name = 'SpamProtectionFailedError';\n this.type = 'spam_protection_failed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if spam protection is not loaded when trying to\n * complete the required spam protection verification.\n */\nexport default class SpamProtectionNotLoadedError extends StandardError {\n constructor() {\n super('Spam protection is not loaded. Please try again.');\n\n this.name = 'SpamProtectionNotLoadedError';\n this.type = 'spam_protection_failed';\n }\n}\n","import { memoize } from '@bigcommerce/memoize';\nimport { defer, of, throwError, Observable, Subject } from 'rxjs';\nimport { catchError, delay, retryWhen, switchMap } from 'rxjs/operators';\n\nimport { MutationObserverFactory } from '../common/dom';\nimport { NotInitializedError, NotInitializedErrorType } from '../common/error/errors';\n\nimport { SpamProtectionChallengeNotCompletedError, SpamProtectionFailedError, SpamProtectionNotLoadedError } from './errors';\nimport GoogleRecaptchaScriptLoader from './google-recaptcha-script-loader';\n\nconst TIMEOUT = 7000;\nconst RETRY_INTERVAL = 250;\nconst MAX_RETRIES = TIMEOUT / RETRY_INTERVAL;\n\nexport interface RecaptchaResult {\n error?: Error;\n token?: string;\n}\n\nexport default class GoogleRecaptcha {\n private _event$?: Subject<RecaptchaResult>;\n private _recaptcha?: ReCaptchaV2.ReCaptcha;\n private _memoized: (recaptcha: ReCaptchaV2.ReCaptcha, sitekey: string, container: HTMLElement | null) => Subject<RecaptchaResult>;\n private _widgetId?: number;\n\n constructor(\n private googleRecaptchaScriptLoader: GoogleRecaptchaScriptLoader,\n private mutationObserverFactory: MutationObserverFactory\n ) {\n this._memoized = memoize((recaptcha: ReCaptchaV2.ReCaptcha, sitekey: string, container: HTMLElement | null) => {\n const event$ = new Subject<RecaptchaResult>();\n\n if (!container) {\n throw new Error();\n }\n\n this._widgetId = recaptcha.render(container.id, {\n sitekey,\n size: 'invisible',\n callback: () => {\n event$.next({\n token: recaptcha.getResponse(this._widgetId),\n });\n recaptcha.reset(this._widgetId);\n },\n 'error-callback': () => {\n event$.next({\n error: new SpamProtectionFailedError(),\n });\n },\n });\n\n return event$;\n }, { isEqual: (a, b) => a === b });\n }\n\n load(containerId: string, sitekey: string): Promise<void> {\n return this.googleRecaptchaScriptLoader.load()\n .then(recaptcha => {\n this._event$ = this._memoized(recaptcha, sitekey, document.getElementById(containerId));\n\n this._recaptcha = recaptcha;\n });\n }\n\n execute(): Observable<RecaptchaResult> {\n return defer(() => {\n const event$ = this._event$;\n const recaptcha = this._recaptcha;\n\n if (!event$ || !recaptcha) {\n throw new NotInitializedError(NotInitializedErrorType.SpamProtectionNotInitialized);\n }\n\n return defer(() => {\n const element = document.querySelector('iframe[src*=\"bframe\"]');\n\n return element ? of(element) : throwError(new SpamProtectionNotLoadedError());\n })\n .pipe(\n retryWhen(errors => errors.pipe(\n delay(RETRY_INTERVAL),\n switchMap((error, index) =>\n index < MAX_RETRIES ? of(error) : throwError(error)\n )\n )),\n switchMap(element => {\n this._watchRecaptchaChallengeWindow(event$, element);\n recaptcha.execute(this._widgetId);\n\n return event$;\n }),\n catchError(error => of({ error }))\n );\n });\n }\n\n private _watchRecaptchaChallengeWindow(event: Subject<RecaptchaResult>, element: Element) {\n const iframeContainer = element.parentElement;\n\n if (!iframeContainer) {\n throw new SpamProtectionNotLoadedError();\n }\n\n const container = iframeContainer.parentElement;\n\n if (!container) {\n throw new SpamProtectionNotLoadedError();\n }\n\n this.mutationObserverFactory.create(() => {\n // When customer closes the Google ReCaptcha challenge window, throw SpamProtectionNotCompletedError\n if (container.style.visibility === 'hidden') {\n event.next({\n error: new SpamProtectionChallengeNotCompletedError(),\n });\n }\n }).observe(container, { attributes: true, attributeFilter: ['style'] });\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nexport default class GoogleRecaptchaScriptLoader {\n private _loadPromise?: Promise<ReCaptchaV2.ReCaptcha>;\n\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: GoogleRecaptchaWindow = window\n ) {}\n\n load(): Promise<ReCaptchaV2.ReCaptcha> {\n if (!this._loadPromise) {\n this._loadPromise = this._loadScript();\n }\n\n return this._loadPromise;\n }\n\n private _loadScript(): Promise<ReCaptchaV2.ReCaptcha> {\n const callbackName = 'initRecaptcha';\n const params = [\n `onload=${callbackName}`,\n 'render=explicit',\n ].join('&');\n\n return new Promise((resolve, reject) => {\n this._window[callbackName] = () => resolve(this._window.grecaptcha);\n\n this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${params}`)\n .catch(error => {\n this._loadPromise = undefined;\n reject(error);\n });\n });\n }\n}\n\nexport interface GoogleRecaptchaWindow extends Window {\n grecaptcha?: ReCaptchaV2.ReCaptcha;\n initRecaptcha?(): void;\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { MutationObserverFactory } from '../common/dom';\n\nimport GoogleRecaptcha from './google-recaptcha';\nimport GoogleRecaptchaScriptLoader from './google-recaptcha-script-loader';\n\nexport default function createSpamProtection(scriptLoader: ScriptLoader): GoogleRecaptcha {\n return new GoogleRecaptcha(\n new GoogleRecaptchaScriptLoader(scriptLoader),\n new MutationObserverFactory()\n );\n}\n","import { Cart } from '../cart';\n\nimport getLineItemsCount from './getLineItemsCount';\n\nexport default function getShippableItemsCount(cart: Cart): number {\n return getLineItemsCount(cart.lineItems.physicalItems.filter(item => !item.addedByPromotion));\n}\n","import { reduce } from 'lodash';\n\nimport { LineItem } from '../cart';\n\nexport default function getLineItemsCount(lineItems: LineItem[]): number {\n return reduce(lineItems, (total, item) => total + item.quantity, 0);\n}\n","import { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { PaymentMethod } from '../../../payment';\nimport { AmazonPayV2ButtonParams, AmazonPayV2PaymentProcessor, AmazonPayV2PayOptions, AmazonPayV2Placement } from '../../../payment/strategies/amazon-pay-v2';\nimport { getShippableItemsCount } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { AmazonPayV2ButtonInitializeOptions } from './amazon-pay-v2-button-options';\n\nexport default class AmazonPayV2ButtonStrategy implements CheckoutButtonStrategy {\n private _walletButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _amazonPayV2PaymentProcessor: AmazonPayV2PaymentProcessor\n ) { }\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId, amazonpay } = options;\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" or \"methodId\" argument is not provided.');\n }\n\n const paymentMethod = this._store.getState().paymentMethods.getPaymentMethodOrThrow(methodId);\n\n await this._amazonPayV2PaymentProcessor.initialize(paymentMethod);\n this._walletButton = await this._createSignInButton(containerId, paymentMethod, amazonpay);\n }\n\n deinitialize(): Promise<void> {\n if (this._walletButton && this._walletButton.parentNode) {\n this._walletButton.parentNode.removeChild(this._walletButton);\n this._walletButton = undefined;\n }\n\n return Promise.resolve();\n }\n\n private async _createSignInButton(containerId: string, paymentMethod: PaymentMethod, options?: AmazonPayV2ButtonInitializeOptions): Promise<HTMLElement> {\n const container = document.getElementById(containerId);\n\n if (!container) {\n throw new InvalidArgumentError('Unable to create sign-in button without valid container ID.');\n }\n\n const amazonButtonOptions = options ?? await this._getAmazonPayV2ButtonOptions(paymentMethod);\n\n this._amazonPayV2PaymentProcessor.createButton(`#${containerId}`, amazonButtonOptions);\n\n return container;\n }\n\n private async _getAmazonPayV2ButtonOptions(paymentMethod: PaymentMethod): Promise<AmazonPayV2ButtonParams> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const cart = state.cart.getCart();\n const { storeProfile: { shopPath }, checkoutSettings: { features } } = state.config.getStoreConfigOrThrow();\n\n const {\n config: {\n merchantId,\n testMode,\n },\n initializationData: {\n checkoutLanguage,\n ledgerCurrency,\n checkoutSessionMethod,\n extractAmazonCheckoutSessionId,\n },\n } = paymentMethod;\n\n if (!merchantId || !ledgerCurrency || !shopPath) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return {\n merchantId,\n createCheckoutSession: {\n // tslint:disable-next-line: no-string-literal\n url: features['INT-5826.amazon_relative_url']\n ? `/remote-checkout/${paymentMethod.id}/payment-session`\n : `${shopPath}/remote-checkout/${paymentMethod.id}/payment-session`,\n method: checkoutSessionMethod,\n extractAmazonCheckoutSessionId,\n },\n sandbox: !!testMode,\n ledgerCurrency,\n checkoutLanguage,\n productType: cart && getShippableItemsCount(cart) === 0 ?\n AmazonPayV2PayOptions.PayOnly :\n AmazonPayV2PayOptions.PayAndShip,\n placement: AmazonPayV2Placement.Cart,\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\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 { RequestSender } from '@bigcommerce/request-sender';\nimport { noop } from 'lodash';\n\nimport { AddressRequestBody } from '../../../address';\nimport { BillingAddressActionCreator } from '../../../billing';\nimport { Cart } from '../../../cart';\nimport { Checkout, CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { StoreConfig } from '../../../config';\nimport { OrderActionCreator } from '../../../order';\nimport { Payment, PaymentActionCreator, PaymentMethod, PaymentMethodActionCreator } from '../../../payment';\nimport { PaymentMethodCancelledError } from '../../../payment/errors';\nimport { assertApplePayWindow, ApplePaySessionFactory } from '../../../payment/strategies/apple-pay';\nimport { RemoteCheckoutActionCreator } from '../../../remote-checkout';\nimport { ConsignmentActionCreator, ShippingOption } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nconst validationEndpoint = (bigPayEndpoint: string) => `${bigPayEndpoint}/api/public/v1/payments/applepay/validate_merchant`;\n\nenum DefaultLabels {\n Subtotal = 'Subtotal',\n Shipping = 'Shipping',\n}\n\nfunction isShippingOptions(options: ShippingOption[] | undefined): options is ShippingOption[] {\n return options instanceof Array;\n}\n\nexport default class ApplePayButtonStrategy implements CheckoutButtonStrategy {\n private _paymentMethod?: PaymentMethod;\n private _applePayButton?: HTMLElement;\n private _onAuthorizeCallback = noop;\n private _subTotalLabel: string = DefaultLabels.Subtotal;\n private _shippingLabel: string = DefaultLabels.Shipping;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _requestSender: RequestSender,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _consignmentActionCreator: ConsignmentActionCreator,\n private _billingAddressActionCreator: BillingAddressActionCreator,\n private _paymentActionCreator: PaymentActionCreator,\n private _remoteCheckoutActionCreator: RemoteCheckoutActionCreator,\n private _orderActionCreator: OrderActionCreator,\n private _sessionFactory: ApplePaySessionFactory\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n\n const { methodId, containerId , applepay} = options;\n\n assertApplePayWindow(window);\n\n if (!methodId || !applepay) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const {\n buttonClassName,\n onPaymentAuthorize,\n } = applepay;\n\n this._onAuthorizeCallback = onPaymentAuthorize;\n\n await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n const state = await this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId));\n this._paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(methodId);\n\n this._applePayButton = this._createButton(containerId, buttonClassName);\n this._applePayButton.addEventListener('click', this._handleWalletButtonClick);\n\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n return Promise.resolve();\n }\n\n private _createButton(containerId: string, buttonClassName = 'apple-pay-checkout-button'): HTMLElement {\n const container = document.getElementById(containerId);\n if (!container) {\n throw new InvalidArgumentError('Unable to create wallet button without valid container ID.');\n }\n\n document.body.classList.add('apple-pay-supported');\n const button = document.createElement('div');\n button.classList.add(buttonClassName);\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', 'Apple Pay button');\n container.appendChild(button);\n\n return button;\n }\n\n @bind\n private _handleWalletButtonClick(event: Event) {\n event.preventDefault();\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const checkout = state.checkout.getCheckoutOrThrow();\n\n if (!this._paymentMethod || !this._paymentMethod.initializationData) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n const request = this._getBaseRequest(cart, checkout, config, this._paymentMethod);\n const applePaySession = this._sessionFactory.create(request);\n this._handleApplePayEvents(applePaySession, this._paymentMethod, config);\n\n applePaySession.begin();\n }\n\n private _getBaseRequest(\n cart: Cart,\n checkout: Checkout,\n config: StoreConfig,\n paymentMethod: PaymentMethod\n ): ApplePayJS.ApplePayPaymentRequest {\n const { storeProfile: { storeCountryCode, storeName } } = config;\n const { currency: { code, decimalPlaces} } = cart;\n\n const { initializationData : { merchantCapabilities, supportedNetworks } } = paymentMethod;\n\n const requiresShipping = cart.lineItems.physicalItems.length > 0;\n const total: ApplePayJS.ApplePayLineItem = requiresShipping ? {\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n type: 'pending',\n } : {\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n type: 'final',\n };\n\n const request: ApplePayJS.ApplePayPaymentRequest = {\n requiredBillingContactFields: ['postalAddress'],\n requiredShippingContactFields: ['email', 'phone'],\n countryCode: storeCountryCode,\n currencyCode: code,\n merchantCapabilities,\n supportedNetworks,\n lineItems: [],\n total,\n };\n\n if (requiresShipping) {\n request.requiredShippingContactFields?.push('postalAddress');\n } else {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [\n { label: this._subTotalLabel, amount: `${checkout.subtotal.toFixed(decimalPlaces)}`},\n ];\n\n checkout.taxes.forEach(tax =>\n lineItems.push({ label: tax.name, amount: `${tax.amount.toFixed(decimalPlaces)}` }));\n\n request.lineItems = lineItems;\n }\n\n return request;\n }\n\n private _handleApplePayEvents(\n applePaySession: ApplePaySession,\n paymentMethod: PaymentMethod,\n config: StoreConfig\n ) {\n applePaySession.onvalidatemerchant = async event => {\n try {\n const { body: merchantSession } = await this._onValidateMerchant(paymentMethod, event);\n applePaySession.completeMerchantValidation(merchantSession);\n } catch (error) {\n throw new Error('Merchant validation failed');\n }\n };\n\n applePaySession.onshippingcontactselected = async event =>\n this._handleShippingContactSelected(applePaySession, config, event);\n\n applePaySession.onshippingmethodselected = async event =>\n this._handleShippingMethodSelected(applePaySession, config, event);\n\n applePaySession.oncancel = async () => {\n try {\n await this._store.dispatch(this._remoteCheckoutActionCreator.signOut(paymentMethod.id));\n\n return this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout());\n } catch (error) {\n throw new PaymentMethodCancelledError();\n }\n };\n\n applePaySession.onpaymentauthorized = async event =>\n this._onPaymentAuthorized(event, applePaySession, paymentMethod);\n }\n\n private async _handleShippingContactSelected(\n applePaySession: ApplePaySession,\n config: StoreConfig,\n event: ApplePayJS.ApplePayShippingContactSelectedEvent\n ) {\n const shippingAddress = this._transformContactToAddress(event.shippingContact);\n\n try {\n await this._store.dispatch(\n this._consignmentActionCreator.updateAddress(shippingAddress)\n );\n } catch (error) {\n applePaySession.abort();\n\n throw new Error('Shipping address update failed');\n }\n\n const { storeProfile: { storeName } } = config;\n let state = this._store.getState();\n const { currency: { decimalPlaces } } = state.cart.getCartOrThrow();\n let checkout = state.checkout.getCheckoutOrThrow();\n const selectionShippingOptionId = checkout.consignments[0].selectedShippingOption?.id;\n const availableOptions = checkout.consignments[0].availableShippingOptions;\n const selectedOption = availableOptions?.find(({id}) => id === selectionShippingOptionId);\n const unselectedOptions = availableOptions?.filter(option => option.id !== selectionShippingOptionId);\n const shippingOptions: ApplePayJS.ApplePayShippingMethod[] = selectedOption ? [{\n label: selectedOption.description,\n amount: `${selectedOption.cost.toFixed(decimalPlaces)}`,\n detail: selectedOption.additionalDescription,\n identifier: selectedOption.id,\n }] : [];\n unselectedOptions?.forEach(option => shippingOptions.push(\n {\n label: option.description,\n amount: `${option.cost.toFixed(decimalPlaces)}`,\n detail: option.additionalDescription,\n identifier: option.id,\n }\n ));\n\n if (!isShippingOptions(availableOptions)) {\n throw new Error('Shipping options not available.');\n }\n\n if (availableOptions.length === 0) {\n applePaySession.completeShippingContactSelection(\n ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,\n [],\n {\n type: 'pending',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n []\n );\n\n return;\n }\n\n const recommendedOption = availableOptions.find(\n option => option.isRecommended\n );\n\n const optionId = recommendedOption ? recommendedOption.id : availableOptions[0].id;\n const selectedOptionId = selectedOption ? selectedOption.id : optionId;\n try {\n await this._updateShippingOption(selectedOptionId);\n } catch (error) {\n throw new Error('Shipping options update failed');\n }\n\n state = this._store.getState();\n checkout = state.checkout.getCheckoutOrThrow();\n\n applePaySession.completeShippingContactSelection({\n newShippingMethods: shippingOptions,\n newTotal: {\n type: 'final',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n newLineItems: this._getUpdatedLineItems(checkout, decimalPlaces),\n });\n }\n\n private async _handleShippingMethodSelected(\n applePaySession: ApplePaySession,\n config: StoreConfig,\n event: ApplePayJS.ApplePayShippingMethodSelectedEvent\n ) {\n const { storeProfile: { storeName } } = config;\n const { shippingMethod: { identifier: optionId } } = event;\n try {\n await this._updateShippingOption(optionId);\n } catch (error) {\n applePaySession.abort();\n\n throw new Error('Shipping option selection update failed.');\n }\n\n const state = this._store.getState();\n const { currency: { decimalPlaces } } = state.cart.getCartOrThrow();\n const checkout = state.checkout.getCheckoutOrThrow();\n\n applePaySession.completeShippingMethodSelection({\n newTotal: {\n type: 'final',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n newLineItems: this._getUpdatedLineItems(checkout, decimalPlaces),\n });\n }\n\n private _getUpdatedLineItems(checkout: Checkout, decimalPlaces: number): ApplePayJS.ApplePayLineItem[] {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [\n { label: this._subTotalLabel, amount: `${checkout.subtotal.toFixed(decimalPlaces)}`},\n ];\n\n checkout.taxes.forEach(tax =>\n lineItems.push({ label: tax.name, amount: `${tax.amount.toFixed(decimalPlaces)}` }));\n lineItems.push({ label: this._shippingLabel, amount: `${checkout.shippingCostTotal.toFixed(decimalPlaces)}`});\n\n return lineItems;\n }\n\n private async _updateShippingOption(optionId: string) {\n return await this._store.dispatch(\n this._consignmentActionCreator.selectShippingOption(optionId)\n );\n }\n\n private async _onValidateMerchant(paymentData: PaymentMethod, event: ApplePayJS.ApplePayValidateMerchantEvent) {\n const body = [\n `validationUrl=${event.validationURL}`,\n `merchantIdentifier=${paymentData.initializationData.merchantId}`,\n `displayName=${paymentData.initializationData.storeName}`,\n `domainName=${window.location.hostname}`,\n ].join('&');\n\n return this._requestSender.post(validationEndpoint(paymentData.initializationData.paymentsUrl), {\n credentials: false,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-XSRF-TOKEN': null,\n },\n body,\n });\n }\n\n private async _onPaymentAuthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n applePaySession: ApplePaySession,\n paymentMethod: PaymentMethod\n ) {\n const { token, billingContact, shippingContact } = event.payment;\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const requiresShipping = cart.lineItems.physicalItems.length > 0;\n const payment: Payment = {\n methodId: paymentMethod.id,\n paymentData: {\n formattedPayload: {\n apple_pay_token: {\n payment_data: token.paymentData,\n payment_method: token.paymentMethod,\n transaction_id: token.transactionIdentifier,\n },\n },\n },\n };\n\n const transformedBillingAddress = this._transformContactToAddress(billingContact);\n const transformedShippingAddress = this._transformContactToAddress(shippingContact);\n const emailAddress = shippingContact?.emailAddress;\n\n try {\n await this._store.dispatch(\n this._billingAddressActionCreator.updateAddress({ ...transformedBillingAddress, email: emailAddress })\n );\n\n if (requiresShipping) {\n await this._store.dispatch(\n this._consignmentActionCreator.updateAddress(transformedShippingAddress)\n );\n }\n\n await this._store.dispatch(this._orderActionCreator.submitOrder(\n {\n useStoreCredit: false,\n })\n );\n await this._store.dispatch(this._paymentActionCreator.submitPayment(payment));\n applePaySession.completePayment(ApplePaySession.STATUS_SUCCESS);\n\n return this._onAuthorizeCallback();\n } catch (error) {\n applePaySession.completePayment(ApplePaySession.STATUS_FAILURE);\n\n throw new Error('Payment cannot complete');\n }\n }\n\n private _transformContactToAddress(contact?: ApplePayJS.ApplePayPaymentContact): AddressRequestBody {\n return {\n firstName: contact?.givenName || '',\n lastName: contact?.familyName || '',\n city: contact?.locality || '',\n company: '',\n address1: contact?.addressLines && contact?.addressLines[0] || '',\n address2: contact?.addressLines && contact?.addressLines[1] || '',\n postalCode: contact?.postalCode || '',\n countryCode: contact?.countryCode || '',\n phone: contact?.phoneNumber || '',\n stateOrProvince: contact?.administrativeArea || '',\n stateOrProvinceCode: contact?.administrativeArea || '',\n customFields: [],\n };\n }\n}\n","import { Address } from '../../../address';\n\nimport { BraintreeShippingAddressOverride } from './braintree';\n\nexport default function mapToBraintreeShippingAddressOverride(address: Address): BraintreeShippingAddressOverride {\n return {\n recipientName: `${address.firstName} ${address.lastName}`,\n line1: address.address1,\n line2: address.address2,\n city: address.city,\n state: address.stateOrProvinceCode,\n postalCode: address.postalCode,\n countryCode: address.countryCode,\n phone: address.phone,\n };\n}\n","export interface PaypalSDK {\n Button: PaypalButton;\n checkout: PaypalExpressCheckout;\n FUNDING: PaypalFundingTypeList;\n Messages(options: MessagingOptions): MessagingRender;\n Buttons(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\nexport interface PaypalFundingTypeList {\n CARD?: string;\n CREDIT?: string;\n PAYPAL?: string;\n PAYLATER?: string;\n}\n\nexport interface PaypalButton {\n render(options: PaypalButtonOptions, container: string): void;\n}\n\nexport interface PaypalButtonRender {\n render(container: string): void;\n isEligible(): boolean;\n}\n\nexport interface MessagingRender {\n render(container: string): void;\n}\n\nexport interface MessagingOptions {\n amount: number;\n placement: string;\n}\n\nexport interface PaypalButtonOptions {\n env?: string;\n commit?: boolean;\n style?: PaypalButtonStyleOptions;\n funding?: PaypalFundingType;\n fundingSource?: string;\n client?: PaypalClientToken;\n payment?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n onAuthorize?(data: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n createOrder?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n onApprove?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n\n}\n\nexport interface PaypalClientToken {\n production?: string;\n sandbox?: string;\n}\n\nexport interface PaypalFundingType {\n allowed?: string[];\n disallowed?: string[];\n}\n\nexport enum PaypalButtonStyleLayoutOption {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n}\n\nexport enum PaypalButtonStyleSizeOption {\n SMALL = 'small',\n MEDIUM = 'medium',\n LARGE = 'large',\n RESPONSIVE = 'responsive',\n}\n\nexport enum PaypalButtonStyleColorOption {\n GOLD = 'gold',\n BLUE = 'blue',\n SIlVER = 'silver',\n BLACK = 'black',\n}\n\nexport enum PaypalButtonStyleLabelOption {\n CHECKOUT = 'checkout',\n PAY = 'pay',\n BUYNOW = 'buynow',\n PAYPAL = 'paypal',\n CREDIT = 'credit',\n}\n\nexport enum PaypalButtonStyleShapeOption {\n PILL = 'pill',\n RECT = 'rect',\n}\n\nexport interface PaypalButtonStyleOptions {\n layout?: PaypalButtonStyleLayoutOption;\n size?: PaypalButtonStyleSizeOption;\n color?: PaypalButtonStyleColorOption;\n label?: PaypalButtonStyleLabelOption;\n shape?: PaypalButtonStyleShapeOption;\n tagline?: boolean;\n fundingicons?: boolean;\n height?: number;\n}\n\nexport interface PaypalActions {\n payment: PaypalPaymentActions;\n request: PaypalRequestActions;\n}\n\nexport interface PaypalPaymentActions {\n get(id: string): Promise<PaypalPaymentPayload>;\n}\n\nexport interface PaypalRequestActions {\n post(url: string, payload?: object, options?: object): Promise<{ id: string }>;\n}\n\nexport interface PaypalTransaction {\n amount?: PaypalAmount;\n payee?: PaypalPayee;\n description?: string;\n note_to_payee?: string;\n item_list?: PaypalItemList;\n}\n\nexport interface PaypalItemList {\n items?: PaypalItem[];\n shipping_address?: PaypalAddress;\n}\n\nexport interface PaypalItem {\n sku?: string;\n name?: string;\n description?: string;\n quantity: string;\n price: string;\n currency: string;\n tax?: string;\n}\n\nexport interface PaypalAmount {\n currency: string;\n total: string;\n}\n\nexport interface PaypalPayer {\n payer_info: object;\n}\n\nexport interface PaypalPayee {\n email?: string;\n merchant_id?: string;\n}\n\nexport interface PaypalAddress {\n line1: string;\n line2?: string;\n city?: string;\n country_code: string;\n postal_code?: string;\n state?: string;\n phone?: string;\n type?: string;\n}\n\nexport interface PaypalPaymentPayload {\n payment: PaypalPaymentPayload;\n payer: PaypalPayer;\n transactions?: PaypalTransaction[];\n}\n\nexport interface PaypalAuthorizeData {\n payerId: string;\n paymentId?: string;\n billingToken?: string;\n // the PayPal side of things uses uppercase ID instead of camel case Id\n payerID?: string;\n paymentID?: string;\n}\n\nexport interface PaypalExpressCheckout {\n initXO(): void;\n startFlow(url: string): void;\n closeFlow(): void;\n setup(merchantId: string, options: PaypalExpressCheckoutOptions): void;\n}\n\nexport interface PaypalExpressCheckoutOptions {\n button: string;\n environment: string;\n}\n\nexport interface PaypalHostWindow extends Window {\n paypal?: PaypalSDK;\n}\n","import { isNil, omitBy } from 'lodash';\n\nimport { PaypalButtonStyleOptions } from '../../../payment/strategies/paypal';\n\nexport default function getValidButtonStyle(style: PaypalButtonStyleOptions): PaypalButtonStyleOptions {\n const { color, fundingicons, height, layout, shape, size, tagline } = style;\n\n const validStyles = {\n color,\n fundingicons,\n height: getValidHeight(height),\n layout,\n shape: shape || 'rect',\n size,\n tagline,\n };\n\n return omitBy(validStyles, isNil);\n}\n\nfunction getValidHeight(height?: number): number {\n const minHeight = 25;\n const maxHeight = 55;\n\n if (typeof height !== 'number' || height > maxHeight) {\n return maxHeight;\n }\n\n if (height < minHeight) {\n return minHeight;\n }\n\n return height;\n}\n","import { LegacyAddress } from '../../../address';\nimport { BraintreeDetails } from '../../../payment/strategies/braintree';\n\nexport default function mapToLegacyBillingAddress(details: BraintreeDetails): Partial<LegacyAddress> {\n const {\n billingAddress,\n email,\n firstName,\n lastName,\n phone,\n shippingAddress,\n } = details;\n\n const address = billingAddress || shippingAddress;\n\n return {\n email,\n first_name: firstName,\n last_name: lastName,\n phone_number: phone,\n address_line_1: address?.line1,\n address_line_2: address?.line2,\n city: address?.city,\n state: address?.state,\n country_code: address?.countryCode,\n postal_code: address?.postalCode,\n };\n}\n\n","import { LegacyAddress } from '../../../address';\nimport { BraintreeDetails } from '../../../payment/strategies/braintree';\n\nexport default function mapToLegacyShippingAddress(details: BraintreeDetails): Partial<LegacyAddress> {\n const { email, phone, shippingAddress } = details;\n\n const recipientName = shippingAddress?.recipientName || '';\n const [firstName, lastName] = recipientName.split(' ');\n\n return {\n email,\n first_name: firstName || '',\n last_name: lastName || '',\n phone_number: phone,\n address_line_1: shippingAddress?.line1,\n address_line_2: shippingAddress?.line2,\n city: shippingAddress?.city,\n state: shippingAddress?.state,\n country_code: shippingAddress?.countryCode,\n postal_code: shippingAddress?.postalCode,\n };\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { Address } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, StandardError, UnsupportedBrowserError } from '../../../common/error/errors';\nimport { mapToBraintreeShippingAddressOverride, BraintreeError, BraintreePaypalCheckout, BraintreeSDKCreator, BraintreeTokenizePayload, BraintreeVenmoCheckout } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalButtonStyleLabelOption, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\nimport { CheckoutButtonMethodType } from '../index';\n\nimport { BraintreePaypalV1ButtonInitializeOptions } from './braintree-paypal-v1-button-options';\nimport getValidButtonStyle from './get-valid-button-style';\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nconst venmoButtonStyle = {\n backgroundColor: '#3D95CE',\n backgroundPosition: '50% 50%',\n backgroundSize: '80px auto',\n backgroundImage: 'url(\"/app/assets/img/payment-providers/venmo-logo-white.svg\")',\n backgroundRepeat: 'no-repeat',\n borderRadius: '4px',\n cursor: 'pointer',\n transition: '0.2s ease',\n minHeight: '40px',\n minWidth: '150px',\n height: '100%',\n width: '100%',\n};\n\nconst venmoButtonStyleHover = {\n backgroundColor: '#0a7fc2',\n};\n\nexport default class BraintreePaypalV1ButtonStrategy implements CheckoutButtonStrategy {\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster,\n private _offerCredit: boolean = false,\n private _window: PaypalHostWindow\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreepaypal, braintreepaypalcredit, containerId, methodId } = options;\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n if (this._offerCredit && !braintreepaypalcredit) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypalcredit\" argument is not provided.`);\n }\n\n if (!this._offerCredit && !braintreepaypal) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypal\" argument is not provided.`);\n }\n\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const currency = state.cart.getCartOrThrow()?.currency.code;\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(options.methodId);\n\n const providerOptions = (this._offerCredit ? braintreepaypalcredit : braintreepaypal) || {};\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const errorCallback = (error: BraintreeError | UnsupportedBrowserError) => providerOptions?.onError?.(error);\n const venmoCheckoutCallback = (braintreeVenmoCheckout: BraintreeVenmoCheckout) => this._renderVenmoComponent(braintreeVenmoCheckout, containerId, errorCallback);\n const paypalCheckoutCallback = (braintreePaypalCheckout: BraintreePaypalCheckout) =>\n this._renderPaypalComponents(\n braintreePaypalCheckout,\n providerOptions,\n containerId,\n methodId,\n Boolean(paymentMethod.config.testMode)\n );\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getPaypalCheckout({ currency }, paypalCheckoutCallback, errorCallback);\n\n if (paymentMethod.initializationData.isBraintreeVenmoEnabled) {\n await this._braintreeSDKCreator.getVenmoCheckout(venmoCheckoutCallback, errorCallback);\n }\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderPaypalComponents(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n providerOptions: BraintreePaypalV1ButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { messagingContainerId } = providerOptions;\n\n this._renderPayPalMessages(messagingContainerId);\n this._renderPayPalButtons(braintreePaypalCheckout, providerOptions, containerId, methodId, testMode);\n }\n\n private _renderPayPalButtons(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n providerOptions: BraintreePaypalV1ButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { allowCredit, style, shippingAddress, shouldProcessPayment, onAuthorizeError, onPaymentError } = providerOptions;\n\n const { paypal } = this._window;\n\n if (paypal) {\n const fundingSources = allowCredit\n ? [paypal.FUNDING.PAYPAL, paypal.FUNDING.PAYLATER, paypal.FUNDING.CREDIT]\n : [paypal.FUNDING.PAYPAL];\n\n const commonValidButtonStyle = style ? getValidButtonStyle(style) : {};\n\n fundingSources.forEach(fundingSource => {\n const buttonStyle = fundingSource === paypal.FUNDING.CREDIT\n ? { label: PaypalButtonStyleLabelOption.CREDIT, ...commonValidButtonStyle }\n : commonValidButtonStyle;\n\n const paypalButtonRender = paypal.Buttons({\n env: testMode ? 'sandbox' : 'production',\n commit: false,\n fundingSource,\n style: buttonStyle,\n createOrder: () => this._setupPayment(braintreePaypalCheckout, shippingAddress, onPaymentError),\n onApprove: (authorizeData: PaypalAuthorizeData) =>\n this._tokenizePayment(authorizeData, braintreePaypalCheckout, methodId, shouldProcessPayment, onAuthorizeError),\n });\n\n if (paypalButtonRender.isEligible()) {\n paypalButtonRender.render(`#${containerId}`);\n }\n });\n }\n }\n\n private _renderPayPalMessages(messagingContainerId?: string): void {\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const storeConfig = state.config.getStoreConfigOrThrow();\n\n const isMessageContainerAvailable = messagingContainerId && !!document.getElementById(messagingContainerId);\n const isMessagesRenderingFeatureOn = storeConfig.checkoutSettings.features['PAYPAL-1149.braintree-new-card-below-totals-banner-placement'];\n\n const { paypal } = this._window;\n\n if (paypal && isMessagesRenderingFeatureOn && messagingContainerId && isMessageContainerAvailable) {\n const paypalMessagesRender = paypal.Messages({ amount: cart.cartAmount, placement: 'cart' });\n paypalMessagesRender.render(`#${messagingContainerId}`);\n } else {\n this._hideElement(messagingContainerId);\n }\n }\n\n private async _setupPayment(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n shippingAddress?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n try {\n const checkout = state.checkout.getCheckoutOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const customer = state.customer.getCustomer();\n\n const address = shippingAddress || customer?.addresses?.[0];\n const shippingAddressOverride = address ? mapToBraintreeShippingAddressOverride(address) : undefined;\n\n return await braintreePaypalCheckout.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride,\n amount: checkout.outstandingBalance,\n currency: config.currency.code,\n offerCredit: this._offerCredit,\n });\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private async _tokenizePayment(\n authorizeData: PaypalAuthorizeData,\n braintreePaypalCheckout: BraintreePaypalCheckout,\n methodId: string,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n try {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector({ paypal: true });\n const tokenizePayload = await braintreePaypalCheckout.tokenizePayment(authorizeData);\n const { details, nonce } = tokenizePayload;\n\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce,\n device_data: deviceData,\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n\n return tokenizePayload;\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private _renderVenmoComponent(\n braintreeVenmoCheckout: BraintreeVenmoCheckout,\n containerId: string,\n onError?: (error: BraintreeError | StandardError) => void\n ): void {\n const venmoButtonParentContainer = document.getElementById(containerId);\n\n if (!venmoButtonParentContainer) {\n throw new InvalidArgumentError('Unable to create wallet button without valid container ID.');\n }\n\n const venmoButton = document.createElement('div');\n venmoButtonParentContainer?.appendChild(venmoButton);\n venmoButton.setAttribute('aria-label', 'Venmo');\n Object.assign(venmoButton.style, venmoButtonStyle);\n\n venmoButton.addEventListener('click', () => {\n venmoButton.setAttribute('disabled', 'true');\n\n if (braintreeVenmoCheckout.tokenize) {\n braintreeVenmoCheckout.tokenize(async (error: BraintreeError, payload: BraintreeTokenizePayload) => {\n venmoButton.removeAttribute('disabled');\n\n if (error && onError) {\n return onError(error);\n }\n\n await this._handlePostForm(payload);\n });\n }\n });\n\n venmoButton.addEventListener('mouseenter', () => {\n venmoButton.style.backgroundColor = venmoButtonStyleHover.backgroundColor;\n });\n\n venmoButton.addEventListener('mouseleave', () => {\n venmoButton.style.backgroundColor = venmoButtonStyle.backgroundColor;\n });\n }\n\n private async _handlePostForm(payload: BraintreeTokenizePayload): Promise<void> {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector();\n const { nonce, details } = payload;\n\n this._formPoster.postForm('/checkout.php', {\n nonce,\n provider: CheckoutButtonMethodType.BRAINTREE_VENMO,\n payment_type: 'paypal',\n device_data: deviceData,\n action: 'set_external_checkout',\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n }\n\n private _hideElement(elementId?: string): void {\n const element = elementId && document.getElementById(elementId);\n\n if (element) {\n Object.assign(element?.style, { display: 'none' });\n }\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { Address } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, StandardError } from '../../../common/error/errors';\nimport { mapToBraintreeShippingAddressOverride, BraintreeError, BraintreePaypalCheckout, BraintreeSDKCreator, BraintreeTokenizePayload } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { BraintreePaypalButtonInitializeOptions } from './braintree-paypal-button-options';\nimport getValidButtonStyle from './get-valid-button-style';\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nexport default class BraintreePaypalButtonStrategy implements CheckoutButtonStrategy {\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster,\n private _window: PaypalHostWindow\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreepaypal, containerId, methodId } = options;\n const { messagingContainerId, onError } = braintreepaypal || {};\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n // TODO: this line should be removed with BraintreePayPalV1Button strategy\n const updatedMethodId = methodId === 'braintreepaypalv2' ? 'braintreepaypal' : methodId;\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n if (!braintreepaypal) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypal\" argument is not provided.`);\n }\n\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(updatedMethodId);\n const currency = state.cart.getCartOrThrow()?.currency.code;\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const paypalCheckoutOptions = { currency };\n const paypalCheckoutSuccessCallback = (braintreePaypalCheckout: BraintreePaypalCheckout) => {\n this._renderPayPalComponents(\n braintreePaypalCheckout,\n braintreepaypal,\n containerId,\n updatedMethodId,\n Boolean(paymentMethod.config.testMode)\n );\n };\n const paypalCheckoutErrorCallback = (error: BraintreeError) =>\n this._handleError(error, containerId, messagingContainerId, onError);\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getPaypalCheckout(\n paypalCheckoutOptions,\n paypalCheckoutSuccessCallback,\n paypalCheckoutErrorCallback\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderPayPalComponents(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypal: BraintreePaypalButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { messagingContainerId } = braintreepaypal;\n\n this._renderPayPalMessages(messagingContainerId);\n this._renderPayPalButton(braintreePaypalCheckout, braintreepaypal, containerId, methodId, testMode);\n }\n\n private _renderPayPalButton(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypal: BraintreePaypalButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { style, shippingAddress, shouldProcessPayment, onAuthorizeError, onPaymentError } = braintreepaypal;\n\n const { paypal } = this._window;\n const fundingSource = paypal?.FUNDING.PAYPAL;\n\n if (paypal && fundingSource) {\n const validButtonStyle = style ? getValidButtonStyle(style) : {};\n\n const paypalButtonRender = paypal.Buttons({\n env: testMode ? 'sandbox' : 'production',\n commit: false,\n fundingSource,\n style: validButtonStyle,\n createOrder: () => this._setupPayment(braintreePaypalCheckout, shippingAddress, onPaymentError),\n onApprove: (authorizeData: PaypalAuthorizeData) =>\n this._tokenizePayment(authorizeData, braintreePaypalCheckout, methodId, shouldProcessPayment, onAuthorizeError),\n });\n\n if (paypalButtonRender.isEligible()) {\n paypalButtonRender.render(`#${containerId}`);\n }\n } else {\n this._removeElement(containerId);\n }\n }\n\n private _renderPayPalMessages(messagingContainerId?: string): void {\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const storeConfig = state.config.getStoreConfigOrThrow();\n\n const isMessageContainerAvailable = messagingContainerId && !!document.getElementById(messagingContainerId);\n const isMessagesRenderingFeatureOn = storeConfig.checkoutSettings.features['PAYPAL-1149.braintree-new-card-below-totals-banner-placement'];\n\n const { paypal } = this._window;\n\n if (paypal && isMessagesRenderingFeatureOn && messagingContainerId && isMessageContainerAvailable) {\n const paypalMessagesRender = paypal.Messages({ amount: cart.cartAmount, placement: 'cart' });\n paypalMessagesRender.render(`#${messagingContainerId}`);\n } else {\n this._removeElement(messagingContainerId);\n }\n }\n\n private async _setupPayment(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n shippingAddress?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n try {\n const checkout = state.checkout.getCheckoutOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const customer = state.customer.getCustomer();\n\n const address = shippingAddress || customer?.addresses?.[0];\n const shippingAddressOverride = address ? mapToBraintreeShippingAddressOverride(address) : undefined;\n\n return await braintreePaypalCheckout.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride,\n amount: checkout.outstandingBalance,\n currency: config.currency.code,\n offerCredit: false,\n });\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private async _tokenizePayment(\n authorizeData: PaypalAuthorizeData,\n braintreePaypalCheckout: BraintreePaypalCheckout,\n methodId: string,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n try {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector({ paypal: true });\n const tokenizePayload = await braintreePaypalCheckout.tokenizePayment(authorizeData);\n const { details, nonce } = tokenizePayload;\n\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce,\n device_data: deviceData,\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n\n return tokenizePayload;\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private _handleError(\n error: BraintreeError,\n buttonContainerId: string,\n messagingContainerId?: string,\n onErrorCallback?: (error: BraintreeError) => void\n ): void {\n this._removeElement(buttonContainerId);\n this._removeElement(messagingContainerId);\n\n if (onErrorCallback) {\n onErrorCallback(error);\n }\n }\n\n private _removeElement(elementId?: string): void {\n const element = elementId && document.getElementById(elementId);\n\n if (element) {\n element.remove();\n }\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { Address } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, StandardError } from '../../../common/error/errors';\nimport { mapToBraintreeShippingAddressOverride, BraintreeError, BraintreePaypalCheckout, BraintreeSDKCreator, BraintreeTokenizePayload } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalButtonStyleLabelOption, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { BraintreePaypalCreditButtonInitializeOptions } from './braintree-paypal-credit-button-options';\nimport getValidButtonStyle from './get-valid-button-style';\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nexport default class BraintreePaypalCreditButtonStrategy implements CheckoutButtonStrategy {\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster,\n private _window: PaypalHostWindow\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreepaypalcredit, containerId, methodId } = options;\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n // TODO: this line should be removed when registry will contain braintreepaypalcredit only\n const updatedMethodId = methodId === 'braintreepaypalcreditv2' ? 'braintreepaypalcredit' : methodId;\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n if (!braintreepaypalcredit) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypalcredit\" argument is not provided.`);\n }\n\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(updatedMethodId);\n const currency = state.cart.getCartOrThrow()?.currency.code;\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const paypalCheckoutOptions = { currency };\n const paypalCheckoutCallback = (braintreePaypalCheckout: BraintreePaypalCheckout) =>\n this._renderPayPalButton(\n braintreePaypalCheckout,\n braintreepaypalcredit,\n containerId,\n updatedMethodId,\n Boolean(paymentMethod.config.testMode)\n );\n const paypalCheckoutErrorCallback = (error: BraintreeError) =>\n this._handleError(error, containerId, braintreepaypalcredit.onError);\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getPaypalCheckout(\n paypalCheckoutOptions,\n paypalCheckoutCallback,\n paypalCheckoutErrorCallback\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderPayPalButton(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypalcredit: BraintreePaypalCreditButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { style, shippingAddress, shouldProcessPayment, onAuthorizeError, onPaymentError } = braintreepaypalcredit;\n const { paypal } = this._window;\n\n let hasRenderedSmartButton = false;\n\n if (paypal) {\n const fundingSources = [paypal.FUNDING.PAYLATER, paypal.FUNDING.CREDIT];\n const commonButtonStyle = style ? getValidButtonStyle(style) : {};\n\n fundingSources.forEach(fundingSource => {\n const buttonStyle = fundingSource === paypal.FUNDING.CREDIT\n ? { label: PaypalButtonStyleLabelOption.CREDIT, ...commonButtonStyle }\n : commonButtonStyle;\n\n if (!hasRenderedSmartButton) {\n const paypalButtonRender = paypal.Buttons({\n env: testMode ? 'sandbox' : 'production',\n commit: false,\n fundingSource,\n style: buttonStyle,\n createOrder: () => this._setupPayment(braintreePaypalCheckout, shippingAddress, onPaymentError),\n onApprove: (authorizeData: PaypalAuthorizeData) =>\n this._tokenizePayment(authorizeData, braintreePaypalCheckout, methodId, shouldProcessPayment, onAuthorizeError),\n });\n\n if (paypalButtonRender.isEligible()) {\n paypalButtonRender.render(`#${containerId}`);\n hasRenderedSmartButton = true;\n }\n }\n });\n }\n\n if (!paypal || !hasRenderedSmartButton) {\n this._removeElement(containerId);\n }\n }\n\n private async _setupPayment(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n shippingAddress?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n try {\n const checkout = state.checkout.getCheckoutOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const customer = state.customer.getCustomer();\n\n const address = shippingAddress || customer?.addresses?.[0];\n const shippingAddressOverride = address ? mapToBraintreeShippingAddressOverride(address) : undefined;\n\n return await braintreePaypalCheckout.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride,\n amount: checkout.outstandingBalance,\n currency: config.currency.code,\n offerCredit: true,\n });\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private async _tokenizePayment(\n authorizeData: PaypalAuthorizeData,\n braintreePaypalCheckout: BraintreePaypalCheckout,\n methodId: string,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n try {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector({ paypal: true });\n const tokenizePayload = await braintreePaypalCheckout.tokenizePayment(authorizeData);\n const { details, nonce } = tokenizePayload;\n\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce,\n device_data: deviceData,\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n\n return tokenizePayload;\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private _handleError(\n error: BraintreeError,\n containerId: string,\n onErrorCallback?: (error: BraintreeError) => void\n ): void {\n this._removeElement(containerId);\n\n if (onErrorCallback) {\n onErrorCallback(error);\n }\n }\n\n private _removeElement(elementId?: string): void {\n const element = elementId && document.getElementById(elementId);\n\n if (element) {\n element.remove();\n }\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { noop } from 'lodash';\n\nimport { CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, UnsupportedBrowserError } from '../../../common/error/errors';\nimport { PaymentMethodActionCreator } from '../../../payment';\nimport { BraintreeError, BraintreeSDKCreator, BraintreeTokenizePayload, BraintreeVenmoCheckout } from '../../../payment/strategies/braintree';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\nimport { CheckoutButtonMethodType } from '../index';\n\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nconst venmoButtonStyle = {\n backgroundColor: '#3D95CE',\n backgroundPosition: '50% 50%',\n backgroundSize: '80px auto',\n backgroundImage: 'url(\"/app/assets/img/payment-providers/venmo-logo-white.svg\")',\n backgroundRepeat: 'no-repeat',\n borderRadius: '4px',\n cursor: 'pointer',\n transition: '0.2s ease',\n minHeight: '40px',\n minWidth: '150px',\n height: '100%',\n width: '100%',\n};\n\nconst venmoButtonStyleHover = {\n backgroundColor: '#0a7fc2',\n};\n\nexport default class BraintreeVenmoButtonStrategy implements CheckoutButtonStrategy {\n private _onError = noop;\n\n constructor(\n private _store: CheckoutStore,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreevenmo, containerId, methodId } = options;\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n const state = await this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId));\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(methodId);\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n this._onError = braintreevenmo?.onError || this._handleError;\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getVenmoCheckout(\n braintreeVenmoCheckout => this._handleInitializationVenmoSuccess(braintreeVenmoCheckout, containerId),\n error => this._handleInitializationVenmoError(error, containerId)\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _handleError(error: BraintreeError) {\n throw new Error(error.message);\n }\n\n private _handleInitializationVenmoSuccess(braintreeVenmoCheckout: BraintreeVenmoCheckout, parentContainerId: string): void {\n return this._renderVenmoButton(braintreeVenmoCheckout, parentContainerId);\n }\n\n private _handleInitializationVenmoError(error: BraintreeError | UnsupportedBrowserError, containerId: string): void {\n this._removeVenmoContainer(containerId);\n\n return this._onError(error);\n }\n\n private _removeVenmoContainer(containerId: string): void {\n const buttonContainer = document.getElementById(containerId);\n\n if (buttonContainer) {\n buttonContainer.remove();\n }\n }\n\n private _renderVenmoButton(braintreeVenmoCheckout: BraintreeVenmoCheckout, containerId: string): void {\n const venmoButton = document.getElementById(containerId);\n\n if (!venmoButton) {\n throw new InvalidArgumentError('Unable to create wallet button without valid container ID.');\n }\n\n venmoButton.setAttribute('aria-label', 'Venmo');\n Object.assign(venmoButton.style, venmoButtonStyle);\n\n venmoButton.addEventListener('click', () => {\n venmoButton.setAttribute('disabled', 'true');\n\n if (braintreeVenmoCheckout.tokenize) {\n braintreeVenmoCheckout.tokenize(async (error: BraintreeError, payload: BraintreeTokenizePayload) => {\n venmoButton.removeAttribute('disabled');\n\n if (error) {\n return this._onError(error);\n }\n\n await this._handlePostForm(payload);\n });\n }\n });\n\n venmoButton.addEventListener('mouseenter', () => {\n venmoButton.style.backgroundColor = venmoButtonStyleHover.backgroundColor;\n });\n\n venmoButton.addEventListener('mouseleave', () => {\n venmoButton.style.backgroundColor = venmoButtonStyle.backgroundColor;\n });\n }\n\n private async _handlePostForm(payload: BraintreeTokenizePayload): Promise<void> {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector();\n const { nonce, details } = payload;\n\n this._formPoster.postForm('/checkout.php', {\n nonce,\n provider: CheckoutButtonMethodType.BRAINTREE_VENMO,\n payment_type: 'paypal',\n device_data: deviceData,\n action: 'set_external_checkout',\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { CheckoutButtonMethodType } from '../';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { GooglePayPaymentProcessor } from '../../../payment/strategies/googlepay';\nimport { getShippableItemsCount } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { GooglePayButtonInitializeOptions } from './googlepay-button-options';\nexport default class GooglePayButtonStrategy implements CheckoutButtonStrategy {\n private _methodId?: string;\n private _walletButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _formPoster: FormPoster,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _googlePayPaymentProcessor: GooglePayPaymentProcessor\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId } = options;\n\n const googlePayOptions = this._getGooglePayOptions(options);\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" argument is not provided.');\n }\n\n this._methodId = methodId;\n\n await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n await this._googlePayPaymentProcessor.initialize(this._getMethodId());\n\n this._walletButton = this._createSignInButton(containerId, googlePayOptions);\n }\n\n deinitialize(): Promise<void> {\n if (this._walletButton && this._walletButton.parentNode) {\n this._walletButton.parentNode.removeChild(this._walletButton);\n this._walletButton = undefined;\n }\n\n return this._googlePayPaymentProcessor.deinitialize();\n }\n\n private _createSignInButton(containerId: string, buttonOptions: GooglePayButtonInitializeOptions): HTMLElement {\n const container = document.getElementById(containerId);\n const { buttonType, buttonColor } = buttonOptions;\n\n if (!container) {\n throw new InvalidArgumentError('Unable to create sign-in button without valid container ID.');\n }\n\n const googlePayButton = this._googlePayPaymentProcessor.createButton(this._handleWalletButtonClick, buttonType, buttonColor);\n\n container.appendChild(googlePayButton);\n\n return googlePayButton;\n }\n\n private _getMethodId(): string {\n if (!this._methodId) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._methodId;\n }\n\n private _getGooglePayOptions(options: CheckoutButtonInitializeOptions): GooglePayButtonInitializeOptions {\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ADYENV2 && options.googlepayadyenv2) {\n return options.googlepayadyenv2;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ADYENV3 && options.googlepayadyenv3) {\n return options.googlepayadyenv3;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_AUTHORIZENET && options.googlepayauthorizenet) {\n return options.googlepayauthorizenet;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_BRAINTREE && options.googlepaybraintree) {\n return options.googlepaybraintree;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_CHECKOUTCOM && options.googlepaycheckoutcom) {\n return options.googlepaycheckoutcom;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_CYBERSOURCEV2 && options.googlepaycybersourcev2) {\n return options.googlepaycybersourcev2;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ORBITAL && options.googlepayorbital) {\n return options.googlepayorbital;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_STRIPE && options.googlepaystripe) {\n return options.googlepaystripe;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_STRIPEUPE && options.googlepaystripeupe) {\n return options.googlepaystripeupe;\n }\n\n throw new InvalidArgumentError();\n }\n\n @bind\n private async _handleWalletButtonClick(event: Event): Promise<void> {\n event.preventDefault();\n const cart = this._store.getState().cart.getCartOrThrow();\n const hasPhysicalItems = getShippableItemsCount(cart) > 0;\n\n try {\n const paymentData = await this._googlePayPaymentProcessor.displayWallet();\n await this._googlePayPaymentProcessor.handleSuccess(paymentData);\n if (hasPhysicalItems && paymentData.shippingAddress) {\n await this._googlePayPaymentProcessor.updateShippingAddress(paymentData.shippingAddress);\n }\n await this._onPaymentSelectComplete();\n } catch (error) {\n if (error && error.message !== 'CANCELED') {\n throw error;\n }\n }\n }\n\n private _onPaymentSelectComplete(): void {\n this._formPoster.postForm('/checkout.php', {\n headers: {\n Accept: 'text/html',\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n}\n","export const supportedLocales: {[language: string]: string[]} = {es: ['es_es', 'es_mx', 'es_pe', 'es_co', 'es_ar', 'es_cl'],\n en: ['en_us', 'en_gb', 'en_ca', 'en_es', 'en_fr', 'en_ie', 'en_sg', 'en_au', 'en_nz', 'en_my', 'en_hk', 'en_th', 'en_ae', 'en_sa', 'en_qa', 'en_kw', 'en_za'],\n pt: ['pt_br'],\n zu: ['zu_za'],\n ar: ['ar_sa', 'ar_ae', 'ar_qa', 'ar_kw'],\n zh: ['zh_sg', 'zh_hk'],\n ms: ['ms_my'],\n uk: ['uk_ua'],\n sv: ['sv_se'],\n hr: ['hr_hr'],\n pl: ['pl_pl'],\n nl: ['nl_be'],\n it: ['it_it'],\n de: ['de_de'],\n fr: ['fr_fr', 'fr_ca']};\n","import { supportedLocales } from './masterpass-supported-locales';\n\nexport default function formatLocale(localeLanguage: string): string {\n const [language, country] = localeLanguage.replace('-', '_').toLowerCase().split('_');\n const formattedLocale = `${language}_${country}`;\n const countryLocales = supportedLocales[language];\n\n if (!countryLocales) {\n return 'en_us';\n }\n\n return countryLocales.indexOf(formattedLocale) > -1 ? formattedLocale : countryLocales[0];\n}\n","import { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { formatLocale, getCallbackUrl, Masterpass, MasterpassCheckoutOptions, MasterpassScriptLoader } from '../../../payment/strategies/masterpass';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class MasterpassButtonStrategy implements CheckoutButtonStrategy {\n private _masterpassClient?: Masterpass;\n private _methodId?: string;\n private _signInButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _masterpassScriptLoader: MasterpassScriptLoader,\n private _locale: string\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId } = options;\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" argument is not provided.');\n }\n\n this._methodId = methodId;\n\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const paymentMethod = state.paymentMethods.getPaymentMethod(methodId);\n\n if (!paymentMethod || !paymentMethod.initializationData.checkoutId) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const masterpassScriptLoaderParams = {\n useMasterpassSrc: paymentMethod.initializationData.isMasterpassSrcEnabled,\n language: formatLocale(this._locale),\n testMode: paymentMethod.config.testMode,\n checkoutId: paymentMethod.initializationData.checkoutId,\n };\n\n return this._masterpassScriptLoader.load(masterpassScriptLoaderParams);\n })\n .then(masterpass => {\n this._masterpassClient = masterpass;\n this._signInButton = this._createSignInButton(containerId);\n });\n }\n\n deinitialize(): Promise<void> {\n if (this._signInButton && this._signInButton.parentNode) {\n this._signInButton.removeEventListener('click', this._handleWalletButtonClick);\n this._signInButton.parentNode.removeChild(this._signInButton);\n this._signInButton = undefined;\n }\n\n return Promise.resolve();\n }\n\n private _createSignInButton(containerId: string): HTMLElement {\n const buttonContainer = document.getElementById(containerId);\n const state = this._store.getState();\n const paymentMethod = this._methodId ? state.paymentMethods.getPaymentMethod(this._methodId) : null;\n const storeConfig = state.config.getStoreConfig();\n\n if (!buttonContainer) {\n throw new Error('Need a container to place the button');\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!storeConfig) {\n throw new InvalidArgumentError('Unable to retrieve store configuration');\n }\n\n const button = document.createElement('input');\n\n button.type = 'image';\n\n if (paymentMethod.initializationData.isMasterpassSrcEnabled) {\n const subdomain = paymentMethod.config.testMode ? 'sandbox.' : '';\n const { checkoutId } = paymentMethod.initializationData;\n\n const params = [\n `locale=${formatLocale(this._locale)}`,\n `paymentmethod=master,visa,amex,discover`,\n `checkoutid=${checkoutId}`,\n ];\n\n button.src = [\n `https://${subdomain}src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg`,\n params.join('&'),\n ].join('?');\n } else {\n button.src = 'https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg';\n }\n\n buttonContainer.appendChild(button);\n\n button.addEventListener('click', this._handleWalletButtonClick);\n\n return button;\n }\n\n private _createMasterpassPayload(): MasterpassCheckoutOptions {\n const state = this._store.getState();\n const checkout = state.checkout.getCheckout();\n const paymentMethod = this._methodId ? state.paymentMethods.getPaymentMethod(this._methodId) : null;\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return {\n checkoutId: paymentMethod.initializationData.checkoutId,\n allowedCardTypes: paymentMethod.initializationData.allowedCardTypes,\n amount: checkout.cart.cartAmount.toString(),\n currency: checkout.cart.currency.code,\n cartId: checkout.cart.id,\n callbackUrl: getCallbackUrl('cart'),\n };\n }\n\n @bind\n private _handleWalletButtonClick(): void {\n if (!this._masterpassClient) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n this._masterpassClient.checkout(this._createMasterpassPayload());\n }\n}\n","export default function getCallbackUrl(origin: string): string {\n return `${window.location.origin}/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=${origin}`;\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { pick } from 'lodash';\n\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType, StandardError } from '../../../common/error/errors';\nimport { INTERNAL_USE_ONLY, SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { PaymentMethod } from '../../../payment';\nimport { PaypalActions, PaypalAuthorizeData, PaypalButtonStyleShapeOption, PaypalButtonStyleSizeOption, PaypalClientToken, PaypalScriptLoader } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class PaypalButtonStrategy implements CheckoutButtonStrategy {\n private _paymentMethod?: PaymentMethod;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _paypalScriptLoader: PaypalScriptLoader,\n private _formPoster: FormPoster,\n private _host: string = ''\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const paypalOptions = options.paypal;\n const state = this._store.getState();\n const paymentMethod = this._paymentMethod = state.paymentMethods.getPaymentMethod(options.methodId);\n\n if (!paypalOptions) {\n throw new InvalidArgumentError();\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return this._paypalScriptLoader.loadPaypal(paymentMethod.config.merchantId)\n .then(paypal => {\n if (!paymentMethod || !paymentMethod.config.merchantId) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const merchantId = paymentMethod.config.merchantId;\n const env = paymentMethod.config.testMode ? 'sandbox' : 'production';\n const clientToken: PaypalClientToken = { [env]: paypalOptions.clientId };\n\n const fundingCreditOption = paypal.FUNDING.CREDIT || 'credit';\n const allowedSources = paypalOptions.allowCredit ? [fundingCreditOption] : [];\n const disallowedSources = !paypalOptions.allowCredit ? [fundingCreditOption] : [];\n\n return paypal.Button.render({\n env,\n client: clientToken,\n commit: paypalOptions.shouldProcessPayment,\n funding: {\n allowed: allowedSources,\n disallowed: disallowedSources,\n },\n style: {\n shape: PaypalButtonStyleShapeOption.RECT,\n ...pick(paypalOptions.style, 'layout', 'color', 'label', 'shape', 'tagline', 'fundingicons'),\n size: (paymentMethod.id === 'paypalexpress' && paypalOptions.style?.size === 'small') ? PaypalButtonStyleSizeOption.RESPONSIVE : paypalOptions.style?.size,\n },\n payment: (_, actions) => this._setupPayment(merchantId, actions, paypalOptions.onPaymentError),\n onAuthorize: (data, actions) => this._tokenizePayment(data, actions, paypalOptions.shouldProcessPayment, paypalOptions.onAuthorizeError),\n }, options.containerId);\n });\n }\n\n deinitialize(): Promise<void> {\n this._paymentMethod = undefined;\n\n return Promise.resolve();\n }\n\n private _setupPayment(merchantId: string, actions?: PaypalActions, onError?: (error: StandardError) => void): Promise<string> {\n if (!actions) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const cart = state.cart.getCart();\n const cartId = cart ? cart.id : '';\n\n return actions.request.post(`${this._host}/api/storefront/payment/paypalexpress`, { merchantId, cartId }, {\n headers: {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n })\n .then(res => res.id)\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _tokenizePayment(\n data: PaypalAuthorizeData,\n actions?: PaypalActions,\n shouldProcessPayment?: boolean,\n _onError?: (error: StandardError) => void // FIXME: This parameter seems to be unused\n ): Promise<void> {\n if (!this._paymentMethod) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n if (!actions) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n if (!data.paymentID || !data.payerID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n\n const methodId = this._paymentMethod.id;\n\n return actions.payment.get(data.paymentID).then(payload => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n paymentId: data.paymentID,\n payerId: data.payerID,\n payerInfo: JSON.stringify(payload.payer.payer_info),\n });\n });\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { includes } from 'lodash';\n\nimport { Cart } from '../../../cart';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { ApproveDataOptions, ButtonsOptions, ClickDataOptions, FundingType, PaypalCommerceInitializationData, PaypalCommercePaymentProcessor, PaypalCommerceScriptParams } from '../../../payment/strategies/paypal-commerce';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class PaypalCommerceButtonStrategy implements CheckoutButtonStrategy {\n private _isCredit?: boolean;\n private _isVenmo?: boolean;\n private _isVenmoEnabled?: boolean;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _formPoster: FormPoster,\n private _paypalCommercePaymentProcessor: PaypalCommercePaymentProcessor\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n let state = this._store.getState();\n const { initializationData } = state.paymentMethods.getPaymentMethodOrThrow(options.methodId);\n\n if (!initializationData.clientId) {\n throw new InvalidArgumentError();\n }\n\n this._isVenmoEnabled = initializationData.isVenmoEnabled;\n state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const cart = state.cart.getCartOrThrow();\n const buttonParams: ButtonsOptions = {\n onApprove: data => this._tokenizePayment(data),\n onClick: data => this._handleClickButtonProvider(data),\n };\n\n if (options.paypalCommerce && options.paypalCommerce.style) {\n buttonParams.style = options.paypalCommerce.style;\n }\n\n const messagingContainer = options.paypalCommerce?.messagingContainer;\n const isMessagesAvailable = Boolean(messagingContainer && document.getElementById(messagingContainer));\n\n await this._paypalCommercePaymentProcessor.initialize(this._getParamsScript(initializationData, cart), undefined, undefined, initializationData.isVenmoEnabled);\n\n this._paypalCommercePaymentProcessor.renderButtons(cart.id, `#${options.containerId}`, buttonParams);\n\n if (isMessagesAvailable) {\n this._paypalCommercePaymentProcessor.renderMessages(cart.cartAmount, `#${messagingContainer}`);\n }\n\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n this._isCredit = undefined;\n this._isVenmo = undefined;\n\n return Promise.resolve();\n }\n\n private _handleClickButtonProvider({ fundingSource }: ClickDataOptions): void {\n this._isCredit = fundingSource === 'credit' || fundingSource === 'paylater';\n this._isVenmo = fundingSource === 'venmo';\n }\n\n private _tokenizePayment({ orderID }: ApproveDataOptions) {\n if (!orderID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n let provider;\n\n if (this._isVenmo && this._isVenmoEnabled) {\n provider = 'paypalcommercevenmo';\n } else if (this._isCredit) {\n provider = 'paypalcommercecredit';\n } else {\n provider = 'paypalcommerce';\n }\n\n return this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n action: 'set_external_checkout',\n provider,\n order_id: orderID,\n });\n }\n\n private _getParamsScript(initializationData: PaypalCommerceInitializationData, cart: Cart): PaypalCommerceScriptParams {\n const {\n clientId,\n intent,\n isPayPalCreditAvailable,\n merchantId,\n attributionId,\n availableAlternativePaymentMethods = [],\n enabledAlternativePaymentMethods = [],\n isVenmoEnabled,\n } = initializationData;\n\n const disableFunding: FundingType = [ 'card' ];\n const enableFunding: FundingType = enabledAlternativePaymentMethods.slice();\n\n /**\n * The default value is different depending on the countries,\n * therefore there's a need to add credit, paylater or APM name to enable/disable funding explicitly\n */\n availableAlternativePaymentMethods.forEach(apm => {\n if (!includes(enabledAlternativePaymentMethods, apm)) {\n disableFunding.push(apm);\n }\n });\n\n if (isPayPalCreditAvailable) {\n enableFunding.push('credit', 'paylater');\n } else {\n disableFunding.push('credit', 'paylater');\n }\n\n if (isVenmoEnabled) {\n enableFunding.push('venmo');\n } else if (!enableFunding.includes('venmo')) {\n disableFunding.push('venmo');\n }\n\n return {\n 'client-id': clientId,\n 'merchant-id': merchantId,\n commit: false,\n currency: cart.currency.code,\n components: ['buttons', 'messages'],\n 'disable-funding': disableFunding,\n ...(enableFunding.length && {'enable-funding': enableFunding}),\n intent,\n 'data-partner-attribution-id': attributionId,\n };\n }\n}\n","import { createFormPoster } from '@bigcommerce/form-poster';\nimport { createRequestSender } from '@bigcommerce/request-sender';\n\nimport { createCheckoutStore } from '../checkout';\nimport { createPaymentClient, PaymentMethodActionCreator, PaymentMethodRequestSender } from '../payment';\n\nimport CheckoutButtonInitializer from './checkout-button-initializer';\nimport CheckoutButtonInitializerOptions from './checkout-button-initializer-options';\nimport CheckoutButtonStrategyActionCreator from './checkout-button-strategy-action-creator';\nimport createCheckoutButtonRegistry from './create-checkout-button-registry';\n\n/**\n * Creates an instance of `CheckoutButtonInitializer`.\n *\n * @remarks\n * ```js\n * const initializer = createCheckoutButtonInitializer();\n *\n * initializer.initializeButton({\n * methodId: 'braintreepaypal',\n * braintreepaypal: {\n * container: '#checkoutButton',\n * },\n * });\n * ```\n *\n * @alpha\n * Please note that `CheckoutButtonInitializer` is currently in an early stage\n * of development. Therefore the API is unstable and not ready for public\n * consumption.\n *\n * @param options - A set of construction options.\n * @returns an instance of `CheckoutButtonInitializer`.\n */\nexport default function createCheckoutButtonInitializer(\n options?: CheckoutButtonInitializerOptions\n): CheckoutButtonInitializer {\n const { host, locale = 'en' } = options ?? {};\n const store = createCheckoutStore();\n const paymentClient = createPaymentClient(store);\n const requestSender = createRequestSender({ host });\n const formPoster = createFormPoster({ host });\n\n return new CheckoutButtonInitializer(\n store,\n new CheckoutButtonStrategyActionCreator(\n createCheckoutButtonRegistry(store, paymentClient, requestSender, formPoster, locale, host),\n new PaymentMethodActionCreator(new PaymentMethodRequestSender(requestSender))\n )\n );\n}\n","// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../payment/bigpay-client.d.ts\" /> \nimport { createClient as createBigpayClient } from '@bigcommerce/bigpay-client';\n\nimport { CheckoutStore } from '../checkout';\n\nexport default function createPaymentClient(store: CheckoutStore) {\n const paymentClient = createBigpayClient();\n\n store.subscribe(\n state => {\n const config = state.config.getStoreConfig();\n\n if (config) {\n paymentClient.setHost(config.paymentSettings.bigpayBaseUrl);\n }\n },\n state => state.config.getStoreConfig()\n );\n\n return paymentClient;\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { RequestSender } from '@bigcommerce/request-sender';\nimport { createScriptLoader, getScriptLoader } from '@bigcommerce/script-loader';\n\nimport { BillingAddressActionCreator, BillingAddressRequestSender } from '../billing';\nimport { CheckoutActionCreator, CheckoutRequestSender, CheckoutStore, CheckoutValidator } from '../checkout';\nimport { Registry } from '../common/registry';\nimport { ConfigActionCreator, ConfigRequestSender } from '../config';\nimport { FormFieldsActionCreator, FormFieldsRequestSender } from '../form';\nimport { OrderActionCreator, OrderRequestSender } from '../order';\nimport { PaymentActionCreator, PaymentMethodActionCreator, PaymentMethodRequestSender, PaymentRequestSender, PaymentRequestTransformer } from '../payment';\nimport { createAmazonPayV2PaymentProcessor } from '../payment/strategies/amazon-pay-v2';\nimport { ApplePaySessionFactory } from '../payment/strategies/apple-pay';\nimport { BraintreeScriptLoader, BraintreeSDKCreator } from '../payment/strategies/braintree';\nimport { createGooglePayPaymentProcessor, GooglePayAdyenV2Initializer, GooglePayAdyenV3Initializer, GooglePayAuthorizeNetInitializer, GooglePayBraintreeInitializer, GooglePayCheckoutcomInitializer, GooglePayCybersourceV2Initializer, GooglePayOrbitalInitializer, GooglePayStripeInitializer, GooglePayStripeUPEInitializer } from '../payment/strategies/googlepay';\nimport { MasterpassScriptLoader } from '../payment/strategies/masterpass';\nimport { PaypalScriptLoader } from '../payment/strategies/paypal';\nimport { createPaypalCommercePaymentProcessor } from '../payment/strategies/paypal-commerce';\nimport { RemoteCheckoutActionCreator, RemoteCheckoutRequestSender } from '../remote-checkout';\nimport { ConsignmentActionCreator, ConsignmentRequestSender } from '../shipping';\nimport { createSpamProtection, PaymentHumanVerificationHandler } from '../spam-protection';\nimport { SubscriptionsActionCreator, SubscriptionsRequestSender } from '../subscription';\n\nimport { CheckoutButtonMethodType, CheckoutButtonStrategy } from './strategies';\nimport { AmazonPayV2ButtonStrategy } from './strategies/amazon-pay-v2';\nimport { ApplePayButtonStrategy } from './strategies/apple-pay';\nimport { BraintreePaypalButtonStrategy, BraintreePaypalCreditButtonStrategy, BraintreeVenmoButtonStrategy, BraintreePaypalV1ButtonStrategy } from './strategies/braintree';\nimport { GooglePayButtonStrategy } from './strategies/googlepay';\nimport { MasterpassButtonStrategy } from './strategies/masterpass';\nimport { PaypalButtonStrategy } from './strategies/paypal';\nimport { PaypalCommerceButtonStrategy } from './strategies/paypal-commerce';\n\nexport default function createCheckoutButtonRegistry(\n store: CheckoutStore,\n paymentClient: any,\n requestSender: RequestSender,\n formPoster: FormPoster,\n locale: string,\n host?: string\n): Registry<CheckoutButtonStrategy, CheckoutButtonMethodType> {\n const registry = new Registry<CheckoutButtonStrategy, CheckoutButtonMethodType>();\n const scriptLoader = getScriptLoader();\n const checkoutActionCreator = new CheckoutActionCreator(\n new CheckoutRequestSender(requestSender),\n new ConfigActionCreator(new ConfigRequestSender(requestSender)),\n new FormFieldsActionCreator(new FormFieldsRequestSender(requestSender))\n );\n const checkoutRequestSender = new CheckoutRequestSender(requestSender);\n const paymentMethodActionCreator = new PaymentMethodActionCreator(new PaymentMethodRequestSender(requestSender));\n const remoteCheckoutRequestSender = new RemoteCheckoutRequestSender(requestSender);\n const remoteCheckoutActionCreator = new RemoteCheckoutActionCreator(remoteCheckoutRequestSender, checkoutActionCreator);\n const checkoutValidator = new CheckoutValidator(checkoutRequestSender);\n const orderActionCreator = new OrderActionCreator(new OrderRequestSender(requestSender), checkoutValidator);\n const paymentRequestSender = new PaymentRequestSender(paymentClient);\n const paymentRequestTransformer = new PaymentRequestTransformer();\n const paymentHumanVerificationHandler = new PaymentHumanVerificationHandler(createSpamProtection(createScriptLoader()));\n const paymentActionCreator = new PaymentActionCreator(paymentRequestSender, orderActionCreator, paymentRequestTransformer, paymentHumanVerificationHandler);\n const paypalCommercePaymentProcessor = createPaypalCommercePaymentProcessor(scriptLoader, requestSender, store, orderActionCreator, paymentActionCreator);\n const braintreeSdkCreator = new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader));\n\n registry.register(CheckoutButtonMethodType.APPLEPAY, () =>\n new ApplePayButtonStrategy(\n store,\n checkoutActionCreator,\n requestSender,\n paymentMethodActionCreator,\n new ConsignmentActionCreator(\n new ConsignmentRequestSender(requestSender),\n new CheckoutRequestSender(requestSender)\n ),\n new BillingAddressActionCreator(\n new BillingAddressRequestSender(requestSender),\n new SubscriptionsActionCreator(\n new SubscriptionsRequestSender(requestSender)\n )\n ),\n new PaymentActionCreator(\n new PaymentRequestSender(paymentClient),\n new OrderActionCreator(\n new OrderRequestSender(requestSender),\n new CheckoutValidator(checkoutRequestSender)\n ),\n new PaymentRequestTransformer(),\n new PaymentHumanVerificationHandler(createSpamProtection(createScriptLoader()))\n ),\n remoteCheckoutActionCreator,\n new OrderActionCreator(\n new OrderRequestSender(requestSender),\n new CheckoutValidator(checkoutRequestSender)\n ),\n new ApplePaySessionFactory()\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL, () =>\n new BraintreePaypalV1ButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n undefined,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPALV2, () =>\n new BraintreePaypalButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, () =>\n new BraintreePaypalV1ButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n true,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDITV2, () =>\n new BraintreePaypalCreditButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_VENMO, () =>\n new BraintreeVenmoButtonStrategy(\n store,\n paymentMethodActionCreator,\n braintreeSdkCreator,\n formPoster\n )\n );\n\n registry.register(CheckoutButtonMethodType.MASTERPASS, () =>\n new MasterpassButtonStrategy(\n store,\n checkoutActionCreator,\n new MasterpassScriptLoader(scriptLoader),\n locale\n ));\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ADYENV2, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAdyenV2Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ADYENV3, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAdyenV3Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_AUTHORIZENET, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAuthorizeNetInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_BRAINTREE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayBraintreeInitializer(braintreeSdkCreator)\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_CHECKOUTCOM, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayCheckoutcomInitializer(requestSender)\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_CYBERSOURCEV2, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayCybersourceV2Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ORBITAL, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayOrbitalInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_STRIPE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayStripeInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_STRIPEUPE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayStripeUPEInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.PAYPALEXPRESS, () =>\n new PaypalButtonStrategy(\n store,\n checkoutActionCreator,\n new PaypalScriptLoader(scriptLoader),\n formPoster,\n host\n )\n );\n\n registry.register(CheckoutButtonMethodType.PAYPALCOMMERCE, () =>\n new PaypalCommerceButtonStrategy(\n store,\n checkoutActionCreator,\n formPoster,\n paypalCommercePaymentProcessor\n )\n );\n\n registry.register(CheckoutButtonMethodType.AMAZON_PAY_V2, () =>\n new AmazonPayV2ButtonStrategy(\n store,\n checkoutActionCreator,\n createAmazonPayV2PaymentProcessor()\n )\n );\n\n return registry;\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { CheckoutStore } from '../../../checkout';\nimport { OrderActionCreator } from '../../../order';\nimport PaymentActionCreator from '../../payment-action-creator';\n\nimport { PaypalCommercePaymentProcessor, PaypalCommerceRequestSender, PaypalCommerceScriptLoader } from './index';\n\nexport default function createPaypalCommercePaymentProcessor(\n scriptLoader: ScriptLoader,\n requestSender: RequestSender,\n store: CheckoutStore,\n orderActionCreator: OrderActionCreator,\n paymentActionCreator: PaymentActionCreator\n) {\n const paypalScriptLoader = new PaypalCommerceScriptLoader(scriptLoader);\n const paypalCommerceRequestSender = new PaypalCommerceRequestSender(requestSender);\n\n return new PaypalCommercePaymentProcessor(\n paypalScriptLoader,\n paypalCommerceRequestSender,\n store,\n orderActionCreator,\n paymentActionCreator\n );\n}\n","import { getScriptLoader } from '@bigcommerce/script-loader';\n\nimport AmazonPayV2PaymentProcessor from './amazon-pay-v2-payment-processor';\nimport AmazonPayV2ScriptLoader from './amazon-pay-v2-script-loader';\n\nexport default function createAmazonPayV2PaymentProcessor(): AmazonPayV2PaymentProcessor {\n return new AmazonPayV2PaymentProcessor(\n new AmazonPayV2ScriptLoader(getScriptLoader())\n );\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","message","object","name","type","setPrototypeOf","__proto__","Error","captureStackTrace","stack","DEFAULT_RESPONSE","body","headers","status","response","errors","joinErrors","reduce","result","error","join","Array","isArray","_factoryMethods","this","register","detail","title","length","map","code","mapFromInternalErrorResponse","mapFromStorefrontErrorResponse","mapFromPaymentErrorResponse","factoryMethod","createError","_getType","default","_isStorefrontErrorResponseBody","_isInternalErrorResponseBody","internalType","last","split","errorResponse","storefrontErrorResponse","internalErrorResponse","CheckoutActionType","ErrorActionType","OrderActionType","SubscriptionsActionType","BillingAddressActionType","omitDeep","predicate","isPlainObject","transform","omitBy","clearErrorReducer","state","action","ClearError","isClearErrorAction","payload","isEqual","objectA","objectB","options","index","isArrayEqual","Date","getTime","isDateEqual","RegExp","toString","isRegExpEqual","filter","keyFilter","keysA","keys","keysB","isObjectEqual","replace","currentValue","newValue","undefined","objectSet","DEFAULT_STATE","statuses","billingAddressReducer","combineReducers","data","dataReducer","composeReducers","errorsReducer","statusesReducer","reducer","UpdateBillingAddressSucceeded","ContinueAsGuestSucceeded","LoadCheckoutSucceeded","LoadOrderSucceeded","billingAddress","LoadCheckoutRequested","LoadCheckoutFailed","UpdateBillingAddressRequested","UpdateBillingAddressFailed","UpdateSubscriptionsRequested","UpdateSubscriptionsSucceeded","ContinueAsGuestRequested","UpdateSubscriptionsFailed","ContinueAsGuestFailed","arrayReplace","currentArray","newArray","matchObject","b","id","sameAsCurrentCount","sameAsNewCount","countSameAsReplaced","replacedValue","newItem","currentItem","objectMerge","currentObject","newObject","CouponActionType","GiftCertificateActionType","ConsignmentActionType","CheckoutButtonActionType","cartReducer","CreateConsignmentsSucceeded","DeleteConsignmentSucceeded","UpdateConsignmentSucceeded","UpdateShippingOptionSucceeded","LoadShippingOptionsSucceeded","ApplyCouponSucceeded","RemoveCouponSucceeded","ApplyGiftCertificateSucceeded","RemoveGiftCertificateSucceeded","cart","ConfigActionType","DEFAULT_DATA_STATE","initializedContainers","DEFAULT_ERROR_STATE","DEFAULT_STATUS_STATE","checkoutButtonReducer","meta","methodId","InitializeButtonSucceeded","containerId","DeinitializeButtonSucceeded","InitializeButtonRequested","InitializeButtonFailed","DeinitializeButtonRequested","DeinitializeButtonFailed","configReducer","LoadConfigSucceeded","LoadConfigFailed","LoadConfigRequested","couponReducer","coupons","ApplyCouponRequested","ApplyCouponFailed","RemoveCouponRequested","RemoveCouponFailed","CustomerActionType","giftCertificateReducer","giftCertificates","ApplyGiftCertificateRequested","ApplyGiftCertificateFailed","RemoveGiftCertificateRequested","RemoveGiftCertificateFailed","CustomerStrategyActionType","customerReducer","customer","CreateCustomerAddressSucceeded","CreateCustomerRequested","CreateCustomerSucceeded","CreateCustomerFailed","CreateCustomerAddressRequested","CreateCustomerAddressFailed","FormFieldsActionType","customerStrategyReducer","InitializeSucceeded","isInitialized","DeinitializeSucceeded","InitializeRequested","initializeError","initializeMethodId","InitializeFailed","DeinitializeRequested","deinitializeError","deinitializeMethodId","DeinitializeFailed","SignInRequested","SignInSucceeded","signInError","signInMethodId","SignInFailed","SignOutRequested","SignOutSucceeded","signOutError","signOutMethodId","SignOutFailed","ExecutePaymentMethodCheckoutRequested","ExecutePaymentMethodCheckoutSucceeded","executePaymentMethodCheckoutError","executePaymentMethodCheckoutMethodId","ExecutePaymentMethodCheckoutFailed","WidgetInteractionStarted","WidgetInteractionFinished","widgetInteractionError","widgetInteractionMethodId","WidgetInteractionFailed","isInitializing","isDeinitializing","isSigningIn","isSigningOut","isExecutingPaymentMethodCheckout","isWidgetInteracting","CountryActionType","formFieldsReducer","LoadFormFieldsSucceeded","LoadFormFieldsFailed","LoadFormFieldsRequested","countryReducer","LoadCountriesSucceeded","LoadCountriesRequested","LoadCountriesFailed","PaymentActionType","PaymentMethodActionType","orderReducer","metaReducer","LoadOrderPaymentsSucceeded","omit","FinalizeOrderSucceeded","SubmitOrderSucceeded","callbackUrl","order","orderToken","token","payment","LoadOrderRequested","LoadOrderPaymentsRequested","LoadOrderFailed","LoadOrderPaymentsFailed","paymentReducer","SubmitPaymentSucceeded","PaymentStrategyActionType","paymentMethodReducer","LoadPaymentMethodSucceeded","array","item","defaultPredicate","pick","findIndex","pickBy","push","existingItem","mergeOrPush","gateway","LoadPaymentMethodsSucceeded","methodA","methodB","LoadPaymentMethodsRequested","LoadPaymentMethodsFailed","LoadPaymentMethodRequested","loadMethodId","loadMethodError","LoadPaymentMethodFailed","isLoadingMethod","InstrumentActionType","paymentStrategyReducer","ExecuteRequested","ExecuteSucceeded","executeError","executeMethodId","ExecuteFailed","FinalizeRequested","FinalizeSucceeded","finalizeError","finalizeMethodId","FinalizeFailed","isExecuting","isFinalizing","RemoteCheckoutActionType","instrumentReducer","LoadInstrumentsSucceeded","vaultedInstruments","DeleteInstrumentSucceeded","LoadInstrumentsRequested","DeleteInstrumentRequested","deleteError","failedInstrument","LoadInstrumentsFailed","DeleteInstrumentFailed","instrumentId","isDeleting","deletingInstrument","remoteCheckoutReducer","InitializeRemoteBillingSucceeded","billing","InitializeRemoteShippingSucceeded","shipping","LoadRemoteSettingsSucceeded","UpdateRemoteCheckout","PickupOptionActionType","updateShippingOptionError","updateError","isUpdating","isUpdatingShippingOption","consignmentReducer","consignments","SignOutCustomerSucceeded","LoadShippingOptionsRequested","LoadShippingOptionsFailed","CreateConsignmentsRequested","CreateConsignmentsFailed","UpdateConsignmentRequested","UpdateConsignmentFailed","DeleteConsignmentRequested","DeleteConsignmentFailed","UpdateShippingOptionRequested","UpdateShippingOptionFailed","objectFlatten","parent","flattened","forEach","keyString","assign","objectWithSortedKeys","sortedArray","sort","previous","current","ShippingCountryActionType","pickupOptionReducer","LoadPickupOptionsSucceeded","sortedflattenedMeta","consignmentId","searchArea","btoa","JSON","stringify","LoadPickupOptionsRequested","LoadPickupOptionsFailed","ShippingStrategyActionType","shippingCountryReducer","LoadShippingCountriesSucceeded","LoadShippingCountriesRequested","LoadShippingCountriesFailed","SignInEmailActionType","shippingStrategyReducer","UpdateAddressRequested","UpdateAddressSucceeded","updateAddressError","updateAddressMethodId","UpdateAddressFailed","SelectOptionRequested","SelectOptionSucceeded","selectOptionError","selectOptionMethodId","SelectOptionFailed","isUpdatingAddress","isSelectingOption","StoreCreditActionType","signInEmailReducer","SendSignInEmailSucceeded","SendSignInEmailRequested","SendSignInEmailFailed","storeCreditReducer","ApplyStoreCreditRequested","ApplyStoreCreditSucceeded","ApplyStoreCreditFailed","SpamProtectionActionType","subscriptionsReducer","checkoutReducer","UpdateCheckoutSucceeded","VerifyCheckoutSucceeded","orderId","UpdateCheckoutRequested","UpdateCheckoutFailed","MissingDataErrorType","subtype","MissingBillingAddress","MissingCart","MissingConsignments","MissingCheckout","MissingCustomer","MissingCheckoutConfig","MissingOrderConfig","MissingOrder","MissingOrderId","MissingPayment","MissingPaymentToken","MissingPaymentMethod","MissingShippingAddress","getErrorMessage","creator","combiner","args","pop","combinerArgs","memoize","guard","errorFactory","createFreezeProxy","target","trap","proxy","create","iteratee","getPrototypeOf","traversePrototypeOf","getOwnPropertyNames","charAt","deepFreeze","createProxy","provider","method","barclays","braintree","braintreepaypal","authorizenet","elavon","checkoutcom","sagepay","stripe","cybersource","cybersourcev2","converge","bluesnapv2","orbital","paymetric","bolt","digitalriver","moneris","cba_mpgs","normalize","address","firstName","lastName","company","address1","address2","city","stateOrProvince","countryCode","postalCode","phone","customFields","identity","createInternalCheckoutSelectorsFactory","getBillingAddress","getBillingAddressOrThrow","getUpdateError","getContinueAsGuestError","getLoadError","isContinuingAsGuest","isLoading","getState","getInitializeError","getDeinitializeError","getCoupons","getRemoveError","getApplyError","isApplying","isRemoving","getCustomer","getCustomerOrThrow","getCreateAccountError","isCreatingCustomerAccount","getCreateAddressError","isCreatingCustomerAddress","getCheckout","getShippingAddress","getShippingAddressOrThrow","getInternalPayment","getGatewayPayment","getHostedPayment","getPaymentId","getPaymentIdOrThrow","getPaymentStatus","getPaymentStatusOrThrow","getPaymentToken","getPaymentTokenOrThrow","getPaymentRedirectUrl","getPaymentRedirectUrlOrThrow","isPaymentDataRequired","isPaymentDataSubmitted","getEmail","getSendError","isSending","createBillingAddressSelector","continueAsGuestError","loadError","memoizeOne","createCartSelector","getCart","getCartOrThrow","createCartSelectorFactory","createCheckoutButtonSelector","some","find","values","createConfigSelector","getConfig","getFlashMessages","filterType","flashMessages","context","getStoreConfig","_","formState","formFields","storeConfig","getStoreConfigOrThrow","getContextConfig","getExternalSource","externalSource","getVariantIdentificationToken","variantIdentificationToken","createConfigSelectorFactory","createCountrySelector","getCountries","countries","createCountrySelectorFactory","createCouponSelector","removeCouponError","applyCouponError","isApplyingCoupon","isRemovingCoupon","createCustomerSelector","isCreating","createAddressError","isCreatingAddress","createCustomerStrategySelector","getSignInError","getSignOutError","getExecutePaymentMethodCheckoutError","getWidgetInteractionError","createCustomerStrategySelectorFactory","createGiftCertificateSelector","getGiftCertificates","removeGiftCertificateError","applyGiftCertificateError","isApplyingGiftCertificate","isRemovingGiftCertificate","createGiftCertificateSelectorFactory","createInstrumentSelector","getInstrumentsByPaymentMethod","instruments","paymentMethod","paymentMethodKey","currentMethod","getCardInstrument","cards","instrument","bigpayToken","card","isMatch","getCardInstrumentOrThrow","MissingPaymentInstrument","getInstruments","flatMap","supportedProvider","getInstrumentsMeta","getDeleteError","createInstrumentSelectorFactory","createFormSelector","getShippingAddressFields","selectedCountry","shippingAddress","field","processField","getBillingAddressFields","getCustomerAccountFields","customerAccount","country","items","label","fieldType","itemtype","processCountry","subdivisions","requiresState","required","processProvince","hasPostalCodes","Boolean","processsPostCode","createFormSelectorFactory","createPaymentMethodSelector","getPaymentMethods","paymentMethods","getPaymentMethodsMeta","getPaymentMethod","gatewayId","getPaymentMethodOrThrow","getLoadMethodError","createPaymentMethodSelectorFactory","createPaymentStrategySelector","getExecuteError","getFinalizeError","getWidgetInteractingError","createPaymentStrategySelectorFactory","createPickupOptionSelector","getPickupOptions","pickupOptions","sortedFlattenedParams","createPickupOptionSelectorFactory","createRemoteCheckoutSelector","createShippingAddressSelector","shippingConsignment","consignment","selectedPickupOption","createShippingCountrySelector","getShippingCountries","createShippingCountrySelectorFactory","createShippingStrategySelector","getUpdateAddressError","getSelectOptionError","createShippingStrategySelectorFactory","createConsignmentSelector","getConsignments","getConsignmentsOrThrow","getConsignmentById","getConsignmentByAddress","addressA","addressB","getShippingOption","selectedShippingOption","getCreateError","getLoadShippingOptionsError","loadShippingOptionsError","getUnassignedItems","assignedLineItemIds","itemIds","concat","lineItemIds","lineItems","physicalItems","indexOf","getItemAssignmentError","getUpdateShippingOptionError","isLoadingShippingOptions","isAssigningItems","createConsignmentSelectorFactory","createCheckoutSelector","getCheckoutOrThrow","getOutstandingBalance","useStoreCredit","checkout","grandTotal","storeCredit","Math","max","outstandingBalance","isExecutingSpamCheck","createCheckoutSelectorFactory","createOrderSelector","getOrder","getOrderOrThrow","getOrderMeta","payments","currentPayment","paymentId","createOrderSelectorFactory","createPaymentSelector","providerId","internalPayment","MissingPaymentId","step","MissingPaymentStatus","redirectUrl","MissingPaymentRedirectUrl","nonce","createStoreCreditSelector","applyError","createStoreCreditSelectorFactory","createSubscriptionsSelector","createSubscriptionsSelectorFactory","createSignInEmailSelector","signInEmail","sendError","checkoutButton","customerStrategies","form","paymentStrategies","remoteCheckout","shippingCountries","shippingStrategies","subscriptions","selectors","config","shouldWarnMutation","createCheckoutStore","initialState","factory","requestErrorFactory","actionTransformer","action$","from","pipe","catchError","every","createInternalCheckoutSelectors","createDataStore","stateTransformer","cacheAction","fn","Observable","shareReplay","store","isActionOptions","param","useCache","cachableActionDecorator","descriptor","memoizedMethods","WeakMap","decorateMethod","lastArg","instanceMethods","set","isApplePayWindow","window","assertApplePayWindow","_requestSender","loadPaymentMethods","observer","next","createAction","then","deviceSessionId","sessionHash","methods","filteredMethods","_filterApplePay","complete","catch","createErrorAction","loadPaymentMethod","ContentType","INTERNAL_USE_ONLY","SDK_VERSION_HEADERS","timeout","Accept","params","url","bindMethodDecorator","decoratedTarget","getOwnPropertyDescriptor","bindClassDecorator","boundMethod","bind","isTerminalCacheKeyMap","_lastId","_map","maps","_usedMaps","_options","maxSize","onExpire","noop","getKey","_resolveMap","parentMap","cacheKey","usedCount","_generateMap","slice","_removeLeastUsedMap","getUsedCount","isMatched","mapIndex","unshift","splice","terminalMap","recentlyUsedMap","_removeMap","isRootCacheKeyMap","isPrivate","selectorDecorator","resolver","memoizedMethod","cachedValue","cache","selectorMethodDecorator","_checkoutButton","getInitializeButtonError","getDeinitializeButtonError","CheckoutButtonErrorSelector","isInitializingButton","isDeinitializingButton","CheckoutButtonStatusSelector","createCheckoutButtonSelectors","_store","_buttonStrategyActionCreator","_state","subscribe","subscriber","filters","initializeButton","containerIds","test","selector","idPrefix","containers","document","querySelectorAll","container","uniqueId","setUniqueElementId","Promise","all","initialize","queueId","dispatch","deinitializeButton","deinitialize","CheckoutButtonInitializer","throwErrorAction","of","throwError","CheckoutButtonMethodType","methodMap","_registry","_paymentMethodActionCreator","empty","defer","_subscriptionActionCreator","continueAsGuest","credentials","isGuest","billingAddressRequestBody","existingBillingAddressRequestBody","merge","_createOrUpdateBillingAddress","_updateCustomerConsent","updateAddress","email","acceptsAbandonedCartEmails","acceptsMarketingNewsletter","updateSubscriptions","checkoutId","createAddress","DEFAULT_PARAMS","include","post","put","_checkoutRequestSender","_configActionCreator","_formFieldsActionCreator","loadCheckout","loadConfig","loadFormFields","loadDefaultCheckout","updateCheckout","loadCurrentCheckout","joinIncludes","includes","uniq","joinOrMergeIncludes","baseIncludes","includeDictionaryOrList","includesDictionary","deletions","on","additions","difference","mergeIncludes","cartA","cartB","_normalize","cartAmount","currency","digitalItems","itemA","itemB","productId","variantId","localeCompare","extendedSalePrice","quantity","amount","recipient","giftWrapping","updated","validate","comparator","_compareCoupons","_compareGiftCertificates","_getComparableCheckout","couponsA","couponsB","giftCertificatesA","giftCertificatesB","_factories","_instances","defaultToken","cacheToken","_getInstance","_hasFactory","_hasInstance","_configRequestSender","_formFieldsRequestSender","loadFields","_orderRequestSender","_checkoutValidator","loadOrder","loadOrderPayments","loadCurrentOrder","_getCurrentOrderId","submitOrder","SubmitOrderRequested","shouldExecuteSpamCheck","_mapToOrderRequestBody","customerMessage","checkoutVariant","switchMap","SubmitOrderFailed","finalizeOrder","FinalizeOrderRequested","FinalizeOrderFailed","cartId","paymentData","isNil","_client","submitPayment","resolve","reject","_transformResponse","initializeOffsitePayment","statusText","mapToInternalAddress","addressId","isBillingAddressLike","addressLine1","addressLine2","province","provinceCode","stateOrProvinceCode","postCode","_decimalPlaces","toInteger","round","pow","couponTypes","mapToInternalCoupon","coupon","discount","displayName","discountType","couponType","mapToInternalGiftCertificate","giftCertificate","discountedAmount","used","remainingBalance","remaining","balance","purchaseDate","mapToInternalLineItems","itemMap","decimalPlaces","idKey","amountTransformer","imageUrl","amountAfterDiscount","integerAmount","integerAmountAfterDiscount","integerUnitPrice","integerUnitPriceAfterDiscount","integerDiscount","sender","attributes","mapGiftCertificateToInternalLineItem","extendedListPrice","discountAmount","listPrice","salePrice","downloadsPageUrl","downloadPageUrl","brand","sku","categoryNames","option","addedByPromotion","mapToInternalLineItem","mapToInternalLineItemType","mapToInternalCart","promotions","notifications","sum","discountNotifications","promotion","banners","banner","placeholders","messageHtml","text","totalDiscountedAmount","certificate","appliedGiftCertificates","keyBy","shippingCostTotal","amountBeforeDiscount","shippingCostBeforeDiscount","integerAmountBeforeDiscount","lineItem","isShippingRequired","subtotal","taxSubtotal","taxTotal","taxes","handling","handlingCostTotal","mapToInternalCustomer","addresses","customerId","fullName","customerGroupName","customerGroup","format","month","year","trimmedMonth","trimmedYear","toObject","number","maxLength","creditCardType","info","lengths","unformattedValue","unformat","gaps","gapIndex","output","mapToInternalOrder","orderMeta","customerCanBeCreated","mapToInternalOrderPayment","baseAmount","socialData","mapToInternalSocialDataList","hasDigitalItems","isDownloadable","isComplete","mapToStoreCredit","orderAmount","orderAmountAsInteger","isDefaultOrderPayment","helpText","instructions","returnUrl","socialDataObject","socialMedia","description","image","link","shareText","sharingLink","channelName","channel","channelCode","mapToInternalShippingOption","isSelected","price","cost","selected","isRecommended","transitTime","_cardExpiryFormatter","_cardNumberFormatter","checkoutState","shippingOption","contextConfig","instrumentMeta","paymentMeta","internalCustomer","authToken","formattedInstrument","formattedPayload","bigpay_token","isFormattedVaultedInstrument","vaultAccessToken","additionalAction","_transformPaymentMethod","quoteMeta","request","geoCountryCode","source","storeProfile","transformWithHostedFormData","paymentMethodMeta","_transformHostedInputValues","initializationData","ccCvv","cardCodeVerification","ccNumber","cardNumberVerification","hostedFormNonce","cardCode","ccExpiry","cardExpiry","ccName","cardName","cardNumber","_paymentRequestSender","_orderActionCreator","_paymentRequestTransformer","_paymentHumanVerificationHandler","promise","shouldSaveInstrument","shouldSetAsDefaultInstrument","vault_payment_instrument","set_as_default_stored_instrument","InitializeOffsitePaymentRequested","race","InitializeOffsitePaymentSucceeded","InitializeOffsitePaymentFailed","SubmitPaymentRequested","handle","SubmitPaymentFailed","NotInitializedErrorType","CustomerNotInitialized","PaymentNotInitialized","ShippingNotInitialized","SpamProtectionNotInitialized","_amazonPayV2ScriptLoader","load","_amazonPayV2SDK","bindButton","buttonId","sessionId","changeAction","_getAmazonPayV2SDK","Pay","bindChangeAction","amazonCheckoutSessionId","createButton","renderButton","signout","AmazonPayV2Regions","AmazonPayV2CheckoutLanguage","AmazonPayV2Placement","AmazonPayV2LedgerCurrency","AmazonPayV2PayOptions","_scriptLoader","_window","amazonPayV2Region","loadScript","amazon","ApplePaySession","PAYPAL_COMPONENTS","_braintreeScriptLoader","_dataCollectors","clientToken","_clientToken","getClient","loadClient","client","authorization","getPaypal","_paypal","loadPaypal","getPaypalCheckout","onSuccess","onError","loadPaypalCheckout","paypalCheckout","paypalCheckoutConfig","paypalCheckoutCallback","braintreePaypalCheckout","paypalSdkLoadConfig","components","paypal","loadPayPalSDK","_paypalCheckout","getVenmoCheckout","_venmoCheckout","loadVenmoCheckout","venmoCheckout","venmoCheckoutConfig","allowDesktop","paymentMethodUsage","venmoCheckoutCallback","braintreeVenmoCheckout","isBrowserSupported","get3DS","_3ds","load3DS","version","getDataCollector","cached","loadDataCollector","kount","deviceData","teardown","getVisaCheckout","_visaCheckout","loadVisaCheckout","getGooglePaymentComponent","_googlePay","loadGooglePayment","createHostedFields","loadHostedFields","_teardown","mod","threeDSecure","dataCollector","visaCheckout","venmo","googlePayment","hostedFields","CheckoutIncludes","_consignmentRequestSender","unassignItemsByAddress","_consignmentHasAddress","existingConsignment","_removeLineItems","updateConsignment","deleteConsignment","assignItemsByAddress","_createOrUpdateConsignment","_addLineItems","selectShippingOption","consignmentUpdateBody","shippingOptionId","consignmentMeta","loadShippingOptions","AvailableShippingOptions","_getUpdateAddressRequestBody","createConsignments","updateShippingOption","_isUpdateConsignmentRequest","customItems","itemId","_hydrateLineItems","sharedItem","DEFAULT_INCLUDES","delete","_subscriptionsRequestSender","ButtonType","ButtonColor","BillingAddressFormat","getFirstAndLastName","nameParts","_googlePayScriptLoader","_googlePayInitializer","_billingAddressActionCreator","_consignmentActionCreator","_methodId","_configureWallet","onClick","buttonType","buttonColor","Short","Default","_googlePayClient","displayWallet","loadPaymentData","_getPaymentDataRequest","handleSuccess","parseResponse","tokenizePayload","_postForm","_updateBillingAddress","updateShippingAddress","_mapGooglePayAddressToShippingAddress","_getMethodId","hasShippingAddress","testMode","googlePay","paymentDataRequest","_getGooglePayClient","_paymentDataRequest","isReadyToPay","allowedPaymentMethods","parameters","allowedAuthMethods","allowedCardNetworks","apiVersion","apiVersionMinor","_getCardInformation","cardInformation","cardType","lastFour","google","environment","api","PaymentsClient","_mapGooglePayAddressToBillingAddress","customerEmail","paymentMethodData","locality","companyName","address3","administrativeArea","phoneNumber","postPaymentData","details","payment_type","tokenFormat","card_information","remoteBillingAddress","googlePayAddressMapped","createGooglePayPaymentProcessor","initializer","requestSender","createRequestSender","scriptLoader","getScriptLoader","_getGooglePayPaymentDataRequest","currencyCode","gatewayMerchantId","merchantName","merchantId","merchantInfo","authJwt","billingAddressRequired","billingAddressParameters","Full","phoneNumberRequired","tokenizationSpecification","transactionInfo","totalPriceStatus","totalPrice","toFixed","emailRequired","shippingAddressRequired","shippingAddressParameters","baseRequest","_getGooglePaymentDataRequest","supportedCards","paymentGatewaySpecification","_getPaymentGatewaySpecification","cardPaymentMethod","_getCardPaymentMethod","_braintreeSDKCreator","googleBraintreePaymentInstance","_googlePaymentInstance","_createGooglePayPayload","parse","tokenizationData","androidPayCards","lastTwo","binData","platformToken","googlePayBraintreePaymentDataRequest","googleMerchantName","googleMerchantId","cardRequirements","billingAddressFormat","_mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2","createPaymentDataRequest","googlePayBraintreeDataRequestV1","paymentMethodTokenizationParameters","_publishableKey","_testMode","_errorMessage","checkoutcomkey","_mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2","err","signature","protocolVersion","signedMessage","_convertToken","finalToken","cardNetwork","cardDetails","token_format","_requestCheckoutcomTokenize","token_data","checkoutcomToken","checkoutcomKey","Authorization","last4","stripeVersion","stripePublishableKey","stripeConnectedAccount","useMasterpassSrc","language","sourceUrl","masterpass","scriptSrc","async","loadPaypalCommerce","isProgressiveOnboardingAvailable","_validateParams","paypalLoadScript","CLIENT_ID","MERCHANT_ID","setupPayment","isCredit","isCheckout","isCreditCard","isAPM","isVenmo","getOrderStatus","PaymentStrategyType","StyleButtonLabel","StyleButtonLayout","StyleButtonColor","StyleButtonShape","NON_INSTANT_PAYMENT_METHODS","_paypalScriptLoader","_paypalCommerceRequestSender","_paymentActionCreator","_validateStyleParams","style","updatedStyle","color","layout","shape","height","tagline","horizontal","paramsScript","isVenmoEnabled","_gatewayId","_isVenmoEnabled","renderButtons","optionalParams","Buttons","paramsForProvider","fundingKey","onRenderButton","buttonParams","createOrder","_setupPayment","actions","_fundingSource","fundingSource","FUNDING","_paypalButtons","isEligible","_processNotEligible","render","renderFields","apmFieldsContainer","apmFieldsStyles","PaymentFields","fieldsParams","fields","_paypalFields","fieldContainerElement","querySelector","innerHTML","getOrderId","_orderId","renderMessages","cartTotal","Messages","_paypalMessages","placement","renderHostedFields","events","HostedFields","styles","paymentsSDK","_hostedFields","submitHostedFields","submit","getHostedFieldsValidationState","isValid","close","_patchNonInstantPaymentMethods","device_info","method_id","paypal_account","order_id","paymentRequestOptions","toUpperCase","PAYLATER","CREDIT","initializeBilling","methodName","initializeShipping","initializePayment","loadSettings","signOut","generateToken","trackAuthorizationEvent","forgetCheckout","_remoteCheckoutRequestSender","_checkoutActionCreator","InitializeRemoteBillingRequested","InitializeRemoteBillingFailed","InitializeRemoteShippingRequested","InitializeRemoteShippingFailed","InitializeRemotePaymentRequested","InitializeRemotePaymentSucceeded","InitializeRemotePaymentFailed","LoadRemoteSettingsRequested","LoadRemoteSettingsFailed","SignOutRemoteCustomerRequested","SignOutRemoteCustomerSucceeded","SignOutRemoteCustomerFailed","ForgetCheckoutRemoteCustomerRequested","ForgetCheckoutRemoteCustomerSucceeded","ForgetCheckoutRemoteCustomerFailed","_googleRecaptcha","errorOrId","handleWithRecaptchaSitekey","handleWithPaymentHumanVerificationRequestError","_isPaymentHumanVerificationRequest","_initialize","additional_action_required","_performRecaptcha","execute","take","human_verification_token","toPromise","recaptchaSitekey","cardingProtectionElementId","cardingProtectionElement","getElementById","parentNode","removeChild","createElement","setAttribute","appendChild","callback","MutationObserver","googleRecaptchaScriptLoader","mutationObserverFactory","_memoized","recaptcha","sitekey","event$","Subject","_widgetId","size","getResponse","reset","_event$","_recaptcha","element","retryWhen","delay","TIMEOUT","_watchRecaptchaChallengeWindow","event","iframeContainer","parentElement","visibility","observe","attributeFilter","_loadPromise","_loadScript","grecaptcha","createSpamProtection","MutationObserverFactory","getShippableItemsCount","total","_amazonPayV2PaymentProcessor","amazonpay","_createSignInButton","_walletButton","_getAmazonPayV2ButtonOptions","amazonButtonOptions","shopPath","features","checkoutLanguage","ledgerCurrency","checkoutSessionMethod","extractAmazonCheckoutSessionId","createCheckoutSession","sandbox","productType","PayOnly","PayAndShip","Cart","DefaultLabels","_remoteCheckoutActionCreator","_sessionFactory","_onAuthorizeCallback","_subTotalLabel","Subtotal","_shippingLabel","Shipping","applepay","buttonClassName","onPaymentAuthorize","_paymentMethod","_applePayButton","_createButton","addEventListener","_handleWalletButtonClick","classList","add","button","preventDefault","_getBaseRequest","applePaySession","_handleApplePayEvents","begin","storeCountryCode","storeName","merchantCapabilities","supportedNetworks","requiresShipping","requiredBillingContactFields","requiredShippingContactFields","tax","onvalidatemerchant","_onValidateMerchant","merchantSession","completeMerchantValidation","onshippingcontactselected","_handleShippingContactSelected","onshippingmethodselected","_handleShippingMethodSelected","oncancel","onpaymentauthorized","_onPaymentAuthorized","_transformContactToAddress","shippingContact","abort","selectionShippingOptionId","availableOptions","availableShippingOptions","selectedOption","unselectedOptions","shippingOptions","additionalDescription","identifier","completeShippingContactSelection","STATUS_INVALID_SHIPPING_POSTAL_ADDRESS","recommendedOption","optionId","selectedOptionId","_updateShippingOption","newShippingMethods","newTotal","newLineItems","_getUpdatedLineItems","completeShippingMethodSelection","validationURL","location","hostname","bigPayEndpoint","paymentsUrl","billingContact","apple_pay_token","payment_data","payment_method","transaction_id","transactionIdentifier","transformedBillingAddress","transformedShippingAddress","emailAddress","completePayment","STATUS_SUCCESS","STATUS_FAILURE","contact","givenName","familyName","addressLines","mapToBraintreeShippingAddressOverride","recipientName","line1","line2","PaypalButtonStyleLayoutOption","PaypalButtonStyleSizeOption","PaypalButtonStyleColorOption","PaypalButtonStyleLabelOption","PaypalButtonStyleShapeOption","getValidButtonStyle","fundingicons","validStyles","getValidHeight","mapToLegacyBillingAddress","first_name","last_name","phone_number","address_line_1","address_line_2","country_code","postal_code","mapToLegacyShippingAddress","venmoButtonStyle","backgroundColor","backgroundPosition","backgroundSize","backgroundImage","backgroundRepeat","borderRadius","cursor","transition","minHeight","minWidth","width","_formPoster","_offerCredit","braintreepaypalcredit","providerOptions","errorCallback","_renderVenmoComponent","_renderPaypalComponents","isBraintreeVenmoEnabled","messagingContainerId","_renderPayPalMessages","_renderPayPalButtons","allowCredit","shouldProcessPayment","onAuthorizeError","onPaymentError","fundingSources","PAYPAL","buttonStyle","paypalButtonRender","env","commit","onApprove","authorizeData","_tokenizePayment","isMessageContainerAvailable","isMessagesRenderingFeatureOn","checkoutSettings","_hideElement","shippingAddressOverride","createPayment","flow","enableShippingAddress","shippingAddressEditable","offerCredit","tokenizePayment","postForm","device_data","billing_address","shipping_address","venmoButtonParentContainer","venmoButton","tokenize","removeAttribute","_handlePostForm","elementId","display","updatedMethodId","paypalCheckoutOptions","paypalCheckoutSuccessCallback","_renderPayPalComponents","paypalCheckoutErrorCallback","_handleError","_renderPayPalButton","validButtonStyle","_removeElement","buttonContainerId","onErrorCallback","remove","hasRenderedSmartButton","_onError","braintreevenmo","_handleInitializationVenmoSuccess","_handleInitializationVenmoError","parentContainerId","_renderVenmoButton","_removeVenmoContainer","buttonContainer","_googlePayPaymentProcessor","googlePayOptions","_getGooglePayOptions","buttonOptions","googlePayButton","googlepayadyenv2","googlepayadyenv3","googlepayauthorizenet","googlepaybraintree","googlepaycheckoutcom","googlepaycybersourcev2","googlepayorbital","googlepaystripe","googlepaystripeupe","hasPhysicalItems","_onPaymentSelectComplete","supportedLocales","es","en","pt","zu","ar","zh","ms","uk","sv","hr","pl","nl","it","de","fr","formatLocale","localeLanguage","toLowerCase","formattedLocale","countryLocales","_masterpassScriptLoader","_locale","masterpassScriptLoaderParams","isMasterpassSrcEnabled","_masterpassClient","_signInButton","removeEventListener","subdomain","src","_createMasterpassPayload","allowedCardTypes","origin","CheckoutButtonNotInitialized","_host","paypalOptions","clientId","fundingCreditOption","allowedSources","disallowedSources","Button","funding","allowed","disallowed","RECT","RESPONSIVE","onAuthorize","res","paymentID","payerID","payerId","payerInfo","payer","payer_info","_paypalCommercePaymentProcessor","_handleClickButtonProvider","paypalCommerce","messagingContainer","isMessagesAvailable","_getParamsScript","_isCredit","_isVenmo","orderID","intent","isPayPalCreditAvailable","attributionId","availableAlternativePaymentMethods","enabledAlternativePaymentMethods","disableFunding","enableFunding","apm","createCheckoutButtonInitializer","host","locale","paymentClient","setHost","paymentSettings","bigpayBaseUrl","createPaymentClient","formPoster","createFormPoster","registry","checkoutActionCreator","checkoutRequestSender","paymentMethodActionCreator","remoteCheckoutRequestSender","remoteCheckoutActionCreator","checkoutValidator","orderActionCreator","paymentRequestSender","paymentRequestTransformer","paymentHumanVerificationHandler","createScriptLoader","paymentActionCreator","paypalCommercePaymentProcessor","paypalScriptLoader","paypalCommerceRequestSender","createPaypalCommercePaymentProcessor","braintreeSdkCreator","createCheckoutButtonRegistry"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"checkout-button.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,8FCLvD,MAAM,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ryD,SAAS,oBAA0C,WACxD,WAAI,GACA+qB,EACAynC,EACAc,EACAnB,MAIRE,EAASryD,SAAS,eAAqC,WACnD,WAAI,GACA+qB,EACAunC,EACA,IAAI,GAAuBzhB,GAC3BghB,MAGRQ,EAASryD,SAAS,sBAA4C,WAC1D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,sBAA4C,WAC1D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,2BAAiD,WAC/D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,wBAA8C,WAC5D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,GAA8BuoC,QAK9CjB,EAASryD,SAAS,0BAAgD,WAC9D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,GAAgC4lB,QAKhD0hB,EAASryD,SAAS,4BAAkD,WAChE,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,sBAA4C,WAC1D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,qBAA2C,WACzD,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,wBAA8C,WAC5D,WAAI,GACA+qB,EACAonC,EACAG,EACA7hB,GACI1lB,EACA,IAAI,QAKhBsnC,EAASryD,SAAS,kBAAwC,WACtD,WAAI,GACA+qB,EACAunC,EACA,IAAI,GAAmBzhB,GACvBshB,EACAP,MAIRS,EAASryD,SAAS,mBAAyC,WACvD,WAAI,GACA+qB,EACAunC,EACAH,EACAe,MAIRb,EAASryD,SAAS,kBAAwC,WACtD,WAAI,GACA+qB,EACAunC,EErRD,IAAI,GACP,IAAI,IAAwB,KAAAxhB,yBFyRzBuhB,EFlPCkB,CAA6BxoC,EAAO+mC,EAAenhB,EAAewhB,EAAYN,EAAQD,GACtF,IAAI,GAA2B,IAAI,GAA2BjhB,M","sources":["webpack://@bigcommerce/checkout-sdk/webpack/bootstrap","webpack://@bigcommerce/checkout-sdk/webpack/runtime/compat get default export","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/external commonjs \"@bigcommerce/request-sender\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/form-poster\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"tslib\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/data-store\"","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/request-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-invalid-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/unrecoverable-error.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"lodash\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-internal-error-response.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-payment-error-response.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/timeout-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/request-error-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/map-from-storefront-error-response.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"rxjs\"","webpack://@bigcommerce/checkout-sdk/external commonjs \"rxjs/operators\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/error-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/omit-deep.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/clear-error-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-equal.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/replace.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-set.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-plain-object.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/array-replace.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-merge.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/merge-or-push.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-flatten.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/object-with-sorted-keys.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/spam-protection-actions.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-reducer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-reducer.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/memoize\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/missing-data-error.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"reselect\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/create-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/with-memoized-combiner.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/guard.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/create-freeze-proxy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/supported-payment-instruments.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/address/is-address-equal.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-state.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-internal-checkout-selectors.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/coupon-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-address-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/signin-email/signin-email-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/geography/country-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/customer-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/gift-certificate-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/instrument/instrument-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/pickup-option-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-country-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/shipping-strategy-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-types.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-status-types.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/store-credit/store-credit-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-checkout-store.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/create-request-error-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-action-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/create-checkout-store-reducer.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/bigpay-client\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/cache-action.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/is-action-options.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/data-store/cachable-action-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/apple-pay/is-apple-pay-window.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/content-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/internal-api-headers.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/sdk-version-headers.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-method-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/invalid-argument-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/bind-decorator.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"shallowequal\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/cache-key-maps.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/cache-key-resolver.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/is-private.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/selector/selector-decorator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-error-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-status-selector.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-selectors.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/is-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/set-unique-element-id.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/throw-error-action.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/checkout-button-method-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/checkout-button-strategy-action-creator.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"@bigcommerce/script-loader\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/errors/unable-to-continue-as-guest-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/billing-address-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/join-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/join-or-merge-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/http-request/merge-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-default-includes.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/errors/checkout-not-available-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/cart-comparator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/errors/cart-changed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-validator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/registry/registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/config/config-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/form/form-fields-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/errors/order-tax-provider-unavailable-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/order-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/address/map-to-internal-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/billing/is-billing-address-like.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/utility/amount-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/map-to-internal-coupon.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/coupon/map-to-internal-gift-certificate.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-line-items.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-gift-certificate-to-internal-line-item.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-line-item.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/cart/map-to-internal-cart.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/promotion/map-to-discount-notifications.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/customer/map-to-internal-customer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/hosted-form/iframe-content/card-expiry-formatter.ts","webpack://@bigcommerce/checkout-sdk/external commonjs \"card-validator\"","webpack://@bigcommerce/checkout-sdk/./packages/core/src/hosted-form/iframe-content/card-number-formatter.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/order/map-to-internal-order.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/map-to-internal-shipping-option.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-request-transformer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/is-vaulted-instrument.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/not-initialized-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-client-unavailable-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/amazon-pay-v2-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/apple-pay/apple-pay-session-factory.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/unsupported-browser-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree-sdk-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/braintree-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout/checkout-params.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/consignment-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/errors/update-subscriptions-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/subscription/subscriptions-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/errors/remote-checkout-synchronization-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-get-first-and-last-name.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/create-googlepay-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-adyenv2-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-adyenv3-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-authorizenet-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-braintree-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-checkoutcom-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-cybersourcev2-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-orbital-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-stripe-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/googlepay/googlepay-stripe-upe-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/masterpass-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal/paypal-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/error/errors/not-implemented-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/payment-strategy-type.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-sdk.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/paypal-commerce-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-request-sender.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/remote-checkout/remote-checkout-action-creator.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-challenge-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/carding-protection-challenge-not-completed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/carding-protection-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/payment-human-verification-handler.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/common/dom/mutation-observer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-failed-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/errors/spam-protection-not-loaded-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/google-recaptcha.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/google-recaptcha-script-loader.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/spam-protection/create-spam-protection.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/getShippableItemsCount.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/shipping/getLineItemsCount.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/amazon-pay-v2/amazon-pay-v2-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/errors/payment-method-cancelled-error.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/apple-pay/apple-pay-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/braintree/map-to-braintree-shipping-address-override.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/get-valid-button-style.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/map-to-legacy-billing-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/map-to-legacy-shipping-address.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-paypal-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal/paypal-sdk.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-paypal-credit-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/braintree/braintree-venmo-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/googlepay/googlepay-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/masterpass-supported-locales.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/format-locale.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/masterpass/masterpass-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/masterpass/get-callback-url.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/paypal/paypal-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/strategies/paypal-commerce/paypal-commerce-button-strategy.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-initializer.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/create-payment-client.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/checkout-buttons/create-checkout-button-registry.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/paypal-commerce/create-paypal-commerce-payment-processor.ts","webpack://@bigcommerce/checkout-sdk/./packages/core/src/payment/strategies/amazon-pay-v2/create-amazon-pay-v2-payment-processor.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\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};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/request-sender\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/form-poster\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"tslib\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/data-store\");","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 { Response } from '@bigcommerce/request-sender';\n\nimport StandardError from './standard-error';\n\nconst DEFAULT_RESPONSE = {\n body: {},\n headers: {},\n status: 0,\n};\n\n/**\n * Throw this error if we are unable to make a request to the server. It wraps\n * any server response into a JS error object.\n */\nexport default class RequestError<TBody = any> extends StandardError {\n body: TBody | {};\n headers: { [key: string]: any };\n errors: Array<{ code: string; message?: string }>;\n status: number;\n\n constructor(\n response?: Response<TBody | {}>,\n { message, errors }: {\n message?: string;\n errors?: Array<{ code: string; message?: string }>;\n } = {}\n ) {\n const { body, headers, status } = response || DEFAULT_RESPONSE;\n\n super(message || 'An unexpected error has occurred.');\n\n this.name = 'RequestError';\n this.type = 'request';\n this.body = body;\n this.headers = headers;\n this.status = status;\n this.errors = errors || [];\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error if we are unable to successfully submit a server request\n * using a payment method because the method has invalid configuration or is in\n * an invalid state.\n */\nexport default class PaymentMethodInvalidError<T = any> extends RequestError<T> {\n constructor(response?: Response<T>) {\n super(response, { message: 'There is a problem processing your payment. Please try again later.' });\n\n this.name = 'PaymentMethodInvalidError';\n this.type = 'payment_method_invalid';\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport RequestError from './request-error';\n\n/**\n * Throw this error if there is an unexpected error and it is not possible to\n * recover from unless the shopper creates a new checkout session.\n */\nexport default class UnrecoverableError<T = any> extends RequestError {\n constructor(response: Response<T>, message?: string) {\n super(response, {\n message: message || 'An unexpected error has occurred. The checkout process cannot continue as a result.',\n });\n\n this.name = 'UnrecoverableError';\n this.type = 'unrecoverable';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"lodash\");","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromInternalErrorResponse(\n response: Response<InternalErrorResponseBody>,\n message?: string\n): RequestError {\n const { body } = response;\n const { errors = [] } = body;\n\n return new RequestError(response, {\n message: joinErrors(errors) || body.detail || body.title || message,\n errors: errors.length ?\n errors.map(message => ({ code: body.type, message })) :\n [{ code: body.type, message: body.detail || body.title }],\n });\n}\n\nfunction joinErrors(errors: string[]): string | undefined {\n return errors.reduce((result: string[], error) => {\n if (error) {\n return [...result, error];\n }\n\n return result;\n }, []).join(' ');\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { PaymentErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromPaymentErrorResponse(\n response: Response<PaymentErrorResponseBody>,\n message?: string\n): RequestError {\n const { body } = response;\n const { errors = [] } = body;\n\n return new RequestError(response, {\n message: joinErrors(errors) || message,\n errors,\n });\n}\n\nfunction joinErrors(errors: Array<{ code: string; message?: string }>): string | undefined {\n if (!Array.isArray(errors)) {\n return;\n }\n\n return errors.reduce((result: string[], error) => {\n if (error && error.message) {\n return [...result, error.message];\n }\n\n return result;\n }, []).join(' ');\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport RequestError from './request-error';\n\n/**\n * Throw this error if a request fails to complete within its required timeframe\n * because of a network issue.\n */\nexport default class TimeoutError<T = any> extends RequestError<T> {\n constructor(response?: Response<T>) {\n super(response, {\n message: 'The request has timed out or aborted.',\n });\n\n this.name = 'TimeoutError';\n this.type = 'timeout';\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\nimport { last } from 'lodash';\n\nimport ErrorResponseBody, { InternalErrorResponseBody, StorefrontErrorResponseBody } from './error-response-body';\nimport { mapFromInternalErrorResponse, mapFromPaymentErrorResponse, mapFromStorefrontErrorResponse, RequestError, TimeoutError } from './errors';\n\nexport default class RequestErrorFactory {\n private _factoryMethods: { [key: string]: ErrorFactoryMethod } = {};\n\n constructor() {\n this.register('default', (response, message) => new RequestError(response, { message }));\n this.register('internal', (response, message) => mapFromInternalErrorResponse(response, message));\n this.register('storefront', (response, message) => mapFromStorefrontErrorResponse(response, message));\n this.register('payment', (response, message) => mapFromPaymentErrorResponse(response, message));\n this.register('timeout', response => new TimeoutError(response));\n }\n\n register(type: string, factoryMethod: ErrorFactoryMethod): void {\n this._factoryMethods[type] = factoryMethod;\n }\n\n createError(response: Response<any>, message?: string): RequestError {\n const factoryMethod = this._factoryMethods[this._getType(response)] || this._factoryMethods.default;\n\n return factoryMethod(response, message);\n }\n\n private _getType(response: Response<ErrorResponseBody>): string {\n if (response.status === 0) {\n return 'timeout';\n }\n\n if (this._isStorefrontErrorResponseBody(response.body)) {\n return 'storefront';\n }\n\n if (this._isInternalErrorResponseBody(response.body)) {\n const internalType = last(response.body.type.split('/'));\n\n return internalType && this._factoryMethods[internalType] ?\n internalType :\n 'internal';\n }\n\n const error = last(response.body && response.body.errors);\n\n if (error && error.code && this._factoryMethods[error.code]) {\n return error.code;\n }\n\n return 'payment';\n }\n\n private _isStorefrontErrorResponseBody(\n errorResponse: ErrorResponseBody\n ): errorResponse is StorefrontErrorResponseBody {\n const storefrontErrorResponse = errorResponse as StorefrontErrorResponseBody;\n\n return !this._isInternalErrorResponseBody(errorResponse) &&\n typeof storefrontErrorResponse.title === 'string' &&\n typeof storefrontErrorResponse.type === 'string' &&\n typeof storefrontErrorResponse.status === 'number' &&\n typeof storefrontErrorResponse.detail === 'string';\n }\n\n private _isInternalErrorResponseBody(\n errorResponse: ErrorResponseBody\n ): errorResponse is InternalErrorResponseBody {\n const internalErrorResponse = errorResponse as InternalErrorResponseBody;\n\n return typeof internalErrorResponse.errors === 'object' &&\n typeof internalErrorResponse.title === 'string' &&\n typeof internalErrorResponse.type === 'string' &&\n typeof internalErrorResponse.status === 'number';\n }\n}\n\nexport type ErrorFactoryMethod<T = any> = (response: Response<T>, message?: string) => RequestError;\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { StorefrontErrorResponseBody } from '../error-response-body';\n\nimport RequestError from './request-error';\n\nexport default function mapFromStorefrontErrorResponse(\n response: Response<StorefrontErrorResponseBody>,\n message?: string\n): RequestError<StorefrontErrorResponseBody> {\n const { body } = response;\n\n return new RequestError(response, {\n message: message || body.detail || body.title,\n errors: [{\n code: body.code || body.type,\n message: body.detail || body.title,\n }],\n });\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rxjs\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"rxjs/operators\");","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadConfigAction } from '../config';\nimport { LoadFormFieldsAction } from '../form';\n\nimport Checkout from './checkout';\n\nexport enum CheckoutActionType {\n LoadCheckoutRequested = 'LOAD_CHECKOUT_REQUESTED',\n LoadCheckoutSucceeded = 'LOAD_CHECKOUT_SUCCEEDED',\n LoadCheckoutFailed = 'LOAD_CHECKOUT_FAILED',\n\n UpdateCheckoutRequested = 'UPDATE_CHECKOUT_REQUESTED',\n UpdateCheckoutSucceeded = 'UPDATE_CHECKOUT_SUCCEEDED',\n UpdateCheckoutFailed = 'UPDATE_CHECKOUT_FAILED',\n}\n\nexport type CheckoutAction = LoadCheckoutAction | UpdateCheckoutAction;\n\nexport type LoadCheckoutAction =\n LoadCheckoutRequestedAction |\n LoadCheckoutSucceededAction |\n LoadCheckoutFailedAction |\n LoadFormFieldsAction |\n LoadConfigAction;\n\nexport type UpdateCheckoutAction =\n UpdateCheckoutRequestedAction |\n UpdateCheckoutSucceededAction |\n UpdateCheckoutFailedAction;\n\nexport interface LoadCheckoutRequestedAction extends Action {\n type: CheckoutActionType.LoadCheckoutRequested;\n}\n\nexport interface LoadCheckoutSucceededAction extends Action<Checkout> {\n type: CheckoutActionType.LoadCheckoutSucceeded;\n}\n\nexport interface LoadCheckoutFailedAction extends Action<Error> {\n type: CheckoutActionType.LoadCheckoutFailed;\n}\n\nexport interface UpdateCheckoutRequestedAction extends Action {\n type: CheckoutActionType.UpdateCheckoutRequested;\n}\n\nexport interface UpdateCheckoutSucceededAction extends Action<Checkout> {\n type: CheckoutActionType.UpdateCheckoutSucceeded;\n}\n\nexport interface UpdateCheckoutFailedAction extends Action<Error> {\n type: CheckoutActionType.UpdateCheckoutFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum ErrorActionType {\n ClearError = 'CLEAR_ERROR',\n}\n\nexport type ErrorAction = ClearErrorAction;\n\nexport interface ClearErrorAction extends Action {\n type: ErrorActionType.ClearError;\n payload: Error;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { InternalOrderResponseData } from './internal-order-responses';\nimport Order from './order';\n\nexport enum OrderActionType {\n LoadOrderRequested = 'LOAD_ORDER_REQUESTED',\n LoadOrderSucceeded = 'LOAD_ORDER_SUCCEEDED',\n LoadOrderFailed = 'LOAD_ORDER_FAILED',\n\n LoadOrderPaymentsRequested = 'LOAD_ORDER_PAYMENTS_REQUESTED',\n LoadOrderPaymentsSucceeded = 'LOAD_ORDER_PAYMENTS_SUCCEEDED',\n LoadOrderPaymentsFailed = 'LOAD_ORDER_PAYMENTS_FAILED',\n\n SubmitOrderRequested = 'SUBMIT_ORDER_REQUESTED',\n SubmitOrderSucceeded = 'SUBMIT_ORDER_SUCCEEDED',\n SubmitOrderFailed = 'SUBMIT_ORDER_FAILED',\n\n FinalizeOrderRequested = 'FINALIZE_ORDER_REQUESTED',\n FinalizeOrderSucceeded = 'FINALIZE_ORDER_SUCCEEDED',\n FinalizeOrderFailed = 'FINALIZE_ORDER_FAILED',\n}\n\nexport type OrderAction = LoadOrderAction |\n LoadOrderPaymentsAction |\n SubmitOrderAction |\n FinalizeOrderAction;\n\nexport type LoadOrderPaymentsAction = LoadOrderPaymentsRequestedAction |\n LoadOrderPaymentsSucceededAction |\n LoadOrderPaymentsFailedAction;\n\nexport type LoadOrderAction =\n LoadOrderRequestedAction |\n LoadOrderSucceededAction |\n LoadOrderFailedAction;\n\nexport type SubmitOrderAction =\n SubmitOrderRequestedAction |\n SubmitOrderSucceededAction |\n SubmitOrderFailedAction |\n LoadOrderAction;\n\nexport type FinalizeOrderAction =\n FinalizeOrderRequestedAction |\n FinalizeOrderSucceededAction |\n FinalizeOrderFailedAction |\n LoadOrderAction;\n\nexport interface LoadOrderRequestedAction extends Action {\n type: OrderActionType.LoadOrderRequested;\n}\n\nexport interface LoadOrderSucceededAction extends Action<Order> {\n type: OrderActionType.LoadOrderSucceeded;\n}\n\nexport interface LoadOrderFailedAction extends Action<Error> {\n type: OrderActionType.LoadOrderFailed;\n}\n\nexport interface LoadOrderPaymentsRequestedAction extends Action {\n type: OrderActionType.LoadOrderPaymentsRequested;\n}\n\nexport interface LoadOrderPaymentsSucceededAction extends Action<Order> {\n type: OrderActionType.LoadOrderPaymentsSucceeded;\n}\n\nexport interface LoadOrderPaymentsFailedAction extends Action<Error> {\n type: OrderActionType.LoadOrderPaymentsFailed;\n}\n\nexport interface SubmitOrderRequestedAction extends Action {\n type: OrderActionType.SubmitOrderRequested;\n}\n\nexport interface SubmitOrderSucceededAction extends Action<InternalOrderResponseData> {\n type: OrderActionType.SubmitOrderSucceeded;\n}\n\nexport interface SubmitOrderFailedAction extends Action<Error> {\n type: OrderActionType.SubmitOrderFailed;\n}\n\nexport interface FinalizeOrderRequestedAction extends Action {\n type: OrderActionType.FinalizeOrderRequested;\n}\n\nexport interface FinalizeOrderSucceededAction extends Action<InternalOrderResponseData> {\n type: OrderActionType.FinalizeOrderSucceeded;\n}\n\nexport interface FinalizeOrderFailedAction extends Action<Error> {\n type: OrderActionType.FinalizeOrderFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Subscriptions } from './subscriptions';\n\nexport enum SubscriptionsActionType {\n UpdateSubscriptionsRequested = 'UPDATE_SUBSCRIPTIONS_REQUESTED',\n UpdateSubscriptionsSucceeded = 'UPDATE_SUBSCRIPTIONS_SUCCEEDED',\n UpdateSubscriptionsFailed = 'UPDATE_SUBSCRIPTIONS_FAILED',\n}\nexport type UpdateSubscriptionsAction =\n UpdateSubscriptionsRequestedAction |\n UpdateSubscriptionsSucceededAction |\n UpdateSubscriptionsFailedAction;\n\nexport interface UpdateSubscriptionsRequestedAction extends Action {\n type: SubscriptionsActionType.UpdateSubscriptionsRequested;\n}\n\nexport interface UpdateSubscriptionsSucceededAction extends Action<Subscriptions> {\n type: SubscriptionsActionType.UpdateSubscriptionsSucceeded;\n}\n\nexport interface UpdateSubscriptionsFailedAction extends Action<Error> {\n type: SubscriptionsActionType.UpdateSubscriptionsFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nexport enum BillingAddressActionType {\n UpdateBillingAddressRequested = 'UPDATE_BILLING_ADDRESS_REQUESTED',\n UpdateBillingAddressSucceeded = 'UPDATE_BILLING_ADDRESS_SUCCEEDED',\n UpdateBillingAddressFailed = 'UPDATE_BILLING_ADDRESS_FAILED',\n\n ContinueAsGuestRequested = 'CONTINUE_AS_GUEST_REQUESTED',\n ContinueAsGuestSucceeded = 'CONTINUE_AS_GUEST_SUCCEEDED',\n ContinueAsGuestFailed = 'CONTINUE_AS_GUEST_FAILED',\n}\n\nexport type BillingAddressAction =\n ContinueAsGuestAction |\n UpdateBillingAddressAction;\n\nexport type UpdateBillingAddressAction =\n UpdateBillingAddressRequested |\n UpdateBillingAddressSucceeded |\n UpdateBillingAddressFailed;\n\nexport type ContinueAsGuestAction =\n ContinueAsGuestRequested |\n ContinueAsGuestSucceeded |\n ContinueAsGuestFailed;\n\nexport interface UpdateBillingAddressRequested extends Action {\n type: BillingAddressActionType.UpdateBillingAddressRequested;\n}\n\nexport interface UpdateBillingAddressSucceeded extends Action<Checkout> {\n type: BillingAddressActionType.UpdateBillingAddressSucceeded;\n}\n\nexport interface UpdateBillingAddressFailed extends Action<Error> {\n type: BillingAddressActionType.UpdateBillingAddressFailed;\n}\n\nexport interface ContinueAsGuestRequested extends Action {\n type: BillingAddressActionType.ContinueAsGuestRequested;\n}\n\nexport interface ContinueAsGuestSucceeded extends Action<Checkout> {\n type: BillingAddressActionType.ContinueAsGuestSucceeded;\n}\n\nexport interface ContinueAsGuestFailed extends Action<Error> {\n type: BillingAddressActionType.ContinueAsGuestFailed;\n}\n","import { isPlainObject, omitBy, transform } from 'lodash';\n\nexport default function omitDeep(object: any, predicate: (value: any, key: string) => boolean): any {\n if (Array.isArray(object)) {\n return object.map(value => omitDeep(value, predicate));\n }\n\n if (isPlainObject(object)) {\n return transform(omitBy(object, predicate), (result, value, key) => {\n result[key] = omitDeep(value, predicate);\n }, {} as { [key: string]: any });\n }\n\n return object;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { omitDeep } from '../utility';\n\nimport { ClearErrorAction, ErrorActionType } from './error-actions';\n\nexport default function clearErrorReducer<TState extends { [key: string]: any }, TAction extends Action>(\n state: TState,\n action: TAction\n): TState | undefined {\n if (isClearErrorAction(action)) {\n return omitDeep(state, value => value === action.payload);\n }\n\n return state;\n}\n\nfunction isClearErrorAction(action: Action): action is ClearErrorAction {\n return action.type === ErrorActionType.ClearError;\n}\n","export interface CompareOptions {\n keyFilter?(key: string): boolean;\n}\n\nexport default function isEqual(objectA: any, objectB: any, options?: CompareOptions): boolean {\n if (objectA === objectB) {\n return true;\n }\n\n if (objectA && objectB && typeof objectA === 'object' && typeof objectB === 'object') {\n if (Array.isArray(objectA) && Array.isArray(objectB)) {\n return isArrayEqual(objectA, objectB, options);\n }\n\n if (Array.isArray(objectA) || Array.isArray(objectB)) {\n return false;\n }\n\n if ((objectA instanceof Date) && (objectB instanceof Date)) {\n return isDateEqual(objectA, objectB);\n }\n\n if ((objectA instanceof Date) || (objectB instanceof Date)) {\n return false;\n }\n\n if ((objectA instanceof RegExp) && (objectB instanceof RegExp)) {\n return isRegExpEqual(objectA, objectB);\n }\n\n if ((objectA instanceof RegExp) || (objectB instanceof RegExp)) {\n return false;\n }\n\n return isObjectEqual(objectA, objectB, options);\n }\n\n return objectA === objectB;\n}\n\nfunction isRegExpEqual(objectA: RegExp, objectB: RegExp): boolean {\n return objectA.toString() === objectB.toString();\n}\n\nfunction isDateEqual(objectA: Date, objectB: Date): boolean {\n return objectA.getTime() === objectB.getTime();\n}\n\nfunction isArrayEqual(objectA: any[], objectB: any[], options?: CompareOptions): boolean {\n if (objectA.length !== objectB.length) {\n return false;\n }\n\n for (let index = 0, length = objectA.length; index < length; index++) {\n if (!isEqual(objectA[index], objectB[index], options)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction isObjectEqual(\n objectA: { [key: string]: any },\n objectB: { [key: string]: any },\n options?: CompareOptions\n): boolean {\n const filter = options && options.keyFilter;\n const keysA = filter ? Object.keys(objectA).filter(filter) : Object.keys(objectA);\n const keysB = filter ? Object.keys(objectB).filter(filter) : Object.keys(objectB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n for (let index = 0, length = keysA.length; index < length; index++) {\n const key = keysA[index];\n\n if (!Object.prototype.hasOwnProperty.call(objectB, key)) {\n return false;\n }\n\n if (!isEqual(objectA[key], objectB[key], options)) {\n return false;\n }\n }\n\n return true;\n}\n","import isEqual from './is-equal';\n\n/**\n * Replace the current value with a new value if the former is different to the\n * latter.\n */\nexport default function replace<T>(currentValue: T, newValue?: T): T {\n if (newValue === undefined || isEqual(currentValue, newValue)) {\n return currentValue;\n }\n\n return newValue;\n}\n","import isEqual from './is-equal';\n\n/**\n * Set a new value to an object under a key if the new value is different to the\n * current value of the key.\n */\nexport default function objectSet<T extends { [key: string]: any }, K extends keyof T>(\n object: T | undefined,\n key: K,\n value: T[K]\n): T {\n if (object && Object.prototype.hasOwnProperty.call(object, key) && isEqual(object[key], value)) {\n return object;\n }\n\n return {\n ...object as any,\n [key]: value,\n };\n}\n","import BillingAddress from './billing-address';\n\nexport default interface BillingAddressState {\n data?: BillingAddress;\n errors: BillingAddressErrorsState;\n statuses: BillingAddressStatusesState;\n}\n\nexport interface BillingAddressErrorsState {\n loadError?: Error;\n updateError?: Error;\n continueAsGuestError?: Error;\n}\n\nexport interface BillingAddressStatusesState {\n isLoading?: boolean;\n isUpdating?: boolean;\n isContinuingAsGuest?: boolean;\n}\n\nexport const DEFAULT_STATE: BillingAddressState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet, replace } from '../common/utility';\nimport { OrderAction, OrderActionType } from '../order';\nimport { SubscriptionsActionType, UpdateSubscriptionsAction } from '../subscription';\n\nimport BillingAddress from './billing-address';\nimport { BillingAddressAction, BillingAddressActionType } from './billing-address-actions';\nimport BillingAddressState, { BillingAddressErrorsState, BillingAddressStatusesState, DEFAULT_STATE } from './billing-address-state';\n\nexport default function billingAddressReducer(\n state: BillingAddressState = DEFAULT_STATE,\n action: Action\n): BillingAddressState {\n const reducer = combineReducers<BillingAddressState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: BillingAddress | undefined,\n action: CheckoutAction | BillingAddressAction | OrderAction\n): BillingAddress | undefined {\n switch (action.type) {\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case OrderActionType.LoadOrderSucceeded:\n return replace(data, action.payload && action.payload.billingAddress);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: BillingAddressErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | BillingAddressAction | OrderAction | UpdateSubscriptionsAction\n): BillingAddressErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case BillingAddressActionType.UpdateBillingAddressRequested:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case BillingAddressActionType.UpdateBillingAddressFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n case BillingAddressActionType.ContinueAsGuestRequested:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n return objectSet(errors, 'continueAsGuestError', undefined);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case BillingAddressActionType.ContinueAsGuestFailed:\n return objectSet(errors, 'continueAsGuestError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: BillingAddressStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | BillingAddressAction | OrderAction | UpdateSubscriptionsAction\n): BillingAddressStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case BillingAddressActionType.UpdateBillingAddressRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case BillingAddressActionType.UpdateBillingAddressFailed:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n\n case BillingAddressActionType.ContinueAsGuestRequested:\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n return objectSet(statuses, 'isContinuingAsGuest', true);\n\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case BillingAddressActionType.ContinueAsGuestFailed:\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n return objectSet(statuses, 'isContinuingAsGuest', false);\n\n default:\n return statuses;\n }\n}\n","import { isPlainObject as lodashIsPlainObject } from 'lodash';\n\n// We need this wrapper because Lodash's version doesn't act as a type guard\nexport default function isPlainObject(value: any): value is object {\n return lodashIsPlainObject(value);\n}\n","import { isArray } from 'lodash';\n\nimport isPlainObject from './is-plain-object';\nimport objectMerge from './object-merge';\nimport replace from './replace';\n\nexport interface ArrayReplaceOptions {\n matchObject(objectA: any, objectB: any): boolean;\n}\n\nfunction arrayReplace<T>(currentArray: T[] | undefined, newArray: T[], options?: ArrayReplaceOptions): T[];\nfunction arrayReplace<T>(currentArray: T[], newArray?: T[], options?: ArrayReplaceOptions): undefined;\nfunction arrayReplace<T>(currentArray?: T[], newArray?: T[], options?: ArrayReplaceOptions): T[] | undefined;\nfunction arrayReplace<T>(currentArray?: T[], newArray?: T[], options?: ArrayReplaceOptions): T[] | undefined {\n const { matchObject = (a: any, b: any) => a.id !== undefined && a.id === b.id } = options || {};\n\n // Return the new array if the current array does not exist\n if (!currentArray) {\n return newArray;\n }\n\n // If the new array does not exist, or the current array is strictly equal\n // to the new array, exit early and return the current array so that the\n // object reference doesn't change\n if (!newArray || currentArray === newArray) {\n return currentArray;\n }\n\n // Otherwise, try to replace the items of the current array with the new\n // array. If the item from the two arrays are the same, keep the current\n // one. Do it recursively until all arrays are replaced.\n let sameAsCurrentCount = 0;\n let sameAsNewCount = 0;\n\n const countSameAsReplaced = <T>(replacedValue: T, currentValue: T, newValue: T): T => {\n sameAsCurrentCount += replacedValue === currentValue ? 1 : 0;\n sameAsNewCount += replacedValue === newValue ? 1 : 0;\n\n return replacedValue;\n };\n\n const result = newArray.map((newItem, index) => {\n const currentItem = currentArray && currentArray[index];\n\n if (isPlainObject(currentItem) && isPlainObject(newItem)) {\n if (matchObject(currentItem, newItem)) {\n return countSameAsReplaced(\n objectMerge(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n return countSameAsReplaced(\n replace(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n if (isArray(currentItem) && isArray(newItem)) {\n return countSameAsReplaced(\n arrayReplace(currentItem, newItem),\n currentItem,\n newItem\n );\n }\n\n return countSameAsReplaced(\n replace(currentItem, newItem),\n currentItem,\n newItem\n );\n }) as T[];\n\n // If all items in the result are identical to the current array, and the\n // current array and the new array have the same size, simply return the\n // current array instead of the result.\n if (sameAsCurrentCount === newArray.length && (currentArray && currentArray.length === newArray.length)) {\n return currentArray;\n }\n\n // If all items in the result are identical to the new array, simply return\n // the new array.\n if (sameAsNewCount === newArray.length) {\n return newArray;\n }\n\n return result;\n}\n\nexport default arrayReplace;\n","import { isArray } from 'lodash';\n\nimport arrayReplace from './array-replace';\nimport isPlainObject from './is-plain-object';\nimport objectSet from './object-set';\n\nfunction objectMerge<T extends object>(currentObject: T, newObject?: Partial<T>): T;\nfunction objectMerge<T extends object>(currentObject: T | undefined, newObject: Partial<T>): Partial<T>;\nfunction objectMerge<T extends object>(currentObject?: T, newObject?: Partial<T>): T | undefined;\nfunction objectMerge<T extends object>(currentObject?: T, newObject?: Partial<T>): T | Partial<T> | undefined {\n if (!currentObject) {\n return newObject;\n }\n\n // If the new object does not exist but the current object does, or the new\n // object is strictly equal to the current object, return the current object\n if (!newObject || currentObject === newObject) {\n return currentObject;\n }\n\n // If both objects exist, but some values might be different, perform a merge.\n // Retain values that are equal and only replace them with the new values if\n // they are different.\n return (Object.keys(newObject) as Array<keyof T>)\n .reduce((result, key) => {\n const currentValue = result[key];\n const newValue = newObject[key];\n\n if (isPlainObject(currentValue) && isPlainObject(newValue)) {\n return objectSet(result, key, objectMerge(currentValue, newValue));\n }\n\n if (isArray(currentValue) && isArray(newValue)) {\n return objectSet(result, key, arrayReplace(currentValue, newValue) as any);\n }\n\n return objectSet(result, key, newValue as any);\n }, currentObject);\n}\n\nexport default objectMerge;\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum CouponActionType {\n ApplyCouponRequested = 'APPLY_COUPON_REQUESTED',\n ApplyCouponSucceeded = 'APPLY_COUPON_SUCCEEDED',\n ApplyCouponFailed = 'APPLY_COUPON_FAILED',\n\n RemoveCouponRequested = 'REMOVE_COUPON_REQUESTED',\n RemoveCouponSucceeded = 'REMOVE_COUPON_SUCCEEDED',\n RemoveCouponFailed = 'REMOVE_COUPON_FAILED',\n}\n\nexport type CouponAction =\n ApplyCouponAction |\n RemoveCouponAction;\n\nexport type ApplyCouponAction =\n ApplyCouponRequestedAction |\n ApplyCouponSucceededAction |\n ApplyCouponFailedAction;\n\nexport type RemoveCouponAction =\n RemoveCouponRequestedAction |\n RemoveCouponSucceededAction |\n RemoveCouponFailedAction;\n\nexport interface ApplyCouponRequestedAction extends Action {\n type: CouponActionType.ApplyCouponRequested;\n}\n\nexport interface ApplyCouponSucceededAction extends Action<Checkout> {\n type: CouponActionType.ApplyCouponSucceeded;\n}\n\nexport interface ApplyCouponFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: CouponActionType.ApplyCouponFailed;\n}\n\nexport interface RemoveCouponRequestedAction extends Action {\n type: CouponActionType.RemoveCouponRequested;\n}\n\nexport interface RemoveCouponSucceededAction extends Action<Checkout> {\n type: CouponActionType.RemoveCouponSucceeded;\n}\n\nexport interface RemoveCouponFailedAction extends Action<RequestError> {\n type: CouponActionType.RemoveCouponFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum GiftCertificateActionType {\n ApplyGiftCertificateRequested = 'APPLY_GIFT_CERTIFICATE_REQUESTED',\n ApplyGiftCertificateSucceeded = 'APPLY_GIFT_CERTIFICATE_SUCCEEDED',\n ApplyGiftCertificateFailed = 'APPLY_GIFT_CERTIFICATE_FAILED',\n\n RemoveGiftCertificateRequested = 'REMOVE_GIFT_CERTIFICATE_REQUESTED',\n RemoveGiftCertificateSucceeded = 'REMOVE_GIFT_CERTIFICATE_SUCCEEDED',\n RemoveGiftCertificateFailed = 'REMOVE_GIFT_CERTIFICATE_FAILED',\n}\n\nexport type GiftCertificateAction =\n ApplyGiftCertificateAction |\n RemoveGiftCertificateAction;\n\nexport type ApplyGiftCertificateAction =\n ApplyGiftCertificateRequestedAction |\n ApplyGiftCertificateSucceededAction |\n ApplyGiftCertificateFailedAction;\n\nexport type RemoveGiftCertificateAction =\n RemoveGiftCertificateRequestedAction |\n RemoveGiftCertificateSucceededAction |\n RemoveGiftCertificateFailedAction;\n\nexport interface ApplyGiftCertificateRequestedAction extends Action {\n type: GiftCertificateActionType.ApplyGiftCertificateRequested;\n}\n\nexport interface ApplyGiftCertificateSucceededAction extends Action<Checkout> {\n type: GiftCertificateActionType.ApplyGiftCertificateSucceeded;\n}\n\nexport interface ApplyGiftCertificateFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: GiftCertificateActionType.ApplyGiftCertificateFailed;\n}\n\nexport interface RemoveGiftCertificateRequestedAction extends Action {\n type: GiftCertificateActionType.RemoveGiftCertificateRequested;\n}\n\nexport interface RemoveGiftCertificateSucceededAction extends Action<Checkout> {\n type: GiftCertificateActionType.RemoveGiftCertificateSucceeded;\n}\n\nexport interface RemoveGiftCertificateFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: GiftCertificateActionType.RemoveGiftCertificateFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nimport { ConsignmentMeta } from './consignment';\n\nexport enum ConsignmentActionType {\n CreateConsignmentsRequested = 'CREATE_CONSIGNMENTS_REQUESTED',\n CreateConsignmentsSucceeded = 'CREATE_CONSIGNMENTS_SUCCEEDED',\n CreateConsignmentsFailed = 'CREATE_CONSIGNMENTS_FAILED',\n\n UpdateConsignmentRequested = 'UPDATE_CONSIGNMENT_REQUESTED',\n UpdateConsignmentSucceeded = 'UPDATE_CONSIGNMENT_SUCCEEDED',\n UpdateConsignmentFailed = 'UPDATE_CONSIGNMENT_FAILED',\n\n DeleteConsignmentRequested = 'DELETE_CONSIGNMENT_REQUESTED',\n DeleteConsignmentSucceeded = 'DELETE_CONSIGNMENT_SUCCEEDED',\n DeleteConsignmentFailed = 'DELETE_CONSIGNMENT_FAILED',\n\n UpdateShippingOptionRequested = 'UPDATE_SHIPPING_OPTION_REQUESTED',\n UpdateShippingOptionSucceeded = 'UPDATE_SHIPPING_OPTION_SUCCEEDED',\n UpdateShippingOptionFailed = 'UPDATE_SHIPPING_OPTION_FAILED',\n\n LoadShippingOptionsRequested = 'LOAD_SHIPPING_OPTIONS_REQUESTED',\n LoadShippingOptionsSucceeded = 'LOAD_SHIPPING_OPTIONS_SUCCEEDED',\n LoadShippingOptionsFailed = 'LOAD_SHIPPING_OPTIONS_FAILED',\n}\n\nexport type ConsignmentAction =\n CreateConsignmentsAction |\n UpdateConsignmentAction |\n DeleteConsignmentAction |\n UpdateShippingOptionAction |\n LoadShippingOptionsAction;\n\nexport type CreateConsignmentsAction =\n CreateConsignmentsRequestedAction |\n CreateConsignmentsSucceededAction |\n CreateConsignmentsFailedAction;\n\nexport type UpdateConsignmentAction =\n UpdateConsignmentRequestedAction |\n UpdateConsignmentSucceededAction |\n UpdateConsignmentFailedAction;\n\nexport type DeleteConsignmentAction =\n DeleteConsignmentRequestedAction |\n DeleteConsignmentSucceededAction |\n DeleteConsignmentFailedAction;\n\nexport type UpdateShippingOptionAction =\n UpdateShippingOptionRequestedAction |\n UpdateShippingOptionSucceededAction |\n UpdateShippingOptionFailedAction;\n\nexport type LoadShippingOptionsAction =\n LoadShippingOptionsRequestedAction |\n LoadShippingOptionsSucceededAction |\n LoadShippingOptionsFailedAction;\n\nexport interface CreateConsignmentsRequestedAction extends Action {\n type: ConsignmentActionType.CreateConsignmentsRequested;\n}\n\nexport interface CreateConsignmentsSucceededAction extends Action<Checkout> {\n type: ConsignmentActionType.CreateConsignmentsSucceeded;\n}\n\nexport interface CreateConsignmentsFailedAction extends Action<Error> {\n type: ConsignmentActionType.CreateConsignmentsFailed;\n}\n\nexport interface UpdateConsignmentRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentRequested;\n}\n\nexport interface UpdateConsignmentSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentSucceeded;\n}\n\nexport interface UpdateConsignmentFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateConsignmentFailed;\n}\n\nexport interface DeleteConsignmentRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentRequested;\n}\n\nexport interface DeleteConsignmentSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentSucceeded;\n}\n\nexport interface DeleteConsignmentFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.DeleteConsignmentFailed;\n}\n\nexport interface UpdateShippingOptionRequestedAction extends Action<null, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionRequested;\n}\n\nexport interface UpdateShippingOptionSucceededAction extends Action<Checkout, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionSucceeded;\n}\n\nexport interface UpdateShippingOptionFailedAction extends Action<Error, ConsignmentMeta> {\n type: ConsignmentActionType.UpdateShippingOptionFailed;\n}\n\nexport interface LoadShippingOptionsRequestedAction extends Action {\n type: ConsignmentActionType.LoadShippingOptionsRequested;\n}\n\nexport interface LoadShippingOptionsSucceededAction extends Action<Checkout> {\n type: ConsignmentActionType.LoadShippingOptionsSucceeded;\n}\n\nexport interface LoadShippingOptionsFailedAction extends Action<Error> {\n type: ConsignmentActionType.LoadShippingOptionsFailed;\n}\n","import Cart from './cart';\n\nexport default interface CartState {\n data?: Cart;\n errors: CartErrorsState;\n statuses: CartStatusesState;\n}\n\nexport interface CartErrorsState {\n loadError?: Error;\n}\n\nexport interface CartStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: CartState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadPaymentMethodAction } from '../payment';\n\nimport { CheckoutButtonMethodType } from './strategies';\n\nexport enum CheckoutButtonActionType {\n InitializeButtonFailed = 'INITIALIZE_BUTTON_FAILED',\n InitializeButtonRequested = 'INITIALIZE_BUTTON_REQUESTED',\n InitializeButtonSucceeded = 'INITIALIZE_BUTTON_SUCCEEDED',\n\n DeinitializeButtonFailed = 'DEINITIALIZE_BUTTON_FAILED',\n DeinitializeButtonRequested = 'DEINITIALIZE_BUTTON_REQUESTED',\n DeinitializeButtonSucceeded = 'DEINITIALIZE_BUTTON_SUCCEEDED',\n}\n\nexport type CheckoutButtonAction = InitializeButtonAction | DeinitializeButtonAction;\n\nexport type InitializeButtonAction =\n InitializeButtonRequestedAction |\n InitializeButtonSucceededAction |\n InitializeButtonFailedAction |\n LoadPaymentMethodAction;\n\nexport type DeinitializeButtonAction =\n DeinitializeButtonRequestedAction |\n DeinitializeButtonSucceededAction |\n DeinitializeButtonFailedAction;\n\nexport interface CheckoutButtonActionMeta {\n methodId: CheckoutButtonMethodType;\n}\n\nexport interface InitializeButtonActionMeta extends CheckoutButtonActionMeta {\n containerId: string;\n}\n\nexport interface InitializeButtonRequestedAction extends Action<undefined, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonRequested;\n}\n\nexport interface InitializeButtonSucceededAction extends Action<undefined, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonSucceeded;\n}\n\nexport interface InitializeButtonFailedAction extends Action<Error, InitializeButtonActionMeta> {\n type: CheckoutButtonActionType.InitializeButtonFailed;\n}\n\nexport interface DeinitializeButtonRequestedAction extends Action<undefined, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonRequested;\n}\n\nexport interface DeinitializeButtonSucceededAction extends Action<undefined, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonSucceeded;\n}\n\nexport interface DeinitializeButtonFailedAction extends Action<Error, CheckoutButtonActionMeta> {\n type: CheckoutButtonActionType.DeinitializeButtonFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { BillingAddressAction, BillingAddressActionType } from '../billing';\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType, GiftCertificateAction, GiftCertificateActionType } from '../coupon';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport Cart from './cart';\nimport CartState, { CartErrorsState, CartStatusesState, DEFAULT_STATE } from './cart-state';\n\nexport default function cartReducer(\n state: CartState = DEFAULT_STATE,\n action: Action\n): CartState {\n const reducer = combineReducers<CartState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Cart | undefined,\n action: BillingAddressAction | CheckoutAction | ConsignmentAction | CouponAction | GiftCertificateAction\n): Cart | undefined {\n switch (action.type) {\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return objectMerge(data, action.payload && action.payload.cart);\n\n default:\n return data;\n }\n}\n\nfunction statusesReducer(\n statuses: CartStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction\n): CartStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n\nfunction errorsReducer(\n errors: CartErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction\n): CartErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n","import { CheckoutButtonMethodType } from './strategies';\n\nexport default interface CheckoutButtonState {\n data: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonDataState | undefined\n };\n errors: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonErrorsState | undefined\n };\n statuses: {\n [key in CheckoutButtonMethodType]?: CheckoutButtonStatusesState | undefined\n };\n}\n\nexport interface CheckoutButtonDataState {\n initializedContainers: {\n [key: string]: boolean;\n };\n}\n\nexport interface CheckoutButtonErrorsState {\n initializeError?: Error;\n deinitializeError?: Error;\n}\n\nexport interface CheckoutButtonStatusesState {\n isInitializing?: boolean;\n isDeinitializing?: boolean;\n}\n\nexport const DEFAULT_STATE: CheckoutButtonState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport Config from './config';\n\nexport enum ConfigActionType {\n LoadConfigRequested = 'LOAD_CONFIG_REQUESTED',\n LoadConfigSucceeded = 'LOAD_CONFIG_SUCCEEDED',\n LoadConfigFailed = 'LOAD_CONFIG_FAILED',\n}\n\nexport type LoadConfigAction =\n LoadConfigRequestedAction |\n LoadConfigSucceededAction |\n LoadConfigFailedAction;\n\nexport interface LoadConfigRequestedAction extends Action {\n type: ConfigActionType.LoadConfigRequested;\n}\n\nexport interface LoadConfigSucceededAction extends Action<Config> {\n type: ConfigActionType.LoadConfigSucceeded;\n}\n\nexport interface LoadConfigFailedAction extends Action<Error> {\n type: ConfigActionType.LoadConfigFailed;\n}\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { CheckoutButtonAction, CheckoutButtonActionType } from './checkout-button-actions';\nimport CheckoutButtonState, { CheckoutButtonDataState, CheckoutButtonErrorsState, CheckoutButtonStatusesState, DEFAULT_STATE } from './checkout-button-state';\n\nconst DEFAULT_DATA_STATE: CheckoutButtonDataState = { initializedContainers: {} };\nconst DEFAULT_ERROR_STATE: CheckoutButtonErrorsState = {};\nconst DEFAULT_STATUS_STATE: CheckoutButtonStatusesState = {};\n\nexport default function checkoutButtonReducer(\n state: CheckoutButtonState = DEFAULT_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonState {\n if (!action.meta || !action.meta.methodId) {\n return state;\n }\n\n const reducer = combineReducers<CheckoutButtonState>({\n data: combineReducers({\n [action.meta.methodId]: dataReducer,\n }),\n errors: combineReducers({\n [action.meta.methodId]: errorsReducer,\n }),\n statuses: combineReducers({\n [action.meta.methodId]: statusesReducer,\n }),\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CheckoutButtonDataState = DEFAULT_DATA_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonDataState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n if (!action.meta || !action.meta.containerId) {\n return data;\n }\n\n return objectMerge(data, {\n initializedContainers: {\n [action.meta.containerId]: true,\n },\n });\n\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(data, 'initializedContainers', {});\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: CheckoutButtonErrorsState = DEFAULT_ERROR_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonErrorsState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonRequested:\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n return objectSet(errors, 'initializeError', undefined);\n\n case CheckoutButtonActionType.InitializeButtonFailed:\n return objectSet(errors, 'initializeError', action.payload);\n\n case CheckoutButtonActionType.DeinitializeButtonRequested:\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(errors, 'deinitializeError', undefined);\n\n case CheckoutButtonActionType.DeinitializeButtonFailed:\n return objectSet(errors, 'deinitializeError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CheckoutButtonStatusesState = DEFAULT_STATUS_STATE,\n action: CheckoutButtonAction\n): CheckoutButtonStatusesState {\n switch (action.type) {\n case CheckoutButtonActionType.InitializeButtonRequested:\n return objectSet(statuses, 'isInitializing', true);\n\n case CheckoutButtonActionType.InitializeButtonFailed:\n case CheckoutButtonActionType.InitializeButtonSucceeded:\n return objectSet(statuses, 'isInitializing', false);\n\n case CheckoutButtonActionType.DeinitializeButtonRequested:\n return objectSet(statuses, 'isDeinitializing', true);\n\n case CheckoutButtonActionType.DeinitializeButtonFailed:\n case CheckoutButtonActionType.DeinitializeButtonSucceeded:\n return objectSet(statuses, 'isDeinitializing', false);\n\n default:\n return statuses;\n }\n}\n","import Config from './config';\n\nexport default interface ConfigState {\n data?: Config;\n meta?: ConfigMetaState;\n errors: ConfigErrorsState;\n statuses: ConfigStatusesState;\n}\n\nexport interface ConfigMetaState {\n externalSource?: string;\n variantIdentificationToken?: string;\n}\n\nexport interface ConfigErrorsState {\n loadError?: Error;\n}\n\nexport interface ConfigStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: ConfigState = {\n meta: {},\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport Config from './config';\nimport { ConfigActionType, LoadConfigAction } from './config-actions';\nimport ConfigState, { ConfigErrorsState, ConfigStatusesState, DEFAULT_STATE } from './config-state';\n\nexport default function configReducer(\n state: ConfigState = DEFAULT_STATE,\n action: Action\n): ConfigState {\n const reducer = combineReducers<ConfigState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Config | undefined,\n action: LoadConfigAction\n): Config | undefined {\n switch (action.type) {\n case ConfigActionType.LoadConfigSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ConfigErrorsState = DEFAULT_STATE.errors,\n action: LoadConfigAction\n): ConfigErrorsState {\n switch (action.type) {\n case ConfigActionType.LoadConfigSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case ConfigActionType.LoadConfigFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ConfigStatusesState = DEFAULT_STATE.statuses,\n action: LoadConfigAction\n): ConfigStatusesState {\n switch (action.type) {\n case ConfigActionType.LoadConfigRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ConfigActionType.LoadConfigSucceeded:\n case ConfigActionType.LoadConfigFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nimport Coupon from './coupon';\n\nexport default interface CouponState {\n data?: Coupon[];\n errors: CouponErrorsState;\n statuses: CouponStatusesState;\n}\n\nexport interface CouponErrorsState {\n applyCouponError?: RequestError<StorefrontErrorResponseBody>;\n removeCouponError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface CouponStatusesState {\n isApplyingCoupon?: boolean;\n isRemovingCoupon?: boolean;\n}\n\nexport const DEFAULT_STATE: CouponState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { OrderAction, OrderActionType } from '../order';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport Coupon from './coupon';\nimport { CouponAction, CouponActionType } from './coupon-actions';\nimport CouponState, { CouponErrorsState, CouponStatusesState, DEFAULT_STATE } from './coupon-state';\n\nexport default function couponReducer(\n state: CouponState = DEFAULT_STATE,\n action: Action\n): CouponState {\n const reducer = combineReducers<CouponState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Coupon[] | undefined,\n action: CouponAction | CheckoutAction | OrderAction | ConsignmentAction\n): Coupon[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case OrderActionType.LoadOrderSucceeded:\n return arrayReplace(data, action.payload && action.payload.coupons);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CouponErrorsState = {},\n action: CouponAction\n): CouponErrorsState {\n switch (action.type) {\n case CouponActionType.ApplyCouponRequested:\n case CouponActionType.ApplyCouponSucceeded:\n return objectSet(errors, 'applyCouponError', undefined);\n\n case CouponActionType.ApplyCouponFailed:\n return objectSet(errors, 'applyCouponError', action.payload);\n\n case CouponActionType.RemoveCouponRequested:\n case CouponActionType.RemoveCouponSucceeded:\n return objectSet(errors, 'removeCouponError', undefined);\n\n case CouponActionType.RemoveCouponFailed:\n return objectSet(errors, 'removeCouponError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CouponStatusesState = {},\n action: CouponAction\n): CouponStatusesState {\n switch (action.type) {\n case CouponActionType.ApplyCouponRequested:\n return objectSet(statuses, 'isApplyingCoupon', true);\n\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.ApplyCouponFailed:\n return objectSet(statuses, 'isApplyingCoupon', false);\n\n case CouponActionType.RemoveCouponRequested:\n return objectSet(statuses, 'isRemovingCoupon', true);\n\n case CouponActionType.RemoveCouponSucceeded:\n case CouponActionType.RemoveCouponFailed:\n return objectSet(statuses, 'isRemovingCoupon', false);\n\n default:\n return statuses;\n }\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nimport GiftCertificate from './gift-certificate';\n\nexport default interface GiftCertificateState {\n data?: GiftCertificate[];\n errors: GiftCertificateErrorsState;\n statuses: GiftCertificateStatusesState;\n}\n\nexport interface GiftCertificateErrorsState {\n applyGiftCertificateError?: RequestError<StorefrontErrorResponseBody>;\n removeGiftCertificateError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface GiftCertificateStatusesState {\n isApplyingGiftCertificate?: boolean;\n isRemovingGiftCertificate?: boolean;\n}\n\nexport const DEFAULT_STATE: GiftCertificateState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadCheckoutAction } from '../checkout';\nimport { SpamProtectionAction } from '../spam-protection';\n\nimport Customer from './customer';\nimport { InternalCustomerResponseData } from './internal-customer-responses';\n\nexport enum CustomerActionType {\n SignInCustomerRequested = 'SIGN_IN_CUSTOMER_REQUESTED',\n SignInCustomerSucceeded = 'SIGN_IN_CUSTOMER_SUCCEEDED',\n SignInCustomerFailed = 'SIGN_IN_CUSTOMER_FAILED',\n\n SignOutCustomerRequested = 'SIGN_OUT_CUSTOMER_REQUESTED',\n SignOutCustomerSucceeded = 'SIGN_OUT_CUSTOMER_SUCCEEDED',\n SignOutCustomerFailed = 'SIGN_OUT_CUSTOMER_FAILED',\n\n CreateCustomerRequested = 'CREATE_CUSTOMER_REQUESTED',\n CreateCustomerSucceeded = 'CREATE_CUSTOMER_SUCCEEDED',\n CreateCustomerFailed = 'CREATE_CUSTOMER_FAILED',\n\n CreateCustomerAddressRequested = 'CREATE_CUSTOMER_ADDRESS_REQUESTED',\n CreateCustomerAddressSucceeded = 'CREATE_CUSTOMER_ADDRESS_SUCCEEDED',\n CreateCustomerAddressFailed = 'CREATE_CUSTOMER_ADDRESS_FAILED',\n}\n\nexport type CustomerAction =\n SignInCustomerAction |\n SignOutCustomerAction |\n CreateCustomerAddressAction |\n CreateCustomerAction;\n\nexport type CreateCustomerAction =\n CreateCustomerRequestedAction |\n CreateCustomerSucceededAction |\n CreateCustomerFailedAction |\n SpamProtectionAction |\n LoadCheckoutAction;\n\nexport type CreateCustomerAddressAction =\n CreateCustomerAddressRequestedAction |\n CreateCustomerAddressSucceededAction |\n CreateCustomerAddressFailedAction |\n LoadCheckoutAction;\n\nexport type SignInCustomerAction =\n SignInCustomerRequestedAction |\n SignInCustomerSucceededAction |\n SignInCustomerFailedAction |\n LoadCheckoutAction;\n\nexport type SignOutCustomerAction =\n SignOutCustomerRequestedAction |\n SignOutCustomerSucceededAction |\n SignOutCustomerFailedAction |\n LoadCheckoutAction;\n\nexport interface SignInCustomerRequestedAction extends Action {\n type: CustomerActionType.SignInCustomerRequested;\n}\n\nexport interface SignInCustomerSucceededAction extends Action<InternalCustomerResponseData> {\n type: CustomerActionType.SignInCustomerSucceeded;\n}\n\nexport interface SignInCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.SignInCustomerFailed;\n}\n\nexport interface SignOutCustomerRequestedAction extends Action {\n type: CustomerActionType.SignOutCustomerRequested;\n}\n\nexport interface SignOutCustomerSucceededAction extends Action<InternalCustomerResponseData> {\n type: CustomerActionType.SignOutCustomerSucceeded;\n}\n\nexport interface SignOutCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.SignOutCustomerFailed;\n}\n\nexport interface CreateCustomerRequestedAction extends Action {\n type: CustomerActionType.CreateCustomerRequested;\n}\n\nexport interface CreateCustomerSucceededAction extends Action {\n type: CustomerActionType.CreateCustomerSucceeded;\n}\n\nexport interface CreateCustomerFailedAction extends Action<Error> {\n type: CustomerActionType.CreateCustomerFailed;\n}\n\nexport interface CreateCustomerAddressRequestedAction extends Action {\n type: CustomerActionType.CreateCustomerAddressRequested;\n}\n\nexport interface CreateCustomerAddressSucceededAction extends Action<Customer> {\n type: CustomerActionType.CreateCustomerAddressSucceeded;\n}\n\nexport interface CreateCustomerAddressFailedAction extends Action<Error> {\n type: CustomerActionType.CreateCustomerAddressFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\n\nimport { CouponAction, CouponActionType } from './coupon-actions';\nimport GiftCertificate from './gift-certificate';\nimport { GiftCertificateAction, GiftCertificateActionType } from './gift-certificate-actions';\nimport GiftCertificateState, { DEFAULT_STATE, GiftCertificateErrorsState, GiftCertificateStatusesState } from './gift-certificate-state';\n\nexport default function giftCertificateReducer(\n state: GiftCertificateState = DEFAULT_STATE,\n action: Action\n): GiftCertificateState {\n const reducer = combineReducers<GiftCertificateState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: GiftCertificate[] | undefined,\n action: CheckoutAction | GiftCertificateAction | ConsignmentAction | CouponAction\n): GiftCertificate[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return arrayReplace(data, action.payload && action.payload.giftCertificates);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: GiftCertificateErrorsState = DEFAULT_STATE.errors,\n action: GiftCertificateAction\n): GiftCertificateErrorsState {\n switch (action.type) {\n case GiftCertificateActionType.ApplyGiftCertificateRequested:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n return objectSet(errors, 'applyGiftCertificateError', undefined);\n\n case GiftCertificateActionType.ApplyGiftCertificateFailed:\n return objectSet(errors, 'applyGiftCertificateError', action.payload);\n\n case GiftCertificateActionType.RemoveGiftCertificateRequested:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n return objectSet(errors, 'removeGiftCertificateError', undefined);\n\n case GiftCertificateActionType.RemoveGiftCertificateFailed:\n return objectSet(errors, 'removeGiftCertificateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: GiftCertificateStatusesState = DEFAULT_STATE.statuses,\n action: GiftCertificateAction\n): GiftCertificateStatusesState {\n switch (action.type) {\n case GiftCertificateActionType.ApplyGiftCertificateRequested:\n return objectSet(statuses, 'isApplyingGiftCertificate', true);\n\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateFailed:\n return objectSet(statuses, 'isApplyingGiftCertificate', false);\n\n case GiftCertificateActionType.RemoveGiftCertificateRequested:\n return objectSet(statuses, 'isRemovingGiftCertificate', true);\n\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateFailed:\n return objectSet(statuses, 'isRemovingGiftCertificate', false);\n\n default:\n return statuses;\n }\n}\n","import Customer from './customer';\n\nexport default interface CustomerState {\n data?: Customer;\n statuses: CustomerStatusesState;\n errors: CustomerErrorsState;\n}\n\nexport interface CustomerErrorsState {\n createError?: Error;\n createAddressError?: Error;\n}\n\nexport interface CustomerStatusesState {\n isCreating?: boolean;\n isCreatingAddress?: boolean;\n}\n\nexport const DEFAULT_STATE: CustomerState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum CustomerStrategyActionType {\n SignInFailed = 'CUSTOMER_STRATEGY_SIGN_IN_FAILED',\n SignInRequested = 'CUSTOMER_STRATEGY_SIGN_IN_REQUESTED',\n SignInSucceeded = 'CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED',\n SignOutFailed = 'CUSTOMER_STRATEGY_SIGN_OUT_FAILED',\n SignOutRequested = 'CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED',\n SignOutSucceeded = 'CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED',\n ExecutePaymentMethodCheckoutFailed = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED',\n ExecutePaymentMethodCheckoutRequested = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED',\n ExecutePaymentMethodCheckoutSucceeded = 'CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED',\n InitializeFailed = 'CUSTOMER_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'CUSTOMER_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'CUSTOMER_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type CustomerStrategyAction =\n CustomerStrategySignInAction |\n CustomerStrategySignOutAction |\n CustomerStrategyExecutePaymentMethodCheckoutAction |\n CustomerStrategyInitializeAction |\n CustomerStrategyDeinitializeAction |\n CustomerStrategyWidgetAction;\n\nexport type CustomerStrategySignInAction =\n SignInRequestedAction |\n SignInSucceededAction |\n SignInFailedAction;\n\nexport type CustomerStrategySignOutAction =\n SignOutRequestedAction |\n SignOutSucceededAction |\n SignOutFailedAction;\n\nexport type CustomerStrategyExecutePaymentMethodCheckoutAction =\n ExecutePaymentMethodCheckoutRequestedAction |\n ExecutePaymentMethodCheckoutSucceededAction |\n ExecutePaymentMethodCheckoutFailedAction;\n\nexport type CustomerStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type CustomerStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type CustomerStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface SignInRequestedAction extends Action {\n type: CustomerStrategyActionType.SignInRequested;\n}\n\nexport interface SignInSucceededAction extends Action {\n type: CustomerStrategyActionType.SignInSucceeded;\n}\n\nexport interface SignInFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.SignInFailed;\n}\n\nexport interface SignOutRequestedAction extends Action {\n type: CustomerStrategyActionType.SignOutRequested;\n}\n\nexport interface SignOutSucceededAction extends Action {\n type: CustomerStrategyActionType.SignOutSucceeded;\n}\n\nexport interface SignOutFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.SignOutFailed;\n}\n\nexport interface ExecutePaymentMethodCheckoutRequestedAction extends Action {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested;\n}\n\nexport interface ExecutePaymentMethodCheckoutSucceededAction extends Action {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded;\n}\n\nexport interface ExecutePaymentMethodCheckoutFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: CustomerStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: CustomerStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: CustomerStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: CustomerStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: CustomerStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: CustomerStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: CustomerStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers } from '@bigcommerce/data-store';\n\nimport { BillingAddressActionType, ContinueAsGuestAction } from '../billing';\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport Customer from './customer';\nimport { CustomerAction, CustomerActionType } from './customer-actions';\nimport CustomerState, { CustomerErrorsState, CustomerStatusesState, DEFAULT_STATE } from './customer-state';\n\nexport default function customerReducer(\n state: CustomerState = DEFAULT_STATE,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerState {\n const reducer = combineReducers<CustomerState, CheckoutAction | CustomerAction | ContinueAsGuestAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Customer | undefined,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): Customer | undefined {\n switch (action.type) {\n case BillingAddressActionType.ContinueAsGuestSucceeded:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectMerge(data, action.payload && action.payload.customer);\n\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CustomerErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerErrorsState {\n switch (action.type) {\n case CustomerActionType.CreateCustomerRequested:\n case CustomerActionType.CreateCustomerSucceeded:\n return objectSet(errors, 'createError', undefined);\n\n case CustomerActionType.CreateCustomerFailed:\n return objectSet(errors, 'createError', action.payload);\n\n case CustomerActionType.CreateCustomerAddressRequested:\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectSet(errors, 'createAddressError', undefined);\n\n case CustomerActionType.CreateCustomerAddressFailed:\n return objectSet(errors, 'createAddressError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CustomerStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | ContinueAsGuestAction | CustomerAction\n): CustomerStatusesState {\n switch (action.type) {\n case CustomerActionType.CreateCustomerRequested:\n return objectSet(statuses, 'isCreating', true);\n\n case CustomerActionType.CreateCustomerFailed:\n case CustomerActionType.CreateCustomerSucceeded:\n return objectSet(statuses, 'isCreating', false);\n\n case CustomerActionType.CreateCustomerAddressRequested:\n return objectSet(statuses, 'isCreatingAddress', true);\n\n case CustomerActionType.CreateCustomerAddressFailed:\n case CustomerActionType.CreateCustomerAddressSucceeded:\n return objectSet(statuses, 'isCreatingAddress', false);\n default:\n return statuses;\n }\n}\n","export default interface CustomerStrategyState {\n data: CustomerStrategyDataState;\n errors: CustomerStrategyErrorsState;\n statuses: CustomerStrategyStatusesState;\n}\n\nexport interface CustomerStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface CustomerStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n signInError?: Error;\n signInMethodId?: string;\n signOutError?: Error;\n signOutMethodId?: string;\n executePaymentMethodCheckoutError?: Error;\n executePaymentMethodCheckoutMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface CustomerStrategyStatusesState {\n deinitializeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isInitializing?: boolean;\n isSigningIn?: boolean;\n isSigningOut?: boolean;\n signInMethodId?: string;\n signOutMethodId?: string;\n isExecutingPaymentMethodCheckout?: boolean;\n executePaymentMethodCheckoutMethodId?: string;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: CustomerStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { FormFields } from './form-field';\n\nexport enum FormFieldsActionType {\n LoadFormFieldsRequested = 'LOAD_FORM_FIELDS_REQUESTED',\n LoadFormFieldsSucceeded = 'LOAD_FORM_FIELDS_SUCCEEDED',\n LoadFormFieldsFailed = 'LOAD_FORM_FIELDS_FAILED',\n}\n\nexport type LoadFormFieldsAction =\n LoadFormFieldsRequestedAction |\n LoadFormFieldsSucceededAction |\n LoadFormFieldsFailedAction;\n\nexport interface LoadFormFieldsRequestedAction extends Action {\n type: FormFieldsActionType.LoadFormFieldsRequested;\n}\n\nexport interface LoadFormFieldsSucceededAction extends Action<FormFields> {\n type: FormFieldsActionType.LoadFormFieldsSucceeded;\n}\n\nexport interface LoadFormFieldsFailedAction extends Action<Error> {\n type: FormFieldsActionType.LoadFormFieldsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { CustomerStrategyAction, CustomerStrategyActionType } from './customer-strategy-actions';\nimport CustomerStrategyState, { CustomerStrategyDataState, CustomerStrategyErrorsState, CustomerStrategyStatusesState, DEFAULT_STATE } from './customer-strategy-state';\n\nexport default function customerStrategyReducer(\n state: CustomerStrategyState = DEFAULT_STATE,\n action: Action\n): CustomerStrategyState {\n const reducer = combineReducers<CustomerStrategyState, CustomerStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CustomerStrategyDataState = DEFAULT_STATE.data,\n action: CustomerStrategyAction\n): CustomerStrategyDataState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: CustomerStrategyErrorsState = DEFAULT_STATE.errors,\n action: CustomerStrategyAction\n): CustomerStrategyErrorsState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeRequested:\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.DeinitializeRequested:\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignInRequested:\n case CustomerStrategyActionType.SignInSucceeded:\n return objectMerge(errors, {\n signInError: undefined,\n signInMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignInFailed:\n return objectMerge(errors, {\n signInError: action.payload,\n signInMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignOutRequested:\n case CustomerStrategyActionType.SignOutSucceeded:\n return objectMerge(errors, {\n signOutError: undefined,\n signOutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignOutFailed:\n return objectMerge(errors, {\n signOutError: action.payload,\n signOutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested:\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded:\n return objectMerge(errors, {\n executePaymentMethodCheckoutError: undefined,\n executePaymentMethodCheckoutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed:\n return objectMerge(errors, {\n executePaymentMethodCheckoutError: action.payload,\n executePaymentMethodCheckoutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.WidgetInteractionStarted:\n case CustomerStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case CustomerStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CustomerStrategyStatusesState = DEFAULT_STATE.statuses,\n action: CustomerStrategyAction\n): CustomerStrategyStatusesState {\n switch (action.type) {\n case CustomerStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.InitializeFailed:\n case CustomerStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.DeinitializeFailed:\n case CustomerStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignInRequested:\n return objectMerge(statuses, {\n isSigningIn: true,\n signInMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignInFailed:\n case CustomerStrategyActionType.SignInSucceeded:\n return objectMerge(statuses, {\n isSigningIn: false,\n signInMethodId: undefined,\n });\n\n case CustomerStrategyActionType.SignOutRequested:\n return objectMerge(statuses, {\n isSigningOut: true,\n signOutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.SignOutFailed:\n case CustomerStrategyActionType.SignOutSucceeded:\n return objectMerge(statuses, {\n isSigningOut: false,\n signOutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutRequested:\n return objectMerge(statuses, {\n isExecutingPaymentMethodCheckout: true,\n executePaymentMethodCheckoutMethodId: action.meta && action.meta.methodId,\n });\n\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutFailed:\n case CustomerStrategyActionType.ExecutePaymentMethodCheckoutSucceeded:\n return objectMerge(statuses, {\n isExecutingPaymentMethodCheckout: false,\n executePaymentMethodCheckoutMethodId: undefined,\n });\n\n case CustomerStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n case CustomerStrategyActionType.WidgetInteractionFinished:\n case CustomerStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { FormFields } from './form-field';\n\nexport default interface FormFieldsState {\n data?: FormFields;\n errors: FormFieldsErrorState;\n statuses: FormFieldsStatusesState;\n}\n\nexport interface FormFieldsErrorState {\n loadError?: Error;\n}\n\nexport interface FormFieldsStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: FormFieldsState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport Country from './country';\n\nexport enum CountryActionType {\n LoadCountriesRequested = 'LOAD_COUNTRIES_REQUESTED',\n LoadCountriesSucceeded = 'LOAD_COUNTRIES_SUCCEEDED',\n LoadCountriesFailed = 'LOAD_COUNTRIES_FAILED',\n}\n\nexport type LoadCountriesAction =\n LoadCountriesRequestedAction |\n LoadCountriesSucceededAction |\n LoadCountriesFailedAction;\n\nexport interface LoadCountriesRequestedAction extends Action {\n type: CountryActionType.LoadCountriesRequested;\n}\n\nexport interface LoadCountriesSucceededAction extends Action<Country[]> {\n type: CountryActionType.LoadCountriesSucceeded;\n}\n\nexport interface LoadCountriesFailedAction extends Action<Error> {\n type: CountryActionType.LoadCountriesFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { FormFields } from './form-field';\nimport { FormFieldsActionType, LoadFormFieldsAction } from './form-fields-actions';\nimport FormFieldsState, { DEFAULT_STATE, FormFieldsErrorState, FormFieldsStatusesState } from './form-fields-state';\n\nexport default function formFieldsReducer(\n state: FormFieldsState = DEFAULT_STATE,\n action: Action\n): FormFieldsState {\n const reducer = combineReducers<FormFieldsState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: FormFields | undefined,\n action: LoadFormFieldsAction\n): FormFields | undefined {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: FormFieldsErrorState = DEFAULT_STATE.errors,\n action: LoadFormFieldsAction\n): FormFieldsErrorState {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case FormFieldsActionType.LoadFormFieldsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: FormFieldsStatusesState = DEFAULT_STATE.statuses,\n action: LoadFormFieldsAction\n): FormFieldsStatusesState {\n switch (action.type) {\n case FormFieldsActionType.LoadFormFieldsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case FormFieldsActionType.LoadFormFieldsSucceeded:\n case FormFieldsActionType.LoadFormFieldsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import Country from './country';\n\nexport default interface CountryState {\n data?: Country[];\n errors: CountryErrorsState;\n statuses: CountryStatusesState;\n}\n\nexport interface CountryErrorsState {\n loadError?: Error;\n}\n\nexport interface CountryStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: CountryState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\n\nimport Country from './country';\nimport { CountryActionType, LoadCountriesAction } from './country-actions';\nimport CountryState, { CountryErrorsState, CountryStatusesState, DEFAULT_STATE } from './country-state';\n\nexport default function countryReducer(\n state: CountryState = DEFAULT_STATE,\n action: Action\n): CountryState {\n const reducer = combineReducers<CountryState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Country[] | undefined,\n action: LoadCountriesAction\n): Country[] | undefined {\n switch (action.type) {\n case CountryActionType.LoadCountriesSucceeded:\n return arrayReplace(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CountryErrorsState = DEFAULT_STATE.errors,\n action: LoadCountriesAction\n): CountryErrorsState {\n switch (action.type) {\n case CountryActionType.LoadCountriesRequested:\n case CountryActionType.LoadCountriesSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CountryActionType.LoadCountriesFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CountryStatusesState = DEFAULT_STATE.statuses,\n action: LoadCountriesAction\n): CountryStatusesState {\n switch (action.type) {\n case CountryActionType.LoadCountriesRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CountryActionType.LoadCountriesSucceeded:\n case CountryActionType.LoadCountriesFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { Omit } from '../common/types';\n\nimport { InternalOrderMeta, InternalOrderPayment } from './internal-order';\nimport Order from './order';\n\nexport default interface OrderState {\n data?: OrderDataState;\n meta?: OrderMetaState;\n errors: OrderErrorsState;\n statuses: OrderStatusesState;\n}\n\nexport type OrderDataState = Omit<Order, 'billingAddress' | 'coupons'>;\n\nexport interface OrderMetaState extends InternalOrderMeta {\n token?: string;\n orderToken?: string;\n callbackUrl?: string;\n payment?: InternalOrderPayment;\n}\n\nexport interface OrderErrorsState {\n loadError?: Error;\n submitError?: Error;\n finalizeError?: Error;\n}\n\nexport interface OrderStatusesState {\n isLoading?: boolean;\n isSubmitting?: boolean;\n isFinalizing?: boolean;\n}\n\nexport const DEFAULT_STATE: OrderState = {\n errors: {},\n meta: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadOrderAction } from '../order';\n\nimport PaymentResponseBody from './payment-response-body';\n\nexport enum PaymentActionType {\n SubmitPaymentRequested = 'SUBMIT_PAYMENT_REQUESTED',\n SubmitPaymentSucceeded = 'SUBMIT_PAYMENT_SUCCEEDED',\n SubmitPaymentFailed = 'SUBMIT_PAYMENT_FAILED',\n\n InitializeOffsitePaymentRequested = 'INITIALIZE_OFFSITE_PAYMENT_REQUESTED',\n InitializeOffsitePaymentSucceeded = 'INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED',\n InitializeOffsitePaymentFailed = 'INITIALIZE_OFFSITE_PAYMENT_FAILED',\n}\n\nexport type PaymentAction = SubmitPaymentAction |\n InitializeOffsitePaymentAction;\n\nexport type SubmitPaymentAction =\n SubmitPaymentRequestedAction |\n SubmitPaymentSucceededAction |\n SubmitPaymentFailedAction |\n LoadOrderAction;\n\nexport type InitializeOffsitePaymentAction =\n InitializeOffsitePaymentRequestedAction |\n InitializeOffsitePaymentSucceededAction |\n InitializeOffsitePaymentFailedAction;\n\nexport interface SubmitPaymentRequestedAction extends Action {\n type: PaymentActionType.SubmitPaymentRequested;\n}\n\nexport interface SubmitPaymentSucceededAction extends Action<PaymentResponseBody> {\n type: PaymentActionType.SubmitPaymentSucceeded;\n}\n\nexport interface SubmitPaymentFailedAction extends Action<Error> {\n type: PaymentActionType.SubmitPaymentFailed;\n}\n\nexport interface InitializeOffsitePaymentRequestedAction extends Action {\n type: PaymentActionType.InitializeOffsitePaymentRequested;\n}\n\nexport interface InitializeOffsitePaymentSucceededAction extends Action {\n type: PaymentActionType.InitializeOffsitePaymentSucceeded;\n}\n\nexport interface InitializeOffsitePaymentFailedAction extends Action<Error> {\n type: PaymentActionType.InitializeOffsitePaymentFailed;\n}\n","import { Action } from '@bigcommerce/data-store';\n\nimport PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\n\nexport enum PaymentMethodActionType {\n LoadPaymentMethodRequested = 'LOAD_PAYMENT_METHOD_REQUESTED',\n LoadPaymentMethodSucceeded = 'LOAD_PAYMENT_METHOD_SUCCEEDED',\n LoadPaymentMethodFailed = 'LOAD_PAYMENT_METHOD_FAILED',\n\n LoadPaymentMethodsRequested = 'LOAD_PAYMENT_METHODS_REQUESTED',\n LoadPaymentMethodsSucceeded = 'LOAD_PAYMENT_METHODS_SUCCEEDED',\n LoadPaymentMethodsFailed = 'LOAD_PAYMENT_METHODS_FAILED',\n}\n\nexport type PaymentMethodAction = LoadPaymentMethodAction | LoadPaymentMethodsAction;\n\nexport type LoadPaymentMethodAction =\n LoadPaymentMethodRequestedAction |\n LoadPaymentMethodSucceededAction |\n LoadPaymentMethodFailedAction;\n\nexport type LoadPaymentMethodsAction =\n LoadPaymentMethodsRequestedAction |\n LoadPaymentMethodsSucceededAction |\n LoadPaymentMethodsFailedAction;\n\nexport interface LoadPaymentMethodRequestedAction extends Action {\n type: PaymentMethodActionType.LoadPaymentMethodRequested;\n}\n\nexport interface LoadPaymentMethodSucceededAction extends Action<PaymentMethod> {\n type: PaymentMethodActionType.LoadPaymentMethodSucceeded;\n}\n\nexport interface LoadPaymentMethodFailedAction extends Action<Error> {\n type: PaymentMethodActionType.LoadPaymentMethodFailed;\n}\n\nexport interface LoadPaymentMethodsRequestedAction extends Action {\n type: PaymentMethodActionType.LoadPaymentMethodsRequested;\n}\n\nexport interface LoadPaymentMethodsSucceededAction extends Action<PaymentMethod[], PaymentMethodMeta> {\n type: PaymentMethodActionType.LoadPaymentMethodsSucceeded;\n}\n\nexport interface LoadPaymentMethodsFailedAction extends Action<Error> {\n type: PaymentMethodActionType.LoadPaymentMethodsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\nimport { omit } from 'lodash';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { OrderAction, OrderActionType } from './order-actions';\nimport OrderState, { DEFAULT_STATE, OrderDataState, OrderErrorsState, OrderMetaState, OrderStatusesState } from './order-state';\n\nexport default function orderReducer(\n state: OrderState = DEFAULT_STATE,\n action: Action\n): OrderState {\n const reducer = combineReducers<OrderState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: OrderDataState | undefined,\n action: OrderAction\n): OrderDataState | undefined {\n switch (action.type) {\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n return objectMerge(data, omit(action.payload, ['billingAddress', 'coupons'])) as OrderDataState;\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: OrderMetaState | undefined,\n action: OrderAction\n): OrderMetaState | undefined {\n switch (action.type) {\n case OrderActionType.FinalizeOrderSucceeded:\n case OrderActionType.SubmitOrderSucceeded:\n return objectMerge(meta, {\n ...action.meta,\n callbackUrl: action.payload && action.payload.order.callbackUrl,\n orderToken: action.payload && action.payload.order.token,\n payment: action.payload && action.payload.order && action.payload.order.payment,\n });\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: OrderErrorsState = DEFAULT_STATE.errors,\n action: OrderAction\n): OrderErrorsState {\n switch (action.type) {\n case OrderActionType.LoadOrderRequested:\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n case OrderActionType.LoadOrderPaymentsRequested:\n return objectSet(errors, 'loadError', undefined);\n\n case OrderActionType.LoadOrderFailed:\n case OrderActionType.LoadOrderPaymentsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: OrderStatusesState = DEFAULT_STATE.statuses,\n action: OrderAction\n): OrderStatusesState {\n switch (action.type) {\n case OrderActionType.LoadOrderRequested:\n case OrderActionType.LoadOrderPaymentsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case OrderActionType.LoadOrderSucceeded:\n case OrderActionType.LoadOrderFailed:\n case OrderActionType.LoadOrderPaymentsSucceeded:\n case OrderActionType.LoadOrderPaymentsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { PaymentAction, PaymentActionType } from './payment-actions';\nimport PaymentResponseBody from './payment-response-body';\nimport PaymentState from './payment-state';\n\nexport default function paymentReducer(state: PaymentState = {}, action: PaymentAction): PaymentState {\n const reducer = combineReducers<PaymentState, PaymentAction>({\n data: dataReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(data: PaymentResponseBody | undefined, action: PaymentAction): PaymentResponseBody | undefined {\n switch (action.type) {\n case PaymentActionType.SubmitPaymentSucceeded:\n return action.payload;\n\n default:\n return data;\n }\n}\n","import PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\n\nexport default interface PaymentMethodState {\n data?: PaymentMethod[];\n meta?: PaymentMethodMeta;\n errors: PaymentMethodErrorsState;\n statuses: PaymentMethodStatusesState;\n}\n\nexport interface PaymentMethodErrorsState {\n loadMethodId?: string;\n loadError?: Error;\n loadMethodError?: Error;\n}\n\nexport interface PaymentMethodStatusesState {\n loadMethodId?: string;\n isLoading?: boolean;\n isLoadingMethod?: boolean;\n}\n\nexport const DEFAULT_STATE: PaymentMethodState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { LoadOrderPaymentsAction } from '../order';\n\nexport enum PaymentStrategyActionType {\n ExecuteFailed = 'PAYMENT_STRATEGY_EXECUTE_FAILED',\n ExecuteRequested = 'PAYMENT_STRATEGY_EXECUTE_REQUESTED',\n ExecuteSucceeded = 'PAYMENT_STRATEGY_EXECUTE_SUCCEEDED',\n FinalizeFailed = 'PAYMENT_STRATEGY_FINALIZE_FAILED',\n FinalizeRequested = 'PAYMENT_STRATEGY_FINALIZE_REQUESTED',\n FinalizeSucceeded = 'PAYMENT_STRATEGY_FINALIZE_SUCCEEDED',\n InitializeFailed = 'PAYMENT_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'PAYMENT_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'PAYMENT_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type PaymentStrategyAction =\n PaymentStrategyExecuteAction |\n PaymentStrategyFinalizeAction |\n PaymentStrategyInitializeAction |\n PaymentStrategyDeinitializeAction |\n PaymentStrategyWidgetAction;\n\nexport type PaymentStrategyExecuteAction =\n ExecuteRequestedAction |\n ExecuteSucceededAction |\n ExecuteFailedAction |\n LoadOrderPaymentsAction;\n\nexport type PaymentStrategyFinalizeAction =\n FinalizeRequestedAction |\n FinalizeSucceededAction |\n FinalizeFailedAction |\n LoadOrderPaymentsAction;\n\nexport type PaymentStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type PaymentStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type PaymentStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface ExecuteRequestedAction extends Action {\n type: PaymentStrategyActionType.ExecuteRequested;\n}\n\nexport interface ExecuteSucceededAction extends Action {\n type: PaymentStrategyActionType.ExecuteSucceeded;\n}\n\nexport interface ExecuteFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.ExecuteFailed;\n}\n\nexport interface FinalizeRequestedAction extends Action {\n type: PaymentStrategyActionType.FinalizeRequested;\n}\n\nexport interface FinalizeSucceededAction extends Action {\n type: PaymentStrategyActionType.FinalizeSucceeded;\n}\n\nexport interface FinalizeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.FinalizeFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: PaymentStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: PaymentStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: PaymentStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: PaymentStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: PaymentStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: PaymentStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: PaymentStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, mergeOrPush, objectMerge, objectSet } from '../common/utility';\n\nimport PaymentMethod from './payment-method';\nimport { PaymentMethodAction, PaymentMethodActionType } from './payment-method-actions';\nimport PaymentMethodMeta from './payment-method-meta';\nimport PaymentMethodState, { DEFAULT_STATE, PaymentMethodErrorsState, PaymentMethodStatusesState } from './payment-method-state';\n\nexport default function paymentMethodReducer(\n state: PaymentMethodState = DEFAULT_STATE,\n action: Action\n): PaymentMethodState {\n const reducer = combineReducers<PaymentMethodState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentMethod[] | undefined,\n action: PaymentMethodAction\n): PaymentMethod[] | undefined {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n return mergeOrPush(data || [], action.payload, action.payload && {\n id: action.payload.id,\n gateway: action.payload.gateway,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return arrayReplace(data, action.payload, {\n matchObject: (methodA, methodB) => (\n methodA.id === methodB.id && methodA.gateway === methodB.gateway\n ),\n });\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: PaymentMethodMeta | undefined,\n action: PaymentMethodAction\n): PaymentMethodMeta | undefined {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return objectMerge(meta, action.meta);\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: PaymentMethodErrorsState = DEFAULT_STATE.errors,\n action: PaymentMethodAction\n): PaymentMethodErrorsState {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsRequested:\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case PaymentMethodActionType.LoadPaymentMethodsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case PaymentMethodActionType.LoadPaymentMethodRequested:\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n return objectMerge(errors, {\n loadMethodId: undefined,\n loadMethodError: undefined,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodFailed:\n return objectMerge(errors, {\n loadMethodId: action.meta.methodId,\n loadMethodError: action.payload,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PaymentMethodStatusesState = DEFAULT_STATE.statuses,\n action: PaymentMethodAction\n): PaymentMethodStatusesState {\n switch (action.type) {\n case PaymentMethodActionType.LoadPaymentMethodsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case PaymentMethodActionType.LoadPaymentMethodsSucceeded:\n case PaymentMethodActionType.LoadPaymentMethodsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case PaymentMethodActionType.LoadPaymentMethodRequested:\n return objectMerge(statuses, {\n isLoadingMethod: true,\n loadMethodId: action.meta.methodId,\n });\n\n case PaymentMethodActionType.LoadPaymentMethodSucceeded:\n case PaymentMethodActionType.LoadPaymentMethodFailed:\n return objectMerge(statuses, {\n isLoadingMethod: false,\n loadMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { findIndex, pick, pickBy, ValueKeyIteratee } from 'lodash';\n\nimport isPlainObject from './is-plain-object';\nimport objectMerge from './object-merge';\n\n/**\n * Push an item to an array if it doesn't exist in the array. Otherwise, merge\n * with the existing item in the array. This function always returns a new array.\n */\nexport default function mergeOrPush<T>(\n array: T[],\n item?: T,\n predicate?: ValueKeyIteratee<T>\n): T[] {\n if (!item) {\n return array;\n }\n\n const defaultPredicate = pick(item, 'id');\n const index = findIndex(array, typeof predicate === 'object' ? pickBy(predicate) : (predicate || defaultPredicate));\n const newArray = [...array];\n\n if (index === -1) {\n newArray.push(item);\n } else {\n const existingItem = array[index];\n\n newArray[index] = isPlainObject(existingItem) && isPlainObject(item) ?\n objectMerge(existingItem, item) :\n item;\n }\n\n return newArray;\n}\n","export default interface PaymentStrategyState {\n data: PaymentStrategyDataState;\n errors: PaymentStrategyErrorsState;\n statuses: PaymentStrategyStatusesState;\n}\n\nexport interface PaymentStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface PaymentStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n executeError?: Error;\n executeMethodId?: string;\n finalizeError?: Error;\n finalizeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface PaymentStrategyStatusesState {\n deinitializeMethodId?: string;\n executeMethodId?: string;\n finalizeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isExecuting?: boolean;\n isFinalizing?: boolean;\n isInitializing?: boolean;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: PaymentStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { VaultAccessToken } from './instrument';\nimport { InstrumentsResponseBody } from './instrument-response-body';\n\nexport enum InstrumentActionType {\n LoadInstrumentsRequested = 'LOAD_INSTRUMENTS_REQUESTED',\n LoadInstrumentsSucceeded = 'LOAD_INSTRUMENTS_SUCCEEDED',\n LoadInstrumentsFailed = 'LOAD_INSTRUMENTS_FAILED',\n\n DeleteInstrumentRequested = 'DELETE_INSTRUMENT_REQUESTED',\n DeleteInstrumentSucceeded = 'DELETE_INSTRUMENT_SUCCEEDED',\n DeleteInstrumentFailed = 'DELETE_INSTRUMENT_FAILED',\n}\n\nexport type InstrumentAction =\n LoadInstrumentsAction |\n DeleteInstrumentAction;\n\nexport type LoadInstrumentsAction =\n LoadInstrumentsRequestedAction |\n LoadInstrumentsSucceededAction |\n LoadInstrumentsFailedAction;\n\nexport type DeleteInstrumentAction =\n DeleteInstrumentRequestedAction |\n DeleteInstrumentSucceededAction |\n DeleteInstrumentFailedAction;\n\nexport interface LoadInstrumentsRequestedAction extends Action {\n type: InstrumentActionType.LoadInstrumentsRequested;\n}\n\nexport interface LoadInstrumentsSucceededAction extends Action<InstrumentsResponseBody, VaultAccessToken> {\n type: InstrumentActionType.LoadInstrumentsSucceeded;\n}\n\nexport interface LoadInstrumentsFailedAction extends Action<Error> {\n type: InstrumentActionType.LoadInstrumentsFailed;\n}\n\nexport interface DeleteInstrumentRequestedAction extends Action {\n type: InstrumentActionType.DeleteInstrumentRequested;\n}\n\nexport interface DeleteInstrumentSucceededAction extends Action<InstrumentsResponseBody, VaultAccessToken & { instrumentId: string }> {\n type: InstrumentActionType.DeleteInstrumentSucceeded;\n}\n\nexport interface DeleteInstrumentFailedAction extends Action<Error> {\n type: InstrumentActionType.DeleteInstrumentFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { PaymentStrategyAction, PaymentStrategyActionType } from './payment-strategy-actions';\nimport PaymentStrategyState, { DEFAULT_STATE, PaymentStrategyDataState, PaymentStrategyErrorsState, PaymentStrategyStatusesState } from './payment-strategy-state';\n\nexport default function paymentStrategyReducer(\n state: PaymentStrategyState = DEFAULT_STATE,\n action: Action\n): PaymentStrategyState {\n const reducer = combineReducers<PaymentStrategyState, PaymentStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentStrategyDataState = DEFAULT_STATE.data,\n action: PaymentStrategyAction\n): PaymentStrategyDataState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: PaymentStrategyErrorsState = DEFAULT_STATE.errors,\n action: PaymentStrategyAction\n): PaymentStrategyErrorsState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeRequested:\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.DeinitializeRequested:\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.ExecuteRequested:\n case PaymentStrategyActionType.ExecuteSucceeded:\n return objectMerge(errors, {\n executeError: undefined,\n executeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.ExecuteFailed:\n return objectMerge(errors, {\n executeError: action.payload,\n executeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.FinalizeRequested:\n case PaymentStrategyActionType.FinalizeSucceeded:\n return objectMerge(errors, {\n finalizeError: undefined,\n finalizeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.FinalizeFailed:\n return objectMerge(errors, {\n finalizeError: action.payload,\n finalizeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.WidgetInteractionStarted:\n case PaymentStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case PaymentStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PaymentStrategyStatusesState = DEFAULT_STATE.statuses,\n action: PaymentStrategyAction\n): PaymentStrategyStatusesState {\n switch (action.type) {\n case PaymentStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.InitializeFailed:\n case PaymentStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.DeinitializeFailed:\n case PaymentStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.ExecuteRequested:\n return objectMerge(statuses, {\n isExecuting: true,\n executeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.ExecuteFailed:\n case PaymentStrategyActionType.ExecuteSucceeded:\n return objectMerge(statuses, {\n isExecuting: false,\n executeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.FinalizeRequested:\n return objectMerge(statuses, {\n isFinalizing: true,\n finalizeMethodId: action.meta && action.meta.methodId,\n });\n\n case PaymentStrategyActionType.FinalizeFailed:\n case PaymentStrategyActionType.FinalizeSucceeded:\n return objectMerge(statuses, {\n isFinalizing: false,\n finalizeMethodId: undefined,\n });\n\n case PaymentStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta.methodId,\n });\n\n case PaymentStrategyActionType.WidgetInteractionFinished:\n case PaymentStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import PaymentInstrument, { VaultAccessToken } from './instrument';\n\nexport default interface InstrumentState {\n data?: PaymentInstrument[];\n meta?: InstrumentMeta;\n errors: InstrumentErrorState;\n statuses: InstrumentStatusState;\n}\n\nexport interface InstrumentErrorState {\n deleteError?: Error;\n failedInstrument?: string;\n loadError?: Error;\n vaultError?: Error;\n}\n\nexport interface InstrumentStatusState {\n isDeleting?: boolean;\n isLoading?: boolean;\n isVaulting?: boolean;\n deletingInstrument?: string;\n}\n\nexport type InstrumentMeta = VaultAccessToken;\n\nexport const DEFAULT_STATE = {\n data: [],\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { AmazonPayRemoteCheckout } from './methods';\n\nexport enum RemoteCheckoutActionType {\n ForgetCheckoutRemoteCustomerRequested = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED',\n ForgetCheckoutRemoteCustomerSucceeded = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED',\n ForgetCheckoutRemoteCustomerFailed = 'FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED',\n\n InitializeRemoteBillingRequested = 'INITIALIZE_REMOTE_BILLING_REQUESTED',\n InitializeRemoteBillingSucceeded = 'INITIALIZE_REMOTE_BILLING_SUCCEEDED',\n InitializeRemoteBillingFailed = 'INITIALIZE_REMOTE_BILLING_FAILED',\n\n InitializeRemoteShippingRequested = 'INITIALIZE_REMOTE_SHIPPING_REQUESTED',\n InitializeRemoteShippingSucceeded = 'INITIALIZE_REMOTE_SHIPPING_SUCCEEDED',\n InitializeRemoteShippingFailed = 'INITIALIZE_REMOTE_SHIPPING_FAILED',\n\n InitializeRemotePaymentRequested = 'INITIALIZE_REMOTE_PAYMENT_REQUESTED',\n InitializeRemotePaymentSucceeded = 'INITIALIZE_REMOTE_PAYMENT_SUCCEEDED',\n InitializeRemotePaymentFailed = 'INITIALIZE_REMOTE_PAYMENT_FAILED',\n\n LoadRemoteSettingsRequested = 'LOAD_REMOTE_SETTINGS_REQUESTED',\n LoadRemoteSettingsSucceeded = 'LOAD_REMOTE_SETTINGS_SUCCEEDED',\n LoadRemoteSettingsFailed = 'LOAD_REMOTE_SETTINGS_FAILED',\n\n SignOutRemoteCustomerRequested = 'SIGN_OUT_REMOTE_CUSTOMER_REQUESTED',\n SignOutRemoteCustomerSucceeded = 'SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED',\n SignOutRemoteCustomerFailed = 'SIGN_OUT_REMOTE_CUSTOMER_FAILED',\n\n UpdateRemoteCheckout = 'UPDATE_REMOTE_CHECKOUT',\n}\n\nexport type RemoteCheckoutAction = ForgetCheckoutRemoteCustomerAction |\n InitializeRemoteBillingAction |\n InitializeRemoteShippingAction |\n InitializeRemotePaymentAction |\n SignOutRemoteCustomerAction |\n LoadRemoteSettingsAction |\n UpdateRemoteCheckoutAction;\n\nexport type ForgetCheckoutRemoteCustomerAction = ForgetCheckoutRemoteCustomerRequestedAction |\n ForgetCheckoutRemoteCustomerSucceededAction |\n ForgetCheckoutRemoteCustomerFailedAction;\n\nexport interface ForgetCheckoutRemoteCustomerRequestedAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerRequested;\n}\n\nexport interface ForgetCheckoutRemoteCustomerSucceededAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerSucceeded;\n}\n\nexport interface ForgetCheckoutRemoteCustomerFailedAction extends Action {\n type: RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerFailed;\n}\n\nexport type InitializeRemoteBillingAction = InitializeRemoteBillingSucceededAction |\n InitializeRemoteBillingFailedAction |\n InitializeRemoteBillingRequestedAction;\n\nexport interface InitializeRemoteBillingSucceededAction extends Action<AmazonPayRemoteCheckout> {\n type: RemoteCheckoutActionType.InitializeRemoteBillingSucceeded;\n}\n\nexport interface InitializeRemoteBillingFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteBillingFailed;\n}\n\nexport interface InitializeRemoteBillingRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteBillingRequested;\n}\n\nexport type InitializeRemoteShippingAction = InitializeRemoteShippingSucceededAction |\n InitializeRemoteShippingFailedAction |\n InitializeRemoteShippingRequestedAction;\n\nexport interface InitializeRemoteShippingSucceededAction extends Action<AmazonPayRemoteCheckout> {\n type: RemoteCheckoutActionType.InitializeRemoteShippingSucceeded;\n}\n\nexport interface InitializeRemoteShippingFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteShippingFailed;\n}\n\nexport interface InitializeRemoteShippingRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemoteShippingRequested;\n}\n\nexport type InitializeRemotePaymentAction = InitializeRemotePaymentSucceededAction |\n InitializeRemotePaymentFailedAction |\n InitializeRemotePaymentRequestedAction;\n\nexport interface InitializeRemotePaymentSucceededAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentSucceeded;\n}\n\nexport interface InitializeRemotePaymentFailedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentFailed;\n}\n\nexport interface InitializeRemotePaymentRequestedAction extends Action {\n type: RemoteCheckoutActionType.InitializeRemotePaymentRequested;\n}\n\nexport type SignOutRemoteCustomerAction = SignOutRemoteCustomerSucceededAction |\n SignOutRemoteCustomerFailedAction |\n SignOutRemoteCustomerRequestedAction;\n\nexport interface SignOutRemoteCustomerSucceededAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerSucceeded;\n}\n\nexport interface SignOutRemoteCustomerFailedAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerFailed;\n}\n\nexport interface SignOutRemoteCustomerRequestedAction extends Action {\n type: RemoteCheckoutActionType.SignOutRemoteCustomerRequested;\n}\n\nexport type LoadRemoteSettingsAction = LoadRemoteSettingsSucceededAction |\n LoadRemoteSettingsRequestedAction |\n LoadRemoteSettingsFailedAction;\n\nexport interface LoadRemoteSettingsSucceededAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsSucceeded;\n}\n\nexport interface LoadRemoteSettingsRequestedAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsRequested;\n}\n\nexport interface LoadRemoteSettingsFailedAction extends Action {\n type: RemoteCheckoutActionType.LoadRemoteSettingsFailed;\n}\n\nexport interface UpdateRemoteCheckoutAction extends Action {\n type: RemoteCheckoutActionType.UpdateRemoteCheckout;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../../common/error';\nimport { arrayReplace, objectMerge, objectSet } from '../../common/utility';\n\nimport PaymentInstrument from './instrument';\nimport { InstrumentAction, InstrumentActionType } from './instrument-actions';\nimport InstrumentState, { DEFAULT_STATE, InstrumentErrorState, InstrumentMeta, InstrumentStatusState } from './instrument-state';\n\nexport default function instrumentReducer(\n state: InstrumentState = DEFAULT_STATE,\n action: Action\n): InstrumentState {\n const reducer = combineReducers<InstrumentState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n meta: metaReducer,\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PaymentInstrument[] = DEFAULT_STATE.data,\n action: InstrumentAction\n): PaymentInstrument[] {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsSucceeded:\n return arrayReplace(data, action.payload && action.payload.vaultedInstruments || []);\n\n default:\n return data;\n }\n}\n\nfunction metaReducer(\n meta: InstrumentMeta | undefined,\n action: InstrumentAction\n): InstrumentMeta | undefined {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsSucceeded:\n case InstrumentActionType.DeleteInstrumentSucceeded:\n return objectMerge(meta, action.meta);\n\n default:\n return meta;\n }\n}\n\nfunction errorsReducer(\n errors: InstrumentErrorState = DEFAULT_STATE.errors,\n action: InstrumentAction\n): InstrumentErrorState {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsRequested:\n case InstrumentActionType.LoadInstrumentsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case InstrumentActionType.DeleteInstrumentRequested:\n case InstrumentActionType.DeleteInstrumentSucceeded:\n return objectMerge(errors, {\n deleteError: undefined,\n failedInstrument: undefined,\n });\n\n case InstrumentActionType.LoadInstrumentsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case InstrumentActionType.DeleteInstrumentFailed:\n return objectMerge(errors, {\n deleteError: action.payload,\n failedInstrument: action.meta.instrumentId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: InstrumentStatusState = DEFAULT_STATE.statuses,\n action: InstrumentAction\n): InstrumentStatusState {\n switch (action.type) {\n case InstrumentActionType.LoadInstrumentsRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case InstrumentActionType.DeleteInstrumentRequested:\n return objectMerge(statuses, {\n isDeleting: true,\n deletingInstrument: action.meta.instrumentId,\n });\n\n case InstrumentActionType.LoadInstrumentsSucceeded:\n case InstrumentActionType.LoadInstrumentsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case InstrumentActionType.DeleteInstrumentSucceeded:\n case InstrumentActionType.DeleteInstrumentFailed:\n return objectMerge(statuses, {\n isDeleting: false,\n deletingInstrument: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { AmazonPayRemoteCheckout } from './methods';\n\nexport default interface RemoteCheckoutState {\n data: RemoteCheckoutStateData;\n}\n\nexport interface RemoteCheckoutStateData {\n amazon?: AmazonPayRemoteCheckout;\n}\n\nexport const DEFAULT_STATE: RemoteCheckoutState = {\n data: {},\n};\n","import { combineReducers } from '@bigcommerce/data-store';\n\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport RemoteCheckout from './remote-checkout';\nimport { RemoteCheckoutAction, RemoteCheckoutActionType } from './remote-checkout-actions';\nimport RemoteCheckoutState, { DEFAULT_STATE, RemoteCheckoutStateData } from './remote-checkout-state';\n\nexport default function remoteCheckoutReducer(\n state: RemoteCheckoutState = DEFAULT_STATE,\n action: RemoteCheckoutAction\n): RemoteCheckoutState {\n if (!action.meta || !action.meta.methodId) {\n return state;\n }\n\n const reducer = combineReducers<RemoteCheckoutState>({\n data: combineReducers<RemoteCheckoutStateData>({\n [action.meta.methodId]: dataReducer,\n }),\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: RemoteCheckout,\n action: RemoteCheckoutAction\n): RemoteCheckout {\n switch (action.type) {\n case RemoteCheckoutActionType.InitializeRemoteBillingSucceeded:\n return objectSet(data, 'billing' as any, action.payload && action.payload.billing);\n\n case RemoteCheckoutActionType.InitializeRemoteShippingSucceeded:\n return objectSet(data, 'shipping' as any, action.payload && action.payload.shipping);\n\n case RemoteCheckoutActionType.LoadRemoteSettingsSucceeded:\n return objectSet(data, 'settings', action.payload);\n\n case RemoteCheckoutActionType.UpdateRemoteCheckout:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n","import Consignment from './consignment';\n\nexport default interface ConsignmentState {\n data?: Consignment[];\n errors: ConsignmentErrorsState;\n statuses: ConsignmentStatusesState;\n}\n\nexport interface ConsignmentErrorsState {\n loadError?: Error;\n loadShippingOptionsError?: Error;\n createError?: Error;\n updateError: { [key: string]: Error | undefined };\n deleteError: { [key: string]: Error | undefined };\n updateShippingOptionError: { [key: string]: Error | undefined };\n}\n\nexport interface ConsignmentStatusesState {\n isLoading?: boolean;\n isLoadingShippingOptions?: boolean;\n isCreating?: boolean;\n isUpdating: { [key: string]: boolean };\n isDeleting: { [key: string]: boolean };\n isUpdatingShippingOption: { [key: string]: boolean };\n}\n\nexport const DEFAULT_STATE: ConsignmentState = {\n errors: {\n updateShippingOptionError: {},\n updateError: {},\n deleteError: {},\n },\n statuses: {\n isUpdating: {},\n isUpdatingShippingOption: {},\n isDeleting: {},\n },\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { PickupOptionMeta, PickupOptionResult } from './pickup-option';\n\nexport enum PickupOptionActionType {\n LoadPickupOptionsRequested = 'LOAD_PICKUP_OPTIONS_REQUESTED',\n LoadPickupOptionsSucceeded = 'LOAD_PICKUP_OPTIONS_SUCCEEDED',\n LoadPickupOptionsFailed = 'LOAD_PICKUP_OPTIONS_FAILED',\n}\n\nexport type LoadPickupOptionsAction =\n PickupOptionRequestedAction |\n LoadPickupOptionsSucceededAction |\n LoadPickupOptionsFailedAction;\n\nexport interface PickupOptionRequestedAction extends Action {\n type: PickupOptionActionType.LoadPickupOptionsRequested;\n}\n\nexport interface LoadPickupOptionsSucceededAction extends Action<PickupOptionResult[], PickupOptionMeta> {\n type: PickupOptionActionType.LoadPickupOptionsSucceeded;\n}\n\nexport interface LoadPickupOptionsFailedAction extends Action<Error> {\n type: PickupOptionActionType.LoadPickupOptionsFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { CheckoutAction, CheckoutActionType } from '../checkout';\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType } from '../coupon';\nimport { CustomerAction, CustomerActionType } from '../customer';\n\nimport Consignment from './consignment';\nimport { ConsignmentAction, ConsignmentActionType } from './consignment-actions';\nimport ConsignmentState, { ConsignmentErrorsState, ConsignmentStatusesState, DEFAULT_STATE } from './consignment-state';\n\nexport default function consignmentReducer(\n state: ConsignmentState = DEFAULT_STATE,\n action: Action\n): ConsignmentState {\n const reducer = combineReducers<ConsignmentState, ConsignmentAction | CheckoutAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Consignment[] | undefined,\n action: ConsignmentAction | CheckoutAction | CouponAction | CustomerAction\n): Consignment[] | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n return arrayReplace(data, action.payload && action.payload.consignments);\n\n case CustomerActionType.SignOutCustomerSucceeded:\n return arrayReplace(data, []);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ConsignmentErrorsState = DEFAULT_STATE.errors,\n action: ConsignmentAction | CheckoutAction\n): ConsignmentErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.LoadShippingOptionsRequested:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case ConsignmentActionType.LoadShippingOptionsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case ConsignmentActionType.CreateConsignmentsRequested:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n return objectSet(errors, 'createError', undefined);\n\n case ConsignmentActionType.CreateConsignmentsFailed:\n return objectSet(errors, 'createError', action.payload);\n\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentRequested:\n if (action.meta) {\n return objectMerge(errors, {\n updateError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateConsignmentFailed:\n if (action.meta) {\n return objectMerge(errors, {\n updateError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentRequested:\n if (action.meta) {\n return objectMerge(errors, {\n deleteError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.DeleteConsignmentFailed:\n if (action.meta) {\n return objectMerge(errors, {\n deleteError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateShippingOptionRequested:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n if (action.meta) {\n return objectMerge(errors, {\n updateShippingOptionError: {\n [action.meta.id]: undefined,\n },\n });\n }\n\n return errors;\n\n case ConsignmentActionType.UpdateShippingOptionFailed:\n if (action.meta) {\n return objectMerge(errors, {\n updateShippingOptionError: {\n [action.meta.id]: action.payload,\n },\n });\n }\n\n return errors;\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ConsignmentStatusesState = DEFAULT_STATE.statuses,\n action: ConsignmentAction | CheckoutAction\n): ConsignmentStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ConsignmentActionType.LoadShippingOptionsRequested:\n return objectSet(statuses, 'isLoadingShippingOptions', true);\n\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(statuses, 'isLoading', false);\n\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case ConsignmentActionType.LoadShippingOptionsFailed:\n return objectSet(statuses, 'isLoadingShippingOptions', false);\n\n case ConsignmentActionType.CreateConsignmentsRequested:\n return objectSet(statuses, 'isCreating', true);\n\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.CreateConsignmentsFailed:\n return objectSet(statuses, 'isCreating', false);\n\n case ConsignmentActionType.UpdateConsignmentRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdating: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.UpdateConsignmentFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdating: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.DeleteConsignmentRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isDeleting: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isDeleting: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateShippingOptionRequested:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdatingShippingOption: {\n [action.meta.id]: true,\n },\n });\n }\n\n return statuses;\n\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.UpdateShippingOptionFailed:\n if (action.meta) {\n return objectMerge(statuses, {\n isUpdatingShippingOption: {\n [action.meta.id]: false,\n },\n });\n }\n\n return statuses;\n\n default:\n return statuses;\n }\n}\n","/**\n * Takes a nested object and flattens it.\n */\nexport default function objectFlatten(\n object: { [ key: string ]: any },\n parent?: string\n): { [ key: string ]: any } {\n const flattened: {[key: string]: any} = {};\n Object.keys(object).forEach((key: string) => {\n const value = object[key];\n const keyString = parent ? parent + '.' + key : key;\n if (typeof value === 'object') {\n Object.assign(flattened, objectFlatten(value, keyString));\n } else {\n flattened[keyString] = value;\n }\n });\n\n return flattened;\n}\n","export default function objectWithSortedKeys(\n object: { [ key: string ]: any }\n) {\n const keys = Object.keys(object);\n const sortedKeys = keys.sort();\n\n const sortedArray = sortedKeys.reduce((previous, current) => ({\n ...previous,\n [current]: object[current],\n }), {});\n\n return sortedArray;\n}\n","import { PickupOptionQueryMap } from './pickup-option';\n\nexport default interface PickupOptionState {\n data?: PickupOptionQueryMap;\n errors: PickupOptionErrorsState;\n statuses: PickupOptionStatusesState;\n}\n\nexport interface PickupOptionErrorsState {\n loadError?: Error;\n}\n\nexport interface PickupOptionStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: PickupOptionState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Country } from '../geography';\n\nexport enum ShippingCountryActionType {\n LoadShippingCountriesRequested = 'LOAD_SHIPPING_COUNTRIES_REQUESTED',\n LoadShippingCountriesSucceeded = 'LOAD_SHIPPING_COUNTRIES_SUCCEEDED',\n LoadShippingCountriesFailed = 'LOAD_SHIPPING_COUNTRIES_FAILED',\n}\n\nexport type LoadShippingCountriesAction = LoadShippingCountriesRequestedAction |\n LoadShippingCountriesSucceededAction |\n LoadShippingCountriesFailedAction;\n\nexport interface LoadShippingCountriesRequestedAction extends Action {\n type: ShippingCountryActionType.LoadShippingCountriesRequested;\n}\n\nexport interface LoadShippingCountriesSucceededAction extends Action<Country[]> {\n type: ShippingCountryActionType.LoadShippingCountriesSucceeded;\n}\n\nexport interface LoadShippingCountriesFailedAction extends Action<Error> {\n type: ShippingCountryActionType.LoadShippingCountriesFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectFlatten, objectSet, objectWithSortedKeys } from '../common/utility';\n\nimport { PickupOptionQueryMap } from './pickup-option';\nimport { LoadPickupOptionsAction, PickupOptionActionType } from './pickup-option-actions';\nimport PickupOptionState, { DEFAULT_STATE, PickupOptionErrorsState, PickupOptionStatusesState } from './pickup-option-state';\n\nexport default function pickupOptionReducer(\n state: PickupOptionState = DEFAULT_STATE,\n action: Action\n): PickupOptionState {\n const reducer = combineReducers<PickupOptionState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: PickupOptionQueryMap | undefined,\n action: LoadPickupOptionsAction\n): PickupOptionQueryMap | undefined {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n if (action.meta) {\n const optionQuery = {\n consignmentId: action.meta.consignmentId,\n searchArea: action.meta.searchArea,\n };\n const flattenedMeta = objectFlatten(optionQuery);\n const sortedflattenedMeta = objectWithSortedKeys(flattenedMeta);\n const keyString = btoa(`${JSON.stringify(sortedflattenedMeta)}`);\n\n return objectSet(data, keyString , action.payload);\n }\n break;\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: PickupOptionErrorsState = DEFAULT_STATE.errors,\n action: Action\n) {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsRequested:\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case PickupOptionActionType.LoadPickupOptionsFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: PickupOptionStatusesState = DEFAULT_STATE.statuses,\n action: Action\n) {\n switch (action.type) {\n case PickupOptionActionType.LoadPickupOptionsRequested:\n return objectSet(statuses, 'isLoading', true);\n case PickupOptionActionType.LoadPickupOptionsSucceeded:\n case PickupOptionActionType.LoadPickupOptionsFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","import { Country } from '../geography';\n\nexport default interface ShippingCountryState {\n data?: Country[];\n errors: ShippingCountryErrorsState;\n statuses: ShippingCountryStatusesState;\n}\n\nexport interface ShippingCountryErrorsState {\n loadError?: Error;\n}\n\nexport interface ShippingCountryStatusesState {\n isLoading?: boolean;\n}\n\nexport const DEFAULT_STATE: ShippingCountryState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nexport enum ShippingStrategyActionType {\n UpdateAddressFailed = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED',\n UpdateAddressRequested = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED',\n UpdateAddressSucceeded = 'SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED',\n SelectOptionFailed = 'SHIPPING_STRATEGY_SELECT_OPTION_FAILED',\n SelectOptionRequested = 'SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED',\n SelectOptionSucceeded = 'SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED',\n InitializeFailed = 'SHIPPING_STRATEGY_INITIALIZE_FAILED',\n InitializeRequested = 'SHIPPING_STRATEGY_INITIALIZE_REQUESTED',\n InitializeSucceeded = 'SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED',\n DeinitializeFailed = 'SHIPPING_STRATEGY_DEINITIALIZE_FAILED',\n DeinitializeRequested = 'SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED',\n DeinitializeSucceeded = 'SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED',\n WidgetInteractionStarted = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED',\n WidgetInteractionFinished = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED',\n WidgetInteractionFailed = 'SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED',\n}\n\nexport type ShippingStrategyAction =\n ShippingStrategyUpdateAddressAction |\n ShippingStrategySelectOptionAction |\n ShippingStrategyInitializeAction |\n ShippingStrategyDeinitializeAction |\n ShippingStrategyWidgetAction;\n\nexport type ShippingStrategyUpdateAddressAction =\n UpdateAddressRequestedAction |\n UpdateAddressSucceededAction |\n UpdateAddressFailedAction;\n\nexport type ShippingStrategySelectOptionAction =\n SelectOptionRequestedAction |\n SelectOptionSucceededAction |\n SelectOptionFailedAction;\n\nexport type ShippingStrategyInitializeAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction;\n\nexport type ShippingStrategyDeinitializeAction =\n DeinitializeRequestedAction |\n DeinitializeSucceededAction |\n DeinitializeFailedAction;\n\nexport type ShippingStrategyWidgetAction =\n WidgetInteractionStartedAction |\n WidgetInteractionFinishedAction |\n WidgetInteractionFailedAction;\n\nexport interface UpdateAddressRequestedAction extends Action {\n type: ShippingStrategyActionType.UpdateAddressRequested;\n}\n\nexport interface UpdateAddressSucceededAction extends Action {\n type: ShippingStrategyActionType.UpdateAddressSucceeded;\n}\n\nexport interface UpdateAddressFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.UpdateAddressFailed;\n}\n\nexport interface SelectOptionRequestedAction extends Action {\n type: ShippingStrategyActionType.SelectOptionRequested;\n}\n\nexport interface SelectOptionSucceededAction extends Action {\n type: ShippingStrategyActionType.SelectOptionSucceeded;\n}\n\nexport interface SelectOptionFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.SelectOptionFailed;\n}\n\nexport interface InitializeRequestedAction extends Action {\n type: ShippingStrategyActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: ShippingStrategyActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.InitializeFailed;\n}\n\nexport interface DeinitializeRequestedAction extends Action {\n type: ShippingStrategyActionType.DeinitializeRequested;\n}\n\nexport interface DeinitializeSucceededAction extends Action {\n type: ShippingStrategyActionType.DeinitializeSucceeded;\n}\n\nexport interface DeinitializeFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.DeinitializeFailed;\n}\n\nexport interface WidgetInteractionStartedAction extends Action {\n type: ShippingStrategyActionType.WidgetInteractionStarted;\n}\n\nexport interface WidgetInteractionFinishedAction extends Action {\n type: ShippingStrategyActionType.WidgetInteractionFinished;\n}\n\nexport interface WidgetInteractionFailedAction extends Action<Error> {\n type: ShippingStrategyActionType.WidgetInteractionFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { arrayReplace, objectSet } from '../common/utility';\nimport { Country } from '../geography';\n\nimport { LoadShippingCountriesAction, ShippingCountryActionType } from './shipping-country-actions';\nimport ShippingCountryState, { DEFAULT_STATE, ShippingCountryErrorsState, ShippingCountryStatusesState } from './shipping-country-state';\n\nexport default function shippingCountryReducer(\n state: ShippingCountryState = DEFAULT_STATE,\n action: Action\n): ShippingCountryState {\n const reducer = combineReducers<ShippingCountryState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: Country[] | undefined,\n action: LoadShippingCountriesAction\n): Country[] | undefined {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n return arrayReplace(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: ShippingCountryErrorsState = DEFAULT_STATE.errors,\n action: LoadShippingCountriesAction\n): ShippingCountryErrorsState {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesRequested:\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case ShippingCountryActionType.LoadShippingCountriesFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ShippingCountryStatusesState = DEFAULT_STATE.statuses,\n action: LoadShippingCountriesAction\n): ShippingCountryStatusesState {\n switch (action.type) {\n case ShippingCountryActionType.LoadShippingCountriesRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case ShippingCountryActionType.LoadShippingCountriesSucceeded:\n case ShippingCountryActionType.LoadShippingCountriesFailed:\n return objectSet(statuses, 'isLoading', false);\n\n default:\n return statuses;\n }\n}\n","export default interface ShippingStrategyState {\n data: ShippingStrategyDataState;\n errors: ShippingStrategyErrorsState;\n statuses: ShippingStrategyStatusesState;\n}\n\nexport interface ShippingStrategyDataState {\n [key: string]: {\n isInitialized: boolean;\n };\n}\n\nexport interface ShippingStrategyErrorsState {\n deinitializeError?: Error;\n deinitializeMethodId?: string;\n initializeError?: Error;\n initializeMethodId?: string;\n updateAddressError?: Error;\n updateAddressMethodId?: string;\n selectOptionError?: Error;\n selectOptionMethodId?: string;\n widgetInteractionError?: Error;\n widgetInteractionMethodId?: string;\n}\n\nexport interface ShippingStrategyStatusesState {\n deinitializeMethodId?: string;\n initializeMethodId?: string;\n isDeinitializing?: boolean;\n isInitializing?: boolean;\n isUpdatingAddress?: boolean;\n isSelectingOption?: boolean;\n updateAddressMethodId?: string;\n selectOptionMethodId?: string;\n isWidgetInteracting?: boolean;\n widgetInteractionMethodId?: string;\n}\n\nexport const DEFAULT_STATE: ShippingStrategyState = {\n data: {},\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { SignInEmail } from './signin-email';\n\nexport enum SignInEmailActionType {\n SendSignInEmailRequested = 'SEND_SIGNIN_EMAIL_REQUESTED',\n SendSignInEmailSucceeded = 'SEND_SIGNIN_EMAIL_SUCCEEDED',\n SendSignInEmailFailed = 'SEND_SIGNIN_EMAIL_FAILED',\n}\nexport type SendSignInEmailAction =\n SendSignInEmailRequestedAction |\n SendSignInEmailSucceededAction |\n SendSignInEmailFailedAction;\n\nexport interface SendSignInEmailRequestedAction extends Action {\n type: SignInEmailActionType.SendSignInEmailRequested;\n}\n\nexport interface SendSignInEmailSucceededAction extends Action<SignInEmail> {\n type: SignInEmailActionType.SendSignInEmailSucceeded;\n}\n\nexport interface SendSignInEmailFailedAction extends Action<Error> {\n type: SignInEmailActionType.SendSignInEmailFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge } from '../common/utility';\n\nimport { ShippingStrategyAction, ShippingStrategyActionType } from './shipping-strategy-actions';\nimport ShippingStrategyState, { DEFAULT_STATE, ShippingStrategyDataState, ShippingStrategyErrorsState, ShippingStrategyStatusesState } from './shipping-strategy-state';\n\nexport default function shippingStrategyReducer(\n state: ShippingStrategyState = DEFAULT_STATE,\n action: Action\n): ShippingStrategyState {\n const reducer = combineReducers<ShippingStrategyState, ShippingStrategyAction>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: ShippingStrategyDataState = DEFAULT_STATE.data,\n action: ShippingStrategyAction\n): ShippingStrategyDataState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: true,\n },\n });\n\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(data, {\n [action.meta && action.meta.methodId]: {\n isInitialized: false,\n },\n });\n }\n\n return data;\n}\n\nfunction errorsReducer(\n errors: ShippingStrategyErrorsState = DEFAULT_STATE.errors,\n action: ShippingStrategyAction\n): ShippingStrategyErrorsState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeRequested:\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(errors, {\n initializeError: undefined,\n initializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.InitializeFailed:\n return objectMerge(errors, {\n initializeError: action.payload,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.DeinitializeRequested:\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(errors, {\n deinitializeError: undefined,\n deinitializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.DeinitializeFailed:\n return objectMerge(errors, {\n deinitializeError: action.payload,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.UpdateAddressRequested:\n case ShippingStrategyActionType.UpdateAddressSucceeded:\n return objectMerge(errors, {\n updateAddressError: undefined,\n updateAddressMethodId: undefined,\n });\n\n case ShippingStrategyActionType.UpdateAddressFailed:\n return objectMerge(errors, {\n updateAddressError: action.payload,\n updateAddressMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.SelectOptionRequested:\n case ShippingStrategyActionType.SelectOptionSucceeded:\n return objectMerge(errors, {\n selectOptionError: undefined,\n selectOptionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.SelectOptionFailed:\n return objectMerge(errors, {\n selectOptionError: action.payload,\n selectOptionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.WidgetInteractionStarted:\n case ShippingStrategyActionType.WidgetInteractionFinished:\n return objectMerge(errors, {\n widgetInteractionError: undefined,\n widgetInteractionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.WidgetInteractionFailed:\n return objectMerge(errors, {\n widgetInteractionError: action.payload,\n widgetInteractionMethodId: action.meta && action.meta.methodId,\n });\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: ShippingStrategyStatusesState = DEFAULT_STATE.statuses,\n action: ShippingStrategyAction\n): ShippingStrategyStatusesState {\n switch (action.type) {\n case ShippingStrategyActionType.InitializeRequested:\n return objectMerge(statuses, {\n isInitializing: true,\n initializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.InitializeFailed:\n case ShippingStrategyActionType.InitializeSucceeded:\n return objectMerge(statuses, {\n isInitializing: false,\n initializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.DeinitializeRequested:\n return objectMerge(statuses, {\n isDeinitializing: true,\n deinitializeMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.DeinitializeFailed:\n case ShippingStrategyActionType.DeinitializeSucceeded:\n return objectMerge(statuses, {\n isDeinitializing: false,\n deinitializeMethodId: undefined,\n });\n\n case ShippingStrategyActionType.UpdateAddressRequested:\n return objectMerge(statuses, {\n isUpdatingAddress: true,\n updateAddressMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.UpdateAddressFailed:\n case ShippingStrategyActionType.UpdateAddressSucceeded:\n return objectMerge(statuses, {\n isUpdatingAddress: false,\n updateAddressMethodId: undefined,\n });\n\n case ShippingStrategyActionType.SelectOptionRequested:\n return objectMerge(statuses, {\n isSelectingOption: true,\n selectOptionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.SelectOptionFailed:\n case ShippingStrategyActionType.SelectOptionSucceeded:\n return objectMerge(statuses, {\n isSelectingOption: false,\n selectOptionMethodId: undefined,\n });\n\n case ShippingStrategyActionType.WidgetInteractionStarted:\n return objectMerge(statuses, {\n isWidgetInteracting: true,\n widgetInteractionMethodId: action.meta && action.meta.methodId,\n });\n\n case ShippingStrategyActionType.WidgetInteractionFinished:\n case ShippingStrategyActionType.WidgetInteractionFailed:\n return objectMerge(statuses, {\n isWidgetInteracting: false,\n widgetInteractionMethodId: undefined,\n });\n\n default:\n return statuses;\n }\n}\n","import { SignInEmail } from './signin-email';\n\nexport default interface SignInEmailState {\n data?: SignInEmail;\n errors: SignInEmailErrorsState;\n statuses: SignInEmailStatusesState;\n}\n\nexport interface SignInEmailErrorsState {\n sendError?: Error;\n}\n\nexport interface SignInEmailStatusesState {\n isSending?: boolean;\n}\n\nexport const DEFAULT_STATE: SignInEmailState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport enum StoreCreditActionType {\n ApplyStoreCreditRequested = 'APPLY_STORE_CREDIT_REQUESTED',\n ApplyStoreCreditSucceeded = 'APPLY_STORE_CREDIT_SUCCEEDED',\n ApplyStoreCreditFailed = 'APPLY_STORE_CREDIT_FAILED',\n}\n\nexport type StoreCreditAction =\n ApplyStoreCreditAction;\n\nexport type ApplyStoreCreditAction =\n ApplyStoreCreditRequestedAction |\n ApplyStoreCreditSucceededAction |\n ApplyStoreCreditFailedAction;\n\nexport interface ApplyStoreCreditRequestedAction extends Action {\n type: StoreCreditActionType.ApplyStoreCreditRequested;\n}\n\nexport interface ApplyStoreCreditSucceededAction extends Action<Checkout> {\n type: StoreCreditActionType.ApplyStoreCreditSucceeded;\n}\n\nexport interface ApplyStoreCreditFailedAction extends Action<RequestError<StorefrontErrorResponseBody>> {\n type: StoreCreditActionType.ApplyStoreCreditFailed;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\n\nimport { SignInEmail } from './signin-email';\nimport { SendSignInEmailAction, SignInEmailActionType } from './signin-email-actions';\nimport SignInEmailState, { DEFAULT_STATE, SignInEmailErrorsState, SignInEmailStatusesState } from './signin-email-state';\n\nexport default function signInEmailReducer(\n state: SignInEmailState = DEFAULT_STATE,\n action: Action\n): SignInEmailState {\n const reducer = combineReducers<SignInEmailState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: SignInEmail | undefined,\n action: SendSignInEmailAction\n): SignInEmail | undefined {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectMerge(data, action.payload);\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: SignInEmailErrorsState = DEFAULT_STATE.errors,\n action: SendSignInEmailAction\n): SignInEmailErrorsState {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailRequested:\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectSet(errors, 'sendError', undefined);\n\n case SignInEmailActionType.SendSignInEmailFailed:\n return objectSet(errors, 'sendError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: SignInEmailStatusesState = DEFAULT_STATE.statuses,\n action: SendSignInEmailAction\n): SignInEmailStatusesState {\n switch (action.type) {\n case SignInEmailActionType.SendSignInEmailRequested:\n return objectSet(statuses, 'isSending', true);\n\n case SignInEmailActionType.SendSignInEmailFailed:\n case SignInEmailActionType.SendSignInEmailSucceeded:\n return objectSet(statuses, 'isSending', false);\n default:\n return statuses;\n }\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet } from '../common/utility';\n\nimport { StoreCreditAction, StoreCreditActionType } from './store-credit-actions';\nimport StoreCreditState, { StoreCreditErrorsState, StoreCreditStatusesState } from './store-credit-state';\n\nconst DEFAULT_STATE: StoreCreditState = {\n errors: {},\n statuses: {},\n};\n\nexport default function storeCreditReducer(\n state: StoreCreditState = DEFAULT_STATE,\n action: Action\n): StoreCreditState {\n const reducer = combineReducers<StoreCreditState>({\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction errorsReducer(\n errors: StoreCreditErrorsState = DEFAULT_STATE.errors,\n action: StoreCreditAction\n): StoreCreditErrorsState {\n switch (action.type) {\n case StoreCreditActionType.ApplyStoreCreditRequested:\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n return objectSet(errors, 'applyError', undefined);\n\n case StoreCreditActionType.ApplyStoreCreditFailed:\n return objectSet(errors, 'applyError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: StoreCreditStatusesState = DEFAULT_STATE.statuses,\n action: StoreCreditAction\n): StoreCreditStatusesState {\n switch (action.type) {\n case StoreCreditActionType.ApplyStoreCreditRequested:\n return objectSet(statuses, 'isApplying', true);\n\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n case StoreCreditActionType.ApplyStoreCreditFailed:\n return objectSet(statuses, 'isApplying', false);\n\n default:\n return statuses;\n }\n}\n","export default interface SubscriptionsState {\n errors: SubscriptionsErrorsState;\n statuses: SubscriptionsStatusesState;\n}\n\nexport interface SubscriptionsErrorsState {\n updateError?: Error;\n}\n\nexport interface SubscriptionsStatusesState {\n isUpdating?: boolean;\n}\n\nexport const DEFAULT_STATE: SubscriptionsState = {\n errors: {},\n statuses: {},\n};\n","import { Action } from '@bigcommerce/data-store';\n\nimport { Checkout } from '../checkout';\n\nexport enum SpamProtectionActionType {\n InitializeFailed = 'SPAM_PROTECTION_INITIALIZE_FAILED',\n InitializeSucceeded = 'SPAM_PROTECTION_INITIALIZE_SUCCEEDED',\n InitializeRequested = 'SPAM_PROTECTION_INITIALIZE_REQUESTED',\n VerifyCheckoutRequested = 'SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED',\n VerifyCheckoutSucceeded = 'SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED',\n VerifyCheckoutFailed = 'SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED',\n ExecuteRequested = 'SPAM_PROTECTION_EXECUTE_REQUESTED',\n ExecuteSucceeded = 'SPAM_PROTECTION_EXECUTE_SUCCEEDED',\n ExecuteFailed = 'SPAM_PROTECTION_EXECUTE_FAILED',\n}\n\nexport type SpamProtectionAction =\n InitializeRequestedAction |\n InitializeSucceededAction |\n InitializeFailedAction |\n ExecuteRequestedAction |\n ExecuteSucceededAction |\n ExecuteFailedAction |\n CheckoutVerifyRequestedAction |\n CheckoutVerifyFailedAction |\n CheckoutVerifySucceededAction;\n\nexport interface InitializeRequestedAction extends Action {\n type: SpamProtectionActionType.InitializeRequested;\n}\n\nexport interface InitializeSucceededAction extends Action {\n type: SpamProtectionActionType.InitializeSucceeded;\n}\n\nexport interface InitializeFailedAction extends Action<Error> {\n type: SpamProtectionActionType.InitializeFailed;\n}\n\nexport interface ExecuteRequestedAction extends Action {\n type: SpamProtectionActionType.ExecuteRequested;\n}\n\nexport interface ExecuteSucceededAction extends Action<{ token: string }> {\n type: SpamProtectionActionType.ExecuteSucceeded;\n}\n\nexport interface ExecuteFailedAction extends Action {\n type: SpamProtectionActionType.ExecuteFailed;\n}\n\nexport interface CheckoutVerifyRequestedAction extends Action {\n type: SpamProtectionActionType.VerifyCheckoutRequested;\n}\n\nexport interface CheckoutVerifyFailedAction extends Action<Error> {\n type: SpamProtectionActionType.VerifyCheckoutFailed;\n}\n\nexport interface CheckoutVerifySucceededAction extends Action<Checkout> {\n type: SpamProtectionActionType.VerifyCheckoutSucceeded;\n}\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\n\nimport { clearErrorReducer } from '../common/error';\nimport { objectSet } from '../common/utility';\nimport { SubscriptionsActionType, UpdateSubscriptionsAction } from '../subscription';\n\nimport SubscriptionsState, { DEFAULT_STATE, SubscriptionsErrorsState, SubscriptionsStatusesState } from './subscriptions-state';\n\nexport default function subscriptionsReducer(\n state: SubscriptionsState = DEFAULT_STATE,\n action: Action\n): SubscriptionsState {\n const reducer = combineReducers<SubscriptionsState>({\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction errorsReducer(\n errors: SubscriptionsErrorsState = DEFAULT_STATE.errors,\n action: UpdateSubscriptionsAction\n): SubscriptionsErrorsState {\n switch (action.type) {\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: SubscriptionsStatusesState = DEFAULT_STATE.statuses,\n action: UpdateSubscriptionsAction\n): SubscriptionsStatusesState {\n switch (action.type) {\n case SubscriptionsActionType.UpdateSubscriptionsRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case SubscriptionsActionType.UpdateSubscriptionsFailed:\n case SubscriptionsActionType.UpdateSubscriptionsSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n default:\n return statuses;\n }\n}\n","import { Omit } from '../common/types';\n\nimport Checkout from './checkout';\n\nexport default interface CheckoutState {\n data?: CheckoutDataState;\n errors: CheckoutErrorsState;\n statuses: CheckoutStatusesState;\n}\n\nexport type CheckoutDataState = Omit<Checkout, 'billingAddress' | 'cart' | 'consignments' | 'coupons' | 'giftCertificates'>;\n\nexport interface CheckoutErrorsState {\n loadError?: Error;\n updateError?: Error;\n}\n\nexport interface CheckoutStatusesState {\n isExecutingSpamCheck?: boolean;\n isLoading?: boolean;\n isUpdating?: boolean;\n}\n\nexport const DEFAULT_STATE: CheckoutState = {\n errors: {},\n statuses: {},\n};\n","import { combineReducers, composeReducers, Action } from '@bigcommerce/data-store';\nimport { omit } from 'lodash';\n\nimport { BillingAddressAction, BillingAddressActionType } from '../billing';\nimport { clearErrorReducer } from '../common/error';\nimport { objectMerge, objectSet } from '../common/utility';\nimport { CouponAction, CouponActionType, GiftCertificateAction, GiftCertificateActionType } from '../coupon';\nimport { OrderAction, OrderActionType } from '../order';\nimport { ConsignmentAction, ConsignmentActionType } from '../shipping';\nimport { SpamProtectionAction, SpamProtectionActionType } from '../spam-protection';\nimport { StoreCreditAction, StoreCreditActionType } from '../store-credit';\n\nimport { CheckoutAction, CheckoutActionType } from './checkout-actions';\nimport CheckoutState, { CheckoutDataState, CheckoutErrorsState, CheckoutStatusesState, DEFAULT_STATE } from './checkout-state';\n\nexport default function checkoutReducer(\n state: CheckoutState = DEFAULT_STATE,\n action: Action\n): CheckoutState {\n const reducer = combineReducers<CheckoutState>({\n data: dataReducer,\n errors: composeReducers(errorsReducer, clearErrorReducer),\n statuses: statusesReducer,\n });\n\n return reducer(state, action);\n}\n\nfunction dataReducer(\n data: CheckoutDataState | undefined,\n action: CheckoutAction | BillingAddressAction | ConsignmentAction | CouponAction |\n GiftCertificateAction | OrderAction | SpamProtectionAction | StoreCreditAction\n): CheckoutDataState | undefined {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutSucceeded:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n case StoreCreditActionType.ApplyStoreCreditSucceeded:\n case BillingAddressActionType.UpdateBillingAddressSucceeded:\n case CouponActionType.ApplyCouponSucceeded:\n case CouponActionType.RemoveCouponSucceeded:\n case ConsignmentActionType.CreateConsignmentsSucceeded:\n case ConsignmentActionType.UpdateConsignmentSucceeded:\n case ConsignmentActionType.DeleteConsignmentSucceeded:\n case ConsignmentActionType.UpdateShippingOptionSucceeded:\n case ConsignmentActionType.LoadShippingOptionsSucceeded:\n case GiftCertificateActionType.ApplyGiftCertificateSucceeded:\n case GiftCertificateActionType.RemoveGiftCertificateSucceeded:\n case SpamProtectionActionType.VerifyCheckoutSucceeded:\n return objectMerge(data, omit(action.payload, [\n 'billingAddress',\n 'cart',\n 'consignments',\n 'customer',\n 'coupons',\n 'giftCertificates',\n ])) as CheckoutDataState;\n\n case OrderActionType.SubmitOrderSucceeded:\n return objectSet(data, 'orderId', action.payload && action.payload.order.orderId) ;\n\n default:\n return data;\n }\n}\n\nfunction errorsReducer(\n errors: CheckoutErrorsState = DEFAULT_STATE.errors,\n action: CheckoutAction | OrderAction\n): CheckoutErrorsState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(errors, 'loadError', undefined);\n\n case CheckoutActionType.LoadCheckoutFailed:\n return objectSet(errors, 'loadError', action.payload);\n\n case CheckoutActionType.UpdateCheckoutRequested:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n return objectSet(errors, 'updateError', undefined);\n\n case CheckoutActionType.UpdateCheckoutFailed:\n return objectSet(errors, 'updateError', action.payload);\n\n default:\n return errors;\n }\n}\n\nfunction statusesReducer(\n statuses: CheckoutStatusesState = DEFAULT_STATE.statuses,\n action: CheckoutAction | OrderAction | SpamProtectionAction\n): CheckoutStatusesState {\n switch (action.type) {\n case CheckoutActionType.LoadCheckoutRequested:\n return objectSet(statuses, 'isLoading', true);\n\n case CheckoutActionType.LoadCheckoutFailed:\n case CheckoutActionType.LoadCheckoutSucceeded:\n return objectSet(statuses, 'isLoading', false);\n\n case CheckoutActionType.UpdateCheckoutRequested:\n return objectSet(statuses, 'isUpdating', true);\n\n case CheckoutActionType.UpdateCheckoutFailed:\n case CheckoutActionType.UpdateCheckoutSucceeded:\n return objectSet(statuses, 'isUpdating', false);\n\n case SpamProtectionActionType.ExecuteRequested:\n return objectSet(statuses, 'isExecutingSpamCheck', true);\n\n case SpamProtectionActionType.ExecuteFailed:\n case SpamProtectionActionType.ExecuteSucceeded:\n return objectSet(statuses, 'isExecutingSpamCheck', false);\n\n default:\n return statuses;\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/memoize\");","import StandardError from './standard-error';\n\nexport enum MissingDataErrorType {\n MissingBillingAddress,\n MissingCart,\n MissingCheckout,\n MissingConsignments,\n MissingCustomer,\n MissingCheckoutConfig,\n MissingOrder,\n MissingOrderConfig,\n MissingOrderId,\n MissingPayment,\n MissingPaymentId,\n MissingPaymentInstrument,\n MissingPaymentMethod,\n MissingPaymentRedirectUrl,\n MissingPaymentStatus,\n MissingPaymentToken,\n MissingShippingAddress,\n}\n\n/**\n * Throw this error when data that is expected to exist is missing. Usually it\n * is due to the fact that certain data has not been retrieved from or saved to\n * the server yet. And such data is required to perform certain actions.\n */\nexport default class MissingDataError extends StandardError {\n constructor(\n public subtype: MissingDataErrorType\n ) {\n super(getErrorMessage(subtype));\n\n this.name = 'MissingDataError';\n this.type = 'missing_data';\n }\n}\n\nfunction getErrorMessage(type: MissingDataErrorType): string {\n switch (type) {\n case MissingDataErrorType.MissingBillingAddress:\n return 'Unable to proceed because billing address data is unavailable.';\n\n case MissingDataErrorType.MissingCart:\n return 'Unable to proceed because cart data is unavailable.';\n\n case MissingDataErrorType.MissingConsignments:\n return 'Unable to proceed because consignments data is unavailable.';\n\n case MissingDataErrorType.MissingCheckout:\n return 'Unable to proceed because checkout data is unavailable.';\n\n case MissingDataErrorType.MissingCustomer:\n return 'Unable to proceed because customer data is unavailable.';\n\n case MissingDataErrorType.MissingCheckoutConfig:\n case MissingDataErrorType.MissingOrderConfig:\n return 'Unable to proceed because configuration data is unavailable.';\n\n case MissingDataErrorType.MissingOrder:\n return 'Unable to proceed because order data is unavailable.';\n\n case MissingDataErrorType.MissingOrderId:\n return 'Unable to proceed because order ID is unavailable or not generated yet.';\n\n case MissingDataErrorType.MissingPayment:\n return 'Unable to proceed because payment data is unavailable.';\n\n case MissingDataErrorType.MissingPaymentToken:\n return 'Unable to proceed because the token required to submit a payment is missing.';\n\n case MissingDataErrorType.MissingPaymentMethod:\n return 'Unable to proceed because payment method data is unavailable or not properly configured.';\n\n case MissingDataErrorType.MissingShippingAddress:\n return 'Unable to proceed because shipping address data is unavailable.';\n\n default:\n return 'Unable to proceed because the required data is unavailable.';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"reselect\");","import { createSelector as defaultSelectorCreator } from 'reselect';\n\nimport withMemoizedCombiner from './with-memoized-combiner';\n\n/**\n * This is a decorated version of Reselect's default `createSelector` function.\n * If the return value of the combiner function is a function, it will create a\n * memorized version of that function and return it instead.\n */\nexport default withMemoizedCombiner(defaultSelectorCreator);\n","import { memoize } from '@bigcommerce/memoize';\nimport { createSelector as defaultSelectorCreator } from 'reselect';\n\n/**\n * Decorate selector creators with the ability to memoize the return value of\n * their combiner if it is a function (which effectively works as a partially\n * applied combiner).\n */\nexport default function withMemoizedCombiner<T extends typeof defaultSelectorCreator>(\n creator: T\n): T {\n return ((...args: any[]) => {\n const combiner = args.pop();\n\n // Reselect's default `createSelector` has many overloads. To avoid having\n // to redefine all of them, we're using `any` to bypass the typechecker.\n return (creator as any)(...args, (...combinerArgs: any[]) => {\n // Although there are many overloads, all of them have the last argument\n // as the combiner.\n const result = combiner(...combinerArgs);\n\n if (typeof result === 'function') {\n return memoize(result);\n }\n\n return result;\n });\n }) as T;\n}\n","export default function guard<T>(value: T, errorFactory?: () => Error): NonNullable<T> {\n if (value === undefined || value === null) {\n throw errorFactory ? errorFactory() : new Error('An unexpected error has occurred.');\n }\n\n return value as NonNullable<T>;\n}\n","import { deepFreeze } from '@bigcommerce/data-store';\n\n// tslint:disable-next-line:ban-types\ntype FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? T[K] : never };\n\nexport default function createFreezeProxy<T extends object>(target: T): T {\n return createProxy(target, (target, name) =>\n (...args: any[]) => deepFreeze(target[name].call(target, ...args))\n );\n}\n\nexport function createFreezeProxies<T extends object, TMap extends { [key: string]: T }>(map: TMap): TMap {\n return Object.keys(map)\n .reduce((result, key) => {\n result[key] = createFreezeProxy(map[key]);\n\n return result;\n }, {} as { [key: string]: T }) as TMap;\n}\n\nfunction createProxy<T extends object>(target: T, trap: (target: FunctionProperties<T>, name: keyof FunctionProperties<T>, proxy: T) => any): T {\n const proxy = Object.create(target);\n\n traversePrototypeOf(target, prototype => {\n Object.getOwnPropertyNames(prototype)\n .forEach(name => {\n if (name === 'constructor' || typeof proxy[name] !== 'function' || name.charAt(0) === '_') {\n return;\n }\n\n proxy[name] = trap(target as FunctionProperties<T>, name as keyof T, proxy);\n });\n });\n\n return proxy;\n}\n\nfunction traversePrototypeOf(target: object, iteratee: (prototype: object) => void): void {\n let prototype = Object.getPrototypeOf(target);\n\n while (prototype) {\n iteratee(prototype);\n\n prototype = Object.getPrototypeOf(prototype);\n }\n}\n","import PaymentInstrument from './instrument';\n\ninterface SupportedInstruments {\n [key: string]: Pick<PaymentInstrument, 'method' | 'provider'>;\n}\n\nconst supportedInstruments: SupportedInstruments = {\n 'mollie.credit_card': {\n provider: 'mollie',\n method: 'credit_card',\n },\n 'adyenv2.scheme': {\n provider: 'adyenv2',\n method: 'scheme',\n },\n 'adyenv3.scheme': {\n provider: 'adyenv3',\n method: 'scheme',\n },\n 'adyenv2.bcmc': {\n provider: 'adyenv2',\n method: 'bcmc',\n },\n 'adyenv2.ideal': {\n provider: 'adyenv2',\n method: 'ideal',\n },\n 'adyenv2.sepadirectdebit': {\n provider: 'adyenv2',\n method: 'sepadirectdebit',\n },\n 'adyenv2.directEbanking': {\n provider: 'adyenv2',\n method: 'directEbanking',\n },\n 'adyenv2.giropay': {\n provider: 'adyenv2',\n method: 'giropay',\n },\n barclays: {\n provider: 'barclays',\n method: 'credit_card',\n },\n braintree: {\n provider: 'braintree',\n method: 'credit_card',\n },\n braintreepaypal: {\n provider: 'braintree',\n method: 'paypal',\n },\n authorizenet: {\n provider: 'authorizenet',\n method: 'credit_card',\n },\n elavon: {\n provider: 'elavon',\n method: 'credit_card',\n },\n checkoutcom: {\n provider: 'checkoutcom',\n method: 'credit_card',\n },\n 'checkoutcom.credit_card': {\n provider: 'checkoutcom',\n method: 'credit_card',\n },\n 'checkoutcom.card': {\n provider: 'checkoutcom',\n method: 'card',\n },\n sagepay: {\n provider: 'sagepay',\n method: 'credit_card',\n },\n stripe: {\n provider: 'stripe',\n method: 'credit_card',\n },\n 'stripev3.card': {\n provider: 'stripev3',\n method: 'card',\n },\n 'stripeupe.card': {\n provider: 'stripeupe',\n method: 'card',\n },\n cybersource: {\n provider: 'cybersource',\n method: 'credit_card',\n },\n cybersourcev2: {\n provider: 'cybersourcev2',\n method: 'credit_card',\n },\n converge: {\n provider: 'converge',\n method: 'credit_card',\n },\n bluesnapv2: {\n provider: 'bluesnapv2',\n method: 'credit_card',\n },\n orbital: {\n provider: 'orbital',\n method: 'credit_card',\n },\n paymetric: {\n provider: 'paymetric',\n method: 'credit_card',\n },\n bolt: {\n provider: 'bolt',\n method: 'credit_card',\n },\n 'barclaycard.credit_card': {\n provider: 'barclaycard',\n method: 'credit_card',\n },\n digitalriver: {\n provider: 'digitalriver',\n method: 'credit_card',\n },\n moneris: {\n provider: 'moneris',\n method: 'credit_card',\n },\n cba_mpgs: {\n provider: 'cba_mpgs',\n method: 'credit_card',\n },\n};\n\nexport default supportedInstruments;\n","import { identity, isEqual, pickBy } from 'lodash';\n\nimport Address from './address';\n\nexport default function isAddressEqual(addressA: Partial<Address>, addressB: Partial<Address>): boolean {\n return isEqual(normalize(addressA), normalize(addressB));\n}\n\nfunction normalize(address: Partial<Address>): Partial<Address> {\n return pickBy({\n firstName: address.firstName,\n lastName: address.lastName,\n company: address.company,\n address1: address.address1,\n address2: address.address2,\n city: address.city,\n stateOrProvince: address.stateOrProvince,\n countryCode: address.countryCode,\n postalCode: address.postalCode,\n phone: address.phone,\n customFields: address.customFields,\n }, identity);\n}\n","import { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\n\nexport default interface StoreCreditState {\n errors: StoreCreditErrorsState;\n statuses: StoreCreditStatusesState;\n}\n\nexport interface StoreCreditErrorsState {\n applyError?: RequestError<StorefrontErrorResponseBody>;\n}\n\nexport interface StoreCreditStatusesState {\n isApplying?: boolean;\n}\n\nexport const DEFAULT_STATE: StoreCreditState = {\n errors: {},\n statuses: {},\n};\n","import { createBillingAddressSelectorFactory } from '../billing';\nimport { createCartSelectorFactory } from '../cart';\nimport { createCheckoutButtonSelectorFactory } from '../checkout-buttons';\nimport { createFreezeProxies } from '../common/utility';\nimport { createConfigSelectorFactory } from '../config';\nimport { createCouponSelectorFactory, createGiftCertificateSelectorFactory } from '../coupon';\nimport { createCustomerSelectorFactory, createCustomerStrategySelectorFactory } from '../customer';\nimport { createFormSelectorFactory } from '../form';\nimport { createCountrySelectorFactory } from '../geography';\nimport { createOrderSelectorFactory } from '../order';\nimport { createPaymentMethodSelectorFactory, createPaymentSelectorFactory, createPaymentStrategySelectorFactory } from '../payment';\nimport { createInstrumentSelectorFactory } from '../payment/instrument';\nimport { createRemoteCheckoutSelectorFactory } from '../remote-checkout';\nimport { createConsignmentSelectorFactory, createPickupOptionSelectorFactory, createShippingAddressSelectorFactory, createShippingCountrySelectorFactory, createShippingStrategySelectorFactory } from '../shipping';\nimport { createSignInEmailSelectorFactory } from '../signin-email';\nimport { createStoreCreditSelectorFactory } from '../store-credit';\nimport { createSubscriptionsSelectorFactory } from '../subscription';\n\nimport { createCheckoutSelectorFactory } from './checkout-selector';\nimport { CheckoutStoreOptions } from './checkout-store';\nimport CheckoutStoreState from './checkout-store-state';\nimport InternalCheckoutSelectors from './internal-checkout-selectors';\n\nexport type InternalCheckoutSelectorsFactory = (\n state: CheckoutStoreState,\n options?: CheckoutStoreOptions\n) => InternalCheckoutSelectors;\n\nexport function createInternalCheckoutSelectorsFactory(): InternalCheckoutSelectorsFactory {\n const createBillingAddressSelector = createBillingAddressSelectorFactory();\n const createCartSelector = createCartSelectorFactory();\n const createCheckoutButtonSelector = createCheckoutButtonSelectorFactory();\n const createConfigSelector = createConfigSelectorFactory();\n const createCountrySelector = createCountrySelectorFactory();\n const createCouponSelector = createCouponSelectorFactory();\n const createCustomerSelector = createCustomerSelectorFactory();\n const createCustomerStrategySelector = createCustomerStrategySelectorFactory();\n const createGiftCertificateSelector = createGiftCertificateSelectorFactory();\n const createInstrumentSelector = createInstrumentSelectorFactory();\n const createFormSelector = createFormSelectorFactory();\n const createPaymentMethodSelector = createPaymentMethodSelectorFactory();\n const createPaymentStrategySelector = createPaymentStrategySelectorFactory();\n const createPickupOptionSelector = createPickupOptionSelectorFactory();\n const createRemoteCheckoutSelector = createRemoteCheckoutSelectorFactory();\n const createShippingAddressSelector = createShippingAddressSelectorFactory();\n const createShippingCountrySelector = createShippingCountrySelectorFactory();\n const createShippingStrategySelector = createShippingStrategySelectorFactory();\n const createConsignmentSelector = createConsignmentSelectorFactory();\n const createCheckoutSelector = createCheckoutSelectorFactory();\n const createOrderSelector = createOrderSelectorFactory();\n const createPaymentSelector = createPaymentSelectorFactory();\n const createStoreCreditSelector = createStoreCreditSelectorFactory();\n const createSubscriptionsSelector = createSubscriptionsSelectorFactory();\n const createSignInEmailSelector = createSignInEmailSelectorFactory();\n\n return (state, options = {}) => {\n const billingAddress = createBillingAddressSelector(state.billingAddress);\n const cart = createCartSelector(state.cart);\n const checkoutButton = createCheckoutButtonSelector(state.checkoutButton);\n const countries = createCountrySelector(state.countries);\n const coupons = createCouponSelector(state.coupons);\n const customer = createCustomerSelector(state.customer);\n const customerStrategies = createCustomerStrategySelector(state.customerStrategies);\n const form = createFormSelector(state.formFields);\n const giftCertificates = createGiftCertificateSelector(state.giftCertificates);\n const instruments = createInstrumentSelector(state.instruments);\n const paymentMethods = createPaymentMethodSelector(state.paymentMethods);\n const paymentStrategies = createPaymentStrategySelector(state.paymentStrategies);\n const pickupOptions = createPickupOptionSelector(state.pickupOptions);\n const remoteCheckout = createRemoteCheckoutSelector(state.remoteCheckout);\n const shippingAddress = createShippingAddressSelector(state.consignments);\n const shippingCountries = createShippingCountrySelector(state.shippingCountries);\n const shippingStrategies = createShippingStrategySelector(state.shippingStrategies);\n const subscriptions = createSubscriptionsSelector(state.subscriptions);\n const storeCredit = createStoreCreditSelector(state.storeCredit);\n const signInEmail = createSignInEmailSelector(state.signInEmail);\n\n // Compose selectors\n const consignments = createConsignmentSelector(state.consignments, cart);\n const checkout = createCheckoutSelector(state.checkout, billingAddress, cart, consignments, coupons, customer, giftCertificates);\n const order = createOrderSelector(state.order, billingAddress, coupons);\n const payment = createPaymentSelector(checkout, order);\n const config = createConfigSelector(state.config, state.formFields);\n\n const selectors = {\n billingAddress,\n cart,\n checkout,\n checkoutButton,\n config,\n consignments,\n countries,\n coupons,\n customer,\n customerStrategies,\n form,\n giftCertificates,\n instruments,\n order,\n payment,\n paymentMethods,\n paymentStrategies,\n pickupOptions,\n remoteCheckout,\n shippingAddress,\n shippingCountries,\n shippingStrategies,\n signInEmail,\n subscriptions,\n storeCredit,\n };\n\n return options.shouldWarnMutation ? createFreezeProxies(selectors) : selectors;\n };\n}\n\nexport default function createInternalCheckoutSelectors(\n state: CheckoutStoreState,\n options?: CheckoutStoreOptions\n): InternalCheckoutSelectors {\n return createInternalCheckoutSelectorsFactory()(state, options);\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport BillingAddress from './billing-address';\nimport BillingAddressState, { DEFAULT_STATE } from './billing-address-state';\n\nexport default interface BillingAddressSelector {\n getBillingAddress(): BillingAddress | undefined;\n getBillingAddressOrThrow(): BillingAddress;\n getUpdateError(): Error | undefined;\n getContinueAsGuestError(): Error | undefined;\n getLoadError(): Error | undefined;\n isUpdating(): boolean;\n isContinuingAsGuest(): boolean;\n isLoading(): boolean;\n}\n\nexport type BillingAddressSelectorFactory = (state: BillingAddressState) => BillingAddressSelector;\n\nexport function createBillingAddressSelectorFactory(): BillingAddressSelectorFactory {\n const getBillingAddress = createSelector(\n (state: BillingAddressState) => state.data,\n data => () => data\n );\n\n const getBillingAddressOrThrow = createSelector(\n getBillingAddress,\n getBillingAddress => () => {\n return guard(getBillingAddress(), () => new MissingDataError(MissingDataErrorType.MissingBillingAddress));\n }\n );\n\n const getUpdateError = createSelector(\n (state: BillingAddressState) => state.errors.updateError,\n error => () => error\n );\n\n const getContinueAsGuestError = createSelector(\n (state: BillingAddressState) => state.errors.continueAsGuestError,\n error => () => error\n );\n\n const getLoadError = createSelector(\n (state: BillingAddressState) => state.errors.loadError,\n error => () => error\n );\n\n const isUpdating = createSelector(\n (state: BillingAddressState) => !!state.statuses.isUpdating,\n status => () => status\n );\n\n const isContinuingAsGuest = createSelector(\n (state: BillingAddressState) => !!state.statuses.isContinuingAsGuest,\n status => () => status\n );\n\n const isLoading = createSelector(\n (state: BillingAddressState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: BillingAddressState = DEFAULT_STATE\n ): BillingAddressSelector => {\n return {\n getBillingAddress: getBillingAddress(state),\n getBillingAddressOrThrow: getBillingAddressOrThrow(state),\n getUpdateError: getUpdateError(state),\n getContinueAsGuestError: getContinueAsGuestError(state),\n getLoadError: getLoadError(state),\n isUpdating: isUpdating(state),\n isContinuingAsGuest: isContinuingAsGuest(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoize, memoizeOne } from '@bigcommerce/memoize';\nimport { find, some, values } from 'lodash';\n\nimport { createSelector } from '../common/selector';\n\nimport CheckoutButtonState, { DEFAULT_STATE } from './checkout-button-state';\nimport { CheckoutButtonMethodType } from './strategies';\n\nexport default interface CheckoutButtonSelector {\n getState(): CheckoutButtonState;\n isInitializing(methodId?: CheckoutButtonMethodType): boolean;\n isInitialized(methodId: CheckoutButtonMethodType, containerId?: string): boolean;\n isDeinitializing(methodId?: CheckoutButtonMethodType): boolean;\n getInitializeError(methodId?: CheckoutButtonMethodType): Error | undefined;\n getDeinitializeError(methodId?: CheckoutButtonMethodType): Error | undefined;\n}\n\nexport type CheckoutButtonSelectorFactory = (state: CheckoutButtonState) => CheckoutButtonSelector;\n\nexport function createCheckoutButtonSelectorFactory(): CheckoutButtonSelectorFactory {\n const getState = createSelector(\n (state: CheckoutButtonState) => state,\n state => () => state\n );\n\n const isInitializing = createSelector(\n (state: CheckoutButtonState) => state.statuses,\n statuses => memoize((methodId?: CheckoutButtonMethodType) => {\n if (methodId) {\n const method = statuses[methodId];\n\n return (method && method.isInitializing) === true;\n }\n\n return some(statuses, { isInitializing: true });\n })\n );\n\n const isInitialized = createSelector(\n (state: CheckoutButtonState) => state.data,\n data => memoize((methodId: CheckoutButtonMethodType, containerId?: string) => {\n const method = data[methodId];\n\n if (!method) {\n return false;\n }\n\n if (!containerId) {\n return some(method.initializedContainers, isInitialized => isInitialized === true);\n }\n\n return method.initializedContainers[containerId] === true;\n })\n );\n\n const isDeinitializing = createSelector(\n (state: CheckoutButtonState) => state.statuses,\n statuses => memoize((methodId?: CheckoutButtonMethodType) => {\n if (methodId) {\n const method = statuses[methodId];\n\n return (method && method.isDeinitializing) === true;\n }\n\n return some(statuses, { isDeinitializing: true });\n })\n );\n\n const getInitializeError = createSelector(\n (state: CheckoutButtonState) => state.errors,\n errors => memoize((methodId?: CheckoutButtonMethodType) => {\n const method = methodId ?\n errors[methodId] :\n find(values(errors), method => !!(method && method.initializeError));\n\n return method && method.initializeError;\n })\n );\n\n const getDeinitializeError = createSelector(\n (state: CheckoutButtonState) => state.errors,\n errors => memoize((methodId?: CheckoutButtonMethodType) => {\n const method = methodId ?\n errors[methodId] :\n find(values(errors), method => !!(method && method.deinitializeError));\n\n return method && method.deinitializeError;\n })\n );\n\n return memoizeOne((\n state: CheckoutButtonState = DEFAULT_STATE\n ): CheckoutButtonSelector => {\n return {\n getState: getState(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isDeinitializing: isDeinitializing(state),\n getInitializeError: getInitializeError(state),\n getDeinitializeError: getDeinitializeError(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport Coupon from './coupon';\nimport CouponState, { DEFAULT_STATE } from './coupon-state';\n\nexport default interface CouponSelector {\n getCoupons(): Coupon[] | undefined;\n getRemoveError(): RequestError | undefined;\n getApplyError(): RequestError | undefined;\n isApplying(): boolean;\n isRemoving(): boolean;\n}\n\nexport type CouponSelectorFactory = (state: CouponState) => CouponSelector;\n\nexport function createCouponSelectorFactory(): CouponSelectorFactory {\n const getCoupons = createSelector(\n (state: CouponState) => state.data,\n data => () => data\n );\n\n const getRemoveError = createSelector(\n (state: CouponState) => state.errors.removeCouponError,\n error => () => error\n );\n\n const getApplyError = createSelector(\n (state: CouponState) => state.errors.applyCouponError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: CouponState) => !!state.statuses.isApplyingCoupon,\n status => () => status\n );\n\n const isRemoving = createSelector(\n (state: CouponState) => !!state.statuses.isRemovingCoupon,\n status => () => status\n );\n\n return memoizeOne((\n state: CouponState = DEFAULT_STATE\n ): CouponSelector => {\n return {\n getCoupons: getCoupons(state),\n getRemoveError: getRemoveError(state),\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n isRemoving: isRemoving(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Customer from './customer';\nimport CustomerState, { DEFAULT_STATE } from './customer-state';\n\nexport default interface CustomerSelector {\n getCustomer(): Customer | undefined;\n getCustomerOrThrow(): Customer;\n getCreateAccountError(): Error | undefined;\n isCreatingCustomerAccount(): boolean;\n getCreateAddressError(): Error | undefined;\n isCreatingCustomerAddress(): boolean;\n}\n\nexport type CustomerSelectorFactory = (state: CustomerState) => CustomerSelector;\n\nexport function createCustomerSelectorFactory(): CustomerSelectorFactory {\n const getCustomer = createSelector(\n (state: CustomerState) => state.data,\n customer => () => customer\n );\n\n const getCustomerOrThrow = createSelector(\n getCustomer,\n getCustomer => () => {\n return guard(getCustomer(), () => new MissingDataError(MissingDataErrorType.MissingCustomer));\n }\n );\n\n const getCreateAccountError = createSelector(\n (state: CustomerState) => state.errors.createError,\n error => () => error\n );\n\n const isCreatingCustomerAccount = createSelector(\n (state: CustomerState) => !!state.statuses.isCreating,\n status => () => status\n );\n\n const getCreateAddressError = createSelector(\n (state: CustomerState) => state.errors.createAddressError,\n error => () => error\n );\n\n const isCreatingCustomerAddress = createSelector(\n (state: CustomerState) => !!state.statuses.isCreatingAddress,\n status => () => status\n );\n\n return memoizeOne((\n state: CustomerState = DEFAULT_STATE\n ): CustomerSelector => {\n return {\n getCustomer: getCustomer(state),\n getCustomerOrThrow: getCustomerOrThrow(state),\n getCreateAccountError: getCreateAccountError(state),\n isCreatingCustomerAccount: isCreatingCustomerAccount(state),\n getCreateAddressError: getCreateAddressError(state),\n isCreatingCustomerAddress: isCreatingCustomerAddress(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport RemoteCheckoutState, { DEFAULT_STATE, RemoteCheckoutStateData } from './remote-checkout-state';\n\nexport default interface RemoteCheckoutSelector {\n getCheckout<TMethodId extends keyof RemoteCheckoutStateData>(\n methodId: TMethodId\n ): RemoteCheckoutStateData[TMethodId] | undefined;\n}\n\nexport type RemoteCheckoutSelectorFactory = (state: RemoteCheckoutState) => RemoteCheckoutSelector;\n\nexport function createRemoteCheckoutSelectorFactory(): RemoteCheckoutSelectorFactory {\n const getCheckout = createSelector(\n (state: RemoteCheckoutState) => state.data,\n data => <TMethodId extends keyof RemoteCheckoutStateData>(methodId: TMethodId) => {\n return data[methodId];\n }\n );\n\n return memoizeOne((\n state: RemoteCheckoutState = DEFAULT_STATE\n ): RemoteCheckoutSelector => {\n return {\n getCheckout: getCheckout(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { Address } from '../address';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\n\nexport default interface ShippingAddressSelector {\n getShippingAddress(): Address | undefined;\n getShippingAddressOrThrow(): Address;\n}\n\nexport type ShippingAddressSelectorFactory = (state: ConsignmentState) => ShippingAddressSelector;\n\nexport function createShippingAddressSelectorFactory(): ShippingAddressSelectorFactory {\n const getShippingAddress = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => {\n const shippingConsignment = consignments?.find(consignment => !consignment.selectedPickupOption);\n\n return shippingConsignment?.shippingAddress;\n }\n );\n\n const getShippingAddressOrThrow = createSelector(\n getShippingAddress,\n getShippingAddress => () => {\n return guard(getShippingAddress(), () => new MissingDataError(MissingDataErrorType.MissingShippingAddress));\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE\n ): ShippingAddressSelector => {\n return {\n getShippingAddress: getShippingAddress(state),\n getShippingAddressOrThrow: getShippingAddressOrThrow(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { CheckoutSelector } from '../checkout';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { GatewayOrderPayment, OrderSelector } from '../order';\n\nimport PaymentMethod from './payment-method';\nimport { HOSTED } from './payment-method-types';\nimport { ACKNOWLEDGE, FINALIZE } from './payment-status-types';\n\nexport default interface PaymentSelector {\n getPaymentId(): { providerId: string; gatewayId?: string } | undefined;\n getPaymentIdOrThrow(): { providerId: string; gatewayId?: string };\n getPaymentStatus(): string | undefined;\n getPaymentStatusOrThrow(): string;\n getPaymentToken(): string | undefined;\n getPaymentTokenOrThrow(): string;\n getPaymentRedirectUrl(): string | undefined;\n getPaymentRedirectUrlOrThrow(): string;\n isPaymentDataRequired(useStoreCredit?: boolean): boolean;\n isPaymentDataSubmitted(paymentMethod?: PaymentMethod): boolean;\n}\n\nexport type PaymentSelectorFactory = (\n checkout: CheckoutSelector,\n order: OrderSelector\n) => PaymentSelector;\n\ninterface PaymentSelectorDependencies {\n checkout: CheckoutSelector;\n order: OrderSelector;\n}\n\nexport function createPaymentSelectorFactory(): PaymentSelectorFactory {\n const getInternalPayment = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.payment;\n }\n );\n\n const getGatewayPayment = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrder,\n getOrder => () => {\n const order = getOrder();\n\n return find(order && order.payments, ({ providerId }) =>\n providerId !== 'giftcertificate' && providerId !== 'storecredit'\n ) as GatewayOrderPayment;\n }\n );\n\n const getHostedPayment = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getCheckout,\n getCheckout => () => {\n const checkout = getCheckout();\n\n return find(checkout && checkout.payments, ({ providerType }) =>\n providerType === HOSTED\n );\n }\n );\n\n const getPaymentId = createSelector(\n getInternalPayment,\n getHostedPayment,\n getGatewayPayment,\n (getInternalPayment, getHostedPayment, getGatewayPayment) => () => {\n const internalPayment = getInternalPayment();\n\n if (internalPayment && internalPayment.id) {\n return {\n providerId: internalPayment.id,\n gatewayId: internalPayment.gateway,\n };\n }\n\n const payment = getHostedPayment() || getGatewayPayment();\n\n if (payment && payment.providerId) {\n return {\n providerId: payment.providerId,\n gatewayId: payment.gatewayId,\n };\n }\n }\n );\n\n const getPaymentIdOrThrow = createSelector(\n getPaymentId,\n getPaymentId => () => {\n return guard(getPaymentId(), () => new MissingDataError(MissingDataErrorType.MissingPaymentId));\n }\n );\n\n const getPaymentStatus = createSelector(\n getInternalPayment,\n getHostedPayment,\n getGatewayPayment,\n (getInternalPayment, getHostedPayment, getGatewayPayment) => () => {\n const internalPayment = getInternalPayment();\n\n if (internalPayment && internalPayment.status) {\n return internalPayment.status.replace('PAYMENT_STATUS_', '');\n }\n\n const payment = getHostedPayment() || getGatewayPayment();\n\n if (payment) {\n return payment.detail.step;\n }\n }\n );\n\n const getPaymentStatusOrThrow = createSelector(\n getPaymentStatus,\n getPaymentStatus => () => {\n return guard(getPaymentStatus(), () => new MissingDataError(MissingDataErrorType.MissingPaymentStatus));\n }\n );\n\n const getPaymentToken = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.token;\n }\n );\n\n const getPaymentTokenOrThrow = createSelector(\n getPaymentToken,\n getPaymentToken => () => {\n return guard(getPaymentToken(), () => new MissingDataError(MissingDataErrorType.MissingPaymentToken));\n }\n );\n\n const getPaymentRedirectUrl = createSelector(\n getInternalPayment,\n getInternalPayment => () => {\n const payment = getInternalPayment();\n\n return payment && payment.redirectUrl;\n }\n );\n\n const getPaymentRedirectUrlOrThrow = createSelector(\n getPaymentRedirectUrl,\n getPaymentRedirectUrl => () => {\n return guard(getPaymentRedirectUrl(), () => new MissingDataError(MissingDataErrorType.MissingPaymentRedirectUrl));\n }\n );\n\n const isPaymentDataRequired = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getOutstandingBalance,\n getOutstandingBalance => (useStoreCredit = false) => {\n const grandTotal = getOutstandingBalance(useStoreCredit);\n\n return grandTotal ? grandTotal > 0 : false;\n }\n );\n\n const isPaymentDataSubmitted = createSelector(\n getPaymentStatus,\n getPaymentStatus => (paymentMethod?: PaymentMethod) => {\n if (paymentMethod && paymentMethod.nonce) {\n return true;\n }\n\n return getPaymentStatus() === ACKNOWLEDGE || getPaymentStatus() === FINALIZE;\n }\n );\n\n return memoizeOne((\n checkout: CheckoutSelector,\n order: OrderSelector\n ): PaymentSelector => {\n return {\n getPaymentId: getPaymentId({ checkout, order }),\n getPaymentIdOrThrow: getPaymentIdOrThrow({ checkout, order }),\n getPaymentStatus: getPaymentStatus({ checkout, order }),\n getPaymentStatusOrThrow: getPaymentStatusOrThrow({ checkout, order }),\n getPaymentToken: getPaymentToken({ checkout, order }),\n getPaymentTokenOrThrow: getPaymentTokenOrThrow({ checkout, order }),\n getPaymentRedirectUrl: getPaymentRedirectUrl({ checkout, order }),\n getPaymentRedirectUrlOrThrow: getPaymentRedirectUrlOrThrow({ checkout, order }),\n isPaymentDataRequired: isPaymentDataRequired({ checkout, order }),\n isPaymentDataSubmitted: isPaymentDataSubmitted({ checkout, order }),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport { SignInEmail } from './signin-email';\nimport SignInEmailState, { DEFAULT_STATE } from './signin-email-state';\n\nexport default interface SignInEmailSelector {\n getEmail(): SignInEmail | undefined;\n getSendError(): Error | undefined;\n isSending(): boolean;\n}\n\nexport type SignInEmailSelectorFactory = (state: SignInEmailState) => SignInEmailSelector;\n\nexport function createSignInEmailSelectorFactory(): SignInEmailSelectorFactory {\n const getEmail = createSelector(\n (state: SignInEmailState) => state.data,\n signInEmail => () => signInEmail\n );\n\n const getSendError = createSelector(\n (state: SignInEmailState) => state.errors.sendError,\n error => () => error\n );\n\n const isSending = createSelector(\n (state: SignInEmailState) => !!state.statuses.isSending,\n status => () => status\n );\n\n return memoizeOne((\n state: SignInEmailState = DEFAULT_STATE\n ): SignInEmailSelector => {\n return {\n getEmail: getEmail(state),\n getSendError: getSendError(state),\n isSending: isSending(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Cart from './cart';\nimport CartState, { DEFAULT_STATE } from './cart-state';\n\nexport default interface CartSelector {\n getCart(): Cart | undefined;\n getCartOrThrow(): Cart;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type CartSelectorFactory = (state: CartState) => CartSelector;\n\nexport function createCartSelectorFactory() {\n const getCart = createSelector(\n (state: CartState) => state.data,\n cart => () => cart\n );\n\n const getCartOrThrow = createSelector(\n getCart,\n getCart => () => {\n return guard(getCart(), () => new MissingDataError(MissingDataErrorType.MissingCart));\n }\n );\n\n const getLoadError = createSelector(\n (state: CartState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: CartState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: CartState = DEFAULT_STATE\n ): CartSelector => {\n return {\n getCart: getCart(state),\n getCartOrThrow: getCartOrThrow(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { FormFieldsState } from '../form';\n\nimport Config, { ContextConfig, FlashMessage, FlashMessageType, StoreConfig } from './config';\nimport ConfigState, { DEFAULT_STATE } from './config-state';\n\nexport default interface ConfigSelector {\n getConfig(): Config | undefined;\n getFlashMessages(type?: FlashMessageType): FlashMessage[] | undefined;\n getStoreConfig(): StoreConfig | undefined;\n getStoreConfigOrThrow(): StoreConfig;\n getContextConfig(): ContextConfig | undefined;\n getExternalSource(): string | undefined;\n getVariantIdentificationToken(): string | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type ConfigSelectorFactory = (\n state: ConfigState,\n formState: FormFieldsState\n) => ConfigSelector;\n\ninterface ConfigSelectorDependencies {\n formState: FormFieldsState;\n}\n\nexport function createConfigSelectorFactory(): ConfigSelectorFactory {\n\n const getConfig = createSelector(\n (state: ConfigState) => state.data,\n data => () => data\n );\n\n const getFlashMessages = createSelector(\n (state: ConfigState) => state.data,\n data => (filterType?: FlashMessageType) => {\n if (!data) {\n return;\n }\n\n const { flashMessages } = data.context;\n\n if (!flashMessages) {\n return;\n }\n\n return filterType !== undefined ?\n flashMessages.filter(({ type }) => filterType === type) :\n flashMessages;\n }\n );\n\n const getStoreConfig = createSelector(\n (state: ConfigState) => state.data,\n (_: ConfigState, { formState }: ConfigSelectorDependencies) => formState && formState.data,\n (data, formFields) => () => data && formFields ? ({\n ...data.storeConfig,\n formFields,\n }) : undefined\n );\n\n const getStoreConfigOrThrow = createSelector(\n getStoreConfig,\n getStoreConfig => () => {\n return guard(getStoreConfig(), () => new MissingDataError(MissingDataErrorType.MissingCheckoutConfig));\n }\n );\n\n const getContextConfig = createSelector(\n (state: ConfigState) => state.data && state.data.context,\n data => () => data\n );\n\n const getExternalSource = createSelector(\n (state: ConfigState) => state.meta && state.meta.externalSource,\n data => () => data\n );\n\n const getVariantIdentificationToken = createSelector(\n (state: ConfigState) => state.meta && state.meta.variantIdentificationToken,\n data => () => data\n );\n\n const getLoadError = createSelector(\n (state: ConfigState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: ConfigState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: ConfigState = DEFAULT_STATE,\n formState: FormFieldsState\n ): ConfigSelector => {\n return {\n getConfig: getConfig(state),\n getFlashMessages: getFlashMessages(state),\n getStoreConfig: getStoreConfig(state, { formState }),\n getStoreConfigOrThrow: getStoreConfigOrThrow(state, { formState }),\n getContextConfig: getContextConfig(state),\n getExternalSource: getExternalSource(state),\n getVariantIdentificationToken: getVariantIdentificationToken(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport Country from './country';\nimport CountryState, { DEFAULT_STATE } from './country-state';\n\nexport default interface CountrySelector {\n getCountries(): Country[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type CountrySelectorFactory = (state: CountryState) => CountrySelector;\n\nexport function createCountrySelectorFactory(): CountrySelectorFactory {\n const getCountries = createSelector(\n (state: CountryState) => state.data,\n countries => () => countries\n );\n\n const getLoadError = createSelector(\n (state: CountryState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: CountryState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: CountryState = DEFAULT_STATE\n ): CountrySelector => {\n return {\n getCountries: getCountries(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport CustomerStrategyState, { DEFAULT_STATE } from './customer-strategy-state';\n\nexport default interface CustomerStrategySelector {\n getSignInError(methodId?: string): Error | undefined;\n getSignOutError(methodId?: string): Error | undefined;\n getExecutePaymentMethodCheckoutError(methodId?: string): Error | undefined;\n getInitializeError(methodId?: string): Error | undefined;\n getWidgetInteractionError(methodId?: string): Error | undefined;\n isSigningIn(methodId?: string): boolean;\n isSigningOut(methodId?: string): boolean;\n isExecutingPaymentMethodCheckout(methodId?: string): boolean;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type CustomerStrategySelectorFactory = (state: CustomerStrategyState) => CustomerStrategySelector;\n\nexport function createCustomerStrategySelectorFactory(): CustomerStrategySelectorFactory {\n const getSignInError = createSelector(\n (state: CustomerStrategyState) => state.errors.signInMethodId,\n (state: CustomerStrategyState) => state.errors.signInError,\n (signInMethodId, signInError) => (methodId?: string) => {\n if (methodId && signInMethodId !== methodId) {\n return;\n }\n\n return signInError;\n }\n );\n\n const getSignOutError = createSelector(\n (state: CustomerStrategyState) => state.errors.signOutMethodId,\n (state: CustomerStrategyState) => state.errors.signOutError,\n (signOutMethodId, signOutError) => (methodId?: string) => {\n if (methodId && signOutMethodId !== methodId) {\n return;\n }\n\n return signOutError;\n }\n );\n\n const getExecutePaymentMethodCheckoutError = createSelector(\n (state: CustomerStrategyState) => state.errors.executePaymentMethodCheckoutMethodId,\n (state: CustomerStrategyState) => state.errors.executePaymentMethodCheckoutError,\n (executePaymentMethodCheckoutMethodId, executePaymentMethodCheckoutError) => (methodId?: string) => {\n if (methodId && executePaymentMethodCheckoutMethodId !== methodId) {\n return;\n }\n\n return executePaymentMethodCheckoutError;\n }\n );\n\n const getInitializeError = createSelector(\n (state: CustomerStrategyState) => state.errors.initializeMethodId,\n (state: CustomerStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getWidgetInteractionError = createSelector(\n (state: CustomerStrategyState) => state.errors.widgetInteractionMethodId,\n (state: CustomerStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isSigningIn = createSelector(\n (state: CustomerStrategyState) => state.statuses.signInMethodId,\n (state: CustomerStrategyState) => state.statuses.isSigningIn,\n (signInMethodId, isSigningIn) => (methodId?: string) => {\n if (methodId && signInMethodId !== methodId) {\n return false;\n }\n\n return !!isSigningIn;\n }\n );\n\n const isSigningOut = createSelector(\n (state: CustomerStrategyState) => state.statuses.signOutMethodId,\n (state: CustomerStrategyState) => state.statuses.isSigningOut,\n (signOutMethodId, isSigningOut) => (methodId?: string) => {\n if (methodId && signOutMethodId !== methodId) {\n return false;\n }\n\n return !!isSigningOut;\n }\n );\n\n const isExecutingPaymentMethodCheckout = createSelector(\n (state: CustomerStrategyState) => state.statuses.executePaymentMethodCheckoutMethodId,\n (state: CustomerStrategyState) => state.statuses.isExecutingPaymentMethodCheckout,\n (executePaymentMethodCheckoutMethodId, isExecutingPaymentMethodCheckout) => (methodId?: string) => {\n if (methodId && executePaymentMethodCheckoutMethodId !== methodId) {\n return false;\n }\n\n return !!isExecutingPaymentMethodCheckout;\n }\n );\n\n const isInitializing = createSelector(\n (state: CustomerStrategyState) => state.statuses.initializeMethodId,\n (state: CustomerStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: CustomerStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: CustomerStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: CustomerStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: CustomerStrategyState = DEFAULT_STATE\n ): CustomerStrategySelector => {\n return {\n getSignInError: getSignInError(state),\n getSignOutError: getSignOutError(state),\n getExecutePaymentMethodCheckoutError: getExecutePaymentMethodCheckoutError(state),\n getInitializeError: getInitializeError(state),\n getWidgetInteractionError: getWidgetInteractionError(state),\n isSigningIn: isSigningIn(state),\n isSigningOut: isSigningOut(state),\n isExecutingPaymentMethodCheckout: isExecutingPaymentMethodCheckout(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { StorefrontErrorResponseBody } from '../common/error';\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport GiftCertificate from './gift-certificate';\nimport GiftCertificateState, { DEFAULT_STATE } from './gift-certificate-state';\n\nexport default interface GiftCertificateSelector {\n getGiftCertificates(): GiftCertificate[] | undefined;\n getRemoveError(): RequestError<StorefrontErrorResponseBody> | undefined;\n getApplyError(): RequestError<StorefrontErrorResponseBody> | undefined;\n isApplying(): boolean;\n isRemoving(): boolean;\n}\n\nexport type GiftCertificateSelectorFactory = (state: GiftCertificateState) => GiftCertificateSelector;\n\nexport function createGiftCertificateSelectorFactory(): GiftCertificateSelectorFactory {\n const getGiftCertificates = createSelector(\n (state: GiftCertificateState) => state.data,\n data => () => data\n );\n\n const getRemoveError = createSelector(\n (state: GiftCertificateState) => state.errors.removeGiftCertificateError,\n error => () => error\n );\n\n const getApplyError = createSelector(\n (state: GiftCertificateState) => state.errors.applyGiftCertificateError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: GiftCertificateState) => !!state.statuses.isApplyingGiftCertificate,\n status => () => status\n );\n\n const isRemoving = createSelector(\n (state: GiftCertificateState) => !!state.statuses.isRemovingGiftCertificate,\n status => () => status\n );\n\n return memoizeOne((\n state: GiftCertificateState = DEFAULT_STATE\n ): GiftCertificateSelector => {\n return {\n getGiftCertificates: getGiftCertificates(state),\n getRemoveError: getRemoveError(state),\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n isRemoving: isRemoving(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { filter, flatMap, isMatch, values } from 'lodash';\n\nimport { MissingDataError, MissingDataErrorType } from '../../common/error/errors';\nimport { createSelector } from '../../common/selector';\nimport { guard } from '../../common/utility';\nimport PaymentMethod from '../payment-method';\n\nimport PaymentInstrument, { CardInstrument } from './instrument';\nimport InstrumentState, { DEFAULT_STATE, InstrumentMeta } from './instrument-state';\nimport supportedInstruments from './supported-payment-instruments';\n\nexport default interface InstrumentSelector {\n getCardInstrument(instrumentId: string): CardInstrument | undefined;\n getCardInstrumentOrThrow(instrumentId: string): CardInstrument;\n getInstruments(): PaymentInstrument[] | undefined;\n getInstrumentsByPaymentMethod(paymentMethod: PaymentMethod): PaymentInstrument[] | undefined;\n getInstrumentsMeta(): InstrumentMeta | undefined;\n getLoadError(): Error | undefined;\n getDeleteError(instrumentId?: string): Error | undefined;\n isLoading(): boolean;\n isDeleting(instrumentId?: string): boolean;\n}\n\nexport type InstrumentSelectorFactory = (state: InstrumentState) => InstrumentSelector;\n\nexport function createInstrumentSelectorFactory(): InstrumentSelectorFactory {\n const getInstrumentsByPaymentMethod = createSelector(\n (state: InstrumentState) => state.data,\n instruments => (paymentMethod: PaymentMethod) => {\n if (!instruments) {\n return;\n }\n\n const paymentMethodKey = paymentMethod.gateway ? `${paymentMethod.gateway}.${paymentMethod.id}` : paymentMethod.id;\n\n const currentMethod = supportedInstruments[paymentMethodKey];\n\n if (!currentMethod) {\n return [];\n }\n\n return filter<PaymentInstrument>(instruments, currentMethod);\n }\n );\n\n const getCardInstrument = createSelector(\n (state: InstrumentState) => state.data,\n (instruments = []) => (instrumentId: string) => {\n const cards = values(supportedInstruments);\n\n return instruments?.find((instrument): instrument is CardInstrument =>\n instrument.bigpayToken === instrumentId &&\n instrument.type === 'card' &&\n cards.some(card => isMatch(instrument, card))\n );\n }\n );\n\n const getCardInstrumentOrThrow = createSelector(\n getCardInstrument,\n getCardInstrument => (instrumentId: string) => {\n return guard(getCardInstrument(instrumentId), () => new MissingDataError(MissingDataErrorType.MissingPaymentInstrument));\n }\n );\n\n const getInstruments = createSelector(\n (state: InstrumentState) => state.data,\n instruments => () => {\n if (!instruments) {\n return;\n }\n\n const allSupportedInstruments = flatMap(supportedInstruments, supportedProvider =>\n filter(instruments, (instrument: PaymentInstrument): instrument is PaymentInstrument => {\n return isMatch(instrument, supportedProvider);\n })\n );\n\n return allSupportedInstruments;\n }\n );\n\n const getInstrumentsMeta = createSelector(\n (state: InstrumentState) => state.meta,\n meta => () => meta\n );\n\n const getLoadError = createSelector(\n (state: InstrumentState) => state.errors.loadError,\n loadError => () => loadError\n );\n\n const getDeleteError = createSelector(\n (state: InstrumentState) => state.errors.failedInstrument,\n (state: InstrumentState) => state.errors.deleteError,\n (failedInstrument, deleteError) => (instrumentId?: string) => {\n if (instrumentId && failedInstrument !== instrumentId) {\n return;\n }\n\n return deleteError;\n }\n );\n\n const isLoading = createSelector(\n (state: InstrumentState) => state.statuses.isLoading,\n isLoading => () => !!isLoading\n );\n\n const isDeleting = createSelector(\n (state: InstrumentState) => state.statuses.deletingInstrument,\n (state: InstrumentState) => state.statuses.isDeleting,\n (deletingInstrument, isDeleting) => (instrumentId?: string) => {\n if (instrumentId && deletingInstrument !== instrumentId) {\n return false;\n }\n\n return !!isDeleting;\n }\n );\n\n return memoizeOne((\n state: InstrumentState = DEFAULT_STATE\n ): InstrumentSelector => {\n return {\n getCardInstrument: getCardInstrument(state),\n getCardInstrumentOrThrow: getCardInstrumentOrThrow(state),\n getInstruments: getInstruments(state),\n getInstrumentsByPaymentMethod: getInstrumentsByPaymentMethod(state),\n getInstrumentsMeta: getInstrumentsMeta(state),\n getLoadError: getLoadError(state),\n getDeleteError: getDeleteError(state),\n isLoading: isLoading(state),\n isDeleting: isDeleting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { createSelector } from '../common/selector';\nimport { Country } from '../geography';\n\nimport FormField from './form-field';\nimport FormFieldsState, { DEFAULT_STATE } from './form-fields-state';\n\nexport default interface FormSelector {\n getShippingAddressFields(countries: Country[] | undefined, countryCode: string): FormField[];\n getBillingAddressFields(countries: Country[] | undefined, countryCode: string): FormField[];\n getCustomerAccountFields(): FormField[];\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type FormSelectorFactory = (state: FormFieldsState) => FormSelector;\n\nexport function createFormSelectorFactory(): FormSelectorFactory {\n const getShippingAddressFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => (countries: Country[] = [], countryCode: string) => {\n const selectedCountry = find(countries, { code: countryCode });\n const fields = formFields ? formFields.shippingAddress : [];\n\n return fields.map((field: any) => processField(field, countries, selectedCountry));\n }\n );\n\n const getBillingAddressFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => (countries: Country[] = [], countryCode: string) => {\n const selectedCountry = find(countries, { code: countryCode });\n const fields = formFields ? formFields.billingAddress : [];\n\n return fields.map((field: any) => processField(field, countries, selectedCountry));\n }\n );\n\n const getCustomerAccountFields = createSelector(\n (state: FormFieldsState) => state.data,\n formFields => () => formFields ? formFields.customerAccount : []\n );\n\n const getLoadError = createSelector(\n (state: FormFieldsState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: FormFieldsState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n function processField(field: FormField, countries: Country[], selectedCountry?: Country): FormField {\n if (field.name === 'countryCode') {\n return processCountry(field, countries, selectedCountry);\n }\n\n if (field.name === 'stateOrProvince') {\n return processProvince(field, selectedCountry);\n }\n\n if (field.name === 'postalCode') {\n return processsPostCode(field, selectedCountry);\n }\n\n return field;\n }\n\n function processCountry(field: FormField, countries: Country[] = [], country?: Country): FormField {\n if (!countries.length) {\n return field;\n }\n\n const { code = '' } = country || {};\n const items = countries.map(({ code, name }: any) => ({\n value: code,\n label: name,\n }));\n\n return {\n ...field,\n options: { items },\n default: code,\n type: 'array',\n fieldType: 'dropdown',\n itemtype: 'string',\n };\n }\n\n function processProvince(field: FormField, country?: Country): FormField {\n const { subdivisions = [], requiresState } = country || {};\n\n if (!subdivisions.length) {\n return {\n ...field,\n required: requiresState == null ? false : requiresState,\n };\n }\n\n const items = subdivisions.map(({ code, name }: any) => ({\n value: code,\n label: name,\n }));\n\n return {\n ...field,\n name: 'stateOrProvinceCode',\n options: { items },\n required: requiresState == null ? true : requiresState,\n type: 'array',\n fieldType: 'dropdown',\n itemtype: 'string',\n };\n }\n\n function processsPostCode(field: FormField, country?: Country): FormField {\n const { hasPostalCodes = [] } = country || {};\n\n if (hasPostalCodes === undefined) {\n return field;\n }\n\n return { ...field, required: Boolean(hasPostalCodes) };\n }\n\n return memoizeOne((\n state: FormFieldsState = DEFAULT_STATE\n ): FormSelector => {\n return {\n getShippingAddressFields: getShippingAddressFields(state),\n getBillingAddressFields: getBillingAddressFields(state),\n getCustomerAccountFields: getCustomerAccountFields(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport PaymentMethod from './payment-method';\nimport PaymentMethodMeta from './payment-method-meta';\nimport PaymentMethodState, { DEFAULT_STATE } from './payment-method-state';\n\nexport default interface PaymentMethodSelector {\n getPaymentMethods(): PaymentMethod[] | undefined;\n getPaymentMethodsMeta(): PaymentMethodMeta | undefined;\n getPaymentMethod(methodId: string, gatewayId?: string): PaymentMethod | undefined;\n getPaymentMethodOrThrow(methodId: string, gatewayId ?: string): PaymentMethod;\n getLoadError(): Error | undefined;\n getLoadMethodError(methodId?: string): Error | undefined;\n isLoading(): boolean;\n isLoadingMethod(methodId?: string): boolean;\n}\n\nexport type PaymentMethodSelectorFactory = (state: PaymentMethodState) => PaymentMethodSelector;\n\nexport function createPaymentMethodSelectorFactory(): PaymentMethodSelectorFactory {\n const getPaymentMethods = createSelector(\n (state: PaymentMethodState) => state.data,\n paymentMethods => () => paymentMethods\n );\n\n const getPaymentMethodsMeta = createSelector(\n (state: PaymentMethodState) => state.meta,\n meta => () => meta\n );\n\n const getPaymentMethod = createSelector(\n (state: PaymentMethodState) => state.data,\n paymentMethods => (methodId: string, gatewayId?: string) => {\n return gatewayId ?\n find(paymentMethods, { id: methodId, gateway: gatewayId }) :\n find(paymentMethods, { id: methodId });\n }\n );\n\n const getPaymentMethodOrThrow = createSelector(\n getPaymentMethod,\n getPaymentMethod => (methodId: string, gatewayId?: string) => {\n return guard(getPaymentMethod(methodId, gatewayId), () => new MissingDataError(MissingDataErrorType.MissingPaymentMethod));\n }\n );\n\n const getLoadError = createSelector(\n (state: PaymentMethodState) => state.errors.loadError,\n loadError => () => loadError\n );\n\n const getLoadMethodError = createSelector(\n (state: PaymentMethodState) => state.errors.loadMethodId,\n (state: PaymentMethodState) => state.errors.loadMethodError,\n (loadMethodId, loadMethodError) => (methodId?: string) => {\n if (methodId && loadMethodId !== methodId) {\n return;\n }\n\n return loadMethodError;\n }\n );\n\n const isLoading = createSelector(\n (state: PaymentMethodState) => state.statuses.isLoading,\n isLoading => () => !!isLoading\n );\n\n const isLoadingMethod = createSelector(\n (state: PaymentMethodState) => state.statuses.loadMethodId,\n (state: PaymentMethodState) => state.statuses.isLoadingMethod,\n (loadMethodId, isLoadingMethod) => (methodId?: string) => {\n if (methodId && loadMethodId !== methodId) {\n return false;\n }\n\n return !!isLoadingMethod;\n }\n );\n\n return memoizeOne((\n state: PaymentMethodState = DEFAULT_STATE\n ): PaymentMethodSelector => {\n return {\n getPaymentMethods: getPaymentMethods(state),\n getPaymentMethodsMeta: getPaymentMethodsMeta(state),\n getPaymentMethod: getPaymentMethod(state),\n getPaymentMethodOrThrow: getPaymentMethodOrThrow(state),\n getLoadError: getLoadError(state),\n getLoadMethodError: getLoadMethodError(state),\n isLoading: isLoading(state),\n isLoadingMethod: isLoadingMethod(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport PaymentStrategyState, { DEFAULT_STATE } from './payment-strategy-state';\n\nexport default interface PaymentStrategySelector {\n getInitializeError(methodId?: string): Error | undefined;\n getExecuteError(methodId?: string): Error | undefined;\n getFinalizeError(methodId?: string): Error | undefined;\n getWidgetInteractingError(methodId?: string): Error | undefined;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isExecuting(methodId?: string): boolean;\n isFinalizing(methodId?: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type PaymentStrategySelectorFactory = (state: PaymentStrategyState) => PaymentStrategySelector;\n\nexport function createPaymentStrategySelectorFactory(): PaymentStrategySelectorFactory {\n const getInitializeError = createSelector(\n (state: PaymentStrategyState) => state.errors.initializeMethodId,\n (state: PaymentStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getExecuteError = createSelector(\n (state: PaymentStrategyState) => state.errors.executeMethodId,\n (state: PaymentStrategyState) => state.errors.executeError,\n (executeMethodId, executeError) => (methodId?: string) => {\n if (methodId && executeMethodId !== methodId) {\n return;\n }\n\n return executeError;\n }\n );\n\n const getFinalizeError = createSelector(\n (state: PaymentStrategyState) => state.errors.finalizeMethodId,\n (state: PaymentStrategyState) => state.errors.finalizeError,\n (finalizeMethodId, finalizeError) => (methodId?: string) => {\n if (methodId && finalizeMethodId !== methodId) {\n return;\n }\n\n return finalizeError;\n }\n );\n\n const getWidgetInteractingError = createSelector(\n (state: PaymentStrategyState) => state.errors.widgetInteractionMethodId,\n (state: PaymentStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isInitializing = createSelector(\n (state: PaymentStrategyState) => state.statuses.initializeMethodId,\n (state: PaymentStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: PaymentStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isExecuting = createSelector(\n (state: PaymentStrategyState) => state.statuses.executeMethodId,\n (state: PaymentStrategyState) => state.statuses.isExecuting,\n (executeMethodId, isExecuting) => (methodId?: string) => {\n if (methodId && executeMethodId !== methodId) {\n return false;\n }\n\n return !!isExecuting;\n }\n );\n\n const isFinalizing = createSelector(\n (state: PaymentStrategyState) => state.statuses.finalizeMethodId,\n (state: PaymentStrategyState) => state.statuses.isFinalizing,\n (finalizeMethodId, isFinalizing) => (methodId?: string) => {\n if (methodId && finalizeMethodId !== methodId) {\n return false;\n }\n\n return !!isFinalizing;\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: PaymentStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: PaymentStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: PaymentStrategyState = DEFAULT_STATE\n ): PaymentStrategySelector => {\n return {\n getInitializeError: getInitializeError(state),\n getExecuteError: getExecuteError(state),\n getFinalizeError: getFinalizeError(state),\n getWidgetInteractingError: getWidgetInteractingError(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isExecuting: isExecuting(state),\n isFinalizing: isFinalizing(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\nimport { objectFlatten, objectWithSortedKeys } from '../common/utility';\n\nimport { PickupOptionResult, SearchArea } from './pickup-option';\nimport PickupOptionState, { DEFAULT_STATE } from './pickup-option-state';\n\nexport default interface PickupOptionSelector {\n getPickupOptions(consignmentId: string, searchArea: SearchArea): PickupOptionResult[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type PickupOptionSelectorFactory = (state: PickupOptionState) => PickupOptionSelector;\n\nexport function createPickupOptionSelectorFactory(): PickupOptionSelectorFactory {\n const getPickupOptions = createSelector(\n (state: PickupOptionState) => state.data,\n pickupOptions => (consignmentId: string, searchArea: SearchArea) => {\n if (!pickupOptions) {\n return;\n }\n const flattenedParams = objectFlatten({ consignmentId, searchArea });\n const sortedFlattenedParams = objectWithSortedKeys(flattenedParams);\n const keyString = btoa(`${JSON.stringify(sortedFlattenedParams)}`);\n\n return pickupOptions[keyString];\n }\n );\n\n const getLoadError = createSelector(\n (state: PickupOptionState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: PickupOptionState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: PickupOptionState = DEFAULT_STATE\n ): PickupOptionSelector => {\n return {\n getPickupOptions: getPickupOptions(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\nimport { Country } from '../geography';\n\nimport ShippingCountryState, { DEFAULT_STATE } from './shipping-country-state';\n\nexport default interface ShippingCountrySelector {\n getShippingCountries(): Country[] | undefined;\n getLoadError(): Error | undefined;\n isLoading(): boolean;\n}\n\nexport type ShippingCountrySelectorFactory = (state: ShippingCountryState) => ShippingCountrySelector;\n\nexport function createShippingCountrySelectorFactory(): ShippingCountrySelectorFactory {\n const getShippingCountries = createSelector(\n (state: ShippingCountryState) => state.data,\n data => () => data\n );\n\n const getLoadError = createSelector(\n (state: ShippingCountryState) => state.errors.loadError,\n error => () => error\n );\n\n const isLoading = createSelector(\n (state: ShippingCountryState) => state.statuses.isLoading,\n status => () => !!status\n );\n\n return memoizeOne((\n state: ShippingCountryState = DEFAULT_STATE\n ): ShippingCountrySelector => {\n return {\n getShippingCountries: getShippingCountries(state),\n getLoadError: getLoadError(state),\n isLoading: isLoading(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport ShippingStrategyState, { DEFAULT_STATE } from './shipping-strategy-state';\n\nexport default interface ShippingStrategySelector {\n getUpdateAddressError(methodId?: string): Error | undefined;\n getSelectOptionError(methodId?: string): Error | undefined;\n getInitializeError(methodId?: string): Error | undefined;\n getWidgetInteractionError(methodId?: string): Error | undefined;\n isUpdatingAddress(methodId?: string): boolean;\n isSelectingOption(methodId?: string): boolean;\n isInitializing(methodId?: string): boolean;\n isInitialized(methodId: string): boolean;\n isWidgetInteracting(methodId?: string): boolean;\n}\n\nexport type ShippingStrategySelectorFactory = (state: ShippingStrategyState) => ShippingStrategySelector;\n\nexport function createShippingStrategySelectorFactory(): ShippingStrategySelectorFactory {\n const getUpdateAddressError = createSelector(\n (state: ShippingStrategyState) => state.errors.updateAddressMethodId,\n (state: ShippingStrategyState) => state.errors.updateAddressError,\n (updateAddressMethodId, updateAddressError) => (methodId?: string) => {\n if (methodId && updateAddressMethodId !== methodId) {\n return;\n }\n\n return updateAddressError;\n }\n );\n\n const getSelectOptionError = createSelector(\n (state: ShippingStrategyState) => state.errors.selectOptionMethodId,\n (state: ShippingStrategyState) => state.errors.selectOptionError,\n (selectOptionMethodId, selectOptionError) => (methodId?: string) => {\n if (methodId && selectOptionMethodId !== methodId) {\n return;\n }\n\n return selectOptionError;\n }\n );\n\n const getInitializeError = createSelector(\n (state: ShippingStrategyState) => state.errors.initializeMethodId,\n (state: ShippingStrategyState) => state.errors.initializeError,\n (initializeMethodId, initializeError) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return;\n }\n\n return initializeError;\n }\n );\n\n const getWidgetInteractionError = createSelector(\n (state: ShippingStrategyState) => state.errors.widgetInteractionMethodId,\n (state: ShippingStrategyState) => state.errors.widgetInteractionError,\n (widgetInteractionMethodId, widgetInteractionError) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return;\n }\n\n return widgetInteractionError;\n }\n );\n\n const isUpdatingAddress = createSelector(\n (state: ShippingStrategyState) => state.statuses.updateAddressMethodId,\n (state: ShippingStrategyState) => state.statuses.isUpdatingAddress,\n (updateAddressMethodId, isUpdatingAddress) => (methodId?: string) => {\n if (methodId && updateAddressMethodId !== methodId) {\n return false;\n }\n\n return !!isUpdatingAddress;\n }\n );\n\n const isSelectingOption = createSelector(\n (state: ShippingStrategyState) => state.statuses.selectOptionMethodId,\n (state: ShippingStrategyState) => state.statuses.isSelectingOption,\n (selectOptionMethodId, isSelectingOption) => (methodId?: string) => {\n if (methodId && selectOptionMethodId !== methodId) {\n return false;\n }\n\n return !!isSelectingOption;\n }\n );\n\n const isInitializing = createSelector(\n (state: ShippingStrategyState) => state.statuses.initializeMethodId,\n (state: ShippingStrategyState) => state.statuses.isInitializing,\n (initializeMethodId, isInitializing) => (methodId?: string) => {\n if (methodId && initializeMethodId !== methodId) {\n return false;\n }\n\n return !!isInitializing;\n }\n );\n\n const isInitialized = createSelector(\n (state: ShippingStrategyState) => state.data,\n data => (methodId: string) => {\n return !!(\n data[methodId] &&\n data[methodId].isInitialized\n );\n }\n );\n\n const isWidgetInteracting = createSelector(\n (state: ShippingStrategyState) => state.statuses.widgetInteractionMethodId,\n (state: ShippingStrategyState) => state.statuses.isWidgetInteracting,\n (widgetInteractionMethodId, isWidgetInteracting) => (methodId?: string) => {\n if (methodId && widgetInteractionMethodId !== methodId) {\n return false;\n }\n\n return !!isWidgetInteracting;\n }\n );\n\n return memoizeOne((\n state: ShippingStrategyState = DEFAULT_STATE\n ): ShippingStrategySelector => {\n return {\n getUpdateAddressError: getUpdateAddressError(state),\n getSelectOptionError: getSelectOptionError(state),\n getInitializeError: getInitializeError(state),\n getWidgetInteractionError: getWidgetInteractionError(state),\n isUpdatingAddress: isUpdatingAddress(state),\n isSelectingOption: isSelectingOption(state),\n isInitializing: isInitializing(state),\n isInitialized: isInitialized(state),\n isWidgetInteracting: isWidgetInteracting(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { isAddressEqual, AddressRequestBody } from '../address';\nimport { CartSelector, PhysicalItem } from '../cart';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\n\nimport Consignment from './consignment';\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\nimport ShippingOption from './shipping-option';\n\nexport default interface ConsignmentSelector {\n getConsignments(): Consignment[] | undefined;\n getConsignmentsOrThrow(): Consignment[];\n getConsignmentById(id: string): Consignment | undefined;\n getConsignmentByAddress(address: AddressRequestBody): Consignment | undefined;\n getShippingOption(): ShippingOption | undefined;\n getLoadError(): Error | undefined;\n getCreateError(): Error | undefined;\n getLoadShippingOptionsError(): Error | undefined;\n getUnassignedItems(): PhysicalItem[];\n getUpdateError(consignmentId?: string): Error | undefined;\n getDeleteError(consignmentId?: string): Error | undefined;\n getItemAssignmentError(address: AddressRequestBody): Error | undefined;\n getUpdateShippingOptionError(consignmentId?: string): Error | undefined;\n isLoading(): boolean;\n isLoadingShippingOptions(): boolean;\n isCreating(): boolean;\n isUpdating(consignmentId?: string): boolean;\n isDeleting(consignmentId?: string): boolean;\n isAssigningItems(address: AddressRequestBody): boolean;\n isUpdatingShippingOption(consignmentId?: string): boolean;\n}\n\nexport type ConsignmentSelectorFactory = (\n state: ConsignmentState,\n cart: CartSelector\n) => ConsignmentSelector;\n\ninterface ConsignmentSelectorDependencies {\n cart: CartSelector;\n}\n\nexport function createConsignmentSelectorFactory(): ConsignmentSelectorFactory {\n const getConsignments = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => consignments\n );\n\n const getConsignmentsOrThrow = createSelector(\n getConsignments,\n getConsignments => () => {\n return guard(getConsignments(), () => new MissingDataError(MissingDataErrorType.MissingConsignments));\n }\n );\n\n const getConsignmentById = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => (id: string) => {\n if (!consignments || !consignments.length) {\n return;\n }\n\n return find(consignments, { id });\n }\n );\n\n const getConsignmentByAddress = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => (address: AddressRequestBody) => {\n if (!consignments || !consignments.length) {\n return;\n }\n\n return find(consignments, consignment =>\n isAddressEqual(consignment.shippingAddress, address)\n );\n }\n );\n\n const getShippingOption = createSelector(\n (state: ConsignmentState) => state.data,\n consignments => () => {\n if (consignments && consignments.length) {\n return consignments[0].selectedShippingOption;\n }\n }\n );\n\n const getLoadError = createSelector(\n (state: ConsignmentState) => state.errors.loadError,\n error => () => error\n );\n\n const getCreateError = createSelector(\n (state: ConsignmentState) => state.errors.createError,\n error => () => error\n );\n\n const getLoadShippingOptionsError = createSelector(\n (state: ConsignmentState) => state.errors.loadShippingOptionsError,\n error => () => error\n );\n\n const getUnassignedItems = createSelector(\n getConsignments,\n (_: ConsignmentState, { cart }: ConsignmentSelectorDependencies) => cart.getCart,\n (getConsignments, getCart) => () => {\n const cart = getCart();\n\n if (!cart) {\n return [];\n }\n\n const assignedLineItemIds = (getConsignments() || []).reduce(\n (itemIds, consignment) => itemIds.concat(consignment.lineItemIds),\n [] as string[]\n );\n\n return (cart.lineItems.physicalItems || []).filter(\n item => assignedLineItemIds.indexOf(item.id as string) < 0\n );\n }\n );\n\n const getUpdateError = createSelector(\n (state: ConsignmentState) => state.errors.updateError,\n updateError => (consignmentId?: string) => {\n if (consignmentId) {\n return updateError[consignmentId];\n }\n\n return find(updateError);\n }\n );\n\n const getDeleteError = createSelector(\n (state: ConsignmentState) => state.errors.deleteError,\n deleteError => (consignmentId?: string) => {\n if (consignmentId) {\n return deleteError[consignmentId];\n }\n\n return find(deleteError);\n }\n );\n\n const getItemAssignmentError = createSelector(\n getConsignmentByAddress,\n getUpdateError,\n getCreateError,\n (getConsignmentByAddress, getUpdateError, getCreateError) => (address: AddressRequestBody) => {\n const consignment = getConsignmentByAddress(address);\n\n return consignment ? getUpdateError(consignment.id) : getCreateError();\n }\n );\n\n const getUpdateShippingOptionError = createSelector(\n (state: ConsignmentState) => state.errors.updateShippingOptionError,\n updateShippingOptionError => (consignmentId?: string) => {\n if (consignmentId) {\n return updateShippingOptionError[consignmentId];\n }\n\n return find(updateShippingOptionError);\n }\n );\n\n const isLoading = createSelector(\n (state: ConsignmentState) => state.statuses.isLoading,\n isLoading => () => isLoading === true\n );\n\n const isLoadingShippingOptions = createSelector(\n (state: ConsignmentState) => state.statuses.isLoadingShippingOptions,\n isLoadingShippingOptions => () => isLoadingShippingOptions === true\n );\n\n const isCreating = createSelector(\n (state: ConsignmentState) => state.statuses.isCreating,\n isCreating => () => isCreating === true\n );\n\n const isUpdating = createSelector(\n (state: ConsignmentState) => state.statuses.isUpdating,\n isUpdating => (consignmentId?: string) => {\n if (consignmentId) {\n return isUpdating[consignmentId] === true;\n }\n\n return find(isUpdating) === true;\n }\n );\n\n const isDeleting = createSelector(\n (state: ConsignmentState) => state.statuses.isDeleting,\n isDeleting => (consignmentId?: string) => {\n if (consignmentId) {\n return isDeleting[consignmentId] === true;\n }\n\n return find(isDeleting) === true;\n }\n );\n\n const isAssigningItems = createSelector(\n getConsignmentByAddress,\n isUpdating,\n isCreating,\n (getConsignmentByAddress, isUpdating, isCreating) => (address: AddressRequestBody) => {\n const consignment = getConsignmentByAddress(address);\n\n return consignment ? isUpdating(consignment.id) : isCreating();\n }\n );\n\n const isUpdatingShippingOption = createSelector(\n (state: ConsignmentState) => state.statuses.isUpdatingShippingOption,\n isUpdatingShippingOption => (consignmentId?: string) => {\n if (consignmentId) {\n return isUpdatingShippingOption[consignmentId] === true;\n }\n\n return find(isUpdatingShippingOption) === true;\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE,\n cart: CartSelector\n ): ConsignmentSelector => {\n return {\n getConsignments: getConsignments(state),\n getConsignmentsOrThrow: getConsignmentsOrThrow(state),\n getConsignmentById: getConsignmentById(state),\n getConsignmentByAddress: getConsignmentByAddress(state),\n getShippingOption: getShippingOption(state),\n getLoadError: getLoadError(state),\n getCreateError: getCreateError(state),\n getLoadShippingOptionsError: getLoadShippingOptionsError(state),\n getUnassignedItems: getUnassignedItems(state, { cart }),\n getUpdateError: getUpdateError(state),\n getDeleteError: getDeleteError(state),\n getItemAssignmentError: getItemAssignmentError(state),\n getUpdateShippingOptionError: getUpdateShippingOptionError(state),\n isLoading: isLoading(state),\n isLoadingShippingOptions: isLoadingShippingOptions(state),\n isCreating: isCreating(state),\n isUpdating: isUpdating(state),\n isDeleting: isDeleting(state),\n isAssigningItems: isAssigningItems(state),\n isUpdatingShippingOption: isUpdatingShippingOption(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { BillingAddressSelector } from '../billing';\nimport { CartSelector } from '../cart';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { CouponSelector, GiftCertificateSelector } from '../coupon';\nimport { CustomerSelector } from '../customer';\nimport { ConsignmentSelector } from '../shipping';\n\nimport Checkout from './checkout';\nimport CheckoutState, { DEFAULT_STATE } from './checkout-state';\n\nexport default interface CheckoutSelector {\n getCheckout(): Checkout | undefined;\n getCheckoutOrThrow(): Checkout;\n getOutstandingBalance(useStoreCredit?: boolean): number | undefined;\n getLoadError(): Error | undefined;\n getUpdateError(): Error | undefined;\n isExecutingSpamCheck(): boolean;\n isLoading(): boolean;\n isUpdating(): boolean;\n}\n\nexport type CheckoutSelectorFactory = (\n state: CheckoutState,\n billingAddress: BillingAddressSelector,\n cart: CartSelector,\n consignments: ConsignmentSelector,\n coupons: CouponSelector,\n customer: CustomerSelector,\n giftCertificates: GiftCertificateSelector\n) => CheckoutSelector;\n\ninterface CheckoutSelectorDependencies {\n billingAddress: BillingAddressSelector;\n cart: CartSelector;\n consignments: ConsignmentSelector;\n coupons: CouponSelector;\n customer: CustomerSelector;\n giftCertificates: GiftCertificateSelector;\n}\n\nexport function createCheckoutSelectorFactory(): CheckoutSelectorFactory {\n const getCheckout = createSelector(\n (state: CheckoutState) => state.data,\n (_: CheckoutState, { billingAddress }: CheckoutSelectorDependencies) => billingAddress.getBillingAddress,\n (_: CheckoutState, { cart }: CheckoutSelectorDependencies) => cart.getCart,\n (_: CheckoutState, { customer }: CheckoutSelectorDependencies) => customer.getCustomer,\n (_: CheckoutState, { consignments }: CheckoutSelectorDependencies) => consignments.getConsignments,\n (_: CheckoutState, { coupons }: CheckoutSelectorDependencies) => coupons.getCoupons,\n (_: CheckoutState, { giftCertificates }: CheckoutSelectorDependencies) => giftCertificates.getGiftCertificates,\n (data, getBillingAddress, getCart, getCustomer, getConsignments, getCoupons, getGiftCertificates) => () => {\n const billingAddress = getBillingAddress();\n const cart = getCart();\n const customer = getCustomer();\n const consignments = getConsignments() || [];\n const coupons = getCoupons() || [];\n const giftCertificates = getGiftCertificates() || [];\n\n if (!data || !cart || !customer) {\n return;\n }\n\n return {\n ...data,\n billingAddress,\n cart,\n customer,\n consignments,\n coupons,\n giftCertificates,\n };\n }\n );\n\n const getCheckoutOrThrow = createSelector(\n getCheckout,\n getCheckout => () => {\n return guard(getCheckout(), () => new MissingDataError(MissingDataErrorType.MissingCheckout));\n }\n );\n\n const getOutstandingBalance = createSelector(\n getCheckout,\n getCheckout => (useStoreCredit?: boolean) => {\n const checkout = getCheckout();\n\n if (!checkout) {\n return;\n }\n\n const grandTotal = checkout.grandTotal || 0;\n const storeCredit = checkout.customer.storeCredit || 0;\n\n return useStoreCredit ? Math.max(grandTotal - storeCredit, 0) : checkout.outstandingBalance;\n }\n );\n\n const getLoadError = createSelector(\n (state: CheckoutState) => state.errors.loadError,\n error => () => error\n );\n\n const getUpdateError = createSelector(\n (state: CheckoutState) => state.errors.updateError,\n error => () => error\n );\n\n const isExecutingSpamCheck = createSelector(\n (state: CheckoutState) => state.statuses.isExecutingSpamCheck,\n isExecutingSpamCheck => () => isExecutingSpamCheck === true\n );\n\n const isLoading = createSelector(\n (state: CheckoutState) => state.statuses.isLoading,\n isLoading => () => isLoading === true\n );\n\n const isUpdating = createSelector(\n (state: CheckoutState) => state.statuses.isUpdating,\n isUpdating => () => isUpdating === true\n );\n\n return memoizeOne((\n state: CheckoutState = DEFAULT_STATE,\n billingAddress: BillingAddressSelector,\n cart: CartSelector,\n consignments: ConsignmentSelector,\n coupons: CouponSelector,\n customer: CustomerSelector,\n giftCertificates: GiftCertificateSelector\n ): CheckoutSelector => {\n return {\n getCheckout: getCheckout(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getCheckoutOrThrow: getCheckoutOrThrow(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getOutstandingBalance: getOutstandingBalance(state, {\n billingAddress,\n cart,\n consignments,\n coupons,\n customer,\n giftCertificates,\n }),\n getLoadError: getLoadError(state),\n getUpdateError: getUpdateError(state),\n isExecutingSpamCheck: isExecutingSpamCheck(state),\n isLoading: isLoading(state),\n isUpdating: isUpdating(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { BillingAddressSelector } from '../billing';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\nimport { guard } from '../common/utility';\nimport { CouponSelector } from '../coupon';\n\nimport Order from './order';\nimport OrderState, { DEFAULT_STATE, OrderMetaState } from './order-state';\n\nexport default interface OrderSelector {\n getOrder(): Order | undefined;\n getOrderOrThrow(): Order;\n getOrderMeta(): OrderMetaState | undefined;\n getLoadError(): Error | undefined;\n getPaymentId(methodId: string): string | undefined;\n isLoading(): boolean;\n}\n\nexport type OrderSelectorFactory = (\n state: OrderState,\n billingAddress: BillingAddressSelector,\n coupons: CouponSelector\n) => OrderSelector;\n\ninterface OrderSelectorDependencies {\n billingAddress: BillingAddressSelector;\n coupons: CouponSelector;\n}\n\nexport function createOrderSelectorFactory(): OrderSelectorFactory {\n const getOrder = createSelector(\n (state: OrderState) => state.data,\n (_: OrderState, { billingAddress }: OrderSelectorDependencies) => billingAddress.getBillingAddress(),\n (_: OrderState, { coupons }: OrderSelectorDependencies) => coupons.getCoupons(),\n (data, billingAddress, coupons = []) => () => {\n if (!data || !billingAddress) {\n return;\n }\n\n return {\n ...data,\n billingAddress,\n coupons,\n };\n }\n );\n\n const getOrderOrThrow = createSelector(\n getOrder,\n getOrder => () => {\n return guard(getOrder(), () => new MissingDataError(MissingDataErrorType.MissingOrder));\n }\n );\n\n const getOrderMeta = createSelector(\n (state: OrderState) => state.meta,\n meta => () => meta\n );\n\n const getLoadError = createSelector(\n (state: OrderState) => state.errors.loadError,\n error => () => error\n );\n\n const getPaymentId = createSelector(\n (state: OrderState) => state.data?.payments,\n (payments = []) => (methodId: string) => {\n const currentPayment = payments.find(({ providerId }) => providerId === methodId);\n\n return currentPayment?.paymentId;\n }\n );\n\n const isLoading = createSelector(\n (state: OrderState) => !!state.statuses.isLoading,\n status => () => status\n );\n\n return memoizeOne((\n state: OrderState = DEFAULT_STATE,\n billingAddress: BillingAddressSelector,\n coupons: CouponSelector\n ): OrderSelector => {\n return {\n getOrder: getOrder(state, { billingAddress, coupons }),\n getOrderOrThrow: getOrderOrThrow(state, { billingAddress, coupons }),\n getOrderMeta: getOrderMeta(state),\n getLoadError: getLoadError(state),\n getPaymentId: getPaymentId(state),\n isLoading: isLoading(state),\n };\n });\n}\n","export const HOSTED = 'PAYMENT_TYPE_HOSTED';\nexport const OFFLINE = 'PAYMENT_TYPE_OFFLINE';\n","export const ACKNOWLEDGE = 'ACKNOWLEDGE';\nexport const FINALIZE = 'FINALIZE';\nexport const INITIALIZE = 'INITIALIZE';\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { RequestError } from '../common/error/errors';\nimport { createSelector } from '../common/selector';\n\nimport StoreCreditState, { DEFAULT_STATE } from './store-credit-state';\n\nexport default interface StoreCreditSelector {\n getApplyError(): RequestError | undefined;\n isApplying(): boolean;\n}\n\nexport type StoreCreditSelectorFactory = (state: StoreCreditState) => StoreCreditSelector;\n\nexport function createStoreCreditSelectorFactory(): StoreCreditSelectorFactory {\n const getApplyError = createSelector(\n (state: StoreCreditState) => state.errors.applyError,\n error => () => error\n );\n\n const isApplying = createSelector(\n (state: StoreCreditState) => !!state.statuses.isApplying,\n status => () => status\n );\n\n return memoizeOne((\n state: StoreCreditState = DEFAULT_STATE\n ): StoreCreditSelector => {\n return {\n getApplyError: getApplyError(state),\n isApplying: isApplying(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\n\nimport { createSelector } from '../common/selector';\n\nimport SubscriptionsState, { DEFAULT_STATE } from './subscriptions-state';\n\nexport default interface SubscriptionsSelector {\n getUpdateError(): Error | undefined;\n isUpdating(): boolean;\n}\n\nexport type SubscriptionsSelectorFactory = (state: SubscriptionsState) => SubscriptionsSelector;\n\nexport function createSubscriptionsSelectorFactory(): SubscriptionsSelectorFactory {\n const getUpdateError = createSelector(\n (state: SubscriptionsState) => state.errors.updateError,\n error => () => error\n );\n\n const isUpdating = createSelector(\n (state: SubscriptionsState) => !!state.statuses.isUpdating,\n status => () => status\n );\n\n return memoizeOne((\n state: SubscriptionsState = DEFAULT_STATE\n ): SubscriptionsSelector => {\n return {\n getUpdateError: getUpdateError(state),\n isUpdating: isUpdating(state),\n };\n });\n}\n","import { createDataStore } from '@bigcommerce/data-store';\n\nimport { createRequestErrorFactory } from '../common/error';\n\nimport CheckoutStore, { CheckoutStoreOptions } from './checkout-store';\nimport CheckoutStoreState from './checkout-store-state';\nimport createActionTransformer from './create-action-transformer';\nimport createCheckoutStoreReducer from './create-checkout-store-reducer';\nimport { createInternalCheckoutSelectorsFactory } from './create-internal-checkout-selectors';\n\nexport default function createCheckoutStore(\n initialState: Partial<CheckoutStoreState> = {},\n options?: CheckoutStoreOptions\n): CheckoutStore {\n const actionTransformer = createActionTransformer(createRequestErrorFactory());\n const createInternalCheckoutSelectors = createInternalCheckoutSelectorsFactory();\n const stateTransformer = (state: CheckoutStoreState) => createInternalCheckoutSelectors(state);\n\n return createDataStore(\n createCheckoutStoreReducer(),\n initialState,\n { actionTransformer, stateTransformer, ...options }\n );\n}\n","import { PaymentMethodInvalidError } from '../../payment/errors';\n\nimport { UnrecoverableError } from './errors';\nimport RequestErrorFactory from './request-error-factory';\n\nexport default function createRequestErrorFactory(): RequestErrorFactory {\n const factory = new RequestErrorFactory();\n\n const unrecoverableErrorTypes = [\n 'catalog_only',\n 'empty_cart',\n 'invalid_order_id',\n 'invalid_order_token',\n 'missing_order_token',\n 'missing_provider_token',\n 'missing_shipping_method',\n 'order_completion_error',\n 'order_could_not_be_finalized_error',\n 'order_create_failed',\n 'provider_fatal_error',\n 'provider_setup_error',\n 'stock_too_low',\n ];\n\n unrecoverableErrorTypes.forEach(type => {\n factory.register(type, (response, message) => new UnrecoverableError(response, message));\n });\n\n factory.register('invalid_payment_provider', response => new PaymentMethodInvalidError(response));\n factory.register('payment_config_not_found', response => new PaymentMethodInvalidError(response));\n\n return factory;\n}\n","import { Action } from '@bigcommerce/data-store';\nimport { from, Observable, Subscribable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { RequestErrorFactory } from '../common/error';\n\nexport default function createActionTransformer(\n requestErrorFactory: RequestErrorFactory\n): (action: Subscribable<Action>) => Observable<Action> {\n return action$ => from(action$).pipe(catchError<Action, never>(action => {\n if (action instanceof Error || action.payload instanceof Error) {\n throw action;\n }\n\n if (isResponse(action.payload)) {\n const message = action.payload.body && action.payload.body.detail;\n\n throw { ...action, payload: requestErrorFactory.createError(action.payload, message) };\n }\n\n throw action;\n }));\n}\n\nfunction isResponse(object: any) {\n if (!object || typeof object !== 'object') {\n return false;\n }\n\n return ['body', 'headers', 'status', 'statusText'].every(key =>\n Object.prototype.hasOwnProperty.call(object, key)\n );\n}\n","import { combineReducers, Action, Reducer } from '@bigcommerce/data-store';\n\nimport { billingAddressReducer } from '../billing';\nimport { cartReducer } from '../cart';\nimport { checkoutButtonReducer } from '../checkout-buttons';\nimport { configReducer } from '../config';\nimport { couponReducer, giftCertificateReducer } from '../coupon';\nimport { customerReducer, customerStrategyReducer } from '../customer';\nimport { formFieldsReducer } from '../form';\nimport { countryReducer } from '../geography';\nimport { orderReducer } from '../order';\nimport { paymentMethodReducer, paymentReducer, paymentStrategyReducer } from '../payment';\nimport { instrumentReducer } from '../payment/instrument';\nimport { remoteCheckoutReducer } from '../remote-checkout';\nimport { consignmentReducer, pickupOptionReducer, shippingCountryReducer, shippingStrategyReducer } from '../shipping';\nimport { signInEmailReducer } from '../signin-email';\nimport { storeCreditReducer } from '../store-credit';\nimport { subscriptionsReducer } from '../subscription';\n\nimport checkoutReducer from './checkout-reducer';\nimport CheckoutStoreState from './checkout-store-state';\n\nexport default function createCheckoutStoreReducer(): Reducer<CheckoutStoreState, Action> {\n return combineReducers({\n billingAddress: billingAddressReducer,\n cart: cartReducer,\n checkout: checkoutReducer,\n checkoutButton: checkoutButtonReducer,\n config: configReducer,\n consignments: consignmentReducer,\n countries: countryReducer,\n coupons: couponReducer,\n customer: customerReducer,\n customerStrategies: customerStrategyReducer,\n formFields: formFieldsReducer,\n giftCertificates: giftCertificateReducer,\n instruments: instrumentReducer,\n order: orderReducer,\n payment: paymentReducer,\n paymentMethods: paymentMethodReducer,\n paymentStrategies: paymentStrategyReducer,\n pickupOptions: pickupOptionReducer,\n remoteCheckout: remoteCheckoutReducer,\n shippingCountries: shippingCountryReducer,\n shippingStrategies: shippingStrategyReducer,\n signInEmail: signInEmailReducer,\n subscriptions: subscriptionsReducer,\n storeCredit: storeCreditReducer,\n });\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/bigpay-client\");","import { Action, ThunkAction } from '@bigcommerce/data-store';\nimport { memoize } from '@bigcommerce/memoize';\nimport { from, Observable } from 'rxjs';\nimport { shareReplay } from 'rxjs/operators';\n\nexport default function cacheAction<TFunction extends CreateActionFn>(\n fn: TFunction\n): TFunction {\n function decoratedFn(this: any, ...args: any[]) {\n const action = fn.call(this, ...args);\n\n if (action instanceof Observable) {\n return from(action).pipe(shareReplay());\n }\n\n if (typeof action === 'function') {\n return memoize(store => from(action(store)).pipe(shareReplay()));\n }\n\n return action;\n }\n\n return memoize(decoratedFn as TFunction);\n}\n\ntype CreateActionFn = (...args: any[]) => Observable<Action> | ThunkAction<Action> | Action;\n","import ActionOptions from './action-options';\n\nexport default function isActionOptions(param: any): param is ActionOptions {\n return param && typeof param.useCache === 'boolean';\n}\n","import cacheAction from './cache-action';\nimport isActionOptions from './is-action-options';\n\nexport default function cachableActionDecorator<TMethod extends (...args: any[]) => any>(\n _: object,\n key: string,\n descriptor: TypedPropertyDescriptor<TMethod>\n): TypedPropertyDescriptor<TMethod> {\n const memoizedMethods = new WeakMap<object, { [key: string]: TMethod }>();\n\n function decorateMethod(this: object, method: TMethod): TMethod {\n return ((...args: any[]) => {\n const lastArg = args[args.length - 1];\n const { useCache } = isActionOptions(lastArg) ? lastArg : { useCache: false };\n\n if (!useCache) {\n return method.call(this, ...args);\n }\n\n const instanceMethods = memoizedMethods.get(this) || {};\n\n if (!memoizedMethods.get(this)) {\n memoizedMethods.set(this, instanceMethods);\n }\n\n if (!instanceMethods[key]) {\n instanceMethods[key] = cacheAction(method);\n }\n\n return instanceMethods[key].call(this, ...args);\n }) as TMethod;\n }\n\n return {\n get() {\n if (typeof descriptor.value !== 'function') {\n throw new Error('Decorator should be used in functions');\n }\n\n const value = decorateMethod.call(this, descriptor.value);\n\n Object.defineProperty(this, key, { ...descriptor, value });\n\n return value;\n },\n };\n}\n","export interface ApplePayWindow extends Window {\n ApplePaySession: ApplePaySession;\n}\n\nexport default function isApplePayWindow(window: Window): window is ApplePayWindow {\n return 'ApplePaySession' in window;\n}\n\nexport function assertApplePayWindow(window: Window): asserts window is ApplePayWindow {\n if (!isApplePayWindow(window)) {\n throw new Error('Apple pay is not supported');\n }\n}\n","import { createAction, createErrorAction } from '@bigcommerce/data-store';\nimport { filter } from 'lodash';\nimport { Observable, Observer } from 'rxjs';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { RequestOptions } from '../common/http-request';\n\nimport { PaymentMethod } from '.';\nimport { LoadPaymentMethodsAction, LoadPaymentMethodAction, PaymentMethodActionType } from './payment-method-actions';\nimport PaymentMethodRequestSender from './payment-method-request-sender';\nimport { isApplePayWindow } from './strategies/apple-pay';\n\nconst APPLEPAYID = 'applepay';\n\nexport default class PaymentMethodActionCreator {\n constructor(\n private _requestSender: PaymentMethodRequestSender\n ) {}\n\n loadPaymentMethods(options?: RequestOptions): Observable<LoadPaymentMethodsAction> {\n return Observable.create((observer: Observer<LoadPaymentMethodsAction>) => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsRequested));\n\n this._requestSender.loadPaymentMethods(options)\n .then(response => {\n const meta = {\n deviceSessionId: response.headers['x-device-session-id'],\n sessionHash: response.headers['x-session-hash'],\n };\n const methods = response.body;\n const filteredMethods = Array.isArray(methods) ? this._filterApplePay(methods) : methods;\n\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsSucceeded, filteredMethods, meta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(PaymentMethodActionType.LoadPaymentMethodsFailed, response));\n });\n });\n }\n\n @cachableAction\n loadPaymentMethod(methodId: string, options?: RequestOptions & ActionOptions): Observable<LoadPaymentMethodAction> {\n return Observable.create((observer: Observer<LoadPaymentMethodAction>) => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodRequested, undefined, { methodId }));\n\n this._requestSender.loadPaymentMethod(methodId, options)\n .then(response => {\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodSucceeded, response.body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(PaymentMethodActionType.LoadPaymentMethodFailed, response, { methodId }));\n });\n });\n }\n\n private _filterApplePay(methods: PaymentMethod[]): PaymentMethod[] {\n\n return filter(methods, method => {\n if (method.id === APPLEPAYID && !isApplePayWindow(window)) {\n return false;\n }\n\n return true;\n });\n }\n}\n","enum ContentType {\n Json = 'application/json',\n JsonV1 = 'application/vnd.bc.v1+json',\n}\n\nexport default ContentType;\n","export const INTERNAL_USE_ONLY = 'This API endpoint is for internal use only and may change in the future';\n","export const SDK_VERSION_HEADERS = { 'X-Checkout-SDK-Version': LIBRARY_VERSION };\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport PaymentMethod from './payment-method';\n\nexport default class PaymentMethodRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadPaymentMethods({ timeout }: RequestOptions = {}): Promise<Response<PaymentMethod[]>> {\n const url = '/api/storefront/payments';\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n\n loadPaymentMethod(methodId: string, { timeout, params }: RequestOptions = {}): Promise<Response<PaymentMethod>> {\n const url = `/api/storefront/payments/${methodId}`;\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n params,\n });\n }\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","/**\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>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\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)\n .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>(_: object, key: string, descriptor: TypedPropertyDescriptor<T>): 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 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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"shallowequal\");","export interface RootCacheKeyMap {\n maps: ChildCacheKeyMap[];\n}\n\nexport interface IntermediateCacheKeyMap {\n maps: ChildCacheKeyMap[];\n parentMap: RootCacheKeyMap | IntermediateCacheKeyMap;\n usedCount: number;\n value: any;\n}\n\nexport interface TerminalCacheKeyMap extends IntermediateCacheKeyMap {\n cacheKey: string;\n}\n\nexport type ChildCacheKeyMap = IntermediateCacheKeyMap | TerminalCacheKeyMap;\n\nexport function isTerminalCacheKeyMap(map: ChildCacheKeyMap): map is TerminalCacheKeyMap {\n return Object.prototype.hasOwnProperty.call(map, 'cacheKey');\n}\n\nexport function isRootCacheKeyMap(map: RootCacheKeyMap | ChildCacheKeyMap): map is RootCacheKeyMap {\n return Object.prototype.hasOwnProperty.call(map, 'parentMap');\n}\n","import { noop } from 'lodash';\nimport shallowEqual from 'shallowequal';\n\nimport { isRootCacheKeyMap, isTerminalCacheKeyMap, ChildCacheKeyMap, IntermediateCacheKeyMap, RootCacheKeyMap, TerminalCacheKeyMap } from './cache-key-maps';\n\nexport interface CacheKeyResolverOptions {\n maxSize?: number;\n onExpire?(key: string): void;\n isEqual?(valueA: any, valueB: any): boolean;\n}\n\ninterface ResolveResult {\n index: number;\n parentMap: RootCacheKeyMap | IntermediateCacheKeyMap;\n map?: TerminalCacheKeyMap;\n}\n\nexport default class CacheKeyResolver {\n private _lastId = 0;\n private _map: RootCacheKeyMap = { maps: [] };\n private _usedMaps: TerminalCacheKeyMap[] = [];\n private _options: Required<CacheKeyResolverOptions>;\n\n constructor(options?: CacheKeyResolverOptions) {\n this._options = {\n maxSize: 0,\n isEqual: shallowEqual,\n onExpire: noop,\n ...options,\n };\n }\n\n getKey(...args: any[]): string {\n const result = this._resolveMap(...args);\n const { index, parentMap } = result;\n let { map } = result;\n\n if (map && map.cacheKey) {\n map.usedCount++;\n } else {\n map = this._generateMap(parentMap, args.slice(index));\n }\n\n // Keep track of the least used map so we can remove it if the size of\n // the stack exceeds the maximum size.\n this._removeLeastUsedMap(map);\n\n return map.cacheKey;\n }\n\n getUsedCount(...args: any[]): number {\n const { map } = this._resolveMap(...args);\n\n return map ? map.usedCount : 0;\n }\n\n private _resolveMap(...args: any[]): ResolveResult {\n let index = 0;\n let parentMap = this._map;\n\n // Traverse the tree to find the linked list of maps that match the\n // arguments of the call. Each intermediate or terminal map contains a\n // value that could be used to match with the arguments. The last map in\n // the list (the terminal) should contain a cache key. If it can does\n // not exist, we will return a falsy value so that the caller could\n // handle and generate a new cache key.\n while (parentMap.maps.length) {\n let isMatched = false;\n\n for (let mapIndex = 0; mapIndex < parentMap.maps.length; mapIndex++) {\n const map = parentMap.maps[mapIndex];\n\n if (!this._options.isEqual(map.value, args[index])) {\n continue;\n }\n\n // Move the most recently used map to the top of the stack for\n // quicker access\n parentMap.maps.unshift(...parentMap.maps.splice(mapIndex, 1));\n\n if ((args.length === 0 || index === args.length - 1) && isTerminalCacheKeyMap(map)) {\n return { index, map, parentMap };\n }\n\n isMatched = true;\n parentMap = map;\n index++;\n\n break;\n }\n\n if (!isMatched) {\n break;\n }\n }\n\n return { index, parentMap };\n }\n\n private _generateMap(parent: RootCacheKeyMap | IntermediateCacheKeyMap, args: any[]): TerminalCacheKeyMap {\n let index = 0;\n let parentMap = parent;\n let map: IntermediateCacheKeyMap;\n\n do {\n map = {\n maps: [],\n parentMap,\n usedCount: 1,\n value: args[index],\n };\n\n // Continue to build the tree of maps so that it could be resolved\n // next time when the function is called with the same set of\n // arguments.\n parentMap.maps.unshift(map);\n\n parentMap = map;\n index++;\n } while (index < args.length);\n\n const terminalMap = map as TerminalCacheKeyMap;\n\n terminalMap.cacheKey = `${++this._lastId}`;\n\n return terminalMap;\n }\n\n private _removeLeastUsedMap(recentlyUsedMap: TerminalCacheKeyMap): void {\n if (!this._options.maxSize) {\n return;\n }\n\n const index = this._usedMaps.indexOf(recentlyUsedMap);\n\n this._usedMaps.splice(\n index === -1 ? 0 : index,\n index === -1 ? 0 : 1,\n recentlyUsedMap\n );\n\n if (this._usedMaps.length <= this._options.maxSize) {\n return;\n }\n\n const map = this._usedMaps.pop();\n\n if (!map) {\n return;\n }\n\n this._removeMap(map);\n this._options.onExpire(map.cacheKey);\n }\n\n private _removeMap(map: ChildCacheKeyMap): void {\n if (!map.parentMap) {\n return;\n }\n\n map.parentMap.maps.splice(map.parentMap.maps.indexOf(map), 1);\n\n if (isRootCacheKeyMap(map.parentMap)) {\n return;\n }\n\n this._removeMap(map.parentMap);\n }\n}\n","export default function isPrivate(key: string): boolean {\n return `${key}`.indexOf('$$') === 0 || `${key}`.indexOf('_') === 0;\n}\n","import { memoize } from '@bigcommerce/memoize';\n\nimport { bindDecorator, isEqual, isPrivate, CacheKeyResolver } from '../utility';\n\n/**\n * Decorates a class by patching all of its methods to cache their return values\n * and return them if they are called again with the same set of parameters. The\n * decorator also binds all the methods to the calling instance so it can be\n * destructed.\n */\nexport default function selectorDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype)\n .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 selectorMethodDecorator(target.prototype, key, descriptor)\n );\n });\n\n return decoratedTarget;\n}\n\nfunction selectorMethodDecorator<T extends Method>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let resolver = new CacheKeyResolver();\n let method = descriptor.value;\n let memoizedMethod = memoize(method);\n\n return bindDecorator(target, key, {\n get() {\n const value = ((...args: any[]) => {\n const cachedValue = memoizedMethod.call(this, ...args);\n\n if (resolver.getUsedCount(...args) === 1) {\n return cachedValue;\n }\n\n const newValue = method.call(this, ...args);\n\n if (isEqual(newValue, cachedValue, { keyFilter: key => !isPrivate(key) })) {\n return cachedValue;\n }\n\n memoizedMethod.cache.set(resolver.getKey(...args), newValue);\n\n return newValue;\n }) as T;\n\n Object.defineProperty(this, key, { ...descriptor, value });\n\n return value;\n },\n set(value) {\n resolver = new CacheKeyResolver();\n method = value;\n memoizedMethod = memoize(method);\n },\n });\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\ntype Method = (...args: any[]) => any;\n","import { InternalCheckoutSelectors } from '../checkout';\nimport { selector } from '../common/selector';\n\nimport CheckoutButtonSelector from './checkout-button-selector';\nimport { CheckoutButtonMethodType } from './strategies';\n\n@selector\nexport default class CheckoutButtonErrorSelector {\n private _checkoutButton: CheckoutButtonSelector;\n\n /**\n * @internal\n */\n constructor(selectors: InternalCheckoutSelectors) {\n this._checkoutButton = selectors.checkoutButton;\n }\n\n getInitializeButtonError(methodId?: CheckoutButtonMethodType): Error | undefined {\n return this._checkoutButton.getInitializeError(methodId);\n }\n\n getDeinitializeButtonError(methodId?: CheckoutButtonMethodType): Error | undefined {\n return this._checkoutButton.getDeinitializeError(methodId);\n }\n}\n","import { InternalCheckoutSelectors } from '../checkout';\nimport { selector } from '../common/selector';\n\nimport CheckoutButtonSelector from './checkout-button-selector';\nimport { CheckoutButtonMethodType } from './strategies';\n\n@selector\nexport default class CheckoutButtonStatusSelector {\n private _checkoutButton: CheckoutButtonSelector;\n\n /**\n * @internal\n */\n constructor(selectors: InternalCheckoutSelectors) {\n this._checkoutButton = selectors.checkoutButton;\n }\n\n isInitializingButton(methodId?: CheckoutButtonMethodType): boolean {\n return this._checkoutButton.isInitializing(methodId);\n }\n\n isDeinitializingButton(methodId?: CheckoutButtonMethodType): boolean {\n return this._checkoutButton.isDeinitializing(methodId);\n }\n}\n","import { InternalCheckoutSelectors } from '../checkout';\n\nimport CheckoutButtonErrorSelector from './checkout-button-error-selector';\nimport CheckoutButtonSelectors from './checkout-button-selectors';\nimport CheckoutButtonStatusSelector from './checkout-button-status-selector';\n\nexport default function createCheckoutButtonSelectors(selectors: InternalCheckoutSelectors): CheckoutButtonSelectors {\n const errors = new CheckoutButtonErrorSelector(selectors);\n const statuses = new CheckoutButtonStatusSelector(selectors);\n\n return {\n errors,\n statuses,\n };\n}\n","import { CheckoutStore, InternalCheckoutSelectors } from '../checkout';\nimport { isElementId, setUniqueElementId } from '../common/dom';\nimport { bindDecorator as bind } from '../common/utility';\n\nimport { CheckoutButtonInitializeOptions, CheckoutButtonOptions } from './checkout-button-options';\nimport CheckoutButtonSelectors from './checkout-button-selectors';\nimport CheckoutButtonStrategyActionCreator from './checkout-button-strategy-action-creator';\nimport createCheckoutButtonSelectors from './create-checkout-button-selectors';\n\n@bind\nexport default class CheckoutButtonInitializer {\n private _state: CheckoutButtonSelectors;\n\n /**\n * @internal\n */\n constructor(\n private _store: CheckoutStore,\n private _buttonStrategyActionCreator: CheckoutButtonStrategyActionCreator\n ) {\n this._state = createCheckoutButtonSelectors(this._store.getState());\n\n this._store.subscribe(state => {\n this._state = createCheckoutButtonSelectors(state);\n });\n }\n\n /**\n * Returns a snapshot of the current state.\n *\n * The method returns a new instance every time there is a change in the\n * state. You can query the state by calling any of its getter methods.\n *\n * ```js\n * const state = service.getState();\n *\n * console.log(state.errors.getInitializeButtonError());\n * console.log(state.statuses.isInitializingButton());\n * ```\n *\n * @returns The current customer's checkout state\n */\n getState(): CheckoutButtonSelectors {\n return this._state;\n }\n\n /**\n * Subscribes to any changes to the current state.\n *\n * The method registers a callback function and executes it every time there\n * is a change in the current state.\n *\n * ```js\n * service.subscribe(state => {\n * console.log(state.statuses.isInitializingButton());\n * });\n * ```\n *\n * The method can be configured to notify subscribers only regarding\n * relevant changes, by providing a filter function.\n *\n * ```js\n * const filter = state => state.errors.getInitializeButtonError();\n *\n * // Only trigger the subscriber when the cart changes.\n * service.subscribe(state => {\n * console.log(state.errors.getInitializeButtonError())\n * }, filter);\n * ```\n *\n * @param subscriber - The function to subscribe to state changes.\n * @param filters - One or more functions to filter out irrelevant state\n * changes. If more than one function is provided, the subscriber will only\n * be triggered if all conditions are met.\n * @returns A function, if called, will unsubscribe the subscriber.\n */\n subscribe(\n subscriber: (state: CheckoutButtonSelectors) => void,\n ...filters: Array<(state: CheckoutButtonSelectors) => any>\n ): () => void {\n return this._store.subscribe(\n () => subscriber(this.getState()),\n state => state.checkoutButton.getState(),\n ...filters.map(filter => (state: InternalCheckoutSelectors) => filter(createCheckoutButtonSelectors(state)))\n );\n }\n\n /**\n * Initializes the checkout button of a payment method.\n *\n * When the checkout button is initialized, it will be inserted into the DOM,\n * ready to be interacted with by the customer.\n *\n * ```js\n * initializer.initializeButton({\n * methodId: 'braintreepaypal',\n * containerId: 'checkoutButton',\n * braintreepaypal: {\n * },\n * });\n * ```\n *\n * @param options - Options for initializing the checkout button.\n * @returns A promise that resolves to the current state.\n */\n initializeButton(options: CheckoutButtonInitializeOptions): Promise<CheckoutButtonSelectors> {\n const containerIds = isElementId(options.containerId) ?\n [options.containerId] :\n setUniqueElementId(options.containerId, `${options.methodId}-container`);\n\n return Promise.all(\n containerIds.map(containerId => {\n const action = this._buttonStrategyActionCreator.initialize({ ...options, containerId });\n const queueId = `checkoutButtonStrategy:${options.methodId}:${containerId}`;\n\n return this._store.dispatch(action, { queueId });\n })\n )\n .then(() => this.getState());\n }\n\n /**\n * De-initializes the checkout button by performing any necessary clean-ups.\n *\n * ```js\n * await service.deinitializeButton({\n * methodId: 'braintreepaypal',\n * });\n * ```\n *\n * @param options - Options for deinitializing the checkout button.\n * @returns A promise that resolves to the current state.\n */\n deinitializeButton(options: CheckoutButtonOptions): Promise<CheckoutButtonSelectors> {\n const action = this._buttonStrategyActionCreator.deinitialize(options);\n const queueId = `checkoutButtonStrategy:${options.methodId}`;\n\n return this._store.dispatch(action, { queueId })\n .then(() => this.getState());\n }\n}\n","/* eslint-disable no-useless-escape */\nexport default function isElementId(id: string): boolean {\n return /^\\w[\\w\\-\\:\\.]*$/.test(id);\n}\n","import { uniqueId } from 'lodash';\n\nimport { InvalidArgumentError } from '../error/errors';\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(`Unable to find any element with the specified selector: ${selector}`);\n }\n\n return Array.prototype.slice.call(containers)\n .map((container: HTMLElement) => {\n if (!container.id) {\n container.id = uniqueId(idPrefix);\n }\n\n return container.id;\n });\n}\n","import { createErrorAction, Action } from '@bigcommerce/data-store';\nimport { concat, of, throwError, Observable } from 'rxjs';\n\nexport default function throwErrorAction<TPayload, TMeta, TType extends string>(\n type: TType,\n error?: TPayload,\n meta?: TMeta\n): Observable<Action<TPayload, TMeta, TType>> {\n if (isErrorAction(error)) {\n return concat(of(error), throwError(createErrorAction(type, error.payload, meta)));\n }\n\n return throwError(createErrorAction(type, error, meta));\n}\n\nfunction isErrorAction(action: any): action is Action {\n return action && action.type && action.error;\n}\n","enum CheckoutButtonMethodType {\n APPLEPAY = 'applepay',\n AMAZON_PAY_V2 = 'amazonpay',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_PAYPALV2 = 'braintreepaypalv2', // TODO: remove this code when PAYPAL-1518 hits Tier3\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n BRAINTREE_PAYPAL_CREDITV2 = 'braintreepaypalcreditv2', // TODO: remove this code when PAYPAL-1518 hits Tier3\n GOOGLEPAY_ADYENV2 = 'googlepayadyenv2',\n GOOGLEPAY_ADYENV3 = 'googlepayadyenv3',\n GOOGLEPAY_AUTHORIZENET = 'googlepayauthorizenet',\n GOOGLEPAY_BRAINTREE = 'googlepaybraintree',\n GOOGLEPAY_CHECKOUTCOM = 'googlepaycheckoutcom',\n GOOGLEPAY_CYBERSOURCEV2 = 'googlepaycybersourcev2',\n GOOGLEPAY_ORBITAL = 'googlepayorbital',\n GOOGLEPAY_STRIPE = 'googlepaystripe',\n GOOGLEPAY_STRIPEUPE = 'googlepaystripeupe',\n MASTERPASS = 'masterpass',\n PAYPALEXPRESS = 'paypalexpress',\n PAYPALCOMMERCE = 'paypalcommerce',\n}\n\nexport default CheckoutButtonMethodType;\n","import { createAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, empty, of } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { Registry } from '../common/registry';\nimport { PaymentMethodActionCreator } from '../payment';\n\nimport { CheckoutButtonActionType, DeinitializeButtonAction, InitializeButtonAction } from './checkout-button-actions';\nimport { CheckoutButtonInitializeOptions, CheckoutButtonOptions } from './checkout-button-options';\nimport { CheckoutButtonMethodType, CheckoutButtonStrategy } from './strategies';\n\nconst methodMap: { [key: string]: CheckoutButtonMethodType | undefined } = {\n [CheckoutButtonMethodType.BRAINTREE_PAYPALV2]: CheckoutButtonMethodType.BRAINTREE_PAYPAL, // TODO: this code should be removed after PAYPAL-1518 hits Tier3\n [CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDITV2]: CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, // TODO: this code should be removed after PAYPAL-1518 hits Tier3\n};\n\nconst mapCheckoutButtonMethodId = (methodId: CheckoutButtonMethodType) => {\n return methodMap[methodId] || methodId;\n};\n\nexport default class CheckoutButtonStrategyActionCreator {\n constructor(\n private _registry: Registry<CheckoutButtonStrategy>,\n private _paymentMethodActionCreator: PaymentMethodActionCreator\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): ThunkAction<InitializeButtonAction, InternalCheckoutSelectors> {\n return store => {\n const meta = { methodId: options.methodId, containerId: options.containerId };\n\n if (store.getState().checkoutButton.isInitialized(options.methodId, options.containerId)) {\n return empty();\n }\n\n return concat(\n of(createAction(CheckoutButtonActionType.InitializeButtonRequested, undefined, meta)),\n this._paymentMethodActionCreator.loadPaymentMethod(mapCheckoutButtonMethodId(options.methodId), { timeout: options.timeout, useCache: true }),\n defer(() => this._registry.get(options.methodId).initialize(options)\n .then(() => createAction(CheckoutButtonActionType.InitializeButtonSucceeded, undefined, meta)))\n ).pipe(\n catchError(error => throwErrorAction(CheckoutButtonActionType.InitializeButtonFailed, error, meta))\n );\n };\n }\n\n deinitialize(options: CheckoutButtonOptions): ThunkAction<DeinitializeButtonAction, InternalCheckoutSelectors> {\n return store => {\n const meta = { methodId: options.methodId };\n\n if (!store.getState().checkoutButton.isInitialized(options.methodId)) {\n return empty();\n }\n\n return concat(\n of(createAction(CheckoutButtonActionType.DeinitializeButtonRequested, undefined, meta)),\n defer(() => this._registry.get(options.methodId).deinitialize()\n .then(() => createAction(CheckoutButtonActionType.DeinitializeButtonSucceeded, undefined, meta)))\n ).pipe(\n catchError(error => throwErrorAction(CheckoutButtonActionType.DeinitializeButtonFailed, error, meta))\n );\n };\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@bigcommerce/script-loader\");","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when a shopper tries to sign in as a guest but\n * they are already signed in as a registered customer.\n */\nexport default class UnableToContinueAsGuestError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to continue as a guest because the customer is already signed in.');\n\n this.name = 'UnableToContinueAsGuestError';\n this.type = 'unable_to_continue_as_guest';\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { Response } from '@bigcommerce/request-sender';\nimport { concat, defer, empty, merge, of, Observable, Observer } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { Checkout, InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { GuestCredentials } from '../customer';\nimport { SubscriptionsActionCreator, UpdateSubscriptionsAction } from '../subscription';\n\nimport { BillingAddressRequestSender } from '.';\nimport { BillingAddressUpdateRequestBody } from './billing-address';\nimport { BillingAddressActionType, ContinueAsGuestAction, UpdateBillingAddressAction } from './billing-address-actions';\nimport { UnableToContinueAsGuestError } from './errors';\n\nexport default class BillingAddressActionCreator {\n constructor(\n private _requestSender: BillingAddressRequestSender,\n private _subscriptionActionCreator: SubscriptionsActionCreator\n ) {}\n\n continueAsGuest(\n credentials: GuestCredentials,\n options?: RequestOptions\n ): ThunkAction<ContinueAsGuestAction | UpdateSubscriptionsAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const customer = state.customer.getCustomer();\n\n if (customer && !customer.isGuest) {\n throw new UnableToContinueAsGuestError();\n }\n\n const billingAddress = state.billingAddress.getBillingAddress();\n\n let billingAddressRequestBody: Partial<BillingAddressUpdateRequestBody>;\n\n if (!billingAddress) {\n billingAddressRequestBody = credentials;\n } else {\n const { country, ...existingBillingAddressRequestBody } = billingAddress;\n\n billingAddressRequestBody = {\n ...existingBillingAddressRequestBody,\n ...credentials,\n };\n }\n\n return merge(\n concat(\n of(createAction(BillingAddressActionType.ContinueAsGuestRequested)),\n defer(async () => {\n const { body } = await this._createOrUpdateBillingAddress(\n checkout.id,\n billingAddressRequestBody,\n options\n );\n\n return createAction(BillingAddressActionType.ContinueAsGuestSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(BillingAddressActionType.ContinueAsGuestFailed, error))\n ),\n this._updateCustomerConsent(credentials, options)\n );\n };\n }\n\n updateAddress(\n address: Partial<BillingAddressUpdateRequestBody>,\n options?: RequestOptions\n ): ThunkAction<UpdateBillingAddressAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateBillingAddressAction>) => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(BillingAddressActionType.UpdateBillingAddressRequested));\n\n const billingAddress = state.billingAddress.getBillingAddress();\n\n // If email is not present in the address provided by the client, then\n // fall back to the stored email as it could have been set separately\n // using a convenience method. We can't rely on billingAddress having\n // an ID to consider that there's a preexisting email, as billingAddress\n // object from Order doesn't have an ID.\n const billingAddressRequestBody = {\n ...address,\n email: typeof address.email === 'undefined' && billingAddress ? billingAddress.email : address.email,\n };\n\n if (billingAddress && billingAddress.id) {\n billingAddressRequestBody.id = billingAddress.id;\n }\n\n this._createOrUpdateBillingAddress(checkout.id, billingAddressRequestBody, options)\n .then(({ body }) => {\n observer.next(createAction(BillingAddressActionType.UpdateBillingAddressSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(BillingAddressActionType.UpdateBillingAddressFailed, response));\n });\n });\n }\n\n private _updateCustomerConsent(\n {\n email,\n acceptsAbandonedCartEmails,\n acceptsMarketingNewsletter,\n }: GuestCredentials,\n options?: RequestOptions\n ): Observable<UpdateSubscriptionsAction> {\n if ((acceptsAbandonedCartEmails === undefined || acceptsAbandonedCartEmails === null) &&\n (acceptsMarketingNewsletter === undefined || acceptsMarketingNewsletter === null)) {\n return empty();\n }\n\n return this._subscriptionActionCreator.updateSubscriptions({\n email,\n acceptsMarketingNewsletter: acceptsMarketingNewsletter || false,\n acceptsAbandonedCartEmails: acceptsAbandonedCartEmails || false,\n }, options);\n }\n\n private _createOrUpdateBillingAddress(\n checkoutId: string,\n address: Partial<BillingAddressUpdateRequestBody>,\n options?: RequestOptions\n ): Promise<Response<Checkout>> {\n if (!address.id) {\n return this._requestSender.createAddress(checkoutId, address, options);\n }\n\n return this._requestSender.updateAddress(checkoutId, address, options);\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { AddressRequestBody } from '../address';\nimport { Checkout } from '../checkout';\nimport { ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { BillingAddressUpdateRequestBody } from './billing-address';\n\nconst DEFAULT_PARAMS = {\n include: [\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'promotions.banners',\n ].join(','),\n};\n\nexport default class BillingAddressRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n createAddress(checkoutId: string, address: Partial<AddressRequestBody>, { timeout }: RequestOptions = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/billing-address`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, { body: address, params: DEFAULT_PARAMS, headers, timeout });\n }\n\n updateAddress(checkoutId: string, address: Partial<BillingAddressUpdateRequestBody>, { timeout }: RequestOptions = {}): Promise<Response<Checkout>> {\n const { id, ...body } = address;\n const url = `/api/storefront/checkouts/${checkoutId}/billing-address/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, { params: DEFAULT_PARAMS, body, headers, timeout });\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, merge, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { ConfigActionCreator } from '../config';\nimport { FormFieldsActionCreator } from '../form';\n\nimport { CheckoutRequestBody } from './checkout';\nimport { CheckoutActionType, LoadCheckoutAction, UpdateCheckoutAction } from './checkout-actions';\nimport CheckoutRequestSender from './checkout-request-sender';\nimport InternalCheckoutSelectors from './internal-checkout-selectors';\n\nexport default class CheckoutActionCreator {\n constructor(\n private _checkoutRequestSender: CheckoutRequestSender,\n private _configActionCreator: ConfigActionCreator,\n private _formFieldsActionCreator: FormFieldsActionCreator\n ) {}\n\n loadCheckout(id: string, options?: RequestOptions): Observable<LoadCheckoutAction> {\n return concat(\n of(createAction(CheckoutActionType.LoadCheckoutRequested)),\n merge(\n this._configActionCreator.loadConfig({ ...options, useCache: true, params: {...options?.params, checkoutId: id} }),\n this._formFieldsActionCreator.loadFormFields({ ...options, useCache: true }),\n defer(() => this._checkoutRequestSender.loadCheckout(id, options)\n .then(({ body }) => createAction(CheckoutActionType.LoadCheckoutSucceeded, body)))\n )\n ).pipe(\n catchError(error => throwErrorAction(CheckoutActionType.LoadCheckoutFailed, error))\n );\n }\n\n loadDefaultCheckout(options?: RequestOptions): ThunkAction<LoadCheckoutAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(CheckoutActionType.LoadCheckoutRequested)),\n merge(\n this._configActionCreator.loadConfig(),\n this._formFieldsActionCreator.loadFormFields({ ...options, useCache: true })\n ),\n defer(async () => {\n const state = store.getState();\n const context = state.config.getContextConfig();\n\n if (!context || !context.checkoutId) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckoutConfig);\n }\n\n const { body } = await this._checkoutRequestSender.loadCheckout(context.checkoutId, options);\n\n return createAction(CheckoutActionType.LoadCheckoutSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(CheckoutActionType.LoadCheckoutFailed, error))\n );\n }\n\n updateCheckout(\n body: CheckoutRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateCheckoutAction, InternalCheckoutSelectors> {\n return store => new Observable(observer => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(CheckoutActionType.UpdateCheckoutRequested));\n\n this._checkoutRequestSender.updateCheckout(checkout.id, body, options)\n .then(({ body }) => {\n observer.next(createAction(CheckoutActionType.UpdateCheckoutSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(CheckoutActionType.UpdateCheckoutFailed, response));\n });\n });\n }\n\n loadCurrentCheckout(options?: RequestOptions): ThunkAction<LoadCheckoutAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n return this.loadCheckout(checkout.id, options);\n };\n }\n}\n","import { uniq } from 'lodash';\n\nexport default function joinIncludes<T>(includes: T[]): string {\n return uniq(includes).join(',');\n}\n","import joinIncludes from './join-includes';\nimport mergeIncludes from './merge-includes';\n\n/**\n * Joins or merges a base list of includes with a set of additional includes.\n */\nexport default function joinOrMergeIncludes<T extends string>(\n baseIncludes: T[],\n includeDictionaryOrList: { [key in T]?: boolean } | T[] = []\n): string {\n return Array.isArray(includeDictionaryOrList) ?\n joinIncludes([\n ...baseIncludes,\n ...includeDictionaryOrList,\n ]) :\n mergeIncludes(baseIncludes, includeDictionaryOrList);\n}\n","import { difference, filter, keys, pickBy } from 'lodash';\n\nimport joinIncludes from './join-includes';\n\n/**\n * Merges includes given a list of base includes and a dictionary\n * of includes\n */\nexport default function mergeIncludes<T extends string>(\n baseIncludes: T[],\n includesDictionary?: { [key in T]?: boolean }\n): string {\n const deletions = keys(pickBy(includesDictionary, on => !on));\n const additions = keys(filter(includesDictionary));\n\n return joinIncludes([\n ...difference(baseIncludes, deletions),\n ...additions,\n ]);\n}\n","const CHECKOUT_DEFAULT_INCLUDES = [\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'customer.customerGroup',\n 'payments',\n 'promotions.banners',\n];\n\nexport default CHECKOUT_DEFAULT_INCLUDES;\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../../common/error';\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error when we are unable to retrieve a checkout object from the\n * server using the provided ID. It could be because the shopper does not have\n * permission to view the object, or the ID itself is invalid.\n */\nexport default class CheckoutNotAvailableError extends RequestError {\n constructor(response: Response<InternalErrorResponseBody>) {\n super(response, { message: response.body.title });\n\n this.name = 'CheckoutNotAvailableError';\n this.type = 'checkout_not_available';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { joinOrMergeIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport Checkout, { CheckoutRequestBody } from './checkout';\nimport CHECKOUT_DEFAULT_INCLUDES from './checkout-default-includes';\nimport CheckoutParams from './checkout-params';\nimport { CheckoutNotAvailableError } from './errors';\n\nexport default class CheckoutRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadCheckout(id: string, { params: { include } = {}, timeout }: RequestOptions<CheckoutParams> = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkout/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.get<Checkout>(url, {\n params: {\n include: joinOrMergeIncludes(CHECKOUT_DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n }).catch(error => {\n if (error.status >= 400 && error.status < 500) {\n throw new CheckoutNotAvailableError(error);\n }\n\n throw error;\n });\n }\n\n updateCheckout(id: string, body: CheckoutRequestBody, { params: { include } = {}, timeout }: RequestOptions<CheckoutParams> = {}): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkout/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, {\n params: {\n include: joinOrMergeIncludes(CHECKOUT_DEFAULT_INCLUDES, include),\n },\n body,\n headers,\n timeout,\n });\n }\n}\n","import { isEqual } from 'lodash';\n\nimport { PartialDeep } from '../common/types';\n\nimport Cart from './cart';\n\nexport default class CartComparator {\n isEqual(cartA: Cart, cartB: Cart): boolean {\n return isEqual(\n this._normalize(cartA),\n this._normalize(cartB)\n );\n }\n\n private _normalize(cart: Cart): PartialDeep<Cart> {\n return {\n cartAmount: cart.cartAmount,\n currency: cart.currency,\n id: cart.id,\n lineItems: {\n digitalItems: cart.lineItems.digitalItems\n .slice()\n .sort((itemA, itemB) =>\n `${itemA.productId}${itemA.variantId}`.localeCompare(`${itemB.productId}${itemB.variantId}`)\n )\n .map(item => ({\n extendedSalePrice: item.extendedSalePrice,\n productId: item.productId,\n quantity: item.quantity,\n variantId: item.variantId,\n })),\n giftCertificates: cart.lineItems.giftCertificates\n .slice()\n .sort((itemA, itemB) => `${itemA.id}`.localeCompare(`${itemB.id}`))\n .map(item => ({\n amount: item.amount,\n recipient: item.recipient,\n })),\n physicalItems: cart.lineItems.physicalItems\n .slice()\n .sort((itemA, itemB) =>\n `${itemA.productId}${itemA.variantId}`.localeCompare(`${itemB.productId}${itemB.variantId}`)\n )\n .map(item => ({\n extendedSalePrice: item.extendedSalePrice,\n productId: item.productId,\n quantity: item.quantity,\n variantId: item.variantId,\n giftWrapping: item.giftWrapping,\n })),\n },\n };\n }\n}\n","import { ComparableCheckout } from '../../checkout';\nimport { StandardError } from '../../common/error/errors';\n\nexport default class CartChangedError extends StandardError {\n /**\n * @alpha\n * Please note that this option is currently in an early stage of\n * development. Therefore the API is unstable and not ready for public\n * consumption.\n */\n data: { previous: ComparableCheckout; updated: ComparableCheckout };\n\n constructor(\n previous: ComparableCheckout,\n updated: ComparableCheckout\n ) {\n super('An update to your shopping cart has been detected and your available shipping costs have been updated.');\n\n this.name = 'CartChangedError';\n this.type = 'cart_changed';\n this.data = {\n previous,\n updated,\n };\n }\n}\n","import { isEqual, map } from 'lodash';\n\nimport { Cart, CartComparator } from '../cart';\nimport { CartChangedError } from '../cart/errors';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { Coupon, GiftCertificate } from '../coupon';\n\nimport Checkout from './checkout';\nimport CheckoutRequestSender from './checkout-request-sender';\nexport type ComparableCheckout = Pick<Checkout, 'outstandingBalance' | 'coupons' | 'giftCertificates'>\n & {\n cart: Partial<Cart>;\n };\n\nexport default class CheckoutValidator {\n constructor(\n private _checkoutRequestSender: CheckoutRequestSender\n ) {}\n\n validate(checkout?: Checkout, options?: RequestOptions): Promise<void> {\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n return this._checkoutRequestSender.loadCheckout(checkout.id, options)\n .then(response => {\n const comparator = new CartComparator();\n\n if (checkout.outstandingBalance === response.body.outstandingBalance\n && this._compareCoupons(checkout.coupons, response.body.coupons)\n && this._compareGiftCertificates(checkout.giftCertificates, response.body.giftCertificates)\n && comparator.isEqual(checkout.cart, response.body.cart)\n ) {\n return;\n }\n\n throw new CartChangedError(\n this._getComparableCheckout(checkout),\n this._getComparableCheckout(response.body)\n );\n });\n }\n\n private _compareCoupons(couponsA: Coupon[], couponsB: Coupon[]): boolean {\n return isEqual(map(couponsA, 'code'), map(couponsB, 'code'));\n }\n\n private _compareGiftCertificates(giftCertificatesA: GiftCertificate[], giftCertificatesB: GiftCertificate[]): boolean {\n return isEqual(map(giftCertificatesA, 'code'), map(giftCertificatesB, 'code'));\n }\n\n private _getComparableCheckout(\n checkout: Checkout\n ): ComparableCheckout {\n const { cart, coupons, giftCertificates, outstandingBalance } = checkout;\n\n return {\n cart: {\n cartAmount: cart.cartAmount,\n currency: cart.currency,\n lineItems: cart.lineItems,\n },\n coupons,\n giftCertificates,\n outstandingBalance,\n };\n }\n}\n","import { InvalidArgumentError } from '../error/errors';\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 _options: RegistryOptions;\n\n constructor(options?: RegistryOptions) {\n this._factories = {};\n this._instances = {};\n this._options = { defaultToken: 'default', ...options };\n }\n\n get(token?: K, cacheToken?: string): T {\n try {\n return this._getInstance(\n token || this._options.defaultToken,\n cacheToken || token || this._options.defaultToken\n );\n } catch (error) {\n return this._getInstance(\n this._options.defaultToken,\n cacheToken || this._options.defaultToken\n );\n }\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._factories[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 type Factory<T> = () => T;\n\nexport interface RegistryOptions {\n defaultToken: string;\n}\n","import { createAction, createErrorAction } from '@bigcommerce/data-store';\nimport { Observable, Observer } from 'rxjs';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { RequestOptions } from '../common/http-request';\n\nimport { ConfigRequestSender } from '.';\nimport { ConfigActionType, LoadConfigAction } from './config-actions';\n\nexport default class ConfigActionCreator {\n constructor(\n private _configRequestSender: ConfigRequestSender\n ) {}\n\n @cachableAction\n loadConfig(options?: RequestOptions & ActionOptions): Observable<LoadConfigAction> {\n return Observable.create((observer: Observer<LoadConfigAction>) => {\n observer.next(createAction(ConfigActionType.LoadConfigRequested));\n\n this._configRequestSender.loadConfig(options)\n .then(response => {\n observer.next(createAction(ConfigActionType.LoadConfigSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConfigActionType.LoadConfigFailed, response));\n });\n });\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { CheckoutNotAvailableError } from '../checkout/errors';\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport Config from './config';\n\nexport default class ConfigRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadConfig({ timeout, params }: RequestOptions = {}): Promise<Response<Config>> {\n const url = '/api/storefront/checkout-settings';\n\n return this._requestSender.get<Config>(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n params,\n }).catch(error => {\n if (error.status >= 400 && error.status < 500) {\n throw new CheckoutNotAvailableError(error);\n }\n throw error;\n });\n }\n}\n","import { createAction } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { cachableAction, ActionOptions } from '../common/data-store';\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\n\nimport { FormFieldsActionType, LoadFormFieldsAction } from './form-fields-actions';\nimport FormFieldsRequestSender from './form-fields-request-sender';\n\nexport default class FormFieldsActionCreator {\n constructor(\n private _formFieldsRequestSender: FormFieldsRequestSender\n ) {}\n\n @cachableAction\n loadFormFields(options?: RequestOptions & ActionOptions): Observable<LoadFormFieldsAction> {\n return concat(\n of(createAction(FormFieldsActionType.LoadFormFieldsRequested)),\n defer(async () => {\n const { body } = await this._formFieldsRequestSender.loadFields(options);\n\n return createAction(FormFieldsActionType.LoadFormFieldsSucceeded, body);\n })\n ).pipe(\n catchError(response => throwErrorAction(FormFieldsActionType.LoadFormFieldsFailed, response))\n );\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { FormFields } from './form-field';\n\nexport default class FormFieldsRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadFields({ timeout }: RequestOptions = {}): Promise<Response<FormFields>> {\n const url = '/api/storefront/form-fields';\n\n return this._requestSender.get(url, {\n timeout,\n headers: {\n Accept: ContentType.JsonV1,\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam check.\n */\nexport default class SpamProtectionNotCompletedError extends StandardError {\n constructor() {\n super('You haven\\'t complete our spam check. Please try again.');\n\n this.name = 'SpamProtectionNotCompletedError';\n this.type = 'spam_protection_not_completed';\n }\n}\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, from, of, Observable, Observer } from 'rxjs';\nimport { catchError, switchMap } from 'rxjs/operators';\n\nimport { CheckoutValidator, InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\nimport { SpamProtectionNotCompletedError } from '../spam-protection/errors';\n\nimport InternalOrderRequestBody from './internal-order-request-body';\nimport { FinalizeOrderAction, LoadOrderAction, LoadOrderPaymentsAction, OrderActionType, SubmitOrderAction } from './order-actions';\nimport OrderRequestBody from './order-request-body';\nimport OrderRequestSender from './order-request-sender';\n\nexport default class OrderActionCreator {\n constructor(\n private _orderRequestSender: OrderRequestSender,\n private _checkoutValidator: CheckoutValidator\n ) {}\n\n loadOrder(orderId: number, options?: RequestOptions): Observable<LoadOrderAction> {\n return new Observable((observer: Observer<LoadOrderAction>) => {\n observer.next(createAction(OrderActionType.LoadOrderRequested));\n\n this._orderRequestSender.loadOrder(orderId, options)\n .then(response => {\n observer.next(createAction(OrderActionType.LoadOrderSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(OrderActionType.LoadOrderFailed, response));\n });\n });\n }\n\n // TODO: Remove when checkout does not contain unrelated order data.\n loadOrderPayments(orderId: number, options?: RequestOptions): Observable<LoadOrderPaymentsAction> {\n return new Observable((observer: Observer<LoadOrderPaymentsAction>) => {\n observer.next(createAction(OrderActionType.LoadOrderPaymentsRequested));\n\n this._orderRequestSender.loadOrder(orderId, options)\n .then(response => {\n observer.next(createAction(OrderActionType.LoadOrderPaymentsSucceeded, response.body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(OrderActionType.LoadOrderPaymentsFailed, response));\n });\n });\n }\n\n loadCurrentOrder(options?: RequestOptions): ThunkAction<LoadOrderAction, InternalCheckoutSelectors> {\n return store => defer(() => {\n const orderId = this._getCurrentOrderId(store.getState());\n\n if (!orderId) {\n throw new MissingDataError(MissingDataErrorType.MissingOrderId);\n }\n\n return this.loadOrder(orderId, options);\n });\n }\n\n submitOrder(payload?: OrderRequestBody, options?: RequestOptions): ThunkAction<SubmitOrderAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(OrderActionType.SubmitOrderRequested)),\n defer(() => {\n const state = store.getState();\n const externalSource = state.config.getExternalSource();\n const variantIdentificationToken = state.config.getVariantIdentificationToken();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (checkout.shouldExecuteSpamCheck) {\n throw new SpamProtectionNotCompletedError();\n }\n\n return from(\n this._checkoutValidator.validate(checkout, options)\n .then(() => this._orderRequestSender.submitOrder(\n this._mapToOrderRequestBody(\n payload ?? {},\n checkout.id,\n checkout.customerMessage,\n externalSource\n ),\n {\n ...options,\n headers: {\n checkoutVariant: variantIdentificationToken,\n },\n }))\n ).pipe(\n switchMap(response => concat(\n // TODO: Remove once we can submit orders using storefront API\n this.loadOrder(response.body.data.order.orderId, options),\n of(createAction(OrderActionType.SubmitOrderSucceeded, response.body.data, { ...response.body.meta, token: response.headers.token }))\n ))\n );\n }).pipe(\n catchError(error => throwErrorAction(OrderActionType.SubmitOrderFailed, error))\n )\n );\n }\n\n finalizeOrder(orderId: number, options?: RequestOptions): Observable<FinalizeOrderAction | LoadOrderAction> {\n return concat(\n of(createAction(OrderActionType.FinalizeOrderRequested)),\n from(this._orderRequestSender.finalizeOrder(orderId, options))\n .pipe(\n switchMap(response => concat(\n this.loadOrder(orderId, options),\n of(createAction(OrderActionType.FinalizeOrderSucceeded, response.body.data))\n ))\n )\n ).pipe(\n catchError(error => throwErrorAction(OrderActionType.FinalizeOrderFailed, error))\n );\n }\n\n private _getCurrentOrderId(state: InternalCheckoutSelectors): number | undefined {\n const order = state.order.getOrder();\n const checkout = state.checkout.getCheckout();\n\n return (order && order.orderId) || (checkout && checkout.orderId);\n }\n\n private _mapToOrderRequestBody(\n payload: OrderRequestBody,\n cartId: string,\n customerMessage: string,\n externalSource?: string\n ): InternalOrderRequestBody {\n const { payment, ...order } = payload;\n\n if (!payment) {\n return {\n ...order,\n cartId,\n customerMessage,\n externalSource,\n };\n }\n\n return {\n ...order,\n cartId,\n customerMessage,\n externalSource,\n payment: {\n paymentData: payment.paymentData,\n name: payment.methodId,\n gateway: payment.gatewayId,\n },\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Checkout prevents consumers from placing their orders when a merchant wishes\n * to be able to block transactions if the automated tax provider cannot be reached.\n */\nexport default class OrderTaxProviderUnavailableError extends StandardError {\n constructor(message?: string) {\n super(message || 'The tax provider is unavailable.');\n\n this.name = 'OrderTaxProviderUnavailableError';\n this.type = 'tax_provider_unavailable';\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\nimport { isNil, omitBy } from 'lodash';\n\nimport { joinIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { OrderTaxProviderUnavailableError } from './errors';\nimport InternalOrderRequestBody from './internal-order-request-body';\nimport { InternalOrderResponseBody } from './internal-order-responses';\nimport Order from './order';\nimport OrderParams from './order-params';\n\nexport interface SubmitOrderRequestOptions extends RequestOptions {\n headers?: {\n checkoutVariant?: string;\n };\n}\n\nexport default class OrderRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n loadOrder(orderId: number, { timeout, params }: RequestOptions<OrderParams> = {}): Promise<Response<Order>> {\n const url = `/api/storefront/orders/${orderId}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n const include = [\n 'payments',\n 'lineItems.physicalItems.socialMedia',\n 'lineItems.physicalItems.options',\n 'lineItems.digitalItems.socialMedia',\n 'lineItems.digitalItems.options',\n ];\n\n return this._requestSender.get(url, {\n params: {\n include: joinIncludes([\n ...include,\n ...(params && params.include || []),\n ]),\n },\n headers,\n timeout,\n });\n }\n\n submitOrder(body?: InternalOrderRequestBody, { headers, timeout }: SubmitOrderRequestOptions = {}): Promise<Response<InternalOrderResponseBody>> {\n const url = '/internalapi/v1/checkout/order';\n\n return this._requestSender.post<InternalOrderResponseBody>(url, {\n body,\n headers: omitBy({\n 'X-Checkout-Variant': headers && headers.checkoutVariant,\n ...SDK_VERSION_HEADERS,\n }, isNil),\n timeout,\n }).catch(error => {\n if (error.body.type === 'tax_provider_unavailable') {\n throw new OrderTaxProviderUnavailableError();\n }\n\n throw error;\n });\n }\n\n finalizeOrder(orderId: number, { timeout }: RequestOptions = {}): Promise<Response<InternalOrderResponseBody>> {\n const url = `/internalapi/v1/checkout/order/${orderId}`;\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport PaymentRequestBody from './payment-request-body';\n\n/**\n * @todo Convert this file into TypeScript properly\n */\nexport default class PaymentRequestSender {\n /**\n * @constructor\n * @param {BigpayClient} client\n */\n constructor(\n private _client: any\n ) {}\n\n submitPayment(payload: PaymentRequestBody): Promise<Response<any>> {\n return new Promise((resolve, reject) => {\n this._client.submitPayment(payload, (error: any, response: any) => {\n if (error) {\n reject(this._transformResponse(error));\n } else {\n resolve(this._transformResponse(response));\n }\n });\n });\n }\n\n initializeOffsitePayment(payload: PaymentRequestBody, target?: string): Promise<void> {\n return new Promise(() => {\n this._client.initializeOffsitePayment(payload, null, target);\n });\n }\n\n private _transformResponse(response: any): Response<any> {\n return {\n headers: response.headers,\n body: response.data,\n status: response.status,\n statusText: response.statusText,\n };\n }\n}\n","import { isBillingAddressLike, BillingAddress } from '../billing';\nimport { Consignment } from '../shipping';\n\nimport Address from './address';\nimport InternalAddress from './internal-address';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalAddress(\n address: Address | BillingAddress,\n consignments?: Consignment[]\n): InternalAddress<any> {\n let addressId;\n\n if (isBillingAddressLike(address)) {\n addressId = address.id;\n } else if (consignments && consignments.length) {\n addressId = consignments[0].id;\n }\n\n return {\n id: addressId,\n firstName: address.firstName,\n lastName: address.lastName,\n company: address.company,\n addressLine1: address.address1,\n addressLine2: address.address2,\n city: address.city,\n province: address.stateOrProvince,\n provinceCode: address.stateOrProvinceCode,\n postCode: address.postalCode,\n country: address.country,\n countryCode: address.countryCode,\n phone: address.phone,\n customFields: address.customFields,\n };\n}\n","import { Address } from '../address';\n\nimport BillingAddress from './billing-address';\n\nexport default function isBillingAddressLike(address: Address): address is BillingAddress {\n const billingAddress = address as BillingAddress;\n\n return typeof billingAddress.id !== 'undefined';\n}\n","export default class AmountTransformer {\n constructor(private _decimalPlaces: number) {}\n\n toInteger(amount: number): number {\n return Math.round(amount * Math.pow(10, this._decimalPlaces));\n }\n}\n","import Coupon from './coupon';\nimport InternalCoupon from './internal-coupon';\n\nconst couponTypes = [\n 'per_item_discount',\n 'percentage_discount',\n 'per_total_discount',\n 'shipping_discount',\n 'free_shipping',\n];\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCoupon(coupon: Coupon): InternalCoupon {\n return {\n code: coupon.code,\n discount: coupon.displayName,\n discountType: couponTypes.indexOf(coupon.couponType),\n };\n}\n","import GiftCertificate from './gift-certificate';\nimport InternalGiftCertificate from './internal-gift-certificate';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalGiftCertificate(giftCertificate: GiftCertificate): InternalGiftCertificate {\n return {\n code: giftCertificate.code,\n discountedAmount: giftCertificate.used,\n remainingBalance: giftCertificate.remaining,\n giftCertificate: {\n balance: giftCertificate.balance,\n code: giftCertificate.code,\n purchaseDate: giftCertificate.purchaseDate,\n },\n };\n}\n","import InternalLineItem from './internal-line-item';\nimport { LineItem } from './line-item';\nimport LineItemMap from './line-item-map';\nimport mapGiftCertificateToInternalLineItem from './map-gift-certificate-to-internal-line-item';\nimport mapToInternalLineItem from './map-to-internal-line-item';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalLineItems(\n itemMap: LineItemMap,\n decimalPlaces: number,\n idKey: keyof LineItem = 'id'\n): InternalLineItem[] {\n return (Object.keys(itemMap) as Array<keyof LineItemMap>)\n .reduce((result, key) => [\n ...result,\n ...(itemMap[key] as LineItem[]).map((item: any) => {\n if (key === 'giftCertificates') {\n return mapGiftCertificateToInternalLineItem(item, decimalPlaces);\n }\n\n return mapToInternalLineItem(\n item,\n mapToInternalLineItemType(key),\n decimalPlaces,\n idKey\n );\n }),\n ], [] as InternalLineItem[]);\n}\n\nfunction mapToInternalLineItemType(type: string): string {\n switch (type) {\n case 'physicalItems':\n return 'ItemPhysicalEntity';\n\n case 'digitalItems':\n return 'ItemDigitalEntity';\n\n case 'giftCertificates':\n return 'ItemGiftCertificateEntity';\n\n default:\n return '';\n }\n}\n","import { AmountTransformer } from '../common/utility';\n\nimport InternalLineItem from './internal-line-item';\nimport { GiftCertificateItem } from './line-item';\n\nexport default function mapGiftCertificateToInternalLineItem(\n item: GiftCertificateItem,\n decimalPlaces: number\n): InternalLineItem {\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: item.id,\n imageUrl: '',\n name: item.name,\n amount: item.amount,\n amountAfterDiscount: item.amount,\n discount: 0,\n integerAmount: amountTransformer.toInteger(item.amount),\n integerAmountAfterDiscount: amountTransformer.toInteger(item.amount),\n integerUnitPrice: amountTransformer.toInteger(item.amount),\n integerUnitPriceAfterDiscount: amountTransformer.toInteger(item.amount),\n integerDiscount: 0,\n quantity: 1,\n sender: item.sender,\n recipient: item.recipient,\n type: 'ItemGiftCertificateEntity',\n attributes: [],\n variantId: null,\n };\n}\n","import { AmountTransformer } from '../common/utility';\n\nimport InternalLineItem from './internal-line-item';\nimport { DigitalItem, LineItem } from './line-item';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalLineItem(\n item: LineItem,\n type: string,\n decimalPlaces: number,\n idKey: keyof LineItem = 'id'\n): InternalLineItem {\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: (item[idKey] as string | number),\n imageUrl: item.imageUrl,\n amount: item.extendedListPrice,\n amountAfterDiscount: item.extendedSalePrice,\n discount: item.discountAmount,\n integerAmount: amountTransformer.toInteger(item.extendedListPrice),\n integerAmountAfterDiscount: amountTransformer.toInteger(item.extendedSalePrice),\n integerDiscount: amountTransformer.toInteger(item.discountAmount),\n integerUnitPrice: amountTransformer.toInteger(item.listPrice),\n integerUnitPriceAfterDiscount: amountTransformer.toInteger(item.salePrice),\n downloadsPageUrl: (item as DigitalItem).downloadPageUrl,\n name: item.name,\n quantity: item.quantity,\n brand: item.brand,\n sku: item.sku,\n categoryNames: item.categoryNames,\n variantId: item.variantId,\n productId: item.productId,\n attributes: (item.options || []).map(option => ({\n name: option.name,\n value: option.value,\n })),\n addedByPromotion: item.addedByPromotion,\n type,\n };\n}\n","import { keyBy, reduce, some } from 'lodash';\n\nimport { Checkout } from '../checkout';\nimport { AmountTransformer } from '../common/utility';\nimport { mapToInternalCoupon, mapToInternalGiftCertificate } from '../coupon';\nimport { mapToDiscountNotifications } from '../promotion';\n\nimport InternalCart from './internal-cart';\nimport mapToInternalLineItems from './map-to-internal-line-items';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCart(checkout: Checkout): InternalCart {\n const decimalPlaces = checkout.cart.currency.decimalPlaces;\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: checkout.cart.id,\n items: mapToInternalLineItems(checkout.cart.lineItems, decimalPlaces),\n currency: checkout.cart.currency.code,\n coupon: {\n discountedAmount: reduce(checkout.cart.coupons, (sum, coupon) => {\n return sum + coupon.discountedAmount;\n }, 0),\n coupons: checkout.cart.coupons.map(mapToInternalCoupon),\n },\n discount: {\n amount: checkout.cart.discountAmount,\n integerAmount: amountTransformer.toInteger(checkout.cart.discountAmount),\n },\n discountNotifications: mapToDiscountNotifications(checkout.promotions),\n giftCertificate: {\n totalDiscountedAmount: reduce(checkout.giftCertificates, (sum, certificate) => {\n return sum + certificate.used;\n }, 0),\n appliedGiftCertificates: keyBy(checkout.giftCertificates.map(mapToInternalGiftCertificate), 'code'),\n },\n shipping: {\n amount: checkout.shippingCostTotal,\n integerAmount: amountTransformer.toInteger(checkout.shippingCostTotal),\n amountBeforeDiscount: checkout.shippingCostBeforeDiscount,\n integerAmountBeforeDiscount: amountTransformer.toInteger(checkout.shippingCostBeforeDiscount),\n required: some(checkout.cart.lineItems.physicalItems, lineItem => lineItem.isShippingRequired),\n },\n subtotal: {\n amount: checkout.subtotal,\n integerAmount: amountTransformer.toInteger(checkout.subtotal),\n },\n storeCredit: {\n amount: checkout.customer ? checkout.customer.storeCredit : 0,\n },\n taxSubtotal: {\n amount: checkout.taxTotal,\n integerAmount: amountTransformer.toInteger(checkout.taxTotal),\n },\n taxes: checkout.taxes,\n taxTotal: {\n amount: checkout.taxTotal,\n integerAmount: amountTransformer.toInteger(checkout.taxTotal),\n },\n handling: {\n amount: checkout.handlingCostTotal,\n integerAmount: amountTransformer.toInteger(checkout.handlingCostTotal),\n },\n grandTotal: {\n amount: checkout.grandTotal,\n integerAmount: amountTransformer.toInteger(checkout.grandTotal),\n },\n };\n}\n","import { DiscountNotification } from '../discount';\n\nimport { Promotion } from '.';\n\nexport default function mapToDiscountNotifications(promotions?: Promotion[]): DiscountNotification[] {\n const notifications: DiscountNotification[] = [];\n\n (promotions || []).forEach(promotion => {\n (promotion.banners || []).forEach(banner => {\n notifications.push({\n placeholders: [],\n discountType: null,\n message: '',\n messageHtml: banner.text,\n });\n });\n });\n\n return notifications;\n}\n","import { mapToInternalAddress } from '../address';\nimport { BillingAddress } from '../billing';\n\nimport { Customer } from '.';\nimport InternalCustomer from './internal-customer';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalCustomer(customer: Customer, billingAddress: BillingAddress): InternalCustomer {\n const firstName = customer.firstName || billingAddress.firstName || '';\n const lastName = customer.lastName || billingAddress.lastName || '';\n\n return {\n addresses: (customer.addresses || []).map(address => mapToInternalAddress(address)),\n customerId: customer.id,\n isGuest: customer.isGuest,\n storeCredit: customer.storeCredit,\n email: customer.email || billingAddress.email || '',\n firstName,\n lastName,\n name: customer.fullName || [firstName, lastName].join(' '),\n customerGroupName: customer.customerGroup && customer.customerGroup.name,\n };\n}\n","import CardExpiryDate from './card-expiry-date';\n\nconst NUMBER_SEPARATOR = '/';\n\nexport default class CardExpiryFormatter {\n format(value: string): string {\n const [month = '', year = ''] = value.split(new RegExp(`\\\\s*${NUMBER_SEPARATOR}\\\\s*`));\n const trimmedMonth = month.slice(0, 2);\n const trimmedYear = year.length === 4 ? year.slice(-2) : (year ? year.slice(0, 2) : month.slice(2));\n\n // i.e.: '1'\n if (value.length < 2) {\n return month;\n }\n\n // ie.: '10 /' (without trailing space)\n if (value.length > 3 && !trimmedYear) {\n return trimmedMonth;\n }\n\n return `${trimmedMonth} ${NUMBER_SEPARATOR} ${trimmedYear}`;\n }\n\n toObject(value: string): CardExpiryDate {\n const [month = '', year = ''] = value.split(new RegExp(`\\\\s*${NUMBER_SEPARATOR}\\\\s*`));\n\n if (!/^\\d+$/.test(month) || !/^\\d+$/.test(year)) {\n return { month: '', year: '' };\n }\n\n return {\n month: month.length === 1 ? `0${month}` : month.slice(0, 2),\n year: year.length === 2 ? `20${year}` : year.slice(0, 4),\n };\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"card-validator\");","import { creditCardType, number } from 'card-validator';\nimport { max } from 'lodash';\n\nconst NUMBER_SEPARATOR = ' ';\n\nexport default class CardNumberFormatter {\n format(value: string): string {\n const { card } = number(value);\n\n if (!card) {\n return value;\n }\n\n const maxLength = max(creditCardType(value).map(info => max(info.lengths)));\n const unformattedValue = this.unformat(value).slice(0, maxLength);\n\n return card.gaps\n .filter(gapIndex => unformattedValue.length > gapIndex)\n .reduce((output, gapIndex, index) => (\n [\n output.slice(0, gapIndex + index),\n output.slice(gapIndex + index),\n ].join(NUMBER_SEPARATOR)\n ), unformattedValue);\n }\n\n unformat(value: string): string {\n const { card } = number(value);\n\n if (!card) {\n return value;\n }\n\n return value.replace(new RegExp(NUMBER_SEPARATOR, 'g'), '');\n }\n}\n","import { filter, find, keyBy, reduce } from 'lodash';\n\nimport { mapToInternalLineItems, LineItem } from '../cart';\nimport { Checkout } from '../checkout';\nimport { AmountTransformer } from '../common/utility';\nimport { mapToInternalCoupon } from '../coupon';\nimport { HOSTED } from '../payment';\n\nimport InternalOrder, { InternalGiftCertificateList, InternalIncompleteOrder, InternalOrderPayment, InternalSocialDataList } from './internal-order';\nimport Order, { GatewayOrderPayment, GiftCertificateOrderPayment, OrderPayment, OrderPayments } from './order';\nimport { OrderMetaState } from './order-state';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalOrder(order: Order, orderMeta: OrderMetaState = {}): InternalOrder {\n const decimalPlaces = order.currency.decimalPlaces;\n const amountTransformer = new AmountTransformer(decimalPlaces);\n\n return {\n id: order.orderId,\n items: mapToInternalLineItems(order.lineItems, order.currency.decimalPlaces, 'productId'),\n orderId: order.orderId,\n currency: order.currency.code,\n customerCanBeCreated: order.customerCanBeCreated,\n payment: mapToInternalOrderPayment(order.payments, orderMeta.payment),\n subtotal: {\n amount: order.baseAmount,\n integerAmount: amountTransformer.toInteger(order.baseAmount),\n },\n coupon: {\n discountedAmount: reduce(order.coupons, (sum, coupon) => {\n return sum + coupon.discountedAmount;\n }, 0),\n coupons: order.coupons.map(mapToInternalCoupon),\n },\n discount: {\n amount: order.discountAmount,\n integerAmount: amountTransformer.toInteger(order.discountAmount),\n },\n token: orderMeta.orderToken,\n callbackUrl: orderMeta.callbackUrl,\n discountNotifications: [],\n giftCertificate: mapToGiftCertificates(order.payments),\n socialData: mapToInternalSocialDataList(order),\n status: order.status,\n hasDigitalItems: order.hasDigitalItems,\n isDownloadable: order.isDownloadable,\n isComplete: order.isComplete,\n shipping: {\n amount: order.shippingCostTotal,\n integerAmount: amountTransformer.toInteger(order.shippingCostTotal),\n amountBeforeDiscount: order.shippingCostBeforeDiscount,\n integerAmountBeforeDiscount: amountTransformer.toInteger(order.shippingCostBeforeDiscount),\n },\n storeCredit: {\n amount: mapToStoreCredit(order.payments),\n },\n taxes: order.taxes,\n taxTotal: {\n amount: order.taxTotal,\n integerAmount: amountTransformer.toInteger(order.taxTotal),\n },\n handling: {\n amount: order.handlingCostTotal,\n integerAmount: amountTransformer.toInteger(order.handlingCostTotal),\n },\n grandTotal: {\n amount: order.orderAmount,\n integerAmount: order.orderAmountAsInteger,\n },\n };\n}\n\nexport function mapToInternalIncompleteOrder(checkout: Checkout): InternalIncompleteOrder {\n const payment = find(checkout.payments, { providerType: HOSTED });\n\n return {\n orderId: null,\n isComplete: false,\n payment: !payment ? {} : {\n id: payment.providerId,\n gateway: payment.gatewayId,\n status: mapToInternalPaymentStatus(payment.detail.step),\n },\n };\n}\n\nfunction mapToInternalPaymentStatus(status: string): string {\n return `PAYMENT_STATUS_${status}`;\n}\n\nfunction mapToStoreCredit(payments?: OrderPayments): number {\n const item = find(payments, { providerId: 'storecredit' });\n\n return item ? item.amount : 0;\n}\n\nfunction mapToGiftCertificates(payments?: OrderPayments): InternalGiftCertificateList {\n const items = filter(payments, { providerId: 'giftcertificate' }) as GiftCertificateOrderPayment[];\n\n return {\n totalDiscountedAmount: reduce(items, (sum, item) => item.amount + sum, 0),\n appliedGiftCertificates: keyBy(items.map(item => ({\n code: item.detail.code,\n discountedAmount: item.amount,\n remainingBalance: item.detail.remaining,\n giftCertificate: {\n balance: item.amount + item.detail.remaining,\n code: item.detail.code,\n purchaseDate: '',\n },\n })), 'code'),\n };\n}\n\nfunction mapToInternalOrderPayment(payments?: OrderPayments, payment: InternalOrderPayment = {}): InternalOrderPayment {\n const item = find(payments, isDefaultOrderPayment) as GatewayOrderPayment;\n\n if (!item) {\n return {};\n }\n\n return {\n id: item.providerId,\n status: mapToInternalPaymentStatus(item.detail.step),\n helpText: item.detail.instructions,\n returnUrl: payment.returnUrl,\n };\n}\n\nfunction isDefaultOrderPayment(payment: OrderPayment): payment is GatewayOrderPayment {\n return payment.providerId !== 'giftcertificate' && payment.providerId !== 'storecredit';\n}\n\nfunction mapToInternalSocialDataList(order: Order): { [itemId: string]: InternalSocialDataList } | undefined {\n const socialDataObject: { [itemId: string]: InternalSocialDataList } = {};\n const items = [\n ...order.lineItems.physicalItems,\n ...order.lineItems.digitalItems,\n ];\n\n items.forEach(item => {\n socialDataObject[item.id] = mapToInternalSocialData(item);\n });\n\n return socialDataObject;\n}\n\nfunction mapToInternalSocialData(lineItem: LineItem): InternalSocialDataList {\n const codes = ['fb', 'tw', 'gp'];\n\n return codes.reduce((socialData, code) => {\n const item = lineItem.socialMedia && find(lineItem.socialMedia, item => item.code === code);\n\n if (!item) {\n return socialData;\n }\n\n socialData[code] = {\n name: lineItem.name,\n description: lineItem.name,\n image: lineItem.imageUrl,\n url: item.link,\n shareText: item.text,\n sharingLink: item.link,\n channelName: item.channel,\n channelCode: item.code,\n };\n\n return socialData;\n }, {} as InternalSocialDataList);\n}\n","import InternalShippingOption from './internal-shipping-option';\nimport ShippingOption from './shipping-option';\n\n/**\n * @deprecated This mapper is only for internal use only. It is required during\n * the transition period as we are moving to adopt the new storefront API object\n * schema.\n */\nexport default function mapToInternalShippingOption(option: ShippingOption, isSelected: boolean): InternalShippingOption {\n return {\n description: option.description,\n module: option.type,\n price: option.cost,\n id: option.id,\n selected: isSelected,\n isRecommended: option.isRecommended,\n imageUrl: option.imageUrl,\n transitTime: option.transitTime,\n };\n}\n","import { pick } from 'lodash';\n\nimport { mapToInternalAddress, Address } from '../address';\nimport { mapToInternalCart } from '../cart';\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { CheckoutButtonMethodType } from '../checkout-buttons/strategies';\nimport { MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { mapToInternalCustomer } from '../customer';\nimport { HostedFormOrderData } from '../hosted-form';\nimport { CardExpiryFormatter, CardNumberFormatter, HostedInputValues } from '../hosted-form/iframe-content';\nimport { mapToInternalOrder } from '../order';\nimport { mapToInternalShippingOption } from '../shipping';\n\nimport isVaultedInstrument, { isFormattedVaultedInstrument } from './is-vaulted-instrument';\nimport Payment, { HostedCreditCardInstrument, HostedVaultedInstrument, PaymentInstrument } from './payment';\nimport PaymentMethod from './payment-method';\nimport PaymentRequestBody from './payment-request-body';\n\nexport default class PaymentRequestTransformer {\n private _cardExpiryFormatter = new CardExpiryFormatter();\n private _cardNumberFormatter = new CardNumberFormatter();\n\n transform(payment: Payment, checkoutState: InternalCheckoutSelectors): PaymentRequestBody {\n const billingAddress = checkoutState.billingAddress.getBillingAddress();\n const checkout = checkoutState.checkout.getCheckout();\n const customer = checkoutState.customer.getCustomer();\n const order = checkoutState.order.getOrder();\n const paymentMethod = checkoutState.paymentMethods.getPaymentMethod(payment.methodId, payment.gatewayId);\n const shippingAddress = this._mapShippingAddress(checkoutState, paymentMethod);\n const consignments = checkoutState.consignments.getConsignments();\n const shippingOption = checkoutState.consignments.getShippingOption();\n const storeConfig = checkoutState.config.getStoreConfig();\n const contextConfig = checkoutState.config.getContextConfig();\n const instrumentMeta = checkoutState.instruments.getInstrumentsMeta();\n const paymentMeta = checkoutState.paymentMethods.getPaymentMethodsMeta();\n const orderMeta = checkoutState.order.getOrderMeta();\n const internalCustomer = customer && billingAddress && mapToInternalCustomer(customer, billingAddress);\n\n const authToken = instrumentMeta && payment.paymentData &&\n (isVaultedInstrument(payment.paymentData) || isFormattedVaultedInstrument(payment.paymentData)) ?\n `${checkoutState.payment.getPaymentToken()}, ${instrumentMeta.vaultAccessToken}` :\n checkoutState.payment.getPaymentToken();\n\n if (!authToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentToken);\n }\n\n return {\n additionalAction: payment.additionalAction,\n authToken,\n customer: internalCustomer,\n billingAddress: billingAddress && mapToInternalAddress(billingAddress),\n shippingAddress: shippingAddress && mapToInternalAddress(shippingAddress, consignments),\n shippingOption: shippingOption && mapToInternalShippingOption(shippingOption, true),\n cart: checkout && mapToInternalCart(checkout),\n order: order && mapToInternalOrder(order, orderMeta),\n orderMeta,\n payment: payment.paymentData,\n paymentMethod: paymentMethod && this._transformPaymentMethod(paymentMethod),\n quoteMeta: {\n request: {\n ...paymentMeta,\n geoCountryCode: contextConfig && contextConfig.geoCountryCode,\n },\n },\n source: 'bigcommerce-checkout-js-sdk',\n store: pick(storeConfig && storeConfig.storeProfile, [\n 'storeHash',\n 'storeId',\n 'storeLanguage',\n 'storeName',\n ]),\n };\n }\n\n transformWithHostedFormData(values: HostedInputValues, data: HostedFormOrderData, nonce: string): PaymentRequestBody {\n const { additionalAction, authToken, checkout, config, order, orderMeta, payment = {}, paymentMethod, paymentMethodMeta } = data;\n const consignment = checkout && checkout.consignments[0];\n const shippingAddress = consignment && consignment.shippingAddress;\n const shippingOption = consignment && consignment.selectedShippingOption;\n\n return {\n additionalAction,\n authToken,\n paymentMethod: paymentMethod && this._transformPaymentMethod(paymentMethod),\n customer: order && order.billingAddress && checkout && mapToInternalCustomer(checkout.customer, order.billingAddress),\n billingAddress: order && order.billingAddress && mapToInternalAddress(order.billingAddress),\n shippingAddress: shippingAddress && checkout && mapToInternalAddress(shippingAddress, checkout.consignments),\n shippingOption: shippingOption && mapToInternalShippingOption(shippingOption, true),\n cart: checkout && mapToInternalCart(checkout),\n order: order && mapToInternalOrder(order, orderMeta),\n orderMeta,\n payment: this._transformHostedInputValues(values, payment, nonce),\n quoteMeta: {\n request: {\n ...paymentMethodMeta,\n geoCountryCode: config && config.context.geoCountryCode,\n },\n },\n source: 'bigcommerce-checkout-js-sdk',\n store: config && pick(config.storeConfig.storeProfile, [\n 'storeHash',\n 'storeId',\n 'storeLanguage',\n 'storeName',\n ]),\n };\n }\n\n private _transformPaymentMethod(paymentMethod: PaymentMethod): PaymentMethod {\n if (paymentMethod.method === 'multi-option' && !paymentMethod.gateway) {\n return { ...paymentMethod, gateway: paymentMethod.id };\n }\n\n if (paymentMethod.initializationData && paymentMethod.initializationData.gateway) {\n return { ...paymentMethod, id: paymentMethod.initializationData.gateway };\n }\n\n if (paymentMethod.id === CheckoutButtonMethodType.BRAINTREE_VENMO) {\n return { ...paymentMethod, id: CheckoutButtonMethodType.BRAINTREE_PAYPAL };\n }\n\n return paymentMethod;\n }\n\n private _transformHostedInputValues(\n values: HostedInputValues,\n payment: HostedCreditCardInstrument | HostedVaultedInstrument,\n nonce: string\n ): PaymentInstrument {\n return 'instrumentId' in payment ?\n {\n ...payment,\n ccCvv: values.cardCodeVerification,\n ccNumber: values.cardNumberVerification && this._cardNumberFormatter.unformat(values.cardNumberVerification),\n hostedFormNonce: nonce,\n } :\n {\n ...payment,\n ccCvv: values.cardCode,\n ccExpiry: this._cardExpiryFormatter.toObject(values.cardExpiry || ''),\n ccName: values.cardName || '',\n ccNumber: this._cardNumberFormatter.unformat(values.cardNumber || ''),\n hostedFormNonce: nonce,\n };\n }\n\n private _mapShippingAddress(checkoutState: InternalCheckoutSelectors, paymentMethod?: PaymentMethod): Address | undefined {\n if (paymentMethod) {\n const isBopisEnabled = paymentMethod.initializationData?.bopis?.enabled;\n const requiredAddress = paymentMethod.initializationData?.bopis?.requiredAddress;\n const consignments = checkoutState.consignments.getConsignments();\n const isPickup = consignments?.every(consignment => consignment.selectedPickupOption);\n\n if (isBopisEnabled && isPickup && requiredAddress === 'none') {\n return undefined;\n }\n }\n\n return checkoutState.shippingAddress.getShippingAddress();\n }\n}\n","import { FormattedPayload, FormattedVaultedInstrument, HostedVaultedInstrument, PaymentInstrument, VaultedInstrument } from './payment';\n\nexport default function isVaultedInstrument(instrument: PaymentInstrument): instrument is VaultedInstrument {\n return Boolean((instrument as VaultedInstrument).instrumentId);\n}\n\nexport function isHostedVaultedInstrument(instrument: PaymentInstrument): instrument is HostedVaultedInstrument {\n return (\n Boolean((instrument as HostedVaultedInstrument).instrumentId) &&\n !Object.prototype.hasOwnProperty.call(instrument, 'ccNumber') &&\n !Object.prototype.hasOwnProperty.call(instrument, 'ccCvv')\n );\n}\n\nexport function isFormattedVaultedInstrument(instrument: PaymentInstrument): instrument is FormattedPayload<FormattedVaultedInstrument> {\n const formattedInstrument = (instrument as FormattedPayload<FormattedVaultedInstrument>).formattedPayload;\n\n if (!formattedInstrument) {\n return false;\n }\n\n return typeof formattedInstrument.bigpay_token === 'string' ||\n Boolean(formattedInstrument.bigpay_token && formattedInstrument.bigpay_token.token);\n}\n","import { createAction, ThunkAction } from '@bigcommerce/data-store';\nimport { concat, defer, of } from 'rxjs';\nimport { catchError, switchMap } from 'rxjs/operators';\n\nimport { InternalCheckoutSelectors } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { OrderActionCreator } from '../order';\nimport { PaymentHumanVerificationHandler } from '../spam-protection';\n\nimport Payment, { FormattedHostedInstrument, FormattedPayload, FormattedVaultedInstrument } from './payment';\nimport { InitializeOffsitePaymentAction, PaymentActionType, SubmitPaymentAction } from './payment-actions';\nimport PaymentRequestSender from './payment-request-sender';\nimport PaymentRequestTransformer from './payment-request-transformer';\n\ninterface InitializeOffsitePaymentSettings {\n methodId: string;\n gatewayId?: string;\n instrumentId?: string;\n target?: string;\n promise?: Promise<undefined>;\n shouldSaveInstrument?: boolean;\n shouldSetAsDefaultInstrument?: boolean;\n}\n\ntype InitializeOffsitePayment = (settings: InitializeOffsitePaymentSettings)\n => ThunkAction<InitializeOffsitePaymentAction, InternalCheckoutSelectors>;\n\nexport default class PaymentActionCreator {\n constructor(\n private _paymentRequestSender: PaymentRequestSender,\n private _orderActionCreator: OrderActionCreator,\n private _paymentRequestTransformer: PaymentRequestTransformer,\n private _paymentHumanVerificationHandler: PaymentHumanVerificationHandler\n ) {}\n\n submitPayment(payment: Payment): ThunkAction<SubmitPaymentAction, InternalCheckoutSelectors> {\n return store => concat(\n of(createAction(PaymentActionType.SubmitPaymentRequested)),\n defer(async () => {\n try {\n return await this._paymentRequestSender.submitPayment(\n this._paymentRequestTransformer.transform(payment, store.getState())\n );\n } catch (error) {\n const additionalAction = await this._paymentHumanVerificationHandler.handle(error);\n\n return await this._paymentRequestSender.submitPayment(\n this._paymentRequestTransformer.transform({ ...payment, additionalAction }, store.getState())\n );\n }\n })\n .pipe(\n switchMap(({ body }) => concat(\n this._orderActionCreator.loadCurrentOrder()(store),\n of(createAction(PaymentActionType.SubmitPaymentSucceeded, body))\n ))\n )\n ).pipe(\n catchError(error => throwErrorAction(PaymentActionType.SubmitPaymentFailed, error))\n );\n }\n\n initializeOffsitePayment: InitializeOffsitePayment = ({\n methodId,\n gatewayId,\n instrumentId,\n target,\n promise,\n shouldSaveInstrument,\n shouldSetAsDefaultInstrument,\n }) => {\n return store => {\n let paymentData: FormattedPayload<FormattedHostedInstrument | FormattedVaultedInstrument> | undefined;\n\n if (instrumentId) {\n paymentData = { formattedPayload: { bigpay_token: instrumentId } };\n } else if (shouldSaveInstrument) {\n paymentData = {\n formattedPayload: {\n vault_payment_instrument: shouldSaveInstrument,\n set_as_default_stored_instrument: shouldSetAsDefaultInstrument || null,\n },\n };\n }\n\n const payload = this._paymentRequestTransformer.transform({ gatewayId, methodId, paymentData }, store.getState());\n\n return concat(\n of(createAction(PaymentActionType.InitializeOffsitePaymentRequested)),\n Promise.race([this._paymentRequestSender.initializeOffsitePayment(payload, target), promise].filter(Boolean))\n .then(() => createAction(PaymentActionType.InitializeOffsitePaymentSucceeded))\n ).pipe(\n catchError(error => throwErrorAction(PaymentActionType.InitializeOffsitePaymentFailed, error))\n );\n };\n };\n}\n","import StandardError from './standard-error';\n\nexport enum NotInitializedErrorType {\n CheckoutButtonNotInitialized,\n CustomerNotInitialized,\n PaymentNotInitialized,\n ShippingNotInitialized,\n SpamProtectionNotInitialized,\n}\n\n/**\n * Throw this error if a method requires a certain initialization call to be\n * made first. Some objects can be constructed but they cannot be used until a\n * separate initialization call is made.\n */\nexport default class NotInitializedError extends StandardError {\n constructor(\n public subtype: NotInitializedErrorType\n ) {\n super(getErrorMessage(subtype));\n\n this.name = 'NotInitializedError';\n this.type = 'not_initialized';\n }\n}\n\nfunction getErrorMessage(type: NotInitializedErrorType): string {\n switch (type) {\n case NotInitializedErrorType.CustomerNotInitialized:\n return 'Unable to proceed because the customer step of checkout has not been initialized.';\n\n case NotInitializedErrorType.PaymentNotInitialized:\n return 'Unable to proceed because the payment step of checkout has not been initialized.';\n\n case NotInitializedErrorType.ShippingNotInitialized:\n return 'Unable to proceed because the shipping step of checkout has not been initialized.';\n\n case NotInitializedErrorType.SpamProtectionNotInitialized:\n return 'Unable to proceed because the checkout spam protection has not been initialized.';\n\n default:\n return 'Unable to proceed because the required component has not been initialized.';\n }\n}\n","import { PaymentMethod } from '../..';\nimport { AmazonPayV2ButtonInitializeOptions } from '../../../checkout-buttons/strategies/amazon-pay-v2';\nimport { NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\n\nimport { AmazonPayV2ChangeActionType, AmazonPayV2SDK } from './amazon-pay-v2';\nimport AmazonPayV2ScriptLoader from './amazon-pay-v2-script-loader';\n\nexport default class AmazonPayV2PaymentProcessor {\n private _amazonPayV2SDK?: AmazonPayV2SDK;\n\n constructor(\n private _amazonPayV2ScriptLoader: AmazonPayV2ScriptLoader\n ) { }\n\n async initialize(paymentMethod: PaymentMethod): Promise<void> {\n this._amazonPayV2SDK = await this._amazonPayV2ScriptLoader.load(paymentMethod);\n }\n\n deinitialize(): Promise<void> {\n this._amazonPayV2SDK = undefined;\n\n return Promise.resolve();\n }\n\n bindButton(buttonId: string, sessionId: string, changeAction: AmazonPayV2ChangeActionType): void {\n this._getAmazonPayV2SDK().Pay.bindChangeAction(`#${buttonId}`, {\n amazonCheckoutSessionId: sessionId,\n changeAction,\n });\n }\n\n createButton(containerId: string, options: AmazonPayV2ButtonInitializeOptions): HTMLElement {\n return this._getAmazonPayV2SDK().Pay.renderButton(containerId, options);\n }\n\n async signout(): Promise<void> {\n if (this._amazonPayV2SDK) {\n this._amazonPayV2SDK.Pay.signout();\n }\n\n return Promise.resolve();\n }\n\n private _getAmazonPayV2SDK(): AmazonPayV2SDK {\n if (!this._amazonPayV2SDK) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._amazonPayV2SDK;\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when the client library of a payment method fails\n * to load, or for some reason, it is inaccessible.\n */\nexport default class PaymentMethodClientUnavailableError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to proceed because the client library of a payment method is not loaded or ready to be used.');\n\n this.name = 'PaymentMethodClientUnavailableError';\n this.type = 'payment_method_client_unavailable';\n }\n}\n","export type EnvironmentType = 'PRODUCTION' | 'TEST';\n\nexport interface AmazonPayV2Options {\n environment: EnvironmentType;\n}\n\nexport interface AmazonPayV2SDK {\n Pay: AmazonPayV2Client;\n}\n\nexport interface AmazonPayV2Client {\n /**\n * Render the Amazon Pay button to a HTML container element.\n *\n * @param containerId - HTML element id.\n * @param params - Button rendering params.\n */\n renderButton(containerId: string, params: AmazonPayV2ButtonParams): HTMLElement;\n\n /**\n * Bind click events to HTML elements, so that when the element is clicked, the buyer can select a different shipping address or payment method.\n *\n * @param buttonId - HTML element id.\n * @param options - Element binding options.\n */\n bindChangeAction(buttonId: string, options: AmazonPayV2ChangeActionOptions): void;\n\n /**\n * Allow buyers to sign out from their Amazon account.\n */\n signout(): void;\n}\n\nexport interface AmazonPayV2HostWindow extends Window {\n amazon?: AmazonPayV2SDK;\n}\n\nexport interface AmazonPayV2ButtonParams {\n /**\n * Amazon Pay merchant account identifier.\n */\n merchantId: string;\n\n /**\n * Configuration for calling the endpoint to Create Checkout Session.\n */\n createCheckoutSession: AmazonPayV2CheckoutSession;\n\n /**\n * Placement of the Amazon Pay button on your website.\n */\n placement: AmazonPayV2Placement;\n\n /**\n * Ledger currency provided during registration for the given merchant identifier.\n */\n ledgerCurrency: AmazonPayV2LedgerCurrency;\n\n /**\n * Product type selected for checkout. Default is 'PayAndShip'.\n */\n productType?: AmazonPayV2PayOptions;\n\n /**\n * Language used to render the button and text on Amazon Pay hosted pages.\n */\n checkoutLanguage?: AmazonPayV2CheckoutLanguage;\n\n /**\n * Sets button to Sandbox environment. Default is false.\n */\n sandbox?: boolean;\n}\n\nexport interface AmazonPayV2CheckoutSession {\n /**\n * Endpoint URL to Create Checkout Session.\n */\n url: string;\n\n /**\n * HTTP request method. Default is 'POST'.\n */\n method?: 'GET' | 'POST';\n\n /**\n * Checkout Session ID parameter in the response. Default is 'checkoutSessionId'.\n */\n extractAmazonCheckoutSessionId?: string;\n}\n\nexport type AmazonPayV2ChangeActionType = 'changeAddress' | 'changePayment';\n\nexport interface AmazonPayV2ChangeActionOptions {\n /**\n * Amazon Pay Checkout Session identifier.\n */\n amazonCheckoutSessionId: string;\n\n /**\n * Update requested by the buyer.\n */\n changeAction: AmazonPayV2ChangeActionType;\n}\n\nexport enum AmazonPayV2Regions {\n de = 'eu',\n jp = 'fe',\n uk = 'eu',\n us = 'na',\n}\n\nexport enum AmazonPayV2CheckoutLanguage {\n en_US = 'en_US',\n en_GB = 'en_GB',\n de_DE = 'de_DE',\n fr_FR = 'fr_FR',\n it_IT = 'it_IT',\n es_ES = 'es_ES',\n ja_JP = 'ja_JP',\n}\n\nexport enum AmazonPayV2Placement {\n /** Initial or main page. */\n Home = 'Home',\n\n /** Product details page. */\n Product = 'Product',\n\n /** Cart review page before buyer starts checkout. */\n Cart = 'Cart',\n\n /** Any page after buyer starts checkout. */\n Checkout = 'Checkout',\n\n /** Any page that doesn't fit the previous descriptions. */\n Other = 'Other',\n}\n\nexport enum AmazonPayV2LedgerCurrency {\n USD = 'USD',\n EUR = 'EUR',\n GBP = 'GBP',\n JPY = 'JPY',\n}\n\nexport enum AmazonPayV2PayOptions {\n /** Select this product type if you need the buyer's shipping details. */\n PayAndShip = 'PayAndShip',\n\n /** Select this product type if you do not need the buyer's shipping details. */\n PayOnly = 'PayOnly',\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { AmazonPayV2HostWindow, AmazonPayV2Regions, AmazonPayV2SDK } from './amazon-pay-v2';\n\nexport default class AmazonPayV2ScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: AmazonPayV2HostWindow = window\n ) {}\n\n async load(method: PaymentMethod): Promise<AmazonPayV2SDK> {\n const {\n initializationData: { region = 'us' } = {},\n } = method;\n\n const amazonPayV2Region = (AmazonPayV2Regions as any)[region];\n\n await this._scriptLoader.loadScript(`https://static-${amazonPayV2Region}.payments-amazon.com/checkout.js`);\n if (!this._window.amazon) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.amazon;\n }\n}\n","import { assertApplePayWindow } from './is-apple-pay-window';\n\nexport default class ApplePaySessionFactory {\n create(request: ApplePayJS.ApplePayPaymentRequest): ApplePaySession {\n assertApplePayWindow(window);\n\n return new ApplePaySession(1, request);\n }\n}\n","import StandardError from './standard-error';\n\n/**\n * Throw this error if the shopper is using a browser version that is not\n * supported by us or any third party provider we use.\n */\nexport default class UnsupportedBrowserError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unsupported browser error');\n\n this.name = 'UnsupportedBrowserError';\n this.type = 'unsupported_browser';\n }\n}\n","import { GooglePaymentData, GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1, GooglePayCreator, TokenizePayload } from '../googlepay';\nimport { PaypalAuthorizeData, PaypalButtonOptions, PaypalButtonRender, PaypalSDK } from '../paypal';\n\nimport { VisaCheckoutInitOptions, VisaCheckoutPaymentSuccessPayload, VisaCheckoutTokenizedPayload } from './visacheckout';\n\n/**\n *\n * Constants\n *\n */\nexport const PAYPAL_COMPONENTS = ['buttons', 'messages'];\n\n/**\n *\n * Common\n *\n */\nexport interface BraintreeModuleCreator<TInstance, TOptions = BraintreeModuleCreatorConfig, TError = BraintreeError> {\n create(config: TOptions, callback?: (error: TError, instance: TInstance) => void): Promise<TInstance>;\n}\n\nexport interface BraintreeModuleCreatorConfig {\n client?: BraintreeClient;\n authorization?: string;\n}\n\nexport interface BraintreeModule {\n teardown(): Promise<void>;\n}\n\nexport interface BraintreeSDK {\n client?: BraintreeClientCreator;\n dataCollector?: BraintreeDataCollectorCreator;\n googlePayment?: GooglePayCreator;\n hostedFields?: BraintreeHostedFieldsCreator;\n paypal?: BraintreePaypalCreator;\n paypalCheckout?: BraintreePaypalCheckoutCreator;\n threeDSecure?: BraintreeThreeDSecureCreator;\n venmo?: BraintreeVenmoCheckoutCreator;\n visaCheckout?: BraintreeVisaCheckoutCreator;\n}\n\nexport interface BraintreePaypalRequest {\n amount: string | number;\n billingAgreementDescription?: string;\n currency?: string;\n displayName?: string;\n enableShippingAddress: true;\n flow: 'checkout' | 'vault';\n intent?: 'authorize' | 'order' | 'sale';\n landingPageType?: 'login' | 'billing';\n locale?: string;\n offerCredit?: boolean;\n shippingAddressEditable?: boolean;\n shippingAddressOverride?: BraintreeShippingAddressOverride;\n useraction?: 'commit';\n}\n\nexport interface BraintreeShippingAddressOverride {\n line1: string;\n line2?: string;\n city: string;\n state: string;\n postalCode: string;\n countryCode: string;\n phone?: string;\n recipientName?: string;\n}\n\nexport interface BraintreeTokenizePayload {\n nonce: string;\n type: 'PaypalAccount' | 'VenmoAccount';\n details: BraintreeDetails;\n creditFinancingOffered?: {\n totalCost: {\n value: string;\n currency: string;\n };\n term: number;\n monthlyPayment: {\n value: string;\n currency: string;\n };\n totalInsterest: {\n value: string;\n currency: string;\n };\n payerAcceptance: boolean;\n cartAmountImmutable: boolean;\n };\n}\n\nexport interface BraintreeDetails {\n username?: string;\n email?: string;\n payerId?: string;\n firstName?: string;\n lastName?: string;\n countryCode?: string;\n phone?: string;\n shippingAddress?: BraintreeShippingAddress;\n billingAddress?: BraintreeAddress;\n}\n\nexport interface BraintreeAddress {\n line1: string;\n line2: string;\n city: string;\n state: string;\n postalCode: string;\n countryCode: string;\n}\n\nexport interface BraintreeShippingAddress extends BraintreeAddress {\n recipientName: string;\n}\n\nexport interface BraintreeVerifyPayload {\n nonce: string;\n details: {\n cardType: string;\n lastFour: string;\n lastTwo: string;\n };\n description: string;\n liabilityShiftPossible: boolean;\n liabilityShifted: boolean;\n}\n\nexport interface BraintreeError extends Error {\n type: 'CUSTOMER' | 'MERCHANT' | 'NETWORK' | 'INTERNAL' | 'UNKNOWN';\n code: string;\n details?: unknown;\n}\n\n/**\n *\n * Braintree Client\n *\n */\nexport type BraintreeClientCreator = BraintreeModuleCreator<BraintreeClient>;\n\nexport interface BraintreeClient {\n request(payload: BraintreeRequestData): Promise<BraintreeTokenizeResponse>;\n getVersion(): string | void;\n}\n\nexport interface BraintreeRequestData {\n data: {\n creditCard: {\n billingAddress?: {\n countryCodeAlpha2: string;\n locality: string;\n countryName: string;\n postalCode: string;\n streetAddress: string;\n };\n cardholderName: string;\n cvv?: string;\n expirationDate: string;\n number: string;\n options: {\n validate: boolean;\n };\n };\n };\n endpoint: string;\n method: string;\n}\n\nexport interface BraintreeTokenizeResponse {\n creditCards: Array<{ nonce: string }>;\n}\n\n/**\n *\n * Braintree Data Collector\n *\n */\nexport type BraintreeDataCollectorCreator = BraintreeModuleCreator<BraintreeDataCollector, BraintreeDataCollectorCreatorConfig>;\n\nexport interface BraintreeDataCollectorCreatorConfig extends BraintreeModuleCreatorConfig {\n kount?: boolean;\n paypal?: boolean;\n}\n\nexport interface BraintreeDataCollector extends BraintreeModule {\n deviceData?: string;\n}\n\n/**\n *\n * Braintree Google Pay\n *\n */\nexport interface BraintreeGooglePayThreeDSecure {\n verifyCard(options: BraintreeGooglePayThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeGooglePayThreeDSecureOptions {\n nonce: string;\n amount: number;\n showLoader?: boolean;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\n}\n\nexport interface GooglePayBraintreeSDK extends BraintreeModule {\n createPaymentDataRequest(request?: GooglePayBraintreeDataRequest): GooglePayBraintreePaymentDataRequestV1;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\n/**\n *\n * Braintree Hosted Fields\n *\n */\nexport type BraintreeHostedFieldsCreator = BraintreeModuleCreator<BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig>;\n\nexport interface BraintreeHostedFields {\n teardown(): Promise<void>;\n tokenize(options?: BraintreeHostedFieldsTokenizeOptions): Promise<BraintreeHostedFieldsTokenizePayload>;\n on(eventName: string, callback: (event: BraintreeHostedFieldsState) => void): void;\n}\n\nexport interface BraintreeHostedFieldsCreatorConfig extends BraintreeModuleCreatorConfig {\n fields: {\n number?: BraintreeHostedFieldOption;\n expirationDate?: BraintreeHostedFieldOption;\n expirationMonth?: BraintreeHostedFieldOption;\n expirationYear?: BraintreeHostedFieldOption;\n cvv?: BraintreeHostedFieldOption;\n postalCode?: BraintreeHostedFieldOption;\n };\n styles?: {\n input?: { [key: string]: string };\n '.invalid'?: { [key: string]: string };\n '.valid'?: { [key: string]: string };\n ':focus'?: { [key: string]: string };\n };\n}\n\nexport interface BraintreeHostedFieldOption {\n container: string | HTMLElement;\n placeholder?: string;\n type?: string;\n formatInput?: boolean;\n maskInput?: boolean | { character?: string; showLastFour?: string };\n select?: boolean | { options?: string[] };\n maxCardLength?: number;\n maxlength?: number;\n minlength?: number;\n prefill?: string;\n rejectUnsupportedCards?: boolean;\n supportedCardBrands?: { [key: string]: boolean };\n}\n\nexport interface BraintreeHostedFieldsState {\n cards: BraintreeHostedFieldsCard[];\n emittedBy: string;\n fields: {\n number?: BraintreeHostedFieldsFieldData;\n expirationDate?: BraintreeHostedFieldsFieldData;\n expirationMonth?: BraintreeHostedFieldsFieldData;\n expirationYear?: BraintreeHostedFieldsFieldData;\n cvv?: BraintreeHostedFieldsFieldData;\n postalCode?: BraintreeHostedFieldsFieldData;\n };\n}\n\nexport interface BraintreeHostedFieldsCard {\n type: string;\n niceType: string;\n code: { name: string; size: number };\n}\n\nexport interface BraintreeHostedFieldsFieldData {\n container: HTMLElement;\n isFocused: boolean;\n isEmpty: boolean;\n isPotentiallyValid: boolean;\n isValid: boolean;\n}\n\nexport interface BraintreeHostedFieldsTokenizeOptions {\n vault?: boolean;\n fieldsToTokenize?: string[];\n cardholderName?: string;\n billingAddress?: BraintreeBillingAddressRequestData;\n}\n\nexport interface BraintreeHostedFieldsTokenizePayload {\n nonce: string;\n details: {\n bin: string;\n cardType: string;\n expirationMonth: string;\n expirationYear: string;\n lastFour: string;\n lastTwo: string;\n };\n description: string;\n type: string;\n binData: {\n commercial: string;\n countryOfIssuance: string;\n debit: string;\n durbinRegulated: string;\n healthcare: string;\n issuingBank: string;\n payroll: string;\n prepaid: string;\n productId: string;\n };\n}\n\nexport interface BraintreeBillingAddressRequestData {\n postalCode?: string;\n firstName?: string;\n lastName?: string;\n company?: string;\n streetAddress?: string;\n extendedAddress?: string;\n locality?: string;\n region?: string;\n countryCodeNumeric?: string;\n countryCodeAlpha2?: string;\n countryCodeAlpha3?: string;\n countryName?: string;\n}\n\nexport interface BraintreeHostedFormError extends BraintreeError {\n details?: {\n invalidFieldKeys?: string[];\n };\n}\n\n/**\n *\n * Braintree 3D Secure\n *\n */\nexport type BraintreeThreeDSecureCreator = BraintreeModuleCreator<BraintreeThreeDSecure, BraintreeThreeDSecureCreatorConfig>;\n\nexport interface BraintreeThreeDSecure extends BraintreeModule {\n verifyCard(options: BraintreeThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n cancelVerifyCard(): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeThreeDSecureCreatorConfig extends BraintreeModuleCreatorConfig {\n version?: number;\n}\n\nexport interface BraintreeThreeDSecureOptions {\n nonce: string;\n amount: number;\n challengeRequested: boolean;\n showLoader?: boolean;\n addFrame(error: Error | undefined, iframe: HTMLIFrameElement): void;\n removeFrame(): void;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\n}\n\ninterface BraintreeThreeDSecureVerificationData {\n lookup: {\n threeDSecureVersion: string;\n };\n paymentMethod: BraintreeVerifyPayload;\n requiresUserAuthentication: boolean;\n threeDSecureInfo: {\n liabilityShiftPossible: boolean;\n liabilityShifted: boolean;\n };\n}\n\n/**\n *\n * Braintree PayPal\n *\n */\nexport type BraintreePaypalCreator = BraintreeModuleCreator<BraintreePaypal>;\n\nexport interface BraintreePaypal {\n closeWindow(): void;\n focusWindow(): void;\n tokenize(options: BraintreePaypalRequest): Promise<BraintreeTokenizePayload>;\n Buttons?(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\n/**\n *\n * Braintree PayPal Checkout\n *\n */\nexport type BraintreePaypalCheckoutCreator = BraintreeModuleCreator<BraintreePaypalCheckout>;\n\nexport interface BraintreePaypalCheckout {\n loadPayPalSDK(config: BraintreePaypalSdkCreatorConfig, callback: (instance: BraintreePaypalCheckout) => void): void;\n createPayment(options: BraintreePaypalRequest): Promise<string>;\n teardown(): Promise<void>;\n tokenizePayment(options: PaypalAuthorizeData): Promise<BraintreeTokenizePayload>;\n}\n\nexport interface BraintreePaypalSdkCreatorConfig {\n components?: string;\n currency?: string;\n}\n\n/**\n *\n * Braintree Venmo\n *\n */\nexport type BraintreeVenmoCheckoutCreator = BraintreeModuleCreator<BraintreeVenmoCheckout, BraintreeVenmoCreatorConfig>;\n\nexport interface BraintreeVenmoCheckout extends BraintreeModule {\n tokenize(callback: (error: BraintreeError, payload: BraintreeTokenizePayload) => void): void;\n isBrowserSupported(): boolean;\n}\n\nexport interface BraintreeVenmoCreatorConfig extends BraintreeModuleCreatorConfig {\n allowDesktop: boolean;\n paymentMethodUsage: string;\n}\n\n/**\n *\n * Braintree Visa Checkout\n *\n */\nexport type BraintreeVisaCheckoutCreator = BraintreeModuleCreator<BraintreeVisaCheckout>;\n\nexport interface BraintreeVisaCheckout extends BraintreeModule {\n tokenize(payment: VisaCheckoutPaymentSuccessPayload): Promise<VisaCheckoutTokenizedPayload>;\n createInitOptions(options: Partial<VisaCheckoutInitOptions>): VisaCheckoutInitOptions;\n}\n\n/**\n *\n * Other\n *\n */\nexport interface BraintreeHostWindow extends Window {\n braintree?: BraintreeSDK;\n paypal?: PaypalSDK;\n}\n","import { NotInitializedError, NotInitializedErrorType, UnsupportedBrowserError } from '../../../common/error/errors';\nimport { PaypalHostWindow } from '../paypal';\n\nimport { BraintreeClient, BraintreeDataCollector, BraintreeError, BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig, BraintreeModule, BraintreePaypal, BraintreePaypalCheckout, BraintreeThreeDSecure, BraintreeVenmoCheckout, BraintreeVisaCheckout, GooglePayBraintreeSDK, PAYPAL_COMPONENTS } from './braintree';\nimport BraintreeScriptLoader from './braintree-script-loader';\n\nexport default class BraintreeSDKCreator {\n private _client?: Promise<BraintreeClient>;\n private _3ds?: Promise<BraintreeThreeDSecure>;\n private _paypal?: Promise<BraintreePaypal>;\n private _paypalCheckout?: Promise<BraintreePaypalCheckout>;\n private _clientToken?: string;\n private _visaCheckout?: Promise<BraintreeVisaCheckout>;\n private _venmoCheckout?: Promise<BraintreeVenmoCheckout>;\n private _dataCollectors: {\n default?: Promise<BraintreeDataCollector>;\n paypal?: Promise<BraintreeDataCollector>;\n } = {};\n private _googlePay?: Promise<GooglePayBraintreeSDK>;\n private _window: PaypalHostWindow;\n\n constructor(\n private _braintreeScriptLoader: BraintreeScriptLoader\n ) {\n this._window = window;\n }\n\n initialize(clientToken: string) {\n this._clientToken = clientToken;\n }\n\n getClient(): Promise<BraintreeClient> {\n if (!this._clientToken) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n if (!this._client) {\n this._client = this._braintreeScriptLoader.loadClient()\n .then(client => client.create({ authorization: this._clientToken }));\n }\n\n return this._client;\n }\n\n getPaypal(): Promise<BraintreePaypal> {\n if (!this._paypal) {\n this._paypal = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadPaypal(),\n ])\n .then(([client, paypal]) => paypal.create({ client }));\n }\n\n return this._paypal;\n }\n\n async getPaypalCheckout(\n config: { currency: string },\n onSuccess: (instance: BraintreePaypalCheckout) => void,\n onError: (error: BraintreeError) => void\n ): Promise<BraintreePaypalCheckout> {\n const client = await this.getClient();\n const paypalCheckout = await this._braintreeScriptLoader.loadPaypalCheckout();\n\n const paypalCheckoutConfig = { client };\n const paypalCheckoutCallback = (error: BraintreeError, braintreePaypalCheckout: BraintreePaypalCheckout) => {\n if (error) {\n return onError(error);\n }\n\n const paypalSdkLoadCallback = () => onSuccess(braintreePaypalCheckout);\n const paypalSdkLoadConfig = {\n currency: config.currency,\n components: PAYPAL_COMPONENTS.toString(),\n };\n\n if (!this._window.paypal) {\n braintreePaypalCheckout.loadPayPalSDK(paypalSdkLoadConfig, paypalSdkLoadCallback);\n } else {\n onSuccess(braintreePaypalCheckout);\n }\n };\n\n this._paypalCheckout = paypalCheckout.create(paypalCheckoutConfig, paypalCheckoutCallback);\n\n return this._paypalCheckout;\n }\n\n async getVenmoCheckout(\n onSuccess: (braintreeVenmoCheckout: BraintreeVenmoCheckout) => void,\n onError: (error: BraintreeError | UnsupportedBrowserError) => void\n ): Promise<BraintreeVenmoCheckout> {\n if (!this._venmoCheckout) {\n const client = await this.getClient();\n\n const venmoCheckout = await this._braintreeScriptLoader.loadVenmoCheckout();\n\n const venmoCheckoutConfig = {\n client,\n allowDesktop: true,\n paymentMethodUsage: 'multi_use',\n };\n\n const venmoCheckoutCallback = (error: BraintreeError, braintreeVenmoCheckout: BraintreeVenmoCheckout): void => {\n if (error) {\n return onError(error);\n }\n\n if (!braintreeVenmoCheckout.isBrowserSupported()) {\n return onError(new UnsupportedBrowserError());\n }\n\n onSuccess(braintreeVenmoCheckout);\n };\n\n this._venmoCheckout = venmoCheckout.create(venmoCheckoutConfig, venmoCheckoutCallback);\n }\n\n return this._venmoCheckout;\n }\n\n get3DS(): Promise<BraintreeThreeDSecure> {\n if (!this._3ds) {\n this._3ds = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.load3DS(),\n ])\n .then(([client, threeDSecure]) => threeDSecure.create({ client, version: 2}));\n }\n\n return this._3ds;\n }\n\n getDataCollector(options?: { paypal: boolean }): Promise<BraintreeDataCollector> {\n const cacheKey = options && options.paypal ? 'paypal' : 'default';\n let cached = this._dataCollectors[cacheKey];\n\n if (!cached) {\n cached = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadDataCollector(),\n ])\n .then(([client, dataCollector]) => dataCollector.create({ client, kount: true, ...options }))\n .catch(error => {\n if (error && error.code === 'DATA_COLLECTOR_KOUNT_NOT_ENABLED') {\n return { deviceData: undefined, teardown: () => Promise.resolve() };\n }\n\n throw error;\n });\n\n this._dataCollectors[cacheKey] = cached;\n }\n\n return cached;\n }\n\n getVisaCheckout(): Promise<BraintreeVisaCheckout> {\n if (!this._visaCheckout) {\n this._visaCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadVisaCheckout(),\n ])\n .then(([client, visaCheckout]) => visaCheckout.create({ client }));\n }\n\n return this._visaCheckout;\n }\n\n getGooglePaymentComponent(): Promise<GooglePayBraintreeSDK> {\n if (!this._googlePay) {\n this._googlePay = Promise.all ([\n this.getClient(),\n this._braintreeScriptLoader.loadGooglePayment(),\n ])\n .then(([client, googlePay]) => googlePay.create({ client }));\n }\n\n return this._googlePay;\n }\n\n async createHostedFields(\n options: Pick<BraintreeHostedFieldsCreatorConfig, 'fields' | 'styles'>\n ): Promise<BraintreeHostedFields> {\n const [client, hostedFields] = await Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadHostedFields(),\n ]);\n\n return hostedFields.create({ ...options, client });\n }\n\n teardown(): Promise<void> {\n return Promise.all([\n this._teardown(this._3ds),\n this._teardown(this._dataCollectors.default),\n this._teardown(this._dataCollectors.paypal),\n this._teardown(this._googlePay),\n this._teardown(this._paypalCheckout),\n this._teardown(this._venmoCheckout),\n this._teardown(this._visaCheckout),\n ]).then(() => {\n this._3ds = undefined;\n this._dataCollectors = {};\n this._googlePay = undefined;\n this._paypalCheckout = undefined;\n this._venmoCheckout = undefined;\n this._visaCheckout = undefined;\n });\n }\n\n private _teardown(module?: Promise<BraintreeModule>) {\n return module ?\n module.then(mod => mod.teardown()) :\n Promise.resolve();\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport { GooglePayCreator } from '../googlepay';\n\nimport { BraintreeClientCreator, BraintreeDataCollectorCreator, BraintreeHostedFieldsCreator, BraintreeHostWindow, BraintreePaypalCheckoutCreator, BraintreePaypalCreator, BraintreeThreeDSecureCreator, BraintreeVenmoCheckoutCreator, BraintreeVisaCheckoutCreator } from './braintree';\n\nconst version = '3.81.0';\n\nexport default class BraintreeScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: BraintreeHostWindow = window\n ) {}\n\n loadClient(): Promise<BraintreeClientCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/client.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.client) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.client;\n });\n }\n\n load3DS(): Promise<BraintreeThreeDSecureCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/three-d-secure.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.threeDSecure) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.threeDSecure;\n });\n }\n\n loadDataCollector(): Promise<BraintreeDataCollectorCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/data-collector.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.dataCollector) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.dataCollector;\n });\n }\n\n loadPaypal(): Promise<BraintreePaypalCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/paypal.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.paypal;\n });\n }\n\n loadPaypalCheckout(): Promise<BraintreePaypalCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/paypal-checkout.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.paypalCheckout) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.paypalCheckout;\n });\n }\n\n loadVisaCheckout(): Promise<BraintreeVisaCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/visa-checkout.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.visaCheckout) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.visaCheckout;\n });\n }\n\n loadVenmoCheckout(): Promise<BraintreeVenmoCheckoutCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/venmo.min.js`)\n .then(() => {\n if (!this._window.braintree?.venmo) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.venmo;\n });\n }\n\n loadGooglePayment(): Promise<GooglePayCreator> {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/google-payment.min.js`)\n .then(() => {\n if (!this._window.braintree || !this._window.braintree.googlePayment) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.googlePayment;\n });\n }\n\n async loadHostedFields(): Promise<BraintreeHostedFieldsCreator> {\n await this._scriptLoader.loadScript(`//js.braintreegateway.com/web/${version}/js/hosted-fields.min.js`);\n\n if (!this._window.braintree || !this._window.braintree.hostedFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.braintree.hostedFields;\n }\n}\n","export enum CheckoutIncludes {\n AvailableShippingOptions = 'consignments.availableShippingOptions',\n PhysicalItemsCategoryNames = 'cart.lineItems.physicalItems.categoryNames',\n DigitalItemsCategoryNames = 'cart.lineItems.digitalItems.categoryNames',\n}\n\nexport default interface CheckoutParams {\n include?: CheckoutIncludes[] | CheckoutIncludeParam;\n}\n\nexport type CheckoutIncludeParam = {\n [key in CheckoutIncludes]?: boolean;\n};\n","import { createAction, createErrorAction, ThunkAction } from '@bigcommerce/data-store';\nimport { find } from 'lodash';\nimport { Observable, Observer } from 'rxjs';\n\nimport { AddressRequestBody } from '../address';\nimport { Cart } from '../cart';\nimport { CheckoutIncludes, CheckoutParams, CheckoutRequestSender, InternalCheckoutSelectors, ReadableCheckoutStore } from '../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../common/error/errors';\nimport { RequestOptions } from '../common/http-request';\n\nimport Consignment, { ConsignmentsRequestBody, ConsignmentAssignmentBaseRequestBodyWithAddress, ConsignmentAssignmentBaseRequestBodyWithShippingAddress, ConsignmentAssignmentRequestBody, ConsignmentCreateRequestBody, ConsignmentLineItem, ConsignmentRequestBody, ConsignmentShippingOptionRequestBody, ConsignmentUpdateRequestBody } from './consignment';\nimport { ConsignmentActionType, CreateConsignmentsAction, DeleteConsignmentAction, LoadShippingOptionsAction, UpdateConsignmentAction, UpdateShippingOptionAction } from './consignment-actions';\nimport ConsignmentRequestSender from './consignment-request-sender';\n\nexport default class ConsignmentActionCreator {\n constructor(\n private _consignmentRequestSender: ConsignmentRequestSender,\n private _checkoutRequestSender: CheckoutRequestSender\n ) {}\n\n unassignItemsByAddress(\n consignment: ConsignmentAssignmentRequestBody,\n options?: RequestOptions\n ): ThunkAction<DeleteConsignmentAction | UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const address = this._consignmentHasAddress(consignment) ? consignment.address : consignment.shippingAddress;\n\n const existingConsignment = state.consignments.getConsignmentByAddress(address);\n\n if (!existingConsignment) {\n throw new InvalidArgumentError('No consignment found for the specified address');\n }\n\n const lineItems = this._removeLineItems(\n consignment.lineItems,\n existingConsignment,\n state.cart.getCart()\n );\n\n if (!lineItems.length) {\n return this.deleteConsignment(existingConsignment.id, options)(store);\n }\n\n return this.updateConsignment({\n id: existingConsignment.id,\n address,\n lineItems,\n }, options)(store);\n };\n }\n\n assignItemsByAddress(\n consignment: ConsignmentAssignmentRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateConsignmentAction | CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => {\n const state = store.getState();\n const address = this._consignmentHasAddress(consignment) ? consignment.address : consignment.shippingAddress;\n const existingConsignment = state.consignments.getConsignmentByAddress(address);\n\n return this._createOrUpdateConsignment({\n id: existingConsignment && existingConsignment.id,\n address,\n lineItems: this._addLineItems(\n consignment.lineItems,\n existingConsignment,\n state.cart.getCart()\n ),\n }, options)(store);\n };\n }\n\n selectShippingOption(\n id: string,\n options?: RequestOptions\n ): ThunkAction<UpdateShippingOptionAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateShippingOptionAction>) => {\n const state = store.getState();\n const checkout = state.checkout.getCheckout();\n const consignments = state.consignments.getConsignments();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!consignments || !consignments.length) {\n throw new MissingDataError(MissingDataErrorType.MissingConsignments);\n }\n\n const consignmentUpdateBody = {\n id: consignments[0].id,\n shippingOptionId: id,\n };\n\n const consignmentMeta = {\n id: consignments[0].id,\n };\n\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignmentUpdateBody, options)\n .then(({ body }) => {\n observer.next(createAction(\n ConsignmentActionType.UpdateShippingOptionSucceeded,\n body,\n consignmentMeta\n ));\n\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(\n ConsignmentActionType.UpdateShippingOptionFailed,\n response,\n consignmentMeta\n ));\n });\n });\n }\n\n loadShippingOptions(options?: RequestOptions): ThunkAction<LoadShippingOptionsAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<LoadShippingOptionsAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.LoadShippingOptionsRequested));\n\n this._checkoutRequestSender.loadCheckout(checkout.id, {\n ...options,\n params: {\n include: [CheckoutIncludes.AvailableShippingOptions],\n },\n })\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.LoadShippingOptionsSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.LoadShippingOptionsFailed, response));\n });\n });\n }\n\n updateAddress(\n address: AddressRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<CreateConsignmentsAction | UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => {\n const consignment = this._getUpdateAddressRequestBody(address, store);\n const consignments = store.getState().consignments.getConsignments();\n\n if (consignments && consignments.length) {\n (consignment as ConsignmentUpdateRequestBody).id = consignments[0].id;\n }\n\n return this._createOrUpdateConsignment(consignment, options)(store);\n };\n }\n\n createConsignments(\n consignments: ConsignmentsRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<CreateConsignmentsAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.CreateConsignmentsRequested));\n\n this._consignmentRequestSender.createConsignments(checkout.id, consignments, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.CreateConsignmentsSucceeded, body));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.CreateConsignmentsFailed, response));\n });\n });\n }\n\n updateConsignment(\n consignment: ConsignmentUpdateRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<UpdateConsignmentAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateConsignmentAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const consignmentMeta = { id: consignment.id };\n\n observer.next(createAction(ConsignmentActionType.UpdateConsignmentRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignment, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.UpdateConsignmentSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.UpdateConsignmentFailed, response, consignmentMeta));\n });\n });\n }\n\n deleteConsignment(\n consignmentId: string,\n options?: RequestOptions\n ): ThunkAction<DeleteConsignmentAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<DeleteConsignmentAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n const consignmentMeta = { id: consignmentId };\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n observer.next(createAction(ConsignmentActionType.DeleteConsignmentRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.deleteConsignment(checkout.id, consignmentId, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.DeleteConsignmentSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.DeleteConsignmentFailed, response, consignmentMeta));\n });\n });\n }\n\n updateShippingOption(\n consignment: ConsignmentShippingOptionRequestBody,\n options?: RequestOptions\n ): ThunkAction<UpdateShippingOptionAction, InternalCheckoutSelectors> {\n return store => Observable.create((observer: Observer<UpdateShippingOptionAction>) => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const consignmentMeta = { id: consignment.id };\n\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionRequested, undefined, consignmentMeta));\n\n this._consignmentRequestSender.updateConsignment(checkout.id, consignment, options)\n .then(({ body }) => {\n observer.next(createAction(ConsignmentActionType.UpdateShippingOptionSucceeded, body, consignmentMeta));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(ConsignmentActionType.UpdateShippingOptionFailed, response, consignmentMeta));\n });\n });\n }\n\n private _createOrUpdateConsignment(\n consignment: ConsignmentCreateRequestBody | ConsignmentUpdateRequestBody,\n options?: RequestOptions<CheckoutParams>\n ): ThunkAction<UpdateConsignmentAction | CreateConsignmentsAction, InternalCheckoutSelectors> {\n return store => {\n const checkout = store.getState().checkout.getCheckout();\n\n if (!checkout || !checkout.id) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (this._isUpdateConsignmentRequest(consignment)) {\n return this.updateConsignment(consignment, options)(store);\n }\n\n return this.createConsignments([consignment], options)(store);\n };\n }\n\n private _getUpdateAddressRequestBody(\n address: AddressRequestBody,\n store: ReadableCheckoutStore\n ): ConsignmentRequestBody {\n const state = store.getState();\n const cart = state.cart.getCart();\n\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n const { physicalItems, customItems = [] } = cart.lineItems;\n\n return {\n address,\n lineItems: [ ...physicalItems, ...customItems ].map(item => ({\n itemId: item.id,\n quantity: item.quantity,\n })),\n };\n }\n\n private _removeLineItems(\n lineItems: ConsignmentLineItem[],\n consignment: Consignment,\n cart?: Cart\n ): ConsignmentLineItem[] {\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n\n return this._hydrateLineItems(consignment.lineItemIds, cart).map(existingItem => {\n const sharedItem = find(lineItems, lineItem => lineItem.itemId === existingItem.itemId);\n\n return {\n ...existingItem,\n quantity: sharedItem ? (existingItem.quantity - sharedItem.quantity) : existingItem.quantity,\n };\n }).filter(lineItem => lineItem.quantity > 0);\n }\n\n private _addLineItems(\n lineItems: ConsignmentLineItem[],\n consignment?: Consignment,\n cart?: Cart\n ): ConsignmentLineItem[] {\n if (!consignment) {\n return lineItems;\n }\n\n if (!cart) {\n throw new MissingDataError(MissingDataErrorType.MissingCart);\n }\n\n return lineItems\n .concat(this._hydrateLineItems(consignment.lineItemIds, cart))\n .filter(lineItem => lineItem.quantity > 0);\n }\n\n private _hydrateLineItems(lineItemIds: string[], cart: Cart): ConsignmentLineItem[] {\n return lineItemIds.map(itemId => {\n const item = find(cart.lineItems.physicalItems, lineItem => lineItem.id === itemId);\n\n return {\n itemId,\n quantity: item ? item.quantity : 0,\n };\n });\n }\n\n private _isUpdateConsignmentRequest(\n request: ConsignmentRequestBody\n ): request is ConsignmentUpdateRequestBody {\n const updateRequest = request as ConsignmentUpdateRequestBody;\n\n return !!updateRequest.id;\n }\n\n private _consignmentHasAddress(\n consignment: ConsignmentAssignmentBaseRequestBodyWithAddress | ConsignmentAssignmentBaseRequestBodyWithShippingAddress\n ): consignment is ConsignmentAssignmentBaseRequestBodyWithAddress {\n return typeof consignment === 'object' && 'address' in consignment;\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { Checkout, CheckoutParams } from '../checkout';\nimport { joinIncludes, joinOrMergeIncludes, ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { ConsignmentsRequestBody, ConsignmentUpdateRequestBody } from './consignment';\n\nconst DEFAULT_INCLUDES = [\n 'consignments.availableShippingOptions',\n 'cart.lineItems.physicalItems.options',\n 'cart.lineItems.digitalItems.options',\n 'customer',\n 'promotions.banners',\n];\n\nexport default class ConsignmentRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n createConsignments(\n checkoutId: string,\n consignments: ConsignmentsRequestBody,\n { timeout, params: { include } = {} }: RequestOptions<CheckoutParams> = {}\n ): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/consignments`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, {\n body: consignments,\n params: {\n include: joinOrMergeIncludes(DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n });\n }\n\n updateConsignment(\n checkoutId: string,\n consignment: ConsignmentUpdateRequestBody,\n { timeout, params: { include } = {} }: RequestOptions<CheckoutParams> = {}\n ): Promise<Response<Checkout>> {\n const { id, ...body } = consignment;\n const url = `/api/storefront/checkouts/${checkoutId}/consignments/${id}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.put(url, {\n body,\n params: {\n include: joinOrMergeIncludes(DEFAULT_INCLUDES, include),\n },\n headers,\n timeout,\n });\n }\n\n deleteConsignment(\n checkoutId: string,\n consignmentId: string,\n { timeout }: RequestOptions = {}\n ): Promise<Response<Checkout>> {\n const url = `/api/storefront/checkouts/${checkoutId}/consignments/${consignmentId}`;\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n const include = joinIncludes(DEFAULT_INCLUDES);\n\n return this._requestSender.delete(url, { params: { include }, headers, timeout });\n }\n}\n","import { RequestError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when the subscriptions fails to be updated\n */\nexport default class UpdateSubscriptionsError extends RequestError {\n constructor(response?: Response) {\n super(response);\n\n this.name = 'UpdateSubscriptionsError';\n this.type = 'update_subscriptions';\n }\n}\n","import { createAction } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\nimport { Subscriptions, SubscriptionsActionType, SubscriptionsRequestSender, UpdateSubscriptionsAction } from '../subscription';\n\nimport { UpdateSubscriptionsError } from './errors';\n\nexport default class SubscriptionsActionCreator {\n constructor(\n private _subscriptionsRequestSender: SubscriptionsRequestSender\n ) {}\n\n updateSubscriptions(\n subscriptions: Subscriptions,\n options?: RequestOptions\n ): Observable<UpdateSubscriptionsAction> {\n return concat(\n of(createAction(SubscriptionsActionType.UpdateSubscriptionsRequested)),\n defer(async () => {\n const { body } = await this._subscriptionsRequestSender.updateSubscriptions(subscriptions, options);\n\n return createAction(SubscriptionsActionType.UpdateSubscriptionsSucceeded, body);\n })\n ).pipe(\n catchError(error => throwErrorAction(\n SubscriptionsActionType.UpdateSubscriptionsFailed,\n new UpdateSubscriptionsError(error)\n ))\n );\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { ContentType, RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\nimport { Subscriptions } from './subscriptions';\n\nexport default class SubscriptionsRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n updateSubscriptions(subscriptions: Subscriptions, { timeout }: RequestOptions = {}): Promise<Response<Subscriptions>> {\n const url = '/api/storefront/subscriptions';\n const headers = {\n Accept: ContentType.JsonV1,\n ...SDK_VERSION_HEADERS,\n };\n\n return this._requestSender.post(url, { body: subscriptions, headers, timeout });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we are unable to synchronize the checkout details of a\n * shopper with a hosted / remote checkout provider (i.e.: Amazon).\n */\nexport default class RemoteCheckoutSynchronizationError extends StandardError {\n constructor(\n public error?: Error\n ) {\n super('Unable to synchronize your checkout details with a third party provider. Please try again later.');\n\n this.name = 'RemoteCheckoutSynchronizationError';\n this.type = 'remote_checkout_synchronization';\n }\n}\n","import { PaymentInitializeOptions } from '../..';\nimport { Checkout, InternalCheckoutSelectors } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\nimport { BraintreeModuleCreator, BraintreeVerifyPayload, GooglePayBraintreeSDK } from '../braintree';\n\nexport type EnvironmentType = 'PRODUCTION' | 'TEST';\nexport type TokenizeType = 'AndroidPayCard' | 'CreditCard' | 'CARD';\n\nexport interface GooglePayInitializer {\n initialize(checkout: Checkout, paymentMethod: PaymentMethod, hasShippingAddress: boolean, publishableKey?: string): Promise<GooglePayPaymentDataRequestV2>;\n teardown(): Promise<void>;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\nexport interface GooglePayProviderProcessor {\n initialize(options: PaymentInitializeOptions): Promise<void>;\n processAdditionalAction(error: unknown): Promise<InternalCheckoutSelectors>;\n}\n\nexport type GooglePayCreator = BraintreeModuleCreator<GooglePayBraintreeSDK>\n\nexport interface GooglePayPaymentOptions {\n environment: EnvironmentType;\n}\n\nexport type GooglePayVerifyPayload = BraintreeVerifyPayload | undefined;\n\nexport interface GooglePayIsReadyToPayResponse {\n result: boolean;\n paymentMethodPresend?: boolean;\n}\n\nexport interface GooglePaySDK {\n payments: {\n api: {\n PaymentsClient: new(options: GooglePayPaymentOptions) => GooglePayClient;\n };\n };\n}\n\nexport interface GooglePayClient {\n isReadyToPay(options: object): Promise<GooglePayIsReadyToPayResponse>;\n loadPaymentData(paymentDataRequest: GooglePayPaymentDataRequestV2): Promise<GooglePaymentData>;\n createButton(options: { [key: string]: string | object }): HTMLElement;\n}\n\nexport interface GooglePayHostWindow extends Window {\n google?: GooglePaySDK;\n}\n\nexport interface TokenizePayload {\n nonce: string;\n tokenFormat?: string;\n details: {\n cardType: string;\n lastFour: string;\n lastTwo?: string;\n };\n description?: string;\n type: TokenizeType;\n binData?: {\n commercial: string;\n countryOfIssuance: string;\n debit: string;\n durbinRegulated: string;\n healthcare: string;\n issuingBank: string;\n payroll: string;\n prepaid: string;\n productId: string;\n };\n}\n\nexport interface GooglePaymentData {\n apiVersion: number;\n apiVersionMinor: number;\n paymentMethodData: {\n description: string;\n info: {\n cardDetails: string;\n cardNetwork: string;\n billingAddress: GooglePayAddress;\n };\n tokenizationData: {\n token: string;\n type: string;\n };\n type: TokenizeType;\n };\n shippingAddress: GooglePayAddress;\n email: string;\n}\n\nexport interface GooglePayAddress {\n address1: string;\n address2: string;\n address3: string;\n administrativeArea: string;\n companyName: string;\n countryCode: string;\n locality: string;\n name: string;\n postalCode: string;\n sortingCode: string;\n phoneNumber: string;\n}\n\nexport interface GooglePaymentsError {\n statusCode: string;\n statusMessage?: string;\n}\n\nexport interface PaymentMethodData {\n methodId: string;\n paymentData: {\n method: string;\n nonce: string;\n cardInformation: {\n type: string;\n number: string;\n };\n };\n}\n\nexport enum ButtonType {\n Long = 'long',\n Short = 'short',\n}\nexport enum ButtonColor {\n Default = 'default',\n Black = 'black',\n White = 'white',\n}\n\nexport interface TokenizationSpecification {\n type: string;\n parameters: {\n gateway: string;\n gatewayMerchantId?: string;\n 'braintree:apiVersion'?: string;\n 'braintree:clientKey'?: string;\n 'braintree:merchantId'?: string;\n 'braintree:sdkVersion'?: string;\n 'braintree:authorizationFingerprint'?: string;\n 'stripe:version'?: string;\n 'stripe:publishableKey'?: string;\n };\n}\n\nexport enum BillingAddressFormat {\n /*\n * Name, country code, and postal code (default).\n */\n Min = 'MIN',\n /*\n * Name, street address, locality, region, country code, and postal code.\n */\n Full = 'FULL',\n}\n\nexport interface GooglePayPaymentDataRequestV2 {\n apiVersion: number;\n apiVersionMinor: number;\n merchantInfo: {\n authJwt?: string;\n merchantId?: string;\n merchantName?: string;\n };\n allowedPaymentMethods: [{\n type: string;\n parameters: {\n allowedAuthMethods: string[];\n allowedCardNetworks: string[];\n allowPrepaidCards?: boolean;\n billingAddressRequired?: boolean;\n billingAddressParameters?: {\n format?: BillingAddressFormat;\n phoneNumberRequired?: boolean;\n };\n };\n tokenizationSpecification?: TokenizationSpecification;\n }];\n transactionInfo: {\n currencyCode: string;\n countryCode?: string;\n totalPriceStatus: string;\n totalPrice?: string;\n checkoutOption?: string;\n };\n emailRequired?: boolean;\n shippingAddressRequired?: boolean;\n shippingAddressParameters?: {\n allowedCountryCodes?: string[];\n phoneNumberRequired?: boolean;\n };\n}\n","export function getFirstAndLastName(fullName: string): [string, string] {\n const nameParts = fullName.split(' ');\n\n if (nameParts.length === 1) {\n return [fullName, ''];\n }\n\n const firstName = nameParts.slice(0, -1).join(' ');\n const lastName = nameParts[nameParts.length - 1];\n\n return [firstName, lastName];\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { AddressRequestBody } from '../../../address';\nimport { BillingAddressActionCreator, BillingAddressUpdateRequestBody } from '../../../billing';\nimport { CheckoutStore, InternalCheckoutSelectors } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { RemoteCheckoutSynchronizationError } from '../../../remote-checkout/errors';\nimport { ConsignmentActionCreator } from '../../../shipping';\nimport { PaymentMethodInvalidError } from '../../errors';\nimport PaymentMethodActionCreator from '../../payment-method-action-creator';\n\nimport { ButtonColor, ButtonType, EnvironmentType, GooglePaymentData, GooglePayAddress, GooglePayClient, GooglePayInitializer, GooglePayPaymentDataRequestV2, GooglePaySDK, TokenizePayload } from './googlepay';\nimport { getFirstAndLastName } from './googlepay-get-first-and-last-name';\nimport GooglePayScriptLoader from './googlepay-script-loader';\n\nexport default class GooglePayPaymentProcessor {\n private _googlePayClient?: GooglePayClient;\n private _methodId?: string;\n private _paymentDataRequest?: GooglePayPaymentDataRequestV2;\n\n constructor(\n private _store: CheckoutStore,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _googlePayScriptLoader: GooglePayScriptLoader,\n private _googlePayInitializer: GooglePayInitializer,\n private _billingAddressActionCreator: BillingAddressActionCreator,\n private _consignmentActionCreator: ConsignmentActionCreator,\n private _requestSender: RequestSender\n ) {}\n\n initialize(methodId: string): Promise<void> {\n this._methodId = methodId;\n\n return this._configureWallet();\n }\n\n deinitialize(): Promise<void> {\n return this._googlePayInitializer.teardown();\n }\n\n createButton(\n onClick: (event: Event) => Promise<void>,\n buttonType: ButtonType = ButtonType.Short,\n buttonColor: ButtonColor = ButtonColor.Default\n ): HTMLElement {\n if (!this._googlePayClient) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._googlePayClient.createButton({\n buttonColor,\n buttonType,\n onClick,\n });\n }\n\n displayWallet(): Promise<GooglePaymentData> {\n if (!this._googlePayClient) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._googlePayClient.loadPaymentData(this._getPaymentDataRequest());\n }\n\n handleSuccess(paymentData: GooglePaymentData): Promise<InternalCheckoutSelectors> {\n return this._googlePayInitializer.parseResponse(paymentData)\n .then(tokenizePayload => this._postForm(tokenizePayload))\n .then(() => this._updateBillingAddress(paymentData));\n }\n\n updateShippingAddress(shippingAddress: GooglePayAddress): Promise<InternalCheckoutSelectors> {\n return this._store.dispatch(\n this._consignmentActionCreator.updateAddress(this._mapGooglePayAddressToShippingAddress(shippingAddress))\n );\n }\n\n private _configureWallet(): Promise<void> {\n const methodId = this._getMethodId();\n\n return this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId))\n .then(state => {\n const paymentMethod = state.paymentMethods.getPaymentMethod(methodId);\n const checkout = state.checkout.getCheckout();\n const hasShippingAddress = !!state.shippingAddress.getShippingAddress();\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n const { testMode } = paymentMethod.config;\n\n return Promise.all([\n this._googlePayScriptLoader.load(),\n this._googlePayInitializer.initialize(checkout, paymentMethod, hasShippingAddress),\n ]).then(([googlePay, paymentDataRequest]) => {\n this._googlePayClient = this._getGooglePayClient(googlePay, testMode);\n this._paymentDataRequest = paymentDataRequest;\n\n return this._googlePayClient.isReadyToPay({\n allowedPaymentMethods: [\n {\n type: paymentDataRequest.allowedPaymentMethods[0].type,\n parameters: {\n allowedAuthMethods: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedAuthMethods,\n allowedCardNetworks: paymentDataRequest.allowedPaymentMethods[0].parameters.allowedCardNetworks,\n },\n },\n ],\n apiVersion: paymentDataRequest.apiVersion,\n apiVersionMinor: paymentDataRequest.apiVersionMinor,\n }).then(response => {\n if (response.result) {\n return;\n }\n\n throw new PaymentMethodInvalidError();\n });\n });\n });\n }\n\n private _getCardInformation(cardInformation: { cardType: string; lastFour: string }) {\n return {\n type: cardInformation.cardType,\n number: cardInformation.lastFour,\n };\n }\n\n private _getPaymentDataRequest(): GooglePayPaymentDataRequestV2 {\n if (!this._paymentDataRequest) {\n throw new RemoteCheckoutSynchronizationError();\n }\n\n return this._paymentDataRequest;\n }\n\n private _getGooglePayClient(google: GooglePaySDK, testMode?: boolean): GooglePayClient {\n if (testMode === undefined) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const environment: EnvironmentType = testMode ? 'TEST' : 'PRODUCTION';\n\n return new google.payments.api.PaymentsClient({ environment });\n }\n\n private _getMethodId(): string {\n if (!this._methodId) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._methodId;\n }\n\n private _mapGooglePayAddressToBillingAddress(paymentData: GooglePaymentData, id: string, customerEmail?: string): BillingAddressUpdateRequestBody {\n const fullName = paymentData.paymentMethodData.info.billingAddress.name;\n const [firstName, lastName] = getFirstAndLastName(fullName);\n const address1 = paymentData.paymentMethodData.info.billingAddress.address1;\n const city = paymentData.paymentMethodData.info.billingAddress.locality;\n const postalCode = paymentData.paymentMethodData.info.billingAddress.postalCode;\n const countryCode = paymentData.paymentMethodData.info.billingAddress.countryCode;\n\n if (!firstName || !address1 || !city || !postalCode || !countryCode) {\n throw new MissingDataError(MissingDataErrorType.MissingBillingAddress);\n }\n\n return {\n id,\n firstName,\n lastName,\n company: paymentData.paymentMethodData.info.billingAddress.companyName,\n address1,\n address2: paymentData.paymentMethodData.info.billingAddress.address2 + paymentData.paymentMethodData.info.billingAddress.address3,\n city,\n stateOrProvince: paymentData.paymentMethodData.info.billingAddress.administrativeArea,\n stateOrProvinceCode: paymentData.paymentMethodData.info.billingAddress.administrativeArea,\n postalCode,\n countryCode,\n phone: paymentData.paymentMethodData.info.billingAddress.phoneNumber,\n customFields: [],\n email: customerEmail || paymentData.email,\n };\n }\n\n private _mapGooglePayAddressToShippingAddress(address: GooglePayAddress): AddressRequestBody {\n const [firstName, lastName] = getFirstAndLastName(address.name);\n\n return {\n firstName,\n lastName,\n company: address.companyName,\n address1: address.address1,\n address2: address.address2 + address.address3,\n city: address.locality,\n stateOrProvince: address.administrativeArea,\n stateOrProvinceCode: address.administrativeArea,\n postalCode: address.postalCode,\n countryCode: address.countryCode,\n phone: address.phoneNumber,\n customFields: [],\n };\n }\n\n private _postForm(postPaymentData: TokenizePayload): Promise<Response<void>> {\n const cardInformation = postPaymentData.details;\n\n return this._requestSender.post('/checkout.php', {\n headers: {\n Accept: 'text/html',\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...SDK_VERSION_HEADERS,\n },\n body: {\n payment_type: postPaymentData.type,\n nonce: postPaymentData.nonce,\n tokenFormat: postPaymentData.tokenFormat,\n provider: this._getMethodId(),\n action: 'set_external_checkout',\n card_information: this._getCardInformation(cardInformation),\n },\n });\n }\n\n private _updateBillingAddress(paymentData: GooglePaymentData): Promise<InternalCheckoutSelectors> {\n const remoteBillingAddress = this._store.getState().billingAddress.getBillingAddress();\n\n if (!remoteBillingAddress) {\n throw new MissingDataError(MissingDataErrorType.MissingBillingAddress);\n }\n\n const googlePayAddressMapped = this._mapGooglePayAddressToBillingAddress(paymentData, remoteBillingAddress.id, remoteBillingAddress.email);\n\n return this._store.dispatch(\n this._billingAddressActionCreator.updateAddress(googlePayAddressMapped)\n );\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { GooglePayHostWindow, GooglePaySDK } from './googlepay';\n\nexport default class GooglePayScriptLoader {\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: GooglePayHostWindow = window\n ) {}\n\n load(): Promise<GooglePaySDK> {\n return this._scriptLoader\n .loadScript('https://pay.google.com/gp/p/js/pay.js')\n .then(() => {\n if (!this._window.google) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.google;\n });\n }\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\nimport { getScriptLoader } from '@bigcommerce/script-loader';\n\nimport { BillingAddressActionCreator, BillingAddressRequestSender } from '../../../billing';\nimport { CheckoutRequestSender, CheckoutStore } from '../../../checkout';\nimport { ConsignmentActionCreator, ConsignmentRequestSender } from '../../../shipping';\nimport { SubscriptionsActionCreator, SubscriptionsRequestSender } from '../../../subscription';\nimport PaymentMethodActionCreator from '../../payment-method-action-creator';\nimport PaymentMethodRequestSender from '../../payment-method-request-sender';\n\nimport { GooglePayInitializer } from './googlepay';\nimport GooglePayPaymentProcessor from './googlepay-payment-processor';\nimport GooglePayScriptLoader from './googlepay-script-loader';\n\nexport default function createGooglePayPaymentProcessor(store: CheckoutStore, initializer: GooglePayInitializer): GooglePayPaymentProcessor {\n const requestSender = createRequestSender();\n const scriptLoader = getScriptLoader();\n\n return new GooglePayPaymentProcessor(\n store,\n new PaymentMethodActionCreator(\n new PaymentMethodRequestSender(requestSender)\n ),\n new GooglePayScriptLoader(scriptLoader),\n initializer,\n new BillingAddressActionCreator(\n new BillingAddressRequestSender(requestSender),\n new SubscriptionsActionCreator(\n new SubscriptionsRequestSender(requestSender)\n )\n ),\n new ConsignmentActionCreator(\n new ConsignmentRequestSender(requestSender),\n new CheckoutRequestSender(requestSender)\n ),\n requestSender\n );\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayAdyenV2Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: token,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'adyen',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n countryCode,\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayAdyenV3Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: token,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'adyen',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n countryCode,\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { PaymentMethod } from '../..';\nimport { Checkout } from '../../../checkout';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizationSpecification, TokenizePayload } from './googlepay';\n\nconst baseRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n};\n\nexport default class GooglePayAuthorizeNetInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(\n this._getGooglePaymentDataRequest(checkout, paymentMethod, hasShippingAddress)\n );\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n type,\n nonce: btoa(token),\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePaymentDataRequest(checkout: Checkout, paymentMethod: PaymentMethod, hasShippingAddress: boolean): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n paymentGatewayId: gatewayMerchantId,\n storeCountry: countryCode,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n const paymentGatewaySpecification = this._getPaymentGatewaySpecification(gatewayMerchantId);\n const cardPaymentMethod = this._getCardPaymentMethod(paymentGatewaySpecification, supportedCards);\n\n return {\n ...baseRequest,\n allowedPaymentMethods: [cardPaymentMethod],\n transactionInfo: {\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n currencyCode,\n countryCode,\n },\n merchantInfo : {\n merchantName,\n merchantId,\n authJwt,\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n\n private _getPaymentGatewaySpecification(gatewayMerchantId: string) {\n return {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'authorizenet',\n gatewayMerchantId,\n },\n };\n }\n\n private _getCardPaymentMethod(tokenizationSpecification: TokenizationSpecification, supportedCards: string[]) {\n return {\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification,\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport PaymentMethod from '../../payment-method';\nimport { BraintreeSDKCreator, GooglePayBraintreeSDK } from '../braintree';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\nimport { GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1 } from './googlepay-braintree';\n\nexport default class GooglePayBraintreeInitializer implements GooglePayInitializer {\n private _googlePaymentInstance!: GooglePayBraintreeSDK;\n\n constructor(\n private _braintreeSDKCreator: BraintreeSDKCreator\n ) {}\n\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n\n return this._braintreeSDKCreator.getGooglePaymentComponent()\n .then(googleBraintreePaymentInstance => {\n this._googlePaymentInstance = googleBraintreePaymentInstance;\n\n return this._createGooglePayPayload(\n checkout,\n paymentMethod.initializationData,\n hasShippingAddress\n );\n });\n }\n\n teardown(): Promise<void> {\n return this._braintreeSDKCreator.teardown();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token).androidPayCards[0];\n\n return Promise.resolve({\n nonce: payload.nonce,\n type: payload.type,\n description: payload.description,\n details: {\n cardType: payload.details.cardType,\n lastFour: payload.details.lastFour,\n lastTwo: payload.details.lastTwo,\n },\n binData: payload.binData,\n });\n }\n\n private _createGooglePayPayload(\n checkout: Checkout,\n initializationData: any,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n if (!initializationData.platformToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const googlePayBraintreePaymentDataRequest: GooglePayBraintreeDataRequest = {\n merchantInfo: {\n authJwt: initializationData.platformToken,\n merchantName: initializationData.googleMerchantName,\n merchantId: initializationData.googleMerchantId,\n },\n transactionInfo: {\n currencyCode: checkout.cart.currency.code,\n totalPriceStatus: 'FINAL',\n totalPrice: round(checkout.outstandingBalance, 2).toFixed(2),\n },\n cardRequirements: {\n billingAddressRequired: true,\n billingAddressFormat: 'FULL',\n },\n shippingAddressRequired: !hasShippingAddress,\n emailRequired: true,\n phoneNumberRequired: true,\n };\n\n return this._mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2(\n this._googlePaymentInstance.createPaymentDataRequest(googlePayBraintreePaymentDataRequest)\n );\n }\n\n private _mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2(googlePayBraintreeDataRequestV1: GooglePayBraintreePaymentDataRequestV1): GooglePayPaymentDataRequestV2 {\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt: googlePayBraintreeDataRequestV1.merchantInfo.authJwt,\n merchantId: googlePayBraintreeDataRequestV1.merchantInfo.merchantId,\n merchantName: googlePayBraintreeDataRequestV1.merchantInfo.merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: googlePayBraintreeDataRequestV1.cardRequirements.allowedCardNetworks,\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'braintree',\n 'braintree:apiVersion': 'v1',\n 'braintree:authorizationFingerprint': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:authorizationFingerprint'],\n 'braintree:merchantId': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:merchantId'],\n 'braintree:sdkVersion': googlePayBraintreeDataRequestV1.paymentMethodTokenizationParameters.parameters['braintree:sdkVersion'],\n },\n },\n }],\n transactionInfo: googlePayBraintreeDataRequestV1.transactionInfo,\n emailRequired: true,\n shippingAddressRequired: googlePayBraintreeDataRequestV1.shippingAddressRequired,\n shippingAddressParameters: {\n phoneNumberRequired: googlePayBraintreeDataRequestV1.phoneNumberRequired,\n },\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * This error should be thrown when a payment method experiences some kind of\n * failure (i.e.: its client library returns a rejected promise). And there is\n * no other error type that is more specific than this one.\n */\nexport default class PaymentMethodFailedError extends StandardError {\n constructor(message?: string) {\n super(message || 'Unable to proceed because the client library of a payment method has thrown an unexpected error.');\n\n this.name = 'PaymentMethodFailedError';\n this.type = 'payment_method_client_invalid';\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { ContentType } from '../../../common/http-request';\nimport { PaymentMethodFailedError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\nimport { CheckoutcomGooglePayToken, CheckoutcomToken } from '../checkoutcom';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayCheckoutcomInitializer implements GooglePayInitializer {\n private _publishableKey = '';\n private _testMode = true;\n private _errorMessage = 'Unable to parse response from GooglePay.';\n\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n async initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n this._publishableKey = paymentMethod.initializationData.checkoutcomkey;\n this._testMode = !!paymentMethod.config.testMode;\n\n return this._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(\n checkout,\n paymentMethod.initializationData,\n hasShippingAddress\n );\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n async parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n let token;\n try {\n token = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n } catch (err) {\n throw new InvalidArgumentError(this._errorMessage);\n }\n\n if (!token.signature || !token.protocolVersion || !token.signedMessage) {\n throw new PaymentMethodFailedError(this._errorMessage);\n }\n const finalToken = await this._convertToken(this._testMode, this._publishableKey, token);\n\n const payload: TokenizePayload = {\n nonce: finalToken.token,\n type: 'CreditCard',\n description: paymentData.paymentMethodData.description,\n details: {\n cardType: paymentData.paymentMethodData.info.cardNetwork,\n lastFour: paymentData.paymentMethodData.info.cardDetails,\n },\n };\n\n if (finalToken.token_format) {\n payload.tokenFormat = finalToken.token_format;\n }\n\n return payload;\n }\n\n private async _convertToken(testMode: boolean, checkoutcomkey: string, token: CheckoutcomGooglePayToken): Promise<CheckoutcomToken> {\n const checkoutcomToken: CheckoutcomToken = await this._requestCheckoutcomTokenize(testMode, checkoutcomkey, {\n type: 'googlepay',\n token_data: token,\n });\n\n if (!checkoutcomToken || !checkoutcomToken.token) {\n throw new PaymentMethodFailedError('Unable to parse response from Checkout.com');\n }\n\n return checkoutcomToken;\n }\n\n private async _requestCheckoutcomTokenize(testMode: boolean, checkoutcomKey: string, data = {}): Promise<CheckoutcomToken> {\n const TEST_URL = 'https://api.sandbox.checkout.com/tokens';\n const LIVE_URL = 'https://api.checkout.com/tokens';\n\n const url = testMode ? TEST_URL : LIVE_URL;\n\n const response = await this._requestSender.post(url, {\n credentials: false,\n body: data,\n headers: {\n 'Content-Type': ContentType.Json,\n Authorization: checkoutcomKey,\n 'X-XSRF-TOKEN': null,\n },\n });\n\n return response.body as CheckoutcomToken;\n }\n\n private _mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(\n checkout: Checkout,\n initializationData: any,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt: initializationData.platformToken,\n merchantId: initializationData.googleMerchantId,\n merchantName: initializationData.googleMerchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: ['AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA'],\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'checkoutltd',\n gatewayMerchantId: initializationData.checkoutcomkey,\n },\n },\n }],\n transactionInfo: {\n currencyCode: checkout.cart.currency.code,\n totalPriceStatus: 'FINAL',\n totalPrice: round(checkout.outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayCybersourceV2Initializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n nonce: btoa(token),\n type,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'cybersource',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayOrbitalInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n const {\n paymentMethodData: {\n type,\n tokenizationData: { token },\n info: {\n cardNetwork: cardType,\n cardDetails: lastFour,\n },\n },\n } = paymentData;\n\n return Promise.resolve({\n nonce: btoa(token),\n type,\n details: {\n cardType,\n lastFour,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n gatewayMerchantId,\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'chase',\n gatewayMerchantId,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayStripeInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n try {\n const payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n\n return Promise.resolve({\n nonce: payload.id,\n type: payload.type,\n details: {\n cardType: payload.card.brand,\n lastFour: payload.card.last4,\n },\n });\n } catch (err) {\n throw new InvalidArgumentError('Unable to parse response from Google Pay.');\n }\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode },\n },\n } = checkout;\n\n const {\n initializationData: {\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n stripeVersion,\n stripePublishableKey,\n stripeConnectedAccount,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'stripe',\n 'stripe:version': stripeVersion,\n 'stripe:publishableKey': `${stripePublishableKey}/${stripeConnectedAccount}`,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, 2).toFixed(2),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { round } from 'lodash';\n\nimport { Checkout } from '../../../checkout';\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { PaymentMethodFailedError } from '../../errors';\nimport PaymentMethod from '../../payment-method';\n\nimport { BillingAddressFormat, GooglePaymentData, GooglePayInitializer, GooglePayPaymentDataRequestV2, TokenizePayload } from './googlepay';\n\nexport default class GooglePayStripeUPEInitializer implements GooglePayInitializer {\n initialize(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): Promise<GooglePayPaymentDataRequestV2> {\n return Promise.resolve(this._getGooglePayPaymentDataRequest(\n checkout,\n paymentMethod,\n hasShippingAddress\n ));\n }\n\n teardown(): Promise<void> {\n return Promise.resolve();\n }\n\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload> {\n let payload;\n try {\n payload = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);\n } catch (err) {\n throw new InvalidArgumentError('Unable to parse response from Google Pay.');\n }\n\n if (!payload.id || !payload.type || !payload.card || !payload.card.brand || !payload.card.last4) {\n throw new PaymentMethodFailedError('Unable to parse response from Google Pay.');\n }\n\n return Promise.resolve({\n nonce: payload.id,\n type: payload.type,\n details: {\n cardType: payload.card.brand,\n lastFour: payload.card.last4,\n },\n });\n }\n\n private _getGooglePayPaymentDataRequest(\n checkout: Checkout,\n paymentMethod: PaymentMethod,\n hasShippingAddress: boolean\n ): GooglePayPaymentDataRequestV2 {\n const {\n outstandingBalance,\n cart: {\n currency: { code: currencyCode, decimalPlaces: decimalPlaces },\n },\n } = checkout;\n\n const {\n initializationData: {\n googleMerchantName: merchantName,\n googleMerchantId: merchantId,\n platformToken: authJwt,\n stripeVersion,\n stripePublishableKey,\n stripeConnectedAccount,\n },\n supportedCards,\n } = paymentMethod;\n\n return {\n apiVersion: 2,\n apiVersionMinor: 0,\n merchantInfo: {\n authJwt,\n merchantId,\n merchantName,\n },\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],\n allowedCardNetworks: supportedCards.map(card => card === 'MC' ? 'MASTERCARD' : card),\n billingAddressRequired: true,\n billingAddressParameters: {\n format: BillingAddressFormat.Full,\n phoneNumberRequired: true,\n },\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'stripe',\n 'stripe:version': stripeVersion,\n 'stripe:publishableKey': `${stripePublishableKey}/${stripeConnectedAccount}`,\n },\n },\n }],\n transactionInfo: {\n currencyCode,\n totalPriceStatus: 'FINAL',\n totalPrice: round(outstandingBalance, decimalPlaces).toFixed(decimalPlaces),\n },\n emailRequired: true,\n shippingAddressRequired: !hasShippingAddress,\n shippingAddressParameters: {\n phoneNumberRequired: true,\n },\n };\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { Masterpass, MasterpassHostWindow } from './masterpass';\ninterface MasterpassScriptLoaderParams {\n useMasterpassSrc: boolean;\n language: string;\n testMode?: boolean;\n checkoutId?: string;\n }\nexport default class MasterpassScriptLoader {\n\n constructor(\n private _scriptLoader: ScriptLoader,\n public _window: MasterpassHostWindow = window\n ) {}\n\n async load({ useMasterpassSrc, language, testMode, checkoutId }: MasterpassScriptLoaderParams): Promise<Masterpass> {\n\n if (useMasterpassSrc) {\n const subdomain = testMode ? 'sandbox.' : '';\n const params = [\n `locale=${language}`,\n `checkoutid=${checkoutId}`,\n ];\n\n const sourceUrl = [\n `https://${subdomain}src.mastercard.com/srci/integration/merchant.js`,\n params.join('&'),\n ].join('?');\n\n await this._scriptLoader.loadScript(sourceUrl);\n\n if (!this._window.masterpass) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.masterpass;\n\n }\n\n await this._scriptLoader.loadScript(`//${testMode ? 'sandbox.' : ''}masterpass.com/integration/merchant.js`);\n\n if (!this._window.masterpass) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.masterpass;\n }\n}\n","import { LoadScriptOptions, ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { PaypalHostWindow, PaypalSDK } from './paypal-sdk';\n\nexport default class PaypalScriptLoader {\n private _window: PaypalHostWindow;\n\n constructor(\n private _scriptLoader: ScriptLoader\n ) {\n this._window = window;\n }\n\n async loadPaypal(merchantId = ''): Promise<PaypalSDK> {\n const scriptSrc = '//www.paypalobjects.com/api/checkout.min.js';\n const options: LoadScriptOptions = { async: true, attributes: { 'data-merchant-id': merchantId } };\n\n merchantId\n ? await this._scriptLoader.loadScript(scriptSrc, options)\n : await this._scriptLoader.loadScript(scriptSrc);\n\n if (!this._window.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.paypal;\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { InvalidArgumentError } from '../../../common/error/errors';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\n\nimport { PaypalCommerceHostWindow, PaypalCommerceScriptParams, PaypalCommerceSDK } from './paypal-commerce-sdk';\n\nexport default class PaypalCommerceScriptLoader {\n private _window: PaypalCommerceHostWindow;\n\n constructor(\n private _scriptLoader: ScriptLoader\n ) {\n this._window = window;\n }\n\n async loadPaypalCommerce(params: PaypalCommerceScriptParams): Promise<PaypalCommerceSDK> {\n this._validateParams(params);\n\n if (!this._window.paypalLoadScript) {\n const scriptSrc = 'https://unpkg.com/@paypal/paypal-js@5.0.5/dist/iife/paypal-js.min.js';\n\n await this._scriptLoader.loadScript(scriptSrc, {async: true, attributes: {}});\n\n if (!this._window.paypalLoadScript) {\n throw new PaymentMethodClientUnavailableError();\n }\n }\n\n await this._window.paypalLoadScript(params);\n\n if (!this._window.paypal) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n return this._window.paypal;\n }\n\n _validateParams(options: PaypalCommerceScriptParams): void {\n const CLIENT_ID = 'client-id';\n const MERCHANT_ID = 'merchant-id';\n let param;\n\n if (!options) {\n param = 'options';\n } else if (!options[CLIENT_ID]) {\n param = CLIENT_ID;\n } else if (!options[MERCHANT_ID]) {\n param = MERCHANT_ID;\n }\n\n if (param) {\n throw new InvalidArgumentError(`Unable to proceed because \"${param}\" argument in PayPal script is not provided.`);\n }\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\n\nimport { ContentType, INTERNAL_USE_ONLY, SDK_VERSION_HEADERS } from '../../../common/http-request';\n\nimport { OrderData, OrderStatus } from './paypal-commerce-sdk';\n\nexport interface ParamsForProvider {\n isCredit?: boolean;\n isCheckout?: boolean;\n isCreditCard?: boolean;\n isAPM?: boolean;\n isVenmo?: boolean;\n}\n\nexport default class PaypalCommerceRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n async setupPayment(cartId: string, params: ParamsForProvider = {}): Promise<OrderData> {\n const { isCredit, isCheckout, isCreditCard, isAPM, isVenmo} = params;\n let provider = 'paypalcommerce';\n\n if (isCreditCard) {\n provider = 'paypalcommercecreditcardscheckout';\n } else if (isCheckout) {\n provider = isCredit ? 'paypalcommercecreditcheckout' : 'paypalcommercecheckout';\n } else if (isCredit) {\n provider = 'paypalcommercecredit';\n }\n if (isVenmo && !isAPM) {\n provider = isCheckout ? 'paypalcommercevenmocheckout' : 'paypalcommercevenmo';\n }\n\n if (isAPM) {\n provider = 'paypalcommercealternativemethodscheckout';\n }\n\n const url = `/api/storefront/payment/${provider}`;\n const body = { cartId };\n const headers = {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n 'Content-Type': ContentType.Json,\n ...SDK_VERSION_HEADERS,\n };\n\n const res = await this._requestSender.post(url, { headers, body });\n\n return res.body as OrderData;\n }\n\n async getOrderStatus() {\n const url = '/api/storefront/initialization/paypalcommerce';\n const headers = {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n 'Content-Type': ContentType.Json,\n ...SDK_VERSION_HEADERS,\n };\n\n const res = await this._requestSender.get<OrderStatus>(url, {headers});\n\n return res.body;\n }\n}\n","import StandardError from './standard-error';\n\n/**\n * Throw this error if we try to call a method that is only a stub and has not\n * been fully implemented.\n */\nexport default class NotImplementedError extends StandardError {\n constructor(message?: string) {\n super(message || 'Not implemented.');\n\n this.name = 'NotImplementedError';\n this.type = 'not_implemented';\n }\n}\n","enum PaymentStrategyType {\n ADYENV2 = 'adyenv2',\n ADYENV2_GOOGLEPAY = 'googlepayadyenv2',\n ADYENV3 = 'adyenv3',\n ADYENV3_GOOGLEPAY = 'googlepayadyenv3',\n AFFIRM = 'affirm',\n AFTERPAY = 'afterpay',\n AMAZON = 'amazon',\n AUTHORIZENET_GOOGLE_PAY = 'googlepayauthorizenet',\n AMAZONPAYV2 = 'amazonpay',\n APPLEPAY = 'applepay',\n BARCLAYS = 'barclays',\n BLUESNAPV2 = 'bluesnapv2',\n BOLT = 'bolt',\n CBA_MPGS = 'cba_mpgs',\n CHECKOUTCOM = 'checkoutcom',\n CHECKOUTCOM_APM = 'checkoutcomapm',\n CHECKOUTCOM_FAWRY = 'checkoutcomfawry',\n CHECKOUTCOM_SEPA = 'checkoutcomsepa',\n CHECKOUTCOM_IDEAL = 'checkoutcomideal',\n CREDIT_CARD = 'creditcard',\n CHECKOUTCOM_GOOGLE_PAY = 'googlepaycheckoutcom',\n CLEARPAY = 'clearpay',\n CONVERGE = 'converge',\n CYBERSOURCE = 'cybersource',\n CYBERSOURCEV2 = 'cybersourcev2',\n DIGITALRIVER = 'digitalriver',\n CYBERSOURCEV2_GOOGLE_PAY = 'googlepaycybersourcev2',\n HUMM = 'humm',\n KLARNA = 'klarna',\n KLARNAV2 = 'klarnav2',\n LAYBUY = 'laybuy',\n LEGACY = 'legacy',\n MOLLIE = 'mollie',\n MONERIS = 'moneris',\n NO_PAYMENT_DATA_REQUIRED = 'nopaymentdatarequired',\n OFFLINE = 'offline',\n OFFSITE = 'offsite',\n OPY = 'opy',\n ORBITAL_GOOGLE_PAY = 'googlepayorbital',\n PAYPAL = 'paypal',\n PAYPAL_EXPRESS = 'paypalexpress',\n PAYPAL_EXPRESS_CREDIT = 'paypalexpresscredit',\n PAYPAL_COMMERCE = 'paypalcommerce',\n PAYPAL_COMMERCE_CREDIT = 'paypalcommercecredit',\n PAYPAL_COMMERCE_CREDIT_CARD = 'paypalcommercecreditcards',\n PAYPAL_COMMERCE_ALTERNATIVE_METHODS = 'paypalcommercealternativemethods',\n PAYPAL_COMMERCE_VENMO = 'paypalcommercevenmo',\n PPSDK = 'PAYMENT_TYPE_SDK',\n QUADPAY = 'quadpay',\n SAGE_PAY = 'sagepay',\n SQUARE = 'squarev2',\n STRIPEV3 = 'stripev3',\n STRIPE_UPE = 'stripeupe',\n STRIPE_UPE_GOOGLE_PAY = 'googlepaystripeupe',\n BRAINTREE = 'braintree',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n BRAINTREE_VISA_CHECKOUT = 'braintreevisacheckout',\n BRAINTREE_GOOGLE_PAY = 'googlepaybraintree',\n CHASE_PAY = 'chasepay',\n WE_PAY = 'wepay',\n MASTERPASS = 'masterpass',\n STRIPE_GOOGLE_PAY = 'googlepaystripe',\n SEZZLE = 'sezzle',\n ZIP = 'zip',\n}\n\nexport default PaymentStrategyType;\n","\nexport interface ApproveDataOptions {\n orderID?: string;\n}\n\nexport interface ClickDataOptions {\n fundingSource: string;\n}\n\nexport interface ClickActions {\n reject(): Promise<void>;\n resolve(): Promise<void>;\n}\n\nexport interface OrderData {\n orderId: string;\n approveUrl: string;\n}\n\nexport interface OrderStatus {\n status: 'APPROVED' | 'CREATED' | string;\n}\n\nexport enum StyleButtonLabel {\n paypal = 'paypal',\n checkout = 'checkout',\n buynow = 'buynow',\n pay = 'pay',\n installment = 'installment',\n}\n\nexport enum StyleButtonLayout {\n vertical = 'vertical',\n horizontal = 'horizontal',\n}\n\nexport enum StyleButtonColor {\n gold = 'gold',\n blue = 'blue',\n silver = 'silver',\n black = 'black',\n white = 'white',\n}\n\nexport enum StyleButtonShape {\n pill = 'pill',\n rect = 'rect' ,\n}\n\nexport interface PaypalButtonStyleOptions {\n layout?: StyleButtonLayout;\n color?: StyleButtonColor;\n shape?: StyleButtonShape;\n height?: 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55;\n label?: StyleButtonLabel;\n tagline?: boolean;\n}\n\nexport interface ButtonsOptions {\n style?: PaypalButtonStyleOptions;\n fundingSource?: string;\n createOrder?(): Promise<string>;\n onApprove?(data: ApproveDataOptions): void;\n onClick?(data: ClickDataOptions, actions: ClickActions): void;\n onCancel?(): void;\n onError?(error: Error): void;\n}\n\nexport interface PaypalFieldsStyleOptions {\n variables?: {\n fontFamily?: string;\n fontSizeBase?: string;\n fontSizeSm?: string;\n fontSizeM?: string;\n fontSizeLg?: string;\n textColor?: string;\n colorTextPlaceholder?: string;\n colorBackground?: string;\n colorInfo?: string;\n colorDanger?: string;\n borderRadius?: string;\n borderColor?: string;\n borderWidth?: string;\n borderFocusColor?: string;\n spacingUnit?: string;\n };\n rules?: {\n [key: string]: any;\n };\n}\n\nexport interface FieldsOptions {\n style?: PaypalFieldsStyleOptions;\n fundingSource: string;\n fields: { name?: { value?: string }; email?: { value?: string } };\n}\n\nexport interface MessagesOptions {\n amount: number;\n placement: string;\n style?: MessagesStyleOptions;\n fundingSource?: string;\n}\n\nexport interface MessagesStyleOptions {\n layout?: string;\n}\n\nexport interface PaypalCommerceHostedFieldOption {\n selector: string;\n placeholder?: string;\n}\n\nexport interface PaypalCommerceHostedFieldsRenderOptions {\n fields?: {\n number?: PaypalCommerceHostedFieldOption;\n cvv?: PaypalCommerceHostedFieldOption;\n expirationDate?: PaypalCommerceHostedFieldOption;\n };\n paymentsSDK?: boolean;\n styles?: {\n input?: { [key: string]: string };\n '.invalid'?: { [key: string]: string };\n '.valid'?: { [key: string]: string };\n ':focus'?: { [key: string]: string };\n };\n createOrder(): Promise<string>;\n}\n\nexport interface PaypalCommerceHostedFieldsSubmitOptions {\n contingencies?: Array<'3D_SECURE'>;\n cardholderName?: string;\n}\n\nexport interface PaypalCommerceHostedFieldsApprove {\n orderId: string;\n liabilityShift: 'POSSIBLE' | 'NO' | 'UNKNOWN';\n}\n\nexport interface PaypalCommerceHostedFields {\n submit(options?: PaypalCommerceHostedFieldsSubmitOptions): PaypalCommerceHostedFieldsApprove;\n getState(): PaypalCommerceHostedFieldsState;\n on(eventName: string, callback: (event: PaypalCommerceHostedFieldsState) => void): void;\n}\n\nexport interface PaypalCommerceHostedFieldsState {\n cards: PaypalCommerceHostedFieldsCard[];\n emittedBy: string;\n fields: {\n number?: PaypalCommerceHostedFieldsFieldData;\n expirationDate?: PaypalCommerceHostedFieldsFieldData;\n expirationMonth?: PaypalCommerceHostedFieldsFieldData;\n expirationYear?: PaypalCommerceHostedFieldsFieldData;\n cvv?: PaypalCommerceHostedFieldsFieldData;\n postalCode?: PaypalCommerceHostedFieldsFieldData;\n };\n}\n\nexport interface PaypalCommerceHostedFieldsCard {\n type: string;\n niceType: string;\n code: { name: string; size: number };\n}\n\nexport interface PaypalCommerceHostedFieldsFieldData {\n container: HTMLElement;\n isFocused: boolean;\n isEmpty: boolean;\n isPotentiallyValid: boolean;\n isValid: boolean;\n}\n\nexport interface PaypalCommerceButtons {\n render(id: string): void;\n close(): void;\n isEligible(): boolean;\n}\n\nexport interface PaypalCommerceFields {\n render(id: string): void;\n}\n\nexport interface PaypalCommerceMessages {\n render(id: string): void;\n}\n\nexport interface PaypalCommerceSDKFunding {\n PAYPAL: string;\n CREDIT: string;\n PAYLATER: string;\n BANCONTACT: string;\n GIROPAY: string;\n P24: string;\n EPS: string;\n IDEAL: string;\n MYBANK: string;\n OXXO: string;\n SOFORT: string;\n SEPA: string;\n BLIK: string;\n TRUSTLY: string;\n VERKKOPANKKI: string;\n VENMO: string;\n}\n\nexport const NON_INSTANT_PAYMENT_METHODS = ['oxxo'];\n\nexport interface PaypalCommerceSDK {\n FUNDING: PaypalCommerceSDKFunding;\n HostedFields: {\n isEligible(): boolean;\n render(data: PaypalCommerceHostedFieldsRenderOptions): Promise<PaypalCommerceHostedFields>;\n };\n Buttons(params: ButtonsOptions): PaypalCommerceButtons;\n PaymentFields(params: FieldsOptions): PaypalCommerceFields;\n Messages(params: MessagesOptions): PaypalCommerceMessages;\n}\n\nexport interface PaypalCommerceHostWindow extends Window {\n paypal?: PaypalCommerceSDK;\n paypalLoadScript?(options: PaypalCommerceScriptParams): Promise<{ paypal: PaypalCommerceSDK }>;\n}\n\nexport type FundingType = string[];\nexport type EnableFundingType = FundingType | string;\n\nexport interface PaypalCommerceInitializationData {\n clientId: string;\n merchantId?: string;\n buyerCountry?: string;\n isDeveloperModeApplicable?: boolean;\n intent?: 'capture' | 'authorize';\n isPayPalCreditAvailable?: boolean;\n availableAlternativePaymentMethods: FundingType;\n enabledAlternativePaymentMethods: FundingType;\n clientToken?: string;\n attributionId?: string;\n isVenmoEnabled?: boolean;\n}\n\nexport type ComponentsScriptType = Array<'buttons' | 'messages' | 'hosted-fields' | 'payment-fields'>;\n\nexport interface PaypalCommerceScriptParams {\n 'client-id': string;\n 'merchant-id'?: string;\n 'buyer-country'?: string;\n 'disable-funding'?: FundingType;\n 'enable-funding'?: EnableFundingType;\n 'data-client-token'?: string;\n 'data-partner-attribution-id'?: string;\n currency?: string;\n commit?: boolean;\n intent?: 'capture' | 'authorize';\n components?: ComponentsScriptType;\n}\n","import { isNil, omitBy } from 'lodash';\n\nimport { CheckoutStore, InternalCheckoutSelectors } from '../../../checkout';\nimport { NotImplementedError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { OrderActionCreator } from '../../../order';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentActionCreator from '../../payment-action-creator';\nimport PaymentStrategyType from '../../payment-strategy-type';\n\nimport { ButtonsOptions, FieldsOptions, NON_INSTANT_PAYMENT_METHODS, ParamsForProvider, PaypalButtonStyleOptions, PaypalCommerceButtons, PaypalCommerceFields, PaypalCommerceHostedFields, PaypalCommerceHostedFieldsApprove, PaypalCommerceHostedFieldsRenderOptions, PaypalCommerceHostedFieldsState, PaypalCommerceHostedFieldsSubmitOptions, PaypalCommerceMessages, PaypalCommerceRequestSender, PaypalCommerceScriptLoader, PaypalCommerceScriptParams, PaypalCommerceSDK, PaypalCommerceSDKFunding, PaypalFieldsStyleOptions, StyleButtonColor, StyleButtonLabel, StyleButtonLayout, StyleButtonShape } from './index';\n\nexport interface OptionalParamsRenderButtons {\n paramsForProvider?: ParamsForProvider;\n fundingKey?: keyof PaypalCommerceSDKFunding;\n onRenderButton?(): void;\n}\n\nexport interface ParamsRenderHostedFields {\n fields: PaypalCommerceHostedFieldsRenderOptions['fields'];\n styles?: PaypalCommerceHostedFieldsRenderOptions['styles'];\n}\n\ninterface EventsHostedFields {\n blur?(event: PaypalCommerceHostedFieldsState): void;\n focus?(event: PaypalCommerceHostedFieldsState): void;\n cardTypeChange?(event: PaypalCommerceHostedFieldsState): void;\n validityChange?(event: PaypalCommerceHostedFieldsState): void;\n inputSubmitRequest?(event: PaypalCommerceHostedFieldsState): void;\n}\n\nexport interface RenderApmFieldsParams {\n apmFieldsContainer: string;\n fundingKey: keyof PaypalCommerceSDKFunding;\n apmFieldsStyles?: PaypalFieldsStyleOptions;\n fullName?: string;\n email?: string;\n}\n\nexport default class PaypalCommercePaymentProcessor {\n private _paypal?: PaypalCommerceSDK;\n private _paypalButtons?: PaypalCommerceButtons;\n private _paypalFields?: PaypalCommerceFields;\n private _paypalMessages?: PaypalCommerceMessages;\n private _hostedFields?: PaypalCommerceHostedFields;\n private _fundingSource?: string;\n private _orderId?: string;\n private _gatewayId?: string;\n private _isVenmoEnabled?: boolean;\n\n constructor(\n private _paypalScriptLoader: PaypalCommerceScriptLoader,\n private _paypalCommerceRequestSender: PaypalCommerceRequestSender,\n private _store: CheckoutStore,\n private _orderActionCreator: OrderActionCreator,\n private _paymentActionCreator: PaymentActionCreator\n ) {}\n\n async initialize(paramsScript: PaypalCommerceScriptParams, gatewayId?: string, isVenmoEnabled?: boolean): Promise<PaypalCommerceSDK> {\n this._paypal = await this._paypalScriptLoader.loadPaypalCommerce(paramsScript);\n this._gatewayId = gatewayId;\n this._isVenmoEnabled = isVenmoEnabled;\n\n return this._paypal;\n }\n\n renderButtons(cartId: string, container: string, params: ButtonsOptions = {}, optionalParams: OptionalParamsRenderButtons = {}): PaypalCommerceButtons {\n if (!this._paypal || !this._paypal.Buttons) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const { paramsForProvider, fundingKey, onRenderButton } = optionalParams;\n\n const buttonParams: ButtonsOptions = {\n ...params,\n createOrder: () => this._setupPayment(cartId, paramsForProvider),\n\n onClick: async (data, actions) => {\n this._fundingSource = data.fundingSource;\n\n return params.onClick?.(data, actions);\n },\n };\n\n if (params.style) {\n buttonParams.style = this._validateStyleParams(params.style);\n }\n\n if (fundingKey) {\n this._fundingSource = this._paypal.FUNDING[fundingKey];\n buttonParams.fundingSource = this._fundingSource;\n }\n\n this._paypalButtons = this._paypal.Buttons(buttonParams);\n\n if (!this._paypalButtons.isEligible()) {\n this._processNotEligible(buttonParams, fundingKey);\n }\n\n onRenderButton?.();\n\n this._paypalButtons.render(container);\n\n return this._paypalButtons;\n }\n\n renderFields({\n apmFieldsContainer,\n fundingKey,\n apmFieldsStyles,\n fullName,\n email,\n }: RenderApmFieldsParams): PaypalCommerceFields {\n if (!this._paypal || !this._paypal.PaymentFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const fieldsParams: FieldsOptions = {\n fundingSource: this._paypal.FUNDING[fundingKey],\n style: apmFieldsStyles,\n fields: {\n name: {\n value: fullName,\n },\n email: {\n value: email,\n },\n },\n };\n\n this._paypalFields = this._paypal.PaymentFields(fieldsParams);\n\n const fieldContainerElement = document.querySelector(apmFieldsContainer);\n if (fieldContainerElement) {\n fieldContainerElement.innerHTML = '';\n }\n\n this._paypalFields.render(apmFieldsContainer);\n\n return this._paypalFields;\n }\n\n getOrderId() {\n return this._orderId;\n }\n\n renderMessages(cartTotal: number, container: string): PaypalCommerceMessages {\n if (!this._paypal || !this._paypal.Messages) {\n throw new PaymentMethodClientUnavailableError();\n }\n this._paypalMessages = this._paypal.Messages({\n amount: cartTotal,\n placement: 'cart',\n style: {\n layout: 'text',\n },\n });\n this._paypalMessages.render(container);\n\n return this._paypalMessages;\n }\n\n async renderHostedFields(cartId: string, params: ParamsRenderHostedFields, events?: EventsHostedFields): Promise<void> {\n if (!this._paypal || !this._paypal.HostedFields) {\n throw new PaymentMethodClientUnavailableError();\n }\n\n const { fields, styles } = params;\n\n if (!this._paypal.HostedFields.isEligible()) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n this._hostedFields = await this._paypal.HostedFields.render({\n fields,\n styles,\n paymentsSDK: true,\n createOrder: () => this._setupPayment(cartId, { isCreditCard: true }),\n });\n\n if (events) {\n (Object.keys(events) as Array<keyof EventsHostedFields>).forEach(key => {\n (this._hostedFields as PaypalCommerceHostedFields).on(key, events[key] as (event: PaypalCommerceHostedFieldsState) => void);\n });\n }\n }\n\n async submitHostedFields(options?: PaypalCommerceHostedFieldsSubmitOptions): Promise<PaypalCommerceHostedFieldsApprove> {\n if (!this._hostedFields) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._hostedFields.submit(omitBy(options, isNil));\n }\n\n getHostedFieldsValidationState(): { isValid: boolean; fields: PaypalCommerceHostedFieldsState['fields'] } {\n if (!this._hostedFields) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n const { fields } = this._hostedFields.getState();\n\n const isValid = (Object.keys(fields) as Array<keyof PaypalCommerceHostedFieldsState['fields']>)\n .every(key => fields[key]?.isValid);\n\n return { isValid, fields };\n }\n\n deinitialize() {\n this._paypalButtons?.close?.();\n this._paypal = undefined;\n this._paypalButtons = undefined;\n this._fundingSource = undefined;\n this._hostedFields = undefined;\n }\n\n private async _setupPayment(cartId: string, params: ParamsForProvider = {}): Promise<string> {\n const paramsForProvider = { ...params, isCredit: this._fundingSource === 'credit' || this._fundingSource === 'paylater' };\n const isAPM = this._gatewayId === PaymentStrategyType.PAYPAL_COMMERCE_ALTERNATIVE_METHODS;\n const isVenmo = this._fundingSource === 'venmo' && this._isVenmoEnabled;\n\n const { orderId } = await this._paypalCommerceRequestSender.setupPayment(cartId, {...paramsForProvider, isAPM, isVenmo});\n this._orderId = orderId;\n const methodId = this._fundingSource;\n\n if (methodId && NON_INSTANT_PAYMENT_METHODS.indexOf(methodId) > -1) {\n await this._patchNonInstantPaymentMethods(methodId);\n }\n\n return orderId;\n }\n\n private async _patchNonInstantPaymentMethods(methodId: string): Promise<InternalCheckoutSelectors> {\n const gatewayId = this._gatewayId;\n const paymentData = {\n formattedPayload: {\n vault_payment_instrument: null,\n set_as_default_stored_instrument: null,\n device_info: null,\n method_id: methodId,\n paypal_account: {\n order_id: this._orderId,\n },\n },\n };\n\n const order = { useStoreCredit: false };\n const paymentRequestOptions = {\n gatewayId,\n methodId,\n };\n\n await this._store.dispatch(this._orderActionCreator.submitOrder(\n order,\n { params: paymentRequestOptions }\n ));\n\n return this._store.dispatch(this._paymentActionCreator.submitPayment({\n gatewayId,\n methodId,\n paymentData,\n }));\n }\n\n private _validateStyleParams = (style: PaypalButtonStyleOptions): PaypalButtonStyleOptions => {\n const updatedStyle: PaypalButtonStyleOptions = { ...style };\n const { label, color, layout, shape, height, tagline } = style;\n\n if (label && !StyleButtonLabel[label]) {\n delete updatedStyle.label;\n }\n\n if (layout && !StyleButtonLayout[layout]) {\n delete updatedStyle.layout;\n }\n\n if (color && !StyleButtonColor[color]) {\n delete updatedStyle.color;\n }\n\n if (shape && !StyleButtonShape[shape]) {\n delete updatedStyle.shape;\n }\n\n if (typeof height === 'number') {\n updatedStyle.height = height < 25\n ? 25\n : (height > 55 ? 55 : height);\n } else {\n delete updatedStyle.height;\n }\n\n if (typeof tagline !== 'boolean' || (tagline && updatedStyle.layout !== StyleButtonLayout[StyleButtonLayout.horizontal])) {\n delete updatedStyle.tagline;\n }\n\n return updatedStyle;\n };\n\n private _processNotEligible(buttonParams: ButtonsOptions, fundingKey?: keyof PaypalCommerceSDKFunding): void {\n if (fundingKey?.toUpperCase() === this._paypal?.FUNDING.PAYLATER.toUpperCase()) {\n buttonParams.fundingSource = this._paypal?.FUNDING.CREDIT;\n\n this._paypalButtons = this._paypal?.Buttons(buttonParams);\n\n if (this._paypalButtons?.isEligible()) {\n return;\n }\n }\n\n throw new NotImplementedError(`PayPal ${this._fundingSource || ''} is not available for your region. Please use PayPal Checkout instead.`);\n }\n}\n","import { RequestSender, Response } from '@bigcommerce/request-sender';\n\nimport { RequestOptions, SDK_VERSION_HEADERS } from '../common/http-request';\n\n/**\n * @todo Convert this file into TypeScript properly\n */\nexport default class RemoteCheckoutRequestSender {\n constructor(\n private _requestSender: RequestSender\n ) {}\n\n initializeBilling(methodName: string, params?: { referenceId: string }, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/billing`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n initializeShipping(methodName: string, params?: { referenceId: string }, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/shipping`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n initializePayment(methodName: string, params?: InitializePaymentOptions, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/payment`;\n\n return this._requestSender.get(url, { params, timeout, headers: SDK_VERSION_HEADERS });\n }\n\n loadSettings(methodName: string, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/settings`;\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n signOut(methodName: string, { timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/${methodName}/signout`;\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n generateToken({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = '/remote-checkout-token';\n\n return this._requestSender.get(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n trackAuthorizationEvent({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = '/remote-checkout/events/shopper-checkout-service-provider-authorization-requested';\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n\n forgetCheckout({ timeout }: RequestOptions = {}): Promise<Response<any>> {\n const url = `/remote-checkout/forget-checkout`;\n\n return this._requestSender.post(url, { timeout, headers: SDK_VERSION_HEADERS });\n }\n}\n\nexport interface InitializePaymentOptions {\n authorizationToken?: string;\n customerMessage?: string;\n referenceId?: string;\n useStoreCredit?: boolean;\n}\n","import { createAction, createErrorAction, Action } from '@bigcommerce/data-store';\nimport { concat, defer, of, Observable, Observer } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport { CheckoutActionCreator } from '../checkout';\nimport { throwErrorAction } from '../common/error';\nimport { RequestOptions } from '../common/http-request';\n\nimport { RemoteCheckoutActionType } from './remote-checkout-actions';\nimport RemoteCheckoutRequestSender, { InitializePaymentOptions } from './remote-checkout-request-sender';\nimport { RemoteCheckoutStateData } from './remote-checkout-state';\n\n/**\n * @todo Convert this file into TypeScript properly\n * i.e.: Action<T>\n */\nexport default class RemoteCheckoutActionCreator {\n constructor(\n private _remoteCheckoutRequestSender: RemoteCheckoutRequestSender,\n private _checkoutActionCreator: CheckoutActionCreator\n ) {}\n\n initializeBilling(methodId: string, params?: { referenceId: string }, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteBillingRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializeBilling(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteBillingSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemoteBillingFailed, response, { methodId }));\n });\n });\n }\n\n initializeShipping(methodId: string, params?: { referenceId: string }, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteShippingRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializeShipping(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemoteShippingSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemoteShippingFailed, response, { methodId }));\n });\n });\n }\n\n initializePayment(methodId: string, params?: InitializePaymentOptions, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemotePaymentRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.initializePayment(methodId, params, options)\n .then(({ body = {} }) => {\n observer.next(createAction(RemoteCheckoutActionType.InitializeRemotePaymentSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.InitializeRemotePaymentFailed, response, { methodId }));\n });\n });\n }\n\n loadSettings(methodId: string, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.LoadRemoteSettingsRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.loadSettings(methodId, options)\n .then(({ body }) => {\n observer.next(createAction(RemoteCheckoutActionType.LoadRemoteSettingsSucceeded, body, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.LoadRemoteSettingsFailed, response, { methodId }));\n });\n });\n }\n\n signOut(methodId: string, options?: RequestOptions): Observable<Action> {\n return Observable.create((observer: Observer<Action>) => {\n observer.next(createAction(RemoteCheckoutActionType.SignOutRemoteCustomerRequested, undefined, { methodId }));\n\n this._remoteCheckoutRequestSender.signOut(methodId, options)\n .then(() => {\n observer.next(createAction(RemoteCheckoutActionType.SignOutRemoteCustomerSucceeded, undefined, { methodId }));\n observer.complete();\n })\n .catch(response => {\n observer.error(createErrorAction(RemoteCheckoutActionType.SignOutRemoteCustomerFailed, response, { methodId }));\n });\n });\n }\n\n forgetCheckout(methodId: string, options?: RequestOptions): Observable<Action> {\n return concat(\n of(createAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerRequested, undefined, {methodId})),\n defer(async () => {\n await this._remoteCheckoutRequestSender.forgetCheckout(options);\n await this._checkoutActionCreator.loadCurrentCheckout();\n\n return createAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerSucceeded, undefined, {methodId});\n })\n ).pipe(\n catchError(error => throwErrorAction(RemoteCheckoutActionType.ForgetCheckoutRemoteCustomerFailed, error, { methodId }))\n );\n }\n\n updateCheckout<K extends keyof RemoteCheckoutStateData>(methodId: K, data: Partial<RemoteCheckoutStateData[K]>): Action {\n return createAction(RemoteCheckoutActionType.UpdateRemoteCheckout, data, { methodId });\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam protection\n * challenge (i.e.: they close the reCaptcha window).\n */\nexport default class SpamProtectionChallengeNotCompletedError extends StandardError {\n constructor() {\n super('You haven\\'t complete our spam protection challenge. Please try again.');\n\n this.name = 'SpamProtectionChallengeNotCompletedError';\n this.type = 'spam_protection_challenge_not_completed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if the shopper chooses not to complete the spam protection\n * challenge (i.e.: they close the reCaptcha window).\n */\nexport default class CardingProtectionChallengeNotCompletedError extends StandardError {\n constructor() {\n super('Please complete our human verification challenge and try again.');\n\n this.name = 'CardingProtectionChallengeNotCompletedError';\n this.type = 'carding_protection_challenge_not_completed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we fail to complete the required spam protection\n * verification due to an unknown reason.\n */\nexport default class CardingProtectionFailedError extends StandardError {\n constructor() {\n super('We were not able to verify that you are not a robot. Please try again.');\n\n this.name = 'CardingProtectionFailedError';\n this.type = 'carding_protection_failed';\n }\n}\n","import { switchMap, take } from 'rxjs/operators';\n\nimport { RequestError } from '../common/error/errors';\nimport { PaymentAdditionalAction } from '../payment';\n\nimport { CardingProtectionChallengeNotCompletedError, CardingProtectionFailedError, SpamProtectionChallengeNotCompletedError } from './errors';\nimport GoogleRecaptcha from './google-recaptcha';\n\nexport default class PaymentHumanVerificationHandler {\n\n constructor(\n private _googleRecaptcha: GoogleRecaptcha\n ) {}\n\n handle(error: Error): Promise<PaymentAdditionalAction>;\n handle(id: string, key: string): Promise<PaymentAdditionalAction>;\n async handle(errorOrId: Error | string, key?: string): Promise<PaymentAdditionalAction> {\n if (typeof errorOrId === 'string') {\n return this.handleWithRecaptchaSitekey(errorOrId, key);\n }\n\n return this.handleWithPaymentHumanVerificationRequestError(errorOrId);\n }\n\n private async handleWithPaymentHumanVerificationRequestError(error: Error): Promise<PaymentAdditionalAction> {\n if (!this._isPaymentHumanVerificationRequest(error)) {\n throw error;\n }\n\n await this._initialize(error.body.additional_action_required.data.key);\n\n return this._performRecaptcha();\n }\n\n private async handleWithRecaptchaSitekey(id: string, key?: string): Promise<PaymentAdditionalAction> {\n if (id !== 'recaptcha_v2') {\n throw Error('Human verification method is not supported.');\n }\n\n if (!key) {\n throw Error('Recaptcha site key is missing.');\n }\n\n await this._initialize(key);\n\n return this._performRecaptcha();\n }\n\n private _performRecaptcha(): Promise<PaymentAdditionalAction> {\n return this._googleRecaptcha.execute()\n .pipe(take(1))\n .pipe(switchMap(async ({ error, token }) => {\n if (error instanceof SpamProtectionChallengeNotCompletedError) {\n throw new CardingProtectionChallengeNotCompletedError();\n }\n\n if (error || !token) {\n throw new CardingProtectionFailedError();\n }\n\n return {\n type: 'recaptcha_v2_verification',\n data: {\n human_verification_token: token,\n },\n };\n })).toPromise();\n }\n\n private _initialize(recaptchaSitekey: string): Promise<void> {\n const cardingProtectionElementId = 'cardingProtectionContainer';\n\n let cardingProtectionElement = document.getElementById(cardingProtectionElementId);\n if (cardingProtectionElement && cardingProtectionElement.parentNode) {\n cardingProtectionElement.parentNode.removeChild(cardingProtectionElement);\n }\n\n cardingProtectionElement = document.createElement('div');\n cardingProtectionElement.setAttribute('id', cardingProtectionElementId);\n document.body.appendChild(cardingProtectionElement);\n\n return this._googleRecaptcha.load(cardingProtectionElementId, recaptchaSitekey);\n }\n\n private _isPaymentHumanVerificationRequest(error: Error): error is RequestError {\n const { additional_action_required, status } = (error as RequestError).body || {};\n\n return status === 'additional_action_required'\n && additional_action_required\n && additional_action_required.type === 'recaptcha_v2_verification';\n }\n}\n","export interface MutationObeserverCreator {\n prototype: MutationObserver;\n new(callback: MutationCallback): MutationObserver;\n}\n\nexport interface MutationObserverWindow extends Window {\n MutationObserver: MutationObeserverCreator;\n}\n\nexport class MutationObserverFactory {\n constructor(\n private _window: MutationObserverWindow = window as MutationObserverWindow\n ) {}\n\n create(callback: MutationCallback): MutationObserver {\n return new this._window.MutationObserver(callback);\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if we fail to complete the required spam protection\n * verification due to an unknown reason.\n */\nexport default class SpamProtectionFailedError extends StandardError {\n constructor() {\n super('We were not able to complete your spam protection verification. Please try again.');\n\n this.name = 'SpamProtectionFailedError';\n this.type = 'spam_protection_failed';\n }\n}\n","import { StandardError } from '../../common/error/errors';\n\n/**\n * Throw this error if spam protection is not loaded when trying to\n * complete the required spam protection verification.\n */\nexport default class SpamProtectionNotLoadedError extends StandardError {\n constructor() {\n super('Spam protection is not loaded. Please try again.');\n\n this.name = 'SpamProtectionNotLoadedError';\n this.type = 'spam_protection_failed';\n }\n}\n","import { memoize } from '@bigcommerce/memoize';\nimport { defer, of, throwError, Observable, Subject } from 'rxjs';\nimport { catchError, delay, retryWhen, switchMap } from 'rxjs/operators';\n\nimport { MutationObserverFactory } from '../common/dom';\nimport { NotInitializedError, NotInitializedErrorType } from '../common/error/errors';\n\nimport { SpamProtectionChallengeNotCompletedError, SpamProtectionFailedError, SpamProtectionNotLoadedError } from './errors';\nimport GoogleRecaptchaScriptLoader from './google-recaptcha-script-loader';\n\nconst TIMEOUT = 7000;\nconst RETRY_INTERVAL = 250;\nconst MAX_RETRIES = TIMEOUT / RETRY_INTERVAL;\n\nexport interface RecaptchaResult {\n error?: Error;\n token?: string;\n}\n\nexport default class GoogleRecaptcha {\n private _event$?: Subject<RecaptchaResult>;\n private _recaptcha?: ReCaptchaV2.ReCaptcha;\n private _memoized: (recaptcha: ReCaptchaV2.ReCaptcha, sitekey: string, container: HTMLElement | null) => Subject<RecaptchaResult>;\n private _widgetId?: number;\n\n constructor(\n private googleRecaptchaScriptLoader: GoogleRecaptchaScriptLoader,\n private mutationObserverFactory: MutationObserverFactory\n ) {\n this._memoized = memoize((recaptcha: ReCaptchaV2.ReCaptcha, sitekey: string, container: HTMLElement | null) => {\n const event$ = new Subject<RecaptchaResult>();\n\n if (!container) {\n throw new Error();\n }\n\n this._widgetId = recaptcha.render(container.id, {\n sitekey,\n size: 'invisible',\n callback: () => {\n event$.next({\n token: recaptcha.getResponse(this._widgetId),\n });\n recaptcha.reset(this._widgetId);\n },\n 'error-callback': () => {\n event$.next({\n error: new SpamProtectionFailedError(),\n });\n },\n });\n\n return event$;\n }, { isEqual: (a, b) => a === b });\n }\n\n load(containerId: string, sitekey: string): Promise<void> {\n return this.googleRecaptchaScriptLoader.load()\n .then(recaptcha => {\n this._event$ = this._memoized(recaptcha, sitekey, document.getElementById(containerId));\n\n this._recaptcha = recaptcha;\n });\n }\n\n execute(): Observable<RecaptchaResult> {\n return defer(() => {\n const event$ = this._event$;\n const recaptcha = this._recaptcha;\n\n if (!event$ || !recaptcha) {\n throw new NotInitializedError(NotInitializedErrorType.SpamProtectionNotInitialized);\n }\n\n return defer(() => {\n const element = document.querySelector('iframe[src*=\"bframe\"]');\n\n return element ? of(element) : throwError(new SpamProtectionNotLoadedError());\n })\n .pipe(\n retryWhen(errors => errors.pipe(\n delay(RETRY_INTERVAL),\n switchMap((error, index) =>\n index < MAX_RETRIES ? of(error) : throwError(error)\n )\n )),\n switchMap(element => {\n this._watchRecaptchaChallengeWindow(event$, element);\n recaptcha.execute(this._widgetId);\n\n return event$;\n }),\n catchError(error => of({ error }))\n );\n });\n }\n\n private _watchRecaptchaChallengeWindow(event: Subject<RecaptchaResult>, element: Element) {\n const iframeContainer = element.parentElement;\n\n if (!iframeContainer) {\n throw new SpamProtectionNotLoadedError();\n }\n\n const container = iframeContainer.parentElement;\n\n if (!container) {\n throw new SpamProtectionNotLoadedError();\n }\n\n this.mutationObserverFactory.create(() => {\n // When customer closes the Google ReCaptcha challenge window, throw SpamProtectionNotCompletedError\n if (container.style.visibility === 'hidden') {\n event.next({\n error: new SpamProtectionChallengeNotCompletedError(),\n });\n }\n }).observe(container, { attributes: true, attributeFilter: ['style'] });\n }\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nexport default class GoogleRecaptchaScriptLoader {\n private _loadPromise?: Promise<ReCaptchaV2.ReCaptcha>;\n\n constructor(\n private _scriptLoader: ScriptLoader,\n private _window: GoogleRecaptchaWindow = window\n ) {}\n\n load(): Promise<ReCaptchaV2.ReCaptcha> {\n if (!this._loadPromise) {\n this._loadPromise = this._loadScript();\n }\n\n return this._loadPromise;\n }\n\n private _loadScript(): Promise<ReCaptchaV2.ReCaptcha> {\n const callbackName = 'initRecaptcha';\n const params = [\n `onload=${callbackName}`,\n 'render=explicit',\n ].join('&');\n\n return new Promise((resolve, reject) => {\n this._window[callbackName] = () => resolve(this._window.grecaptcha);\n\n this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${params}`)\n .catch(error => {\n this._loadPromise = undefined;\n reject(error);\n });\n });\n }\n}\n\nexport interface GoogleRecaptchaWindow extends Window {\n grecaptcha?: ReCaptchaV2.ReCaptcha;\n initRecaptcha?(): void;\n}\n","import { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { MutationObserverFactory } from '../common/dom';\n\nimport GoogleRecaptcha from './google-recaptcha';\nimport GoogleRecaptchaScriptLoader from './google-recaptcha-script-loader';\n\nexport default function createSpamProtection(scriptLoader: ScriptLoader): GoogleRecaptcha {\n return new GoogleRecaptcha(\n new GoogleRecaptchaScriptLoader(scriptLoader),\n new MutationObserverFactory()\n );\n}\n","import { Cart } from '../cart';\n\nimport getLineItemsCount from './getLineItemsCount';\n\nexport default function getShippableItemsCount(cart: Cart): number {\n return getLineItemsCount(cart.lineItems.physicalItems.filter(item => !item.addedByPromotion));\n}\n","import { reduce } from 'lodash';\n\nimport { LineItem } from '../cart';\n\nexport default function getLineItemsCount(lineItems: LineItem[]): number {\n return reduce(lineItems, (total, item) => total + item.quantity, 0);\n}\n","import { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { PaymentMethod } from '../../../payment';\nimport { AmazonPayV2ButtonParams, AmazonPayV2PaymentProcessor, AmazonPayV2PayOptions, AmazonPayV2Placement } from '../../../payment/strategies/amazon-pay-v2';\nimport { getShippableItemsCount } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { AmazonPayV2ButtonInitializeOptions } from './amazon-pay-v2-button-options';\n\nexport default class AmazonPayV2ButtonStrategy implements CheckoutButtonStrategy {\n private _walletButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _amazonPayV2PaymentProcessor: AmazonPayV2PaymentProcessor\n ) { }\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId, amazonpay } = options;\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" or \"methodId\" argument is not provided.');\n }\n\n const paymentMethod = this._store.getState().paymentMethods.getPaymentMethodOrThrow(methodId);\n\n await this._amazonPayV2PaymentProcessor.initialize(paymentMethod);\n this._walletButton = await this._createSignInButton(containerId, paymentMethod, amazonpay);\n }\n\n deinitialize(): Promise<void> {\n if (this._walletButton && this._walletButton.parentNode) {\n this._walletButton.parentNode.removeChild(this._walletButton);\n this._walletButton = undefined;\n }\n\n return Promise.resolve();\n }\n\n private async _createSignInButton(containerId: string, paymentMethod: PaymentMethod, options?: AmazonPayV2ButtonInitializeOptions): Promise<HTMLElement> {\n const container = document.getElementById(containerId);\n\n if (!container) {\n throw new InvalidArgumentError('Unable to create sign-in button without valid container ID.');\n }\n\n const amazonButtonOptions = options ?? await this._getAmazonPayV2ButtonOptions(paymentMethod);\n\n this._amazonPayV2PaymentProcessor.createButton(`#${containerId}`, amazonButtonOptions);\n\n return container;\n }\n\n private async _getAmazonPayV2ButtonOptions(paymentMethod: PaymentMethod): Promise<AmazonPayV2ButtonParams> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const cart = state.cart.getCart();\n const { storeProfile: { shopPath }, checkoutSettings: { features } } = state.config.getStoreConfigOrThrow();\n\n const {\n config: {\n merchantId,\n testMode,\n },\n initializationData: {\n checkoutLanguage,\n ledgerCurrency,\n checkoutSessionMethod,\n extractAmazonCheckoutSessionId,\n },\n } = paymentMethod;\n\n if (!merchantId || !ledgerCurrency || !shopPath) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return {\n merchantId,\n createCheckoutSession: {\n // tslint:disable-next-line: no-string-literal\n url: features['INT-5826.amazon_relative_url']\n ? `/remote-checkout/${paymentMethod.id}/payment-session`\n : `${shopPath}/remote-checkout/${paymentMethod.id}/payment-session`,\n method: checkoutSessionMethod,\n extractAmazonCheckoutSessionId,\n },\n sandbox: !!testMode,\n ledgerCurrency,\n checkoutLanguage,\n productType: cart && getShippableItemsCount(cart) === 0 ?\n AmazonPayV2PayOptions.PayOnly :\n AmazonPayV2PayOptions.PayAndShip,\n placement: AmazonPayV2Placement.Cart,\n };\n }\n}\n","import { StandardError } from '../../common/error/errors';\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 { RequestSender } from '@bigcommerce/request-sender';\nimport { noop } from 'lodash';\n\nimport { AddressRequestBody } from '../../../address';\nimport { BillingAddressActionCreator } from '../../../billing';\nimport { Cart } from '../../../cart';\nimport { Checkout, CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { StoreConfig } from '../../../config';\nimport { OrderActionCreator } from '../../../order';\nimport { Payment, PaymentActionCreator, PaymentMethod, PaymentMethodActionCreator } from '../../../payment';\nimport { PaymentMethodCancelledError } from '../../../payment/errors';\nimport { assertApplePayWindow, ApplePaySessionFactory } from '../../../payment/strategies/apple-pay';\nimport { RemoteCheckoutActionCreator } from '../../../remote-checkout';\nimport { ConsignmentActionCreator, ShippingOption } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nconst validationEndpoint = (bigPayEndpoint: string) => `${bigPayEndpoint}/api/public/v1/payments/applepay/validate_merchant`;\n\nenum DefaultLabels {\n Subtotal = 'Subtotal',\n Shipping = 'Shipping',\n}\n\nfunction isShippingOptions(options: ShippingOption[] | undefined): options is ShippingOption[] {\n return options instanceof Array;\n}\n\nexport default class ApplePayButtonStrategy implements CheckoutButtonStrategy {\n private _paymentMethod?: PaymentMethod;\n private _applePayButton?: HTMLElement;\n private _onAuthorizeCallback = noop;\n private _subTotalLabel: string = DefaultLabels.Subtotal;\n private _shippingLabel: string = DefaultLabels.Shipping;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _requestSender: RequestSender,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _consignmentActionCreator: ConsignmentActionCreator,\n private _billingAddressActionCreator: BillingAddressActionCreator,\n private _paymentActionCreator: PaymentActionCreator,\n private _remoteCheckoutActionCreator: RemoteCheckoutActionCreator,\n private _orderActionCreator: OrderActionCreator,\n private _sessionFactory: ApplePaySessionFactory\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n\n const { methodId, containerId , applepay} = options;\n\n assertApplePayWindow(window);\n\n if (!methodId || !applepay) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const {\n buttonClassName,\n onPaymentAuthorize,\n } = applepay;\n\n this._onAuthorizeCallback = onPaymentAuthorize;\n\n await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n const state = await this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId));\n this._paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(methodId);\n\n this._applePayButton = this._createButton(containerId, buttonClassName);\n this._applePayButton.addEventListener('click', this._handleWalletButtonClick);\n\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n return Promise.resolve();\n }\n\n private _createButton(containerId: string, buttonClassName = 'apple-pay-checkout-button'): HTMLElement {\n const container = document.getElementById(containerId);\n if (!container) {\n throw new InvalidArgumentError('Unable to create wallet button without valid container ID.');\n }\n\n document.body.classList.add('apple-pay-supported');\n const button = document.createElement('div');\n button.classList.add(buttonClassName);\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', 'Apple Pay button');\n container.appendChild(button);\n\n return button;\n }\n\n @bind\n private _handleWalletButtonClick(event: Event) {\n event.preventDefault();\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const checkout = state.checkout.getCheckoutOrThrow();\n\n if (!this._paymentMethod || !this._paymentMethod.initializationData) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n const request = this._getBaseRequest(cart, checkout, config, this._paymentMethod);\n const applePaySession = this._sessionFactory.create(request);\n this._handleApplePayEvents(applePaySession, this._paymentMethod, config);\n\n applePaySession.begin();\n }\n\n private _getBaseRequest(\n cart: Cart,\n checkout: Checkout,\n config: StoreConfig,\n paymentMethod: PaymentMethod\n ): ApplePayJS.ApplePayPaymentRequest {\n const { storeProfile: { storeCountryCode, storeName } } = config;\n const { currency: { code, decimalPlaces} } = cart;\n\n const { initializationData : { merchantCapabilities, supportedNetworks } } = paymentMethod;\n\n const requiresShipping = cart.lineItems.physicalItems.length > 0;\n const total: ApplePayJS.ApplePayLineItem = requiresShipping ? {\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n type: 'pending',\n } : {\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n type: 'final',\n };\n\n const request: ApplePayJS.ApplePayPaymentRequest = {\n requiredBillingContactFields: ['postalAddress'],\n requiredShippingContactFields: ['email', 'phone'],\n countryCode: storeCountryCode,\n currencyCode: code,\n merchantCapabilities,\n supportedNetworks,\n lineItems: [],\n total,\n };\n\n if (requiresShipping) {\n request.requiredShippingContactFields?.push('postalAddress');\n } else {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [\n { label: this._subTotalLabel, amount: `${checkout.subtotal.toFixed(decimalPlaces)}`},\n ];\n\n checkout.taxes.forEach(tax =>\n lineItems.push({ label: tax.name, amount: `${tax.amount.toFixed(decimalPlaces)}` }));\n\n request.lineItems = lineItems;\n }\n\n return request;\n }\n\n private _handleApplePayEvents(\n applePaySession: ApplePaySession,\n paymentMethod: PaymentMethod,\n config: StoreConfig\n ) {\n applePaySession.onvalidatemerchant = async event => {\n try {\n const { body: merchantSession } = await this._onValidateMerchant(paymentMethod, event);\n applePaySession.completeMerchantValidation(merchantSession);\n } catch (error) {\n throw new Error('Merchant validation failed');\n }\n };\n\n applePaySession.onshippingcontactselected = async event =>\n this._handleShippingContactSelected(applePaySession, config, event);\n\n applePaySession.onshippingmethodselected = async event =>\n this._handleShippingMethodSelected(applePaySession, config, event);\n\n applePaySession.oncancel = async () => {\n try {\n await this._store.dispatch(this._remoteCheckoutActionCreator.signOut(paymentMethod.id));\n\n return this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout());\n } catch (error) {\n throw new PaymentMethodCancelledError();\n }\n };\n\n applePaySession.onpaymentauthorized = async event =>\n this._onPaymentAuthorized(event, applePaySession, paymentMethod);\n }\n\n private async _handleShippingContactSelected(\n applePaySession: ApplePaySession,\n config: StoreConfig,\n event: ApplePayJS.ApplePayShippingContactSelectedEvent\n ) {\n const shippingAddress = this._transformContactToAddress(event.shippingContact);\n\n try {\n await this._store.dispatch(\n this._consignmentActionCreator.updateAddress(shippingAddress)\n );\n } catch (error) {\n applePaySession.abort();\n\n throw new Error('Shipping address update failed');\n }\n\n const { storeProfile: { storeName } } = config;\n let state = this._store.getState();\n const { currency: { decimalPlaces } } = state.cart.getCartOrThrow();\n let checkout = state.checkout.getCheckoutOrThrow();\n const selectionShippingOptionId = checkout.consignments[0].selectedShippingOption?.id;\n const availableOptions = checkout.consignments[0].availableShippingOptions;\n const selectedOption = availableOptions?.find(({id}) => id === selectionShippingOptionId);\n const unselectedOptions = availableOptions?.filter(option => option.id !== selectionShippingOptionId);\n const shippingOptions: ApplePayJS.ApplePayShippingMethod[] = selectedOption ? [{\n label: selectedOption.description,\n amount: `${selectedOption.cost.toFixed(decimalPlaces)}`,\n detail: selectedOption.additionalDescription,\n identifier: selectedOption.id,\n }] : [];\n unselectedOptions?.forEach(option => shippingOptions.push(\n {\n label: option.description,\n amount: `${option.cost.toFixed(decimalPlaces)}`,\n detail: option.additionalDescription,\n identifier: option.id,\n }\n ));\n\n if (!isShippingOptions(availableOptions)) {\n throw new Error('Shipping options not available.');\n }\n\n if (availableOptions.length === 0) {\n applePaySession.completeShippingContactSelection(\n ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,\n [],\n {\n type: 'pending',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n []\n );\n\n return;\n }\n\n const recommendedOption = availableOptions.find(\n option => option.isRecommended\n );\n\n const optionId = recommendedOption ? recommendedOption.id : availableOptions[0].id;\n const selectedOptionId = selectedOption ? selectedOption.id : optionId;\n try {\n await this._updateShippingOption(selectedOptionId);\n } catch (error) {\n throw new Error('Shipping options update failed');\n }\n\n state = this._store.getState();\n checkout = state.checkout.getCheckoutOrThrow();\n\n applePaySession.completeShippingContactSelection({\n newShippingMethods: shippingOptions,\n newTotal: {\n type: 'final',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n newLineItems: this._getUpdatedLineItems(checkout, decimalPlaces),\n });\n }\n\n private async _handleShippingMethodSelected(\n applePaySession: ApplePaySession,\n config: StoreConfig,\n event: ApplePayJS.ApplePayShippingMethodSelectedEvent\n ) {\n const { storeProfile: { storeName } } = config;\n const { shippingMethod: { identifier: optionId } } = event;\n try {\n await this._updateShippingOption(optionId);\n } catch (error) {\n applePaySession.abort();\n\n throw new Error('Shipping option selection update failed.');\n }\n\n const state = this._store.getState();\n const { currency: { decimalPlaces } } = state.cart.getCartOrThrow();\n const checkout = state.checkout.getCheckoutOrThrow();\n\n applePaySession.completeShippingMethodSelection({\n newTotal: {\n type: 'final',\n label: storeName,\n amount: `${checkout.grandTotal.toFixed(decimalPlaces)}`,\n },\n newLineItems: this._getUpdatedLineItems(checkout, decimalPlaces),\n });\n }\n\n private _getUpdatedLineItems(checkout: Checkout, decimalPlaces: number): ApplePayJS.ApplePayLineItem[] {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [\n { label: this._subTotalLabel, amount: `${checkout.subtotal.toFixed(decimalPlaces)}`},\n ];\n\n checkout.taxes.forEach(tax =>\n lineItems.push({ label: tax.name, amount: `${tax.amount.toFixed(decimalPlaces)}` }));\n lineItems.push({ label: this._shippingLabel, amount: `${checkout.shippingCostTotal.toFixed(decimalPlaces)}`});\n\n return lineItems;\n }\n\n private async _updateShippingOption(optionId: string) {\n return await this._store.dispatch(\n this._consignmentActionCreator.selectShippingOption(optionId)\n );\n }\n\n private async _onValidateMerchant(paymentData: PaymentMethod, event: ApplePayJS.ApplePayValidateMerchantEvent) {\n const body = [\n `validationUrl=${event.validationURL}`,\n `merchantIdentifier=${paymentData.initializationData.merchantId}`,\n `displayName=${paymentData.initializationData.storeName}`,\n `domainName=${window.location.hostname}`,\n ].join('&');\n\n return this._requestSender.post(validationEndpoint(paymentData.initializationData.paymentsUrl), {\n credentials: false,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-XSRF-TOKEN': null,\n },\n body,\n });\n }\n\n private async _onPaymentAuthorized(\n event: ApplePayJS.ApplePayPaymentAuthorizedEvent,\n applePaySession: ApplePaySession,\n paymentMethod: PaymentMethod\n ) {\n const { token, billingContact, shippingContact } = event.payment;\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const requiresShipping = cart.lineItems.physicalItems.length > 0;\n const payment: Payment = {\n methodId: paymentMethod.id,\n paymentData: {\n formattedPayload: {\n apple_pay_token: {\n payment_data: token.paymentData,\n payment_method: token.paymentMethod,\n transaction_id: token.transactionIdentifier,\n },\n },\n },\n };\n\n const transformedBillingAddress = this._transformContactToAddress(billingContact);\n const transformedShippingAddress = this._transformContactToAddress(shippingContact);\n const emailAddress = shippingContact?.emailAddress;\n\n try {\n await this._store.dispatch(\n this._billingAddressActionCreator.updateAddress({ ...transformedBillingAddress, email: emailAddress })\n );\n\n if (requiresShipping) {\n await this._store.dispatch(\n this._consignmentActionCreator.updateAddress(transformedShippingAddress)\n );\n }\n\n await this._store.dispatch(this._orderActionCreator.submitOrder(\n {\n useStoreCredit: false,\n })\n );\n await this._store.dispatch(this._paymentActionCreator.submitPayment(payment));\n applePaySession.completePayment(ApplePaySession.STATUS_SUCCESS);\n\n return this._onAuthorizeCallback();\n } catch (error) {\n applePaySession.completePayment(ApplePaySession.STATUS_FAILURE);\n\n throw new Error('Payment cannot complete');\n }\n }\n\n private _transformContactToAddress(contact?: ApplePayJS.ApplePayPaymentContact): AddressRequestBody {\n return {\n firstName: contact?.givenName || '',\n lastName: contact?.familyName || '',\n city: contact?.locality || '',\n company: '',\n address1: contact?.addressLines && contact?.addressLines[0] || '',\n address2: contact?.addressLines && contact?.addressLines[1] || '',\n postalCode: contact?.postalCode || '',\n countryCode: contact?.countryCode || '',\n phone: contact?.phoneNumber || '',\n stateOrProvince: contact?.administrativeArea || '',\n stateOrProvinceCode: contact?.administrativeArea || '',\n customFields: [],\n };\n }\n}\n","import { Address } from '../../../address';\n\nimport { BraintreeShippingAddressOverride } from './braintree';\n\nexport default function mapToBraintreeShippingAddressOverride(address: Address): BraintreeShippingAddressOverride {\n return {\n recipientName: `${address.firstName} ${address.lastName}`,\n line1: address.address1,\n line2: address.address2,\n city: address.city,\n state: address.stateOrProvinceCode,\n postalCode: address.postalCode,\n countryCode: address.countryCode,\n phone: address.phone,\n };\n}\n","import { isNil, omitBy } from 'lodash';\n\nimport { PaypalButtonStyleOptions } from '../../../payment/strategies/paypal';\n\nexport default function getValidButtonStyle(style: PaypalButtonStyleOptions): PaypalButtonStyleOptions {\n const { color, fundingicons, height, layout, shape, size, tagline } = style;\n\n const validStyles = {\n color,\n fundingicons,\n height: getValidHeight(height),\n layout,\n shape: shape || 'rect',\n size,\n tagline,\n };\n\n return omitBy(validStyles, isNil);\n}\n\nfunction getValidHeight(height?: number): number {\n const minHeight = 25;\n const maxHeight = 55;\n\n if (typeof height !== 'number' || height > maxHeight) {\n return maxHeight;\n }\n\n if (height < minHeight) {\n return minHeight;\n }\n\n return height;\n}\n","import { LegacyAddress } from '../../../address';\nimport { BraintreeDetails } from '../../../payment/strategies/braintree';\n\nexport default function mapToLegacyBillingAddress(details: BraintreeDetails): Partial<LegacyAddress> {\n const {\n billingAddress,\n email,\n firstName,\n lastName,\n phone,\n shippingAddress,\n } = details;\n\n const address = billingAddress || shippingAddress;\n\n return {\n email,\n first_name: firstName,\n last_name: lastName,\n phone_number: phone,\n address_line_1: address?.line1,\n address_line_2: address?.line2,\n city: address?.city,\n state: address?.state,\n country_code: address?.countryCode,\n postal_code: address?.postalCode,\n };\n}\n\n","import { LegacyAddress } from '../../../address';\nimport { BraintreeDetails } from '../../../payment/strategies/braintree';\n\nexport default function mapToLegacyShippingAddress(details: BraintreeDetails): Partial<LegacyAddress> {\n const { email, phone, shippingAddress } = details;\n\n const recipientName = shippingAddress?.recipientName || '';\n const [firstName, lastName] = recipientName.split(' ');\n\n return {\n email,\n first_name: firstName || '',\n last_name: lastName || '',\n phone_number: phone,\n address_line_1: shippingAddress?.line1,\n address_line_2: shippingAddress?.line2,\n city: shippingAddress?.city,\n state: shippingAddress?.state,\n country_code: shippingAddress?.countryCode,\n postal_code: shippingAddress?.postalCode,\n };\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { Address } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, StandardError } from '../../../common/error/errors';\nimport { mapToBraintreeShippingAddressOverride, BraintreeError, BraintreePaypalCheckout, BraintreeSDKCreator, BraintreeTokenizePayload } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { BraintreePaypalButtonInitializeOptions } from './braintree-paypal-button-options';\nimport getValidButtonStyle from './get-valid-button-style';\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nexport default class BraintreePaypalButtonStrategy implements CheckoutButtonStrategy {\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster,\n private _window: PaypalHostWindow\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreepaypal, containerId, methodId } = options;\n const { messagingContainerId, onError } = braintreepaypal || {};\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n // TODO: remove updatedMethodId implementation when PAYPAL-1518 hits Tier3\n const updatedMethodId = methodId === 'braintreepaypalv2' ? 'braintreepaypal' : methodId;\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n if (!braintreepaypal) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypal\" argument is not provided.`);\n }\n\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(updatedMethodId);\n const currency = state.cart.getCartOrThrow()?.currency.code;\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const paypalCheckoutOptions = { currency };\n const paypalCheckoutSuccessCallback = (braintreePaypalCheckout: BraintreePaypalCheckout) => {\n this._renderPayPalComponents(\n braintreePaypalCheckout,\n braintreepaypal,\n containerId,\n updatedMethodId,\n Boolean(paymentMethod.config.testMode)\n );\n };\n const paypalCheckoutErrorCallback = (error: BraintreeError) =>\n this._handleError(error, containerId, messagingContainerId, onError);\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getPaypalCheckout(\n paypalCheckoutOptions,\n paypalCheckoutSuccessCallback,\n paypalCheckoutErrorCallback\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderPayPalComponents(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypal: BraintreePaypalButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { messagingContainerId } = braintreepaypal;\n\n this._renderPayPalMessages(messagingContainerId);\n this._renderPayPalButton(braintreePaypalCheckout, braintreepaypal, containerId, methodId, testMode);\n }\n\n private _renderPayPalButton(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypal: BraintreePaypalButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { style, shippingAddress, shouldProcessPayment, onAuthorizeError, onPaymentError } = braintreepaypal;\n\n const { paypal } = this._window;\n const fundingSource = paypal?.FUNDING.PAYPAL;\n\n if (paypal && fundingSource) {\n const validButtonStyle = style ? getValidButtonStyle(style) : {};\n\n const paypalButtonRender = paypal.Buttons({\n env: testMode ? 'sandbox' : 'production',\n commit: false,\n fundingSource,\n style: validButtonStyle,\n createOrder: () => this._setupPayment(braintreePaypalCheckout, shippingAddress, onPaymentError),\n onApprove: (authorizeData: PaypalAuthorizeData) =>\n this._tokenizePayment(authorizeData, braintreePaypalCheckout, methodId, shouldProcessPayment, onAuthorizeError),\n });\n\n if (paypalButtonRender.isEligible()) {\n paypalButtonRender.render(`#${containerId}`);\n }\n } else {\n this._removeElement(containerId);\n }\n }\n\n private _renderPayPalMessages(messagingContainerId?: string): void {\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const storeConfig = state.config.getStoreConfigOrThrow();\n\n const isMessageContainerAvailable = messagingContainerId && !!document.getElementById(messagingContainerId);\n const isMessagesRenderingFeatureOn = storeConfig.checkoutSettings.features['PAYPAL-1149.braintree-new-card-below-totals-banner-placement'];\n\n const { paypal } = this._window;\n\n if (paypal && isMessagesRenderingFeatureOn && messagingContainerId && isMessageContainerAvailable) {\n const paypalMessagesRender = paypal.Messages({ amount: cart.cartAmount, placement: 'cart' });\n paypalMessagesRender.render(`#${messagingContainerId}`);\n } else {\n this._removeElement(messagingContainerId);\n }\n }\n\n private async _setupPayment(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n shippingAddress?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n try {\n const checkout = state.checkout.getCheckoutOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const customer = state.customer.getCustomer();\n\n const address = shippingAddress || customer?.addresses?.[0];\n const shippingAddressOverride = address ? mapToBraintreeShippingAddressOverride(address) : undefined;\n\n return await braintreePaypalCheckout.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride,\n amount: checkout.outstandingBalance,\n currency: config.currency.code,\n offerCredit: false,\n });\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private async _tokenizePayment(\n authorizeData: PaypalAuthorizeData,\n braintreePaypalCheckout: BraintreePaypalCheckout,\n methodId: string,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n try {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector({ paypal: true });\n const tokenizePayload = await braintreePaypalCheckout.tokenizePayment(authorizeData);\n const { details, nonce } = tokenizePayload;\n\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce,\n device_data: deviceData,\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n\n return tokenizePayload;\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private _handleError(\n error: BraintreeError,\n buttonContainerId: string,\n messagingContainerId?: string,\n onErrorCallback?: (error: BraintreeError) => void\n ): void {\n this._removeElement(buttonContainerId);\n this._removeElement(messagingContainerId);\n\n if (onErrorCallback) {\n onErrorCallback(error);\n }\n }\n\n private _removeElement(elementId?: string): void {\n const element = elementId && document.getElementById(elementId);\n\n if (element) {\n element.remove();\n }\n }\n}\n","export interface PaypalSDK {\n Button: PaypalButton;\n checkout: PaypalExpressCheckout;\n FUNDING: PaypalFundingTypeList;\n Messages(options: MessagingOptions): MessagingRender;\n Buttons(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\nexport interface PaypalFundingTypeList {\n CARD?: string;\n CREDIT?: string;\n PAYPAL?: string;\n PAYLATER?: string;\n}\n\nexport interface PaypalButton {\n render(options: PaypalButtonOptions, container: string): void;\n}\n\nexport interface PaypalButtonRender {\n render(container: string): void;\n isEligible(): boolean;\n}\n\nexport interface MessagingRender {\n render(container: string): void;\n}\n\nexport interface MessagingOptions {\n amount: number;\n placement: string;\n}\n\nexport interface PaypalButtonOptions {\n env?: string;\n commit?: boolean;\n style?: PaypalButtonStyleOptions;\n funding?: PaypalFundingType;\n fundingSource?: string;\n client?: PaypalClientToken;\n payment?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n onAuthorize?(data: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n createOrder?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n onApprove?(data?: PaypalAuthorizeData, actions?: PaypalActions): Promise<any>;\n\n}\n\nexport interface PaypalClientToken {\n production?: string;\n sandbox?: string;\n}\n\nexport interface PaypalFundingType {\n allowed?: string[];\n disallowed?: string[];\n}\n\nexport enum PaypalButtonStyleLayoutOption {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n}\n\nexport enum PaypalButtonStyleSizeOption {\n SMALL = 'small',\n MEDIUM = 'medium',\n LARGE = 'large',\n RESPONSIVE = 'responsive',\n}\n\nexport enum PaypalButtonStyleColorOption {\n GOLD = 'gold',\n BLUE = 'blue',\n SIlVER = 'silver',\n BLACK = 'black',\n}\n\nexport enum PaypalButtonStyleLabelOption {\n CHECKOUT = 'checkout',\n PAY = 'pay',\n BUYNOW = 'buynow',\n PAYPAL = 'paypal',\n CREDIT = 'credit',\n}\n\nexport enum PaypalButtonStyleShapeOption {\n PILL = 'pill',\n RECT = 'rect',\n}\n\nexport interface PaypalButtonStyleOptions {\n layout?: PaypalButtonStyleLayoutOption;\n size?: PaypalButtonStyleSizeOption;\n color?: PaypalButtonStyleColorOption;\n label?: PaypalButtonStyleLabelOption;\n shape?: PaypalButtonStyleShapeOption;\n tagline?: boolean;\n fundingicons?: boolean;\n height?: number;\n}\n\nexport interface PaypalActions {\n payment: PaypalPaymentActions;\n request: PaypalRequestActions;\n}\n\nexport interface PaypalPaymentActions {\n get(id: string): Promise<PaypalPaymentPayload>;\n}\n\nexport interface PaypalRequestActions {\n post(url: string, payload?: object, options?: object): Promise<{ id: string }>;\n}\n\nexport interface PaypalTransaction {\n amount?: PaypalAmount;\n payee?: PaypalPayee;\n description?: string;\n note_to_payee?: string;\n item_list?: PaypalItemList;\n}\n\nexport interface PaypalItemList {\n items?: PaypalItem[];\n shipping_address?: PaypalAddress;\n}\n\nexport interface PaypalItem {\n sku?: string;\n name?: string;\n description?: string;\n quantity: string;\n price: string;\n currency: string;\n tax?: string;\n}\n\nexport interface PaypalAmount {\n currency: string;\n total: string;\n}\n\nexport interface PaypalPayer {\n payer_info: object;\n}\n\nexport interface PaypalPayee {\n email?: string;\n merchant_id?: string;\n}\n\nexport interface PaypalAddress {\n line1: string;\n line2?: string;\n city?: string;\n country_code: string;\n postal_code?: string;\n state?: string;\n phone?: string;\n type?: string;\n}\n\nexport interface PaypalPaymentPayload {\n payment: PaypalPaymentPayload;\n payer: PaypalPayer;\n transactions?: PaypalTransaction[];\n}\n\nexport interface PaypalAuthorizeData {\n payerId: string;\n paymentId?: string;\n billingToken?: string;\n // the PayPal side of things uses uppercase ID instead of camel case Id\n payerID?: string;\n paymentID?: string;\n}\n\nexport interface PaypalExpressCheckout {\n initXO(): void;\n startFlow(url: string): void;\n closeFlow(): void;\n setup(merchantId: string, options: PaypalExpressCheckoutOptions): void;\n}\n\nexport interface PaypalExpressCheckoutOptions {\n button: string;\n environment: string;\n}\n\nexport interface PaypalHostWindow extends Window {\n paypal?: PaypalSDK;\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { Address } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, StandardError } from '../../../common/error/errors';\nimport { mapToBraintreeShippingAddressOverride, BraintreeError, BraintreePaypalCheckout, BraintreeSDKCreator, BraintreeTokenizePayload } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalButtonStyleLabelOption, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { BraintreePaypalCreditButtonInitializeOptions } from './braintree-paypal-credit-button-options';\nimport getValidButtonStyle from './get-valid-button-style';\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nexport default class BraintreePaypalCreditButtonStrategy implements CheckoutButtonStrategy {\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster,\n private _window: PaypalHostWindow\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreepaypalcredit, containerId, methodId } = options;\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n // TODO: remove updatedMethodId implementation when PAYPAL-1518 hits Tier3\n const updatedMethodId = methodId === 'braintreepaypalcreditv2' ? 'braintreepaypalcredit' : methodId;\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n if (!braintreepaypalcredit) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.braintreepaypalcredit\" argument is not provided.`);\n }\n\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(updatedMethodId);\n const currency = state.cart.getCartOrThrow()?.currency.code;\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const paypalCheckoutOptions = { currency };\n const paypalCheckoutCallback = (braintreePaypalCheckout: BraintreePaypalCheckout) =>\n this._renderPayPalButton(\n braintreePaypalCheckout,\n braintreepaypalcredit,\n containerId,\n updatedMethodId,\n Boolean(paymentMethod.config.testMode)\n );\n const paypalCheckoutErrorCallback = (error: BraintreeError) =>\n this._handleError(error, containerId, braintreepaypalcredit.onError);\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getPaypalCheckout(\n paypalCheckoutOptions,\n paypalCheckoutCallback,\n paypalCheckoutErrorCallback\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderPayPalButton(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n braintreepaypalcredit: BraintreePaypalCreditButtonInitializeOptions,\n containerId: string,\n methodId: string,\n testMode: boolean\n ): void {\n const { style, shippingAddress, shouldProcessPayment, onAuthorizeError, onPaymentError } = braintreepaypalcredit;\n const { paypal } = this._window;\n\n let hasRenderedSmartButton = false;\n\n if (paypal) {\n const fundingSources = [paypal.FUNDING.PAYLATER, paypal.FUNDING.CREDIT];\n const commonButtonStyle = style ? getValidButtonStyle(style) : {};\n\n fundingSources.forEach(fundingSource => {\n const buttonStyle = fundingSource === paypal.FUNDING.CREDIT\n ? { label: PaypalButtonStyleLabelOption.CREDIT, ...commonButtonStyle }\n : commonButtonStyle;\n\n if (!hasRenderedSmartButton) {\n const paypalButtonRender = paypal.Buttons({\n env: testMode ? 'sandbox' : 'production',\n commit: false,\n fundingSource,\n style: buttonStyle,\n createOrder: () => this._setupPayment(braintreePaypalCheckout, shippingAddress, onPaymentError),\n onApprove: (authorizeData: PaypalAuthorizeData) =>\n this._tokenizePayment(authorizeData, braintreePaypalCheckout, methodId, shouldProcessPayment, onAuthorizeError),\n });\n\n if (paypalButtonRender.isEligible()) {\n paypalButtonRender.render(`#${containerId}`);\n hasRenderedSmartButton = true;\n }\n }\n });\n }\n\n if (!paypal || !hasRenderedSmartButton) {\n this._removeElement(containerId);\n }\n }\n\n private async _setupPayment(\n braintreePaypalCheckout: BraintreePaypalCheckout,\n shippingAddress?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n const state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n\n try {\n const checkout = state.checkout.getCheckoutOrThrow();\n const config = state.config.getStoreConfigOrThrow();\n const customer = state.customer.getCustomer();\n\n const address = shippingAddress || customer?.addresses?.[0];\n const shippingAddressOverride = address ? mapToBraintreeShippingAddressOverride(address) : undefined;\n\n return await braintreePaypalCheckout.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride,\n amount: checkout.outstandingBalance,\n currency: config.currency.code,\n offerCredit: true,\n });\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private async _tokenizePayment(\n authorizeData: PaypalAuthorizeData,\n braintreePaypalCheckout: BraintreePaypalCheckout,\n methodId: string,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n try {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector({ paypal: true });\n const tokenizePayload = await braintreePaypalCheckout.tokenizePayment(authorizeData);\n const { details, nonce } = tokenizePayload;\n\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce,\n device_data: deviceData,\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n\n return tokenizePayload;\n } catch (error) {\n if (onError) {\n onError(error);\n }\n\n throw error;\n }\n }\n\n private _handleError(\n error: BraintreeError,\n containerId: string,\n onErrorCallback?: (error: BraintreeError) => void\n ): void {\n this._removeElement(containerId);\n\n if (onErrorCallback) {\n onErrorCallback(error);\n }\n }\n\n private _removeElement(elementId?: string): void {\n const element = elementId && document.getElementById(elementId);\n\n if (element) {\n element.remove();\n }\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { noop } from 'lodash';\n\nimport { CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, UnsupportedBrowserError } from '../../../common/error/errors';\nimport { PaymentMethodActionCreator } from '../../../payment';\nimport { BraintreeError, BraintreeSDKCreator, BraintreeTokenizePayload, BraintreeVenmoCheckout } from '../../../payment/strategies/braintree';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\nimport { CheckoutButtonMethodType } from '../index';\n\nimport mapToLegacyBillingAddress from './map-to-legacy-billing-address';\nimport mapToLegacyShippingAddress from './map-to-legacy-shipping-address';\n\nconst venmoButtonStyle = {\n backgroundColor: '#3D95CE',\n backgroundPosition: '50% 50%',\n backgroundSize: '80px auto',\n backgroundImage: 'url(\"/app/assets/img/payment-providers/venmo-logo-white.svg\")',\n backgroundRepeat: 'no-repeat',\n borderRadius: '4px',\n cursor: 'pointer',\n transition: '0.2s ease',\n minHeight: '40px',\n minWidth: '150px',\n height: '100%',\n width: '100%',\n};\n\nconst venmoButtonStyleHover = {\n backgroundColor: '#0a7fc2',\n};\n\nexport default class BraintreeVenmoButtonStrategy implements CheckoutButtonStrategy {\n private _onError = noop;\n\n constructor(\n private _store: CheckoutStore,\n private _paymentMethodActionCreator: PaymentMethodActionCreator,\n private _braintreeSDKCreator: BraintreeSDKCreator,\n private _formPoster: FormPoster\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { braintreevenmo, containerId, methodId } = options;\n\n if (!methodId) {\n throw new InvalidArgumentError('Unable to initialize payment because \"options.methodId\" argument is not provided.');\n }\n\n const state = await this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(methodId));\n const paymentMethod = state.paymentMethods.getPaymentMethodOrThrow(methodId);\n\n if (!paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!containerId) {\n throw new InvalidArgumentError(`Unable to initialize payment because \"options.containerId\" argument is not provided.`);\n }\n\n this._onError = braintreevenmo?.onError || this._handleError;\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n await this._braintreeSDKCreator.getVenmoCheckout(\n braintreeVenmoCheckout => this._handleInitializationVenmoSuccess(braintreeVenmoCheckout, containerId),\n error => this._handleInitializationVenmoError(error, containerId)\n );\n }\n\n deinitialize(): Promise<void> {\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _handleError(error: BraintreeError) {\n throw new Error(error.message);\n }\n\n private _handleInitializationVenmoSuccess(braintreeVenmoCheckout: BraintreeVenmoCheckout, parentContainerId: string): void {\n return this._renderVenmoButton(braintreeVenmoCheckout, parentContainerId);\n }\n\n private _handleInitializationVenmoError(error: BraintreeError | UnsupportedBrowserError, containerId: string): void {\n this._removeVenmoContainer(containerId);\n\n return this._onError(error);\n }\n\n private _removeVenmoContainer(containerId: string): void {\n const buttonContainer = document.getElementById(containerId);\n\n if (buttonContainer) {\n buttonContainer.remove();\n }\n }\n\n private _renderVenmoButton(braintreeVenmoCheckout: BraintreeVenmoCheckout, containerId: string): void {\n const venmoButton = document.getElementById(containerId);\n\n if (!venmoButton) {\n throw new InvalidArgumentError('Unable to create wallet button without valid container ID.');\n }\n\n venmoButton.setAttribute('aria-label', 'Venmo');\n Object.assign(venmoButton.style, venmoButtonStyle);\n\n venmoButton.addEventListener('click', () => {\n venmoButton.setAttribute('disabled', 'true');\n\n if (braintreeVenmoCheckout.tokenize) {\n braintreeVenmoCheckout.tokenize(async (error: BraintreeError, payload: BraintreeTokenizePayload) => {\n venmoButton.removeAttribute('disabled');\n\n if (error) {\n return this._onError(error);\n }\n\n await this._handlePostForm(payload);\n });\n }\n });\n\n venmoButton.addEventListener('mouseenter', () => {\n venmoButton.style.backgroundColor = venmoButtonStyleHover.backgroundColor;\n });\n\n venmoButton.addEventListener('mouseleave', () => {\n venmoButton.style.backgroundColor = venmoButtonStyle.backgroundColor;\n });\n }\n\n private async _handlePostForm(payload: BraintreeTokenizePayload): Promise<void> {\n const { deviceData } = await this._braintreeSDKCreator.getDataCollector();\n const { nonce, details } = payload;\n\n this._formPoster.postForm('/checkout.php', {\n nonce,\n provider: CheckoutButtonMethodType.BRAINTREE_VENMO,\n payment_type: 'paypal',\n device_data: deviceData,\n action: 'set_external_checkout',\n billing_address: JSON.stringify(mapToLegacyBillingAddress(details)),\n shipping_address: JSON.stringify(mapToLegacyShippingAddress(details)),\n });\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\n\nimport { CheckoutButtonMethodType } from '../';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { GooglePayPaymentProcessor } from '../../../payment/strategies/googlepay';\nimport { getShippableItemsCount } from '../../../shipping';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nimport { GooglePayButtonInitializeOptions } from './googlepay-button-options';\nexport default class GooglePayButtonStrategy implements CheckoutButtonStrategy {\n private _methodId?: string;\n private _walletButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _formPoster: FormPoster,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _googlePayPaymentProcessor: GooglePayPaymentProcessor\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId } = options;\n\n const googlePayOptions = this._getGooglePayOptions(options);\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" argument is not provided.');\n }\n\n this._methodId = methodId;\n\n await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n await this._googlePayPaymentProcessor.initialize(this._getMethodId());\n\n this._walletButton = this._createSignInButton(containerId, googlePayOptions);\n }\n\n deinitialize(): Promise<void> {\n if (this._walletButton && this._walletButton.parentNode) {\n this._walletButton.parentNode.removeChild(this._walletButton);\n this._walletButton = undefined;\n }\n\n return this._googlePayPaymentProcessor.deinitialize();\n }\n\n private _createSignInButton(containerId: string, buttonOptions: GooglePayButtonInitializeOptions): HTMLElement {\n const container = document.getElementById(containerId);\n const { buttonType, buttonColor } = buttonOptions;\n\n if (!container) {\n throw new InvalidArgumentError('Unable to create sign-in button without valid container ID.');\n }\n\n const googlePayButton = this._googlePayPaymentProcessor.createButton(this._handleWalletButtonClick, buttonType, buttonColor);\n\n container.appendChild(googlePayButton);\n\n return googlePayButton;\n }\n\n private _getMethodId(): string {\n if (!this._methodId) {\n throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);\n }\n\n return this._methodId;\n }\n\n private _getGooglePayOptions(options: CheckoutButtonInitializeOptions): GooglePayButtonInitializeOptions {\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ADYENV2 && options.googlepayadyenv2) {\n return options.googlepayadyenv2;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ADYENV3 && options.googlepayadyenv3) {\n return options.googlepayadyenv3;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_AUTHORIZENET && options.googlepayauthorizenet) {\n return options.googlepayauthorizenet;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_BRAINTREE && options.googlepaybraintree) {\n return options.googlepaybraintree;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_CHECKOUTCOM && options.googlepaycheckoutcom) {\n return options.googlepaycheckoutcom;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_CYBERSOURCEV2 && options.googlepaycybersourcev2) {\n return options.googlepaycybersourcev2;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_ORBITAL && options.googlepayorbital) {\n return options.googlepayorbital;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_STRIPE && options.googlepaystripe) {\n return options.googlepaystripe;\n }\n\n if (options.methodId === CheckoutButtonMethodType.GOOGLEPAY_STRIPEUPE && options.googlepaystripeupe) {\n return options.googlepaystripeupe;\n }\n\n throw new InvalidArgumentError();\n }\n\n @bind\n private async _handleWalletButtonClick(event: Event): Promise<void> {\n event.preventDefault();\n const cart = this._store.getState().cart.getCartOrThrow();\n const hasPhysicalItems = getShippableItemsCount(cart) > 0;\n\n try {\n const paymentData = await this._googlePayPaymentProcessor.displayWallet();\n await this._googlePayPaymentProcessor.handleSuccess(paymentData);\n if (hasPhysicalItems && paymentData.shippingAddress) {\n await this._googlePayPaymentProcessor.updateShippingAddress(paymentData.shippingAddress);\n }\n await this._onPaymentSelectComplete();\n } catch (error) {\n if (error && error.message !== 'CANCELED') {\n throw error;\n }\n }\n }\n\n private _onPaymentSelectComplete(): void {\n this._formPoster.postForm('/checkout.php', {\n headers: {\n Accept: 'text/html',\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...SDK_VERSION_HEADERS,\n },\n });\n }\n}\n","export const supportedLocales: {[language: string]: string[]} = {es: ['es_es', 'es_mx', 'es_pe', 'es_co', 'es_ar', 'es_cl'],\n en: ['en_us', 'en_gb', 'en_ca', 'en_es', 'en_fr', 'en_ie', 'en_sg', 'en_au', 'en_nz', 'en_my', 'en_hk', 'en_th', 'en_ae', 'en_sa', 'en_qa', 'en_kw', 'en_za'],\n pt: ['pt_br'],\n zu: ['zu_za'],\n ar: ['ar_sa', 'ar_ae', 'ar_qa', 'ar_kw'],\n zh: ['zh_sg', 'zh_hk'],\n ms: ['ms_my'],\n uk: ['uk_ua'],\n sv: ['sv_se'],\n hr: ['hr_hr'],\n pl: ['pl_pl'],\n nl: ['nl_be'],\n it: ['it_it'],\n de: ['de_de'],\n fr: ['fr_fr', 'fr_ca']};\n","import { supportedLocales } from './masterpass-supported-locales';\n\nexport default function formatLocale(localeLanguage: string): string {\n const [language, country] = localeLanguage.replace('-', '_').toLowerCase().split('_');\n const formattedLocale = `${language}_${country}`;\n const countryLocales = supportedLocales[language];\n\n if (!countryLocales) {\n return 'en_us';\n }\n\n return countryLocales.indexOf(formattedLocale) > -1 ? formattedLocale : countryLocales[0];\n}\n","import { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { bindDecorator as bind } from '../../../common/utility';\nimport { formatLocale, getCallbackUrl, Masterpass, MasterpassCheckoutOptions, MasterpassScriptLoader } from '../../../payment/strategies/masterpass';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class MasterpassButtonStrategy implements CheckoutButtonStrategy {\n private _masterpassClient?: Masterpass;\n private _methodId?: string;\n private _signInButton?: HTMLElement;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _masterpassScriptLoader: MasterpassScriptLoader,\n private _locale: string\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const { containerId, methodId } = options;\n\n if (!containerId || !methodId) {\n throw new InvalidArgumentError('Unable to proceed because \"containerId\" argument is not provided.');\n }\n\n this._methodId = methodId;\n\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const paymentMethod = state.paymentMethods.getPaymentMethod(methodId);\n\n if (!paymentMethod || !paymentMethod.initializationData.checkoutId) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const masterpassScriptLoaderParams = {\n useMasterpassSrc: paymentMethod.initializationData.isMasterpassSrcEnabled,\n language: formatLocale(this._locale),\n testMode: paymentMethod.config.testMode,\n checkoutId: paymentMethod.initializationData.checkoutId,\n };\n\n return this._masterpassScriptLoader.load(masterpassScriptLoaderParams);\n })\n .then(masterpass => {\n this._masterpassClient = masterpass;\n this._signInButton = this._createSignInButton(containerId);\n });\n }\n\n deinitialize(): Promise<void> {\n if (this._signInButton && this._signInButton.parentNode) {\n this._signInButton.removeEventListener('click', this._handleWalletButtonClick);\n this._signInButton.parentNode.removeChild(this._signInButton);\n this._signInButton = undefined;\n }\n\n return Promise.resolve();\n }\n\n private _createSignInButton(containerId: string): HTMLElement {\n const buttonContainer = document.getElementById(containerId);\n const state = this._store.getState();\n const paymentMethod = this._methodId ? state.paymentMethods.getPaymentMethod(this._methodId) : null;\n const storeConfig = state.config.getStoreConfig();\n\n if (!buttonContainer) {\n throw new Error('Need a container to place the button');\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n if (!storeConfig) {\n throw new InvalidArgumentError('Unable to retrieve store configuration');\n }\n\n const button = document.createElement('input');\n\n button.type = 'image';\n\n if (paymentMethod.initializationData.isMasterpassSrcEnabled) {\n const subdomain = paymentMethod.config.testMode ? 'sandbox.' : '';\n const { checkoutId } = paymentMethod.initializationData;\n\n const params = [\n `locale=${formatLocale(this._locale)}`,\n `paymentmethod=master,visa,amex,discover`,\n `checkoutid=${checkoutId}`,\n ];\n\n button.src = [\n `https://${subdomain}src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg`,\n params.join('&'),\n ].join('?');\n } else {\n button.src = 'https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg';\n }\n\n buttonContainer.appendChild(button);\n\n button.addEventListener('click', this._handleWalletButtonClick);\n\n return button;\n }\n\n private _createMasterpassPayload(): MasterpassCheckoutOptions {\n const state = this._store.getState();\n const checkout = state.checkout.getCheckout();\n const paymentMethod = this._methodId ? state.paymentMethods.getPaymentMethod(this._methodId) : null;\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return {\n checkoutId: paymentMethod.initializationData.checkoutId,\n allowedCardTypes: paymentMethod.initializationData.allowedCardTypes,\n amount: checkout.cart.cartAmount.toString(),\n currency: checkout.cart.currency.code,\n cartId: checkout.cart.id,\n callbackUrl: getCallbackUrl('cart'),\n };\n }\n\n @bind\n private _handleWalletButtonClick(): void {\n if (!this._masterpassClient) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n this._masterpassClient.checkout(this._createMasterpassPayload());\n }\n}\n","export default function getCallbackUrl(origin: string): string {\n return `${window.location.origin}/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=${origin}`;\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { pick } from 'lodash';\n\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType, StandardError } from '../../../common/error/errors';\nimport { INTERNAL_USE_ONLY, SDK_VERSION_HEADERS } from '../../../common/http-request';\nimport { PaymentMethod } from '../../../payment';\nimport { PaypalActions, PaypalAuthorizeData, PaypalButtonStyleShapeOption, PaypalButtonStyleSizeOption, PaypalClientToken, PaypalScriptLoader } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class PaypalButtonStrategy implements CheckoutButtonStrategy {\n private _paymentMethod?: PaymentMethod;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _paypalScriptLoader: PaypalScriptLoader,\n private _formPoster: FormPoster,\n private _host: string = ''\n ) {}\n\n initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const paypalOptions = options.paypal;\n const state = this._store.getState();\n const paymentMethod = this._paymentMethod = state.paymentMethods.getPaymentMethod(options.methodId);\n\n if (!paypalOptions) {\n throw new InvalidArgumentError();\n }\n\n if (!paymentMethod) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n return this._paypalScriptLoader.loadPaypal(paymentMethod.config.merchantId)\n .then(paypal => {\n if (!paymentMethod || !paymentMethod.config.merchantId) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n const merchantId = paymentMethod.config.merchantId;\n const env = paymentMethod.config.testMode ? 'sandbox' : 'production';\n const clientToken: PaypalClientToken = { [env]: paypalOptions.clientId };\n\n const fundingCreditOption = paypal.FUNDING.CREDIT || 'credit';\n const allowedSources = paypalOptions.allowCredit ? [fundingCreditOption] : [];\n const disallowedSources = !paypalOptions.allowCredit ? [fundingCreditOption] : [];\n\n return paypal.Button.render({\n env,\n client: clientToken,\n commit: paypalOptions.shouldProcessPayment,\n funding: {\n allowed: allowedSources,\n disallowed: disallowedSources,\n },\n style: {\n shape: PaypalButtonStyleShapeOption.RECT,\n ...pick(paypalOptions.style, 'layout', 'color', 'label', 'shape', 'tagline', 'fundingicons'),\n size: (paymentMethod.id === 'paypalexpress' && paypalOptions.style?.size === 'small') ? PaypalButtonStyleSizeOption.RESPONSIVE : paypalOptions.style?.size,\n },\n payment: (_, actions) => this._setupPayment(merchantId, actions, paypalOptions.onPaymentError),\n onAuthorize: (data, actions) => this._tokenizePayment(data, actions, paypalOptions.shouldProcessPayment, paypalOptions.onAuthorizeError),\n }, options.containerId);\n });\n }\n\n deinitialize(): Promise<void> {\n this._paymentMethod = undefined;\n\n return Promise.resolve();\n }\n\n private _setupPayment(merchantId: string, actions?: PaypalActions, onError?: (error: StandardError) => void): Promise<string> {\n if (!actions) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const cart = state.cart.getCart();\n const cartId = cart ? cart.id : '';\n\n return actions.request.post(`${this._host}/api/storefront/payment/paypalexpress`, { merchantId, cartId }, {\n headers: {\n 'X-API-INTERNAL': INTERNAL_USE_ONLY,\n ...SDK_VERSION_HEADERS,\n },\n });\n })\n .then(res => res.id)\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _tokenizePayment(\n data: PaypalAuthorizeData,\n actions?: PaypalActions,\n shouldProcessPayment?: boolean,\n _onError?: (error: StandardError) => void // FIXME: This parameter seems to be unused\n ): Promise<void> {\n if (!this._paymentMethod) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n if (!actions) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n if (!data.paymentID || !data.payerID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n\n const methodId = this._paymentMethod.id;\n\n return actions.payment.get(data.paymentID).then(payload => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n paymentId: data.paymentID,\n payerId: data.payerID,\n payerInfo: JSON.stringify(payload.payer.payer_info),\n });\n });\n }\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { includes } from 'lodash';\n\nimport { Cart } from '../../../cart';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { InvalidArgumentError, MissingDataError, MissingDataErrorType } from '../../../common/error/errors';\nimport { ApproveDataOptions, ButtonsOptions, ClickDataOptions, FundingType, PaypalCommerceInitializationData, PaypalCommercePaymentProcessor, PaypalCommerceScriptParams } from '../../../payment/strategies/paypal-commerce';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\n\nexport default class PaypalCommerceButtonStrategy implements CheckoutButtonStrategy {\n private _isCredit?: boolean;\n private _isVenmo?: boolean;\n private _isVenmoEnabled?: boolean;\n\n constructor(\n private _store: CheckoutStore,\n private _checkoutActionCreator: CheckoutActionCreator,\n private _formPoster: FormPoster,\n private _paypalCommercePaymentProcessor: PaypalCommercePaymentProcessor\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n let state = this._store.getState();\n const { initializationData } = state.paymentMethods.getPaymentMethodOrThrow(options.methodId);\n\n if (!initializationData.clientId) {\n throw new InvalidArgumentError();\n }\n\n this._isVenmoEnabled = initializationData.isVenmoEnabled;\n state = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const cart = state.cart.getCartOrThrow();\n const buttonParams: ButtonsOptions = {\n onApprove: data => this._tokenizePayment(data),\n onClick: data => this._handleClickButtonProvider(data),\n };\n\n if (options.paypalCommerce && options.paypalCommerce.style) {\n buttonParams.style = options.paypalCommerce.style;\n }\n\n const messagingContainer = options.paypalCommerce?.messagingContainer;\n const isMessagesAvailable = Boolean(messagingContainer && document.getElementById(messagingContainer));\n\n await this._paypalCommercePaymentProcessor.initialize(this._getParamsScript(initializationData, cart), undefined, initializationData.isVenmoEnabled);\n\n this._paypalCommercePaymentProcessor.renderButtons(cart.id, `#${options.containerId}`, buttonParams);\n\n if (isMessagesAvailable) {\n this._paypalCommercePaymentProcessor.renderMessages(cart.cartAmount, `#${messagingContainer}`);\n }\n\n return Promise.resolve();\n }\n\n deinitialize(): Promise<void> {\n this._isCredit = undefined;\n this._isVenmo = undefined;\n\n return Promise.resolve();\n }\n\n private _handleClickButtonProvider({ fundingSource }: ClickDataOptions): void {\n this._isCredit = fundingSource === 'credit' || fundingSource === 'paylater';\n this._isVenmo = fundingSource === 'venmo';\n }\n\n private _tokenizePayment({ orderID }: ApproveDataOptions) {\n if (!orderID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n let provider;\n\n if (this._isVenmo && this._isVenmoEnabled) {\n provider = 'paypalcommercevenmo';\n } else if (this._isCredit) {\n provider = 'paypalcommercecredit';\n } else {\n provider = 'paypalcommerce';\n }\n\n return this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n action: 'set_external_checkout',\n provider,\n order_id: orderID,\n });\n }\n\n private _getParamsScript(initializationData: PaypalCommerceInitializationData, cart: Cart): PaypalCommerceScriptParams {\n const {\n clientId,\n intent,\n isPayPalCreditAvailable,\n merchantId,\n attributionId,\n availableAlternativePaymentMethods = [],\n enabledAlternativePaymentMethods = [],\n isVenmoEnabled,\n } = initializationData;\n\n const disableFunding: FundingType = [ 'card' ];\n const enableFunding: FundingType = enabledAlternativePaymentMethods.slice();\n\n /**\n * The default value is different depending on the countries,\n * therefore there's a need to add credit, paylater or APM name to enable/disable funding explicitly\n */\n availableAlternativePaymentMethods.forEach(apm => {\n if (!includes(enabledAlternativePaymentMethods, apm)) {\n disableFunding.push(apm);\n }\n });\n\n if (isPayPalCreditAvailable) {\n enableFunding.push('credit', 'paylater');\n } else {\n disableFunding.push('credit', 'paylater');\n }\n\n if (isVenmoEnabled) {\n enableFunding.push('venmo');\n } else if (!enableFunding.includes('venmo')) {\n disableFunding.push('venmo');\n }\n\n return {\n 'client-id': clientId,\n 'merchant-id': merchantId,\n commit: false,\n currency: cart.currency.code,\n components: ['buttons', 'messages'],\n 'disable-funding': disableFunding,\n ...(enableFunding.length && {'enable-funding': enableFunding}),\n intent,\n 'data-partner-attribution-id': attributionId,\n };\n }\n}\n","import { createFormPoster } from '@bigcommerce/form-poster';\nimport { createRequestSender } from '@bigcommerce/request-sender';\n\nimport { createCheckoutStore } from '../checkout';\nimport { createPaymentClient, PaymentMethodActionCreator, PaymentMethodRequestSender } from '../payment';\n\nimport CheckoutButtonInitializer from './checkout-button-initializer';\nimport CheckoutButtonInitializerOptions from './checkout-button-initializer-options';\nimport CheckoutButtonStrategyActionCreator from './checkout-button-strategy-action-creator';\nimport createCheckoutButtonRegistry from './create-checkout-button-registry';\n\n/**\n * Creates an instance of `CheckoutButtonInitializer`.\n *\n * @remarks\n * ```js\n * const initializer = createCheckoutButtonInitializer();\n *\n * initializer.initializeButton({\n * methodId: 'braintreepaypal',\n * braintreepaypal: {\n * container: '#checkoutButton',\n * },\n * });\n * ```\n *\n * @alpha\n * Please note that `CheckoutButtonInitializer` is currently in an early stage\n * of development. Therefore the API is unstable and not ready for public\n * consumption.\n *\n * @param options - A set of construction options.\n * @returns an instance of `CheckoutButtonInitializer`.\n */\nexport default function createCheckoutButtonInitializer(\n options?: CheckoutButtonInitializerOptions\n): CheckoutButtonInitializer {\n const { host, locale = 'en' } = options ?? {};\n const store = createCheckoutStore();\n const paymentClient = createPaymentClient(store);\n const requestSender = createRequestSender({ host });\n const formPoster = createFormPoster({ host });\n\n return new CheckoutButtonInitializer(\n store,\n new CheckoutButtonStrategyActionCreator(\n createCheckoutButtonRegistry(store, paymentClient, requestSender, formPoster, locale, host),\n new PaymentMethodActionCreator(new PaymentMethodRequestSender(requestSender))\n )\n );\n}\n","// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../payment/bigpay-client.d.ts\" /> \nimport { createClient as createBigpayClient } from '@bigcommerce/bigpay-client';\n\nimport { CheckoutStore } from '../checkout';\n\nexport default function createPaymentClient(store: CheckoutStore) {\n const paymentClient = createBigpayClient();\n\n store.subscribe(\n state => {\n const config = state.config.getStoreConfig();\n\n if (config) {\n paymentClient.setHost(config.paymentSettings.bigpayBaseUrl);\n }\n },\n state => state.config.getStoreConfig()\n );\n\n return paymentClient;\n}\n","import { FormPoster } from '@bigcommerce/form-poster';\nimport { RequestSender } from '@bigcommerce/request-sender';\nimport { createScriptLoader, getScriptLoader } from '@bigcommerce/script-loader';\n\nimport { BillingAddressActionCreator, BillingAddressRequestSender } from '../billing';\nimport { CheckoutActionCreator, CheckoutRequestSender, CheckoutStore, CheckoutValidator } from '../checkout';\nimport { Registry } from '../common/registry';\nimport { ConfigActionCreator, ConfigRequestSender } from '../config';\nimport { FormFieldsActionCreator, FormFieldsRequestSender } from '../form';\nimport { OrderActionCreator, OrderRequestSender } from '../order';\nimport { PaymentActionCreator, PaymentMethodActionCreator, PaymentMethodRequestSender, PaymentRequestSender, PaymentRequestTransformer } from '../payment';\nimport { createAmazonPayV2PaymentProcessor } from '../payment/strategies/amazon-pay-v2';\nimport { ApplePaySessionFactory } from '../payment/strategies/apple-pay';\nimport { BraintreeScriptLoader, BraintreeSDKCreator } from '../payment/strategies/braintree';\nimport { createGooglePayPaymentProcessor, GooglePayAdyenV2Initializer, GooglePayAdyenV3Initializer, GooglePayAuthorizeNetInitializer, GooglePayBraintreeInitializer, GooglePayCheckoutcomInitializer, GooglePayCybersourceV2Initializer, GooglePayOrbitalInitializer, GooglePayStripeInitializer, GooglePayStripeUPEInitializer } from '../payment/strategies/googlepay';\nimport { MasterpassScriptLoader } from '../payment/strategies/masterpass';\nimport { PaypalScriptLoader } from '../payment/strategies/paypal';\nimport { createPaypalCommercePaymentProcessor } from '../payment/strategies/paypal-commerce';\nimport { RemoteCheckoutActionCreator, RemoteCheckoutRequestSender } from '../remote-checkout';\nimport { ConsignmentActionCreator, ConsignmentRequestSender } from '../shipping';\nimport { createSpamProtection, PaymentHumanVerificationHandler } from '../spam-protection';\nimport { SubscriptionsActionCreator, SubscriptionsRequestSender } from '../subscription';\n\nimport { CheckoutButtonMethodType, CheckoutButtonStrategy } from './strategies';\nimport { AmazonPayV2ButtonStrategy } from './strategies/amazon-pay-v2';\nimport { ApplePayButtonStrategy } from './strategies/apple-pay';\nimport { BraintreePaypalButtonStrategy, BraintreePaypalCreditButtonStrategy, BraintreeVenmoButtonStrategy } from './strategies/braintree';\nimport { GooglePayButtonStrategy } from './strategies/googlepay';\nimport { MasterpassButtonStrategy } from './strategies/masterpass';\nimport { PaypalButtonStrategy } from './strategies/paypal';\nimport { PaypalCommerceButtonStrategy } from './strategies/paypal-commerce';\n\nexport default function createCheckoutButtonRegistry(\n store: CheckoutStore,\n paymentClient: any,\n requestSender: RequestSender,\n formPoster: FormPoster,\n locale: string,\n host?: string\n): Registry<CheckoutButtonStrategy, CheckoutButtonMethodType> {\n const registry = new Registry<CheckoutButtonStrategy, CheckoutButtonMethodType>();\n const scriptLoader = getScriptLoader();\n const checkoutActionCreator = new CheckoutActionCreator(\n new CheckoutRequestSender(requestSender),\n new ConfigActionCreator(new ConfigRequestSender(requestSender)),\n new FormFieldsActionCreator(new FormFieldsRequestSender(requestSender))\n );\n const checkoutRequestSender = new CheckoutRequestSender(requestSender);\n const paymentMethodActionCreator = new PaymentMethodActionCreator(new PaymentMethodRequestSender(requestSender));\n const remoteCheckoutRequestSender = new RemoteCheckoutRequestSender(requestSender);\n const remoteCheckoutActionCreator = new RemoteCheckoutActionCreator(remoteCheckoutRequestSender, checkoutActionCreator);\n const checkoutValidator = new CheckoutValidator(checkoutRequestSender);\n const orderActionCreator = new OrderActionCreator(new OrderRequestSender(requestSender), checkoutValidator);\n const paymentRequestSender = new PaymentRequestSender(paymentClient);\n const paymentRequestTransformer = new PaymentRequestTransformer();\n const paymentHumanVerificationHandler = new PaymentHumanVerificationHandler(createSpamProtection(createScriptLoader()));\n const paymentActionCreator = new PaymentActionCreator(paymentRequestSender, orderActionCreator, paymentRequestTransformer, paymentHumanVerificationHandler);\n const paypalCommercePaymentProcessor = createPaypalCommercePaymentProcessor(scriptLoader, requestSender, store, orderActionCreator, paymentActionCreator);\n const braintreeSdkCreator = new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader));\n\n registry.register(CheckoutButtonMethodType.APPLEPAY, () =>\n new ApplePayButtonStrategy(\n store,\n checkoutActionCreator,\n requestSender,\n paymentMethodActionCreator,\n new ConsignmentActionCreator(\n new ConsignmentRequestSender(requestSender),\n new CheckoutRequestSender(requestSender)\n ),\n new BillingAddressActionCreator(\n new BillingAddressRequestSender(requestSender),\n new SubscriptionsActionCreator(\n new SubscriptionsRequestSender(requestSender)\n )\n ),\n new PaymentActionCreator(\n new PaymentRequestSender(paymentClient),\n new OrderActionCreator(\n new OrderRequestSender(requestSender),\n new CheckoutValidator(checkoutRequestSender)\n ),\n new PaymentRequestTransformer(),\n new PaymentHumanVerificationHandler(createSpamProtection(createScriptLoader()))\n ),\n remoteCheckoutActionCreator,\n new OrderActionCreator(\n new OrderRequestSender(requestSender),\n new CheckoutValidator(checkoutRequestSender)\n ),\n new ApplePaySessionFactory()\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL, () =>\n new BraintreePaypalButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n // TODO: this registry should be removed after PAYPAL-1518 hits Tier3\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPALV2, () =>\n new BraintreePaypalButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, () =>\n new BraintreePaypalCreditButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n // TODO: this registry should be removed after PAYPAL-1518 hits Tier3\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDITV2, () =>\n new BraintreePaypalCreditButtonStrategy(\n store,\n checkoutActionCreator,\n braintreeSdkCreator,\n formPoster,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_VENMO, () =>\n new BraintreeVenmoButtonStrategy(\n store,\n paymentMethodActionCreator,\n braintreeSdkCreator,\n formPoster\n )\n );\n\n registry.register(CheckoutButtonMethodType.MASTERPASS, () =>\n new MasterpassButtonStrategy(\n store,\n checkoutActionCreator,\n new MasterpassScriptLoader(scriptLoader),\n locale\n ));\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ADYENV2, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAdyenV2Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ADYENV3, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAdyenV3Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_AUTHORIZENET, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayAuthorizeNetInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_BRAINTREE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayBraintreeInitializer(braintreeSdkCreator)\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_CHECKOUTCOM, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayCheckoutcomInitializer(requestSender)\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_CYBERSOURCEV2, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayCybersourceV2Initializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_ORBITAL, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayOrbitalInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_STRIPE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayStripeInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.GOOGLEPAY_STRIPEUPE, () =>\n new GooglePayButtonStrategy(\n store,\n formPoster,\n checkoutActionCreator,\n createGooglePayPaymentProcessor(\n store,\n new GooglePayStripeUPEInitializer()\n )\n )\n );\n\n registry.register(CheckoutButtonMethodType.PAYPALEXPRESS, () =>\n new PaypalButtonStrategy(\n store,\n checkoutActionCreator,\n new PaypalScriptLoader(scriptLoader),\n formPoster,\n host\n )\n );\n\n registry.register(CheckoutButtonMethodType.PAYPALCOMMERCE, () =>\n new PaypalCommerceButtonStrategy(\n store,\n checkoutActionCreator,\n formPoster,\n paypalCommercePaymentProcessor\n )\n );\n\n registry.register(CheckoutButtonMethodType.AMAZON_PAY_V2, () =>\n new AmazonPayV2ButtonStrategy(\n store,\n checkoutActionCreator,\n createAmazonPayV2PaymentProcessor()\n )\n );\n\n return registry;\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { CheckoutStore } from '../../../checkout';\nimport { OrderActionCreator } from '../../../order';\nimport PaymentActionCreator from '../../payment-action-creator';\n\nimport { PaypalCommercePaymentProcessor, PaypalCommerceRequestSender, PaypalCommerceScriptLoader } from './index';\n\nexport default function createPaypalCommercePaymentProcessor(\n scriptLoader: ScriptLoader,\n requestSender: RequestSender,\n store: CheckoutStore,\n orderActionCreator: OrderActionCreator,\n paymentActionCreator: PaymentActionCreator\n) {\n const paypalScriptLoader = new PaypalCommerceScriptLoader(scriptLoader);\n const paypalCommerceRequestSender = new PaypalCommerceRequestSender(requestSender);\n\n return new PaypalCommercePaymentProcessor(\n paypalScriptLoader,\n paypalCommerceRequestSender,\n store,\n orderActionCreator,\n paymentActionCreator\n );\n}\n","import { getScriptLoader } from '@bigcommerce/script-loader';\n\nimport AmazonPayV2PaymentProcessor from './amazon-pay-v2-payment-processor';\nimport AmazonPayV2ScriptLoader from './amazon-pay-v2-script-loader';\n\nexport default function createAmazonPayV2PaymentProcessor(): AmazonPayV2PaymentProcessor {\n return new AmazonPayV2PaymentProcessor(\n new AmazonPayV2ScriptLoader(getScriptLoader())\n );\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","message","object","name","type","setPrototypeOf","__proto__","Error","captureStackTrace","stack","DEFAULT_RESPONSE","body","headers","status","response","errors","joinErrors","reduce","result","error","join","Array","isArray","_factoryMethods","this","register","detail","title","length","map","code","mapFromInternalErrorResponse","mapFromStorefrontErrorResponse","mapFromPaymentErrorResponse","factoryMethod","createError","_getType","default","_isStorefrontErrorResponseBody","_isInternalErrorResponseBody","internalType","last","split","errorResponse","storefrontErrorResponse","internalErrorResponse","CheckoutActionType","ErrorActionType","OrderActionType","SubscriptionsActionType","BillingAddressActionType","omitDeep","predicate","isPlainObject","transform","omitBy","clearErrorReducer","state","action","ClearError","isClearErrorAction","payload","isEqual","objectA","objectB","options","index","isArrayEqual","Date","getTime","isDateEqual","RegExp","toString","isRegExpEqual","filter","keyFilter","keysA","keys","keysB","isObjectEqual","replace","currentValue","newValue","undefined","objectSet","DEFAULT_STATE","statuses","billingAddressReducer","combineReducers","data","dataReducer","composeReducers","errorsReducer","statusesReducer","reducer","UpdateBillingAddressSucceeded","ContinueAsGuestSucceeded","LoadCheckoutSucceeded","LoadOrderSucceeded","billingAddress","LoadCheckoutRequested","LoadCheckoutFailed","UpdateBillingAddressRequested","UpdateBillingAddressFailed","UpdateSubscriptionsRequested","UpdateSubscriptionsSucceeded","ContinueAsGuestRequested","UpdateSubscriptionsFailed","ContinueAsGuestFailed","arrayReplace","currentArray","newArray","matchObject","b","id","sameAsCurrentCount","sameAsNewCount","countSameAsReplaced","replacedValue","newItem","currentItem","objectMerge","currentObject","newObject","CouponActionType","GiftCertificateActionType","ConsignmentActionType","CheckoutButtonActionType","cartReducer","CreateConsignmentsSucceeded","DeleteConsignmentSucceeded","UpdateConsignmentSucceeded","UpdateShippingOptionSucceeded","LoadShippingOptionsSucceeded","ApplyCouponSucceeded","RemoveCouponSucceeded","ApplyGiftCertificateSucceeded","RemoveGiftCertificateSucceeded","cart","ConfigActionType","DEFAULT_DATA_STATE","initializedContainers","DEFAULT_ERROR_STATE","DEFAULT_STATUS_STATE","checkoutButtonReducer","meta","methodId","InitializeButtonSucceeded","containerId","DeinitializeButtonSucceeded","InitializeButtonRequested","InitializeButtonFailed","DeinitializeButtonRequested","DeinitializeButtonFailed","configReducer","LoadConfigSucceeded","LoadConfigFailed","LoadConfigRequested","couponReducer","coupons","ApplyCouponRequested","ApplyCouponFailed","RemoveCouponRequested","RemoveCouponFailed","CustomerActionType","giftCertificateReducer","giftCertificates","ApplyGiftCertificateRequested","ApplyGiftCertificateFailed","RemoveGiftCertificateRequested","RemoveGiftCertificateFailed","CustomerStrategyActionType","customerReducer","customer","CreateCustomerAddressSucceeded","CreateCustomerRequested","CreateCustomerSucceeded","CreateCustomerFailed","CreateCustomerAddressRequested","CreateCustomerAddressFailed","FormFieldsActionType","customerStrategyReducer","InitializeSucceeded","isInitialized","DeinitializeSucceeded","InitializeRequested","initializeError","initializeMethodId","InitializeFailed","DeinitializeRequested","deinitializeError","deinitializeMethodId","DeinitializeFailed","SignInRequested","SignInSucceeded","signInError","signInMethodId","SignInFailed","SignOutRequested","SignOutSucceeded","signOutError","signOutMethodId","SignOutFailed","ExecutePaymentMethodCheckoutRequested","ExecutePaymentMethodCheckoutSucceeded","executePaymentMethodCheckoutError","executePaymentMethodCheckoutMethodId","ExecutePaymentMethodCheckoutFailed","WidgetInteractionStarted","WidgetInteractionFinished","widgetInteractionError","widgetInteractionMethodId","WidgetInteractionFailed","isInitializing","isDeinitializing","isSigningIn","isSigningOut","isExecutingPaymentMethodCheckout","isWidgetInteracting","CountryActionType","formFieldsReducer","LoadFormFieldsSucceeded","LoadFormFieldsFailed","LoadFormFieldsRequested","countryReducer","LoadCountriesSucceeded","LoadCountriesRequested","LoadCountriesFailed","PaymentActionType","PaymentMethodActionType","orderReducer","metaReducer","LoadOrderPaymentsSucceeded","omit","FinalizeOrderSucceeded","SubmitOrderSucceeded","callbackUrl","order","orderToken","token","payment","LoadOrderRequested","LoadOrderPaymentsRequested","LoadOrderFailed","LoadOrderPaymentsFailed","paymentReducer","SubmitPaymentSucceeded","PaymentStrategyActionType","paymentMethodReducer","LoadPaymentMethodSucceeded","array","item","defaultPredicate","pick","findIndex","pickBy","push","existingItem","mergeOrPush","gateway","LoadPaymentMethodsSucceeded","methodA","methodB","LoadPaymentMethodsRequested","LoadPaymentMethodsFailed","LoadPaymentMethodRequested","loadMethodId","loadMethodError","LoadPaymentMethodFailed","isLoadingMethod","InstrumentActionType","paymentStrategyReducer","ExecuteRequested","ExecuteSucceeded","executeError","executeMethodId","ExecuteFailed","FinalizeRequested","FinalizeSucceeded","finalizeError","finalizeMethodId","FinalizeFailed","isExecuting","isFinalizing","RemoteCheckoutActionType","instrumentReducer","LoadInstrumentsSucceeded","vaultedInstruments","DeleteInstrumentSucceeded","LoadInstrumentsRequested","DeleteInstrumentRequested","deleteError","failedInstrument","LoadInstrumentsFailed","DeleteInstrumentFailed","instrumentId","isDeleting","deletingInstrument","remoteCheckoutReducer","InitializeRemoteBillingSucceeded","billing","InitializeRemoteShippingSucceeded","shipping","LoadRemoteSettingsSucceeded","UpdateRemoteCheckout","PickupOptionActionType","updateShippingOptionError","updateError","isUpdating","isUpdatingShippingOption","consignmentReducer","consignments","SignOutCustomerSucceeded","LoadShippingOptionsRequested","LoadShippingOptionsFailed","CreateConsignmentsRequested","CreateConsignmentsFailed","UpdateConsignmentRequested","UpdateConsignmentFailed","DeleteConsignmentRequested","DeleteConsignmentFailed","UpdateShippingOptionRequested","UpdateShippingOptionFailed","objectFlatten","parent","flattened","forEach","keyString","assign","objectWithSortedKeys","sortedArray","sort","previous","current","ShippingCountryActionType","pickupOptionReducer","LoadPickupOptionsSucceeded","sortedflattenedMeta","consignmentId","searchArea","btoa","JSON","stringify","LoadPickupOptionsRequested","LoadPickupOptionsFailed","ShippingStrategyActionType","shippingCountryReducer","LoadShippingCountriesSucceeded","LoadShippingCountriesRequested","LoadShippingCountriesFailed","SignInEmailActionType","shippingStrategyReducer","UpdateAddressRequested","UpdateAddressSucceeded","updateAddressError","updateAddressMethodId","UpdateAddressFailed","SelectOptionRequested","SelectOptionSucceeded","selectOptionError","selectOptionMethodId","SelectOptionFailed","isUpdatingAddress","isSelectingOption","StoreCreditActionType","signInEmailReducer","SendSignInEmailSucceeded","SendSignInEmailRequested","SendSignInEmailFailed","storeCreditReducer","ApplyStoreCreditRequested","ApplyStoreCreditSucceeded","ApplyStoreCreditFailed","SpamProtectionActionType","subscriptionsReducer","checkoutReducer","UpdateCheckoutSucceeded","VerifyCheckoutSucceeded","orderId","UpdateCheckoutRequested","UpdateCheckoutFailed","MissingDataErrorType","subtype","MissingBillingAddress","MissingCart","MissingConsignments","MissingCheckout","MissingCustomer","MissingCheckoutConfig","MissingOrderConfig","MissingOrder","MissingOrderId","MissingPayment","MissingPaymentToken","MissingPaymentMethod","MissingShippingAddress","getErrorMessage","creator","combiner","args","pop","combinerArgs","memoize","guard","errorFactory","createFreezeProxy","target","trap","proxy","create","iteratee","getPrototypeOf","traversePrototypeOf","getOwnPropertyNames","charAt","deepFreeze","createProxy","provider","method","barclays","braintree","braintreepaypal","authorizenet","elavon","checkoutcom","sagepay","stripe","cybersource","cybersourcev2","converge","bluesnapv2","orbital","paymetric","bolt","digitalriver","moneris","cba_mpgs","normalize","address","firstName","lastName","company","address1","address2","city","stateOrProvince","countryCode","postalCode","phone","customFields","identity","createInternalCheckoutSelectorsFactory","getBillingAddress","getBillingAddressOrThrow","getUpdateError","getContinueAsGuestError","getLoadError","isContinuingAsGuest","isLoading","getState","getInitializeError","getDeinitializeError","getCoupons","getRemoveError","getApplyError","isApplying","isRemoving","getCustomer","getCustomerOrThrow","getCreateAccountError","isCreatingCustomerAccount","getCreateAddressError","isCreatingCustomerAddress","getCheckout","getShippingAddress","getShippingAddressOrThrow","getInternalPayment","getGatewayPayment","getHostedPayment","getPaymentId","getPaymentIdOrThrow","getPaymentStatus","getPaymentStatusOrThrow","getPaymentToken","getPaymentTokenOrThrow","getPaymentRedirectUrl","getPaymentRedirectUrlOrThrow","isPaymentDataRequired","isPaymentDataSubmitted","getEmail","getSendError","isSending","createBillingAddressSelector","continueAsGuestError","loadError","memoizeOne","createCartSelector","getCart","getCartOrThrow","createCartSelectorFactory","createCheckoutButtonSelector","some","find","values","createConfigSelector","getConfig","getFlashMessages","filterType","flashMessages","context","getStoreConfig","_","formState","formFields","storeConfig","getStoreConfigOrThrow","getContextConfig","getExternalSource","externalSource","getVariantIdentificationToken","variantIdentificationToken","createConfigSelectorFactory","createCountrySelector","getCountries","countries","createCountrySelectorFactory","createCouponSelector","removeCouponError","applyCouponError","isApplyingCoupon","isRemovingCoupon","createCustomerSelector","isCreating","createAddressError","isCreatingAddress","createCustomerStrategySelector","getSignInError","getSignOutError","getExecutePaymentMethodCheckoutError","getWidgetInteractionError","createCustomerStrategySelectorFactory","createGiftCertificateSelector","getGiftCertificates","removeGiftCertificateError","applyGiftCertificateError","isApplyingGiftCertificate","isRemovingGiftCertificate","createGiftCertificateSelectorFactory","createInstrumentSelector","getInstrumentsByPaymentMethod","instruments","paymentMethod","paymentMethodKey","currentMethod","getCardInstrument","cards","instrument","bigpayToken","card","isMatch","getCardInstrumentOrThrow","MissingPaymentInstrument","getInstruments","flatMap","supportedProvider","getInstrumentsMeta","getDeleteError","createInstrumentSelectorFactory","createFormSelector","getShippingAddressFields","selectedCountry","shippingAddress","field","processField","getBillingAddressFields","getCustomerAccountFields","customerAccount","country","items","label","fieldType","itemtype","processCountry","subdivisions","requiresState","required","processProvince","hasPostalCodes","Boolean","processsPostCode","createFormSelectorFactory","createPaymentMethodSelector","getPaymentMethods","paymentMethods","getPaymentMethodsMeta","getPaymentMethod","gatewayId","getPaymentMethodOrThrow","getLoadMethodError","createPaymentMethodSelectorFactory","createPaymentStrategySelector","getExecuteError","getFinalizeError","getWidgetInteractingError","createPaymentStrategySelectorFactory","createPickupOptionSelector","getPickupOptions","pickupOptions","sortedFlattenedParams","createPickupOptionSelectorFactory","createRemoteCheckoutSelector","createShippingAddressSelector","shippingConsignment","consignment","selectedPickupOption","createShippingCountrySelector","getShippingCountries","createShippingCountrySelectorFactory","createShippingStrategySelector","getUpdateAddressError","getSelectOptionError","createShippingStrategySelectorFactory","createConsignmentSelector","getConsignments","getConsignmentsOrThrow","getConsignmentById","getConsignmentByAddress","addressA","addressB","getShippingOption","selectedShippingOption","getCreateError","getLoadShippingOptionsError","loadShippingOptionsError","getUnassignedItems","assignedLineItemIds","itemIds","concat","lineItemIds","lineItems","physicalItems","indexOf","getItemAssignmentError","getUpdateShippingOptionError","isLoadingShippingOptions","isAssigningItems","createConsignmentSelectorFactory","createCheckoutSelector","getCheckoutOrThrow","getOutstandingBalance","useStoreCredit","checkout","grandTotal","storeCredit","Math","max","outstandingBalance","isExecutingSpamCheck","createCheckoutSelectorFactory","createOrderSelector","getOrder","getOrderOrThrow","getOrderMeta","payments","currentPayment","paymentId","createOrderSelectorFactory","createPaymentSelector","providerId","internalPayment","MissingPaymentId","step","MissingPaymentStatus","redirectUrl","MissingPaymentRedirectUrl","nonce","createStoreCreditSelector","applyError","createStoreCreditSelectorFactory","createSubscriptionsSelector","createSubscriptionsSelectorFactory","createSignInEmailSelector","signInEmail","sendError","checkoutButton","customerStrategies","form","paymentStrategies","remoteCheckout","shippingCountries","shippingStrategies","subscriptions","selectors","config","shouldWarnMutation","createCheckoutStore","initialState","factory","requestErrorFactory","actionTransformer","action$","from","pipe","catchError","every","createInternalCheckoutSelectors","createDataStore","stateTransformer","cacheAction","fn","Observable","shareReplay","store","isActionOptions","param","useCache","cachableActionDecorator","descriptor","memoizedMethods","WeakMap","decorateMethod","lastArg","instanceMethods","set","isApplePayWindow","window","assertApplePayWindow","_requestSender","loadPaymentMethods","observer","next","createAction","then","deviceSessionId","sessionHash","methods","filteredMethods","_filterApplePay","complete","catch","createErrorAction","loadPaymentMethod","ContentType","INTERNAL_USE_ONLY","SDK_VERSION_HEADERS","timeout","Accept","params","url","bindMethodDecorator","decoratedTarget","getOwnPropertyDescriptor","bindClassDecorator","boundMethod","bind","isTerminalCacheKeyMap","_lastId","_map","maps","_usedMaps","_options","maxSize","onExpire","noop","getKey","_resolveMap","parentMap","cacheKey","usedCount","_generateMap","slice","_removeLeastUsedMap","getUsedCount","isMatched","mapIndex","unshift","splice","terminalMap","recentlyUsedMap","_removeMap","isRootCacheKeyMap","isPrivate","selectorDecorator","resolver","memoizedMethod","cachedValue","cache","selectorMethodDecorator","_checkoutButton","getInitializeButtonError","getDeinitializeButtonError","CheckoutButtonErrorSelector","isInitializingButton","isDeinitializingButton","CheckoutButtonStatusSelector","createCheckoutButtonSelectors","_store","_buttonStrategyActionCreator","_state","subscribe","subscriber","filters","initializeButton","containerIds","test","selector","idPrefix","containers","document","querySelectorAll","container","uniqueId","setUniqueElementId","Promise","all","initialize","queueId","dispatch","deinitializeButton","deinitialize","CheckoutButtonInitializer","throwErrorAction","of","throwError","CheckoutButtonMethodType","methodMap","_registry","_paymentMethodActionCreator","empty","defer","_subscriptionActionCreator","continueAsGuest","credentials","isGuest","billingAddressRequestBody","existingBillingAddressRequestBody","merge","_createOrUpdateBillingAddress","_updateCustomerConsent","updateAddress","email","acceptsAbandonedCartEmails","acceptsMarketingNewsletter","updateSubscriptions","checkoutId","createAddress","DEFAULT_PARAMS","include","post","put","_checkoutRequestSender","_configActionCreator","_formFieldsActionCreator","loadCheckout","loadConfig","loadFormFields","loadDefaultCheckout","updateCheckout","loadCurrentCheckout","joinIncludes","includes","uniq","joinOrMergeIncludes","baseIncludes","includeDictionaryOrList","includesDictionary","deletions","on","additions","difference","mergeIncludes","cartA","cartB","_normalize","cartAmount","currency","digitalItems","itemA","itemB","productId","variantId","localeCompare","extendedSalePrice","quantity","amount","recipient","giftWrapping","updated","validate","comparator","_compareCoupons","_compareGiftCertificates","_getComparableCheckout","couponsA","couponsB","giftCertificatesA","giftCertificatesB","_factories","_instances","defaultToken","cacheToken","_getInstance","_hasFactory","_hasInstance","_configRequestSender","_formFieldsRequestSender","loadFields","_orderRequestSender","_checkoutValidator","loadOrder","loadOrderPayments","loadCurrentOrder","_getCurrentOrderId","submitOrder","SubmitOrderRequested","shouldExecuteSpamCheck","_mapToOrderRequestBody","customerMessage","checkoutVariant","switchMap","SubmitOrderFailed","finalizeOrder","FinalizeOrderRequested","FinalizeOrderFailed","cartId","paymentData","isNil","_client","submitPayment","resolve","reject","_transformResponse","initializeOffsitePayment","statusText","mapToInternalAddress","addressId","isBillingAddressLike","addressLine1","addressLine2","province","provinceCode","stateOrProvinceCode","postCode","_decimalPlaces","toInteger","round","pow","couponTypes","mapToInternalCoupon","coupon","discount","displayName","discountType","couponType","mapToInternalGiftCertificate","giftCertificate","discountedAmount","used","remainingBalance","remaining","balance","purchaseDate","mapToInternalLineItems","itemMap","decimalPlaces","idKey","amountTransformer","imageUrl","amountAfterDiscount","integerAmount","integerAmountAfterDiscount","integerUnitPrice","integerUnitPriceAfterDiscount","integerDiscount","sender","attributes","mapGiftCertificateToInternalLineItem","extendedListPrice","discountAmount","listPrice","salePrice","downloadsPageUrl","downloadPageUrl","brand","sku","categoryNames","option","addedByPromotion","mapToInternalLineItem","mapToInternalLineItemType","mapToInternalCart","promotions","notifications","sum","discountNotifications","promotion","banners","banner","placeholders","messageHtml","text","totalDiscountedAmount","certificate","appliedGiftCertificates","keyBy","shippingCostTotal","amountBeforeDiscount","shippingCostBeforeDiscount","integerAmountBeforeDiscount","lineItem","isShippingRequired","subtotal","taxSubtotal","taxTotal","taxes","handling","handlingCostTotal","mapToInternalCustomer","addresses","customerId","fullName","customerGroupName","customerGroup","format","month","year","trimmedMonth","trimmedYear","toObject","number","maxLength","creditCardType","info","lengths","unformattedValue","unformat","gaps","gapIndex","output","mapToInternalOrder","orderMeta","customerCanBeCreated","mapToInternalOrderPayment","baseAmount","socialData","mapToInternalSocialDataList","hasDigitalItems","isDownloadable","isComplete","mapToStoreCredit","orderAmount","orderAmountAsInteger","isDefaultOrderPayment","helpText","instructions","returnUrl","socialDataObject","socialMedia","description","image","link","shareText","sharingLink","channelName","channel","channelCode","mapToInternalShippingOption","isSelected","price","cost","selected","isRecommended","transitTime","_cardExpiryFormatter","_cardNumberFormatter","checkoutState","_mapShippingAddress","shippingOption","contextConfig","instrumentMeta","paymentMeta","internalCustomer","authToken","formattedInstrument","formattedPayload","bigpay_token","isFormattedVaultedInstrument","vaultAccessToken","additionalAction","_transformPaymentMethod","quoteMeta","request","geoCountryCode","source","storeProfile","transformWithHostedFormData","paymentMethodMeta","_transformHostedInputValues","initializationData","ccCvv","cardCodeVerification","ccNumber","cardNumberVerification","hostedFormNonce","cardCode","ccExpiry","cardExpiry","ccName","cardName","cardNumber","isBopisEnabled","bopis","enabled","requiredAddress","isPickup","_paymentRequestSender","_orderActionCreator","_paymentRequestTransformer","_paymentHumanVerificationHandler","promise","shouldSaveInstrument","shouldSetAsDefaultInstrument","vault_payment_instrument","set_as_default_stored_instrument","InitializeOffsitePaymentRequested","race","InitializeOffsitePaymentSucceeded","InitializeOffsitePaymentFailed","SubmitPaymentRequested","handle","SubmitPaymentFailed","NotInitializedErrorType","CustomerNotInitialized","PaymentNotInitialized","ShippingNotInitialized","SpamProtectionNotInitialized","_amazonPayV2ScriptLoader","load","_amazonPayV2SDK","bindButton","buttonId","sessionId","changeAction","_getAmazonPayV2SDK","Pay","bindChangeAction","amazonCheckoutSessionId","createButton","renderButton","signout","AmazonPayV2Regions","AmazonPayV2CheckoutLanguage","AmazonPayV2Placement","AmazonPayV2LedgerCurrency","AmazonPayV2PayOptions","_scriptLoader","_window","amazonPayV2Region","loadScript","amazon","ApplePaySession","PAYPAL_COMPONENTS","_braintreeScriptLoader","_dataCollectors","clientToken","_clientToken","getClient","loadClient","client","authorization","getPaypal","_paypal","loadPaypal","getPaypalCheckout","onSuccess","onError","loadPaypalCheckout","paypalCheckout","paypalCheckoutConfig","paypalCheckoutCallback","braintreePaypalCheckout","paypalSdkLoadConfig","components","paypal","loadPayPalSDK","_paypalCheckout","getVenmoCheckout","_venmoCheckout","loadVenmoCheckout","venmoCheckout","venmoCheckoutConfig","allowDesktop","paymentMethodUsage","venmoCheckoutCallback","braintreeVenmoCheckout","isBrowserSupported","get3DS","_3ds","load3DS","version","getDataCollector","cached","loadDataCollector","kount","deviceData","teardown","getVisaCheckout","_visaCheckout","loadVisaCheckout","getGooglePaymentComponent","_googlePay","loadGooglePayment","createHostedFields","loadHostedFields","_teardown","mod","threeDSecure","dataCollector","visaCheckout","venmo","googlePayment","hostedFields","CheckoutIncludes","_consignmentRequestSender","unassignItemsByAddress","_consignmentHasAddress","existingConsignment","_removeLineItems","updateConsignment","deleteConsignment","assignItemsByAddress","_createOrUpdateConsignment","_addLineItems","selectShippingOption","consignmentUpdateBody","shippingOptionId","consignmentMeta","loadShippingOptions","AvailableShippingOptions","_getUpdateAddressRequestBody","createConsignments","updateShippingOption","_isUpdateConsignmentRequest","customItems","itemId","_hydrateLineItems","sharedItem","DEFAULT_INCLUDES","delete","_subscriptionsRequestSender","ButtonType","ButtonColor","BillingAddressFormat","getFirstAndLastName","nameParts","_googlePayScriptLoader","_googlePayInitializer","_billingAddressActionCreator","_consignmentActionCreator","_methodId","_configureWallet","onClick","buttonType","buttonColor","Short","Default","_googlePayClient","displayWallet","loadPaymentData","_getPaymentDataRequest","handleSuccess","parseResponse","tokenizePayload","_postForm","_updateBillingAddress","updateShippingAddress","_mapGooglePayAddressToShippingAddress","_getMethodId","hasShippingAddress","testMode","googlePay","paymentDataRequest","_getGooglePayClient","_paymentDataRequest","isReadyToPay","allowedPaymentMethods","parameters","allowedAuthMethods","allowedCardNetworks","apiVersion","apiVersionMinor","_getCardInformation","cardInformation","cardType","lastFour","google","environment","api","PaymentsClient","_mapGooglePayAddressToBillingAddress","customerEmail","paymentMethodData","locality","companyName","address3","administrativeArea","phoneNumber","postPaymentData","details","payment_type","tokenFormat","card_information","remoteBillingAddress","googlePayAddressMapped","createGooglePayPaymentProcessor","initializer","requestSender","createRequestSender","scriptLoader","getScriptLoader","_getGooglePayPaymentDataRequest","currencyCode","gatewayMerchantId","merchantName","merchantId","merchantInfo","authJwt","billingAddressRequired","billingAddressParameters","Full","phoneNumberRequired","tokenizationSpecification","transactionInfo","totalPriceStatus","totalPrice","toFixed","emailRequired","shippingAddressRequired","shippingAddressParameters","baseRequest","_getGooglePaymentDataRequest","supportedCards","paymentGatewaySpecification","_getPaymentGatewaySpecification","cardPaymentMethod","_getCardPaymentMethod","_braintreeSDKCreator","googleBraintreePaymentInstance","_googlePaymentInstance","_createGooglePayPayload","parse","tokenizationData","androidPayCards","lastTwo","binData","platformToken","googlePayBraintreePaymentDataRequest","googleMerchantName","googleMerchantId","cardRequirements","billingAddressFormat","_mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2","createPaymentDataRequest","googlePayBraintreeDataRequestV1","paymentMethodTokenizationParameters","_publishableKey","_testMode","_errorMessage","checkoutcomkey","_mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2","err","signature","protocolVersion","signedMessage","_convertToken","finalToken","cardNetwork","cardDetails","token_format","_requestCheckoutcomTokenize","token_data","checkoutcomToken","checkoutcomKey","Authorization","last4","stripeVersion","stripePublishableKey","stripeConnectedAccount","useMasterpassSrc","language","sourceUrl","masterpass","scriptSrc","async","loadPaypalCommerce","_validateParams","paypalLoadScript","CLIENT_ID","MERCHANT_ID","setupPayment","isCredit","isCheckout","isCreditCard","isAPM","isVenmo","getOrderStatus","PaymentStrategyType","StyleButtonLabel","StyleButtonLayout","StyleButtonColor","StyleButtonShape","NON_INSTANT_PAYMENT_METHODS","_paypalScriptLoader","_paypalCommerceRequestSender","_paymentActionCreator","_validateStyleParams","style","updatedStyle","color","layout","shape","height","tagline","horizontal","paramsScript","isVenmoEnabled","_gatewayId","_isVenmoEnabled","renderButtons","optionalParams","Buttons","paramsForProvider","fundingKey","onRenderButton","buttonParams","createOrder","_setupPayment","actions","_fundingSource","fundingSource","FUNDING","_paypalButtons","isEligible","_processNotEligible","render","renderFields","apmFieldsContainer","apmFieldsStyles","PaymentFields","fieldsParams","fields","_paypalFields","fieldContainerElement","querySelector","innerHTML","getOrderId","_orderId","renderMessages","cartTotal","Messages","_paypalMessages","placement","renderHostedFields","events","HostedFields","styles","paymentsSDK","_hostedFields","submitHostedFields","submit","getHostedFieldsValidationState","isValid","close","_patchNonInstantPaymentMethods","device_info","method_id","paypal_account","order_id","paymentRequestOptions","toUpperCase","PAYLATER","CREDIT","initializeBilling","methodName","initializeShipping","initializePayment","loadSettings","signOut","generateToken","trackAuthorizationEvent","forgetCheckout","_remoteCheckoutRequestSender","_checkoutActionCreator","InitializeRemoteBillingRequested","InitializeRemoteBillingFailed","InitializeRemoteShippingRequested","InitializeRemoteShippingFailed","InitializeRemotePaymentRequested","InitializeRemotePaymentSucceeded","InitializeRemotePaymentFailed","LoadRemoteSettingsRequested","LoadRemoteSettingsFailed","SignOutRemoteCustomerRequested","SignOutRemoteCustomerSucceeded","SignOutRemoteCustomerFailed","ForgetCheckoutRemoteCustomerRequested","ForgetCheckoutRemoteCustomerSucceeded","ForgetCheckoutRemoteCustomerFailed","_googleRecaptcha","errorOrId","handleWithRecaptchaSitekey","handleWithPaymentHumanVerificationRequestError","_isPaymentHumanVerificationRequest","_initialize","additional_action_required","_performRecaptcha","execute","take","human_verification_token","toPromise","recaptchaSitekey","cardingProtectionElementId","cardingProtectionElement","getElementById","parentNode","removeChild","createElement","setAttribute","appendChild","callback","MutationObserver","googleRecaptchaScriptLoader","mutationObserverFactory","_memoized","recaptcha","sitekey","event$","Subject","_widgetId","size","getResponse","reset","_event$","_recaptcha","element","retryWhen","delay","TIMEOUT","_watchRecaptchaChallengeWindow","event","iframeContainer","parentElement","visibility","observe","attributeFilter","_loadPromise","_loadScript","grecaptcha","createSpamProtection","MutationObserverFactory","getShippableItemsCount","total","_amazonPayV2PaymentProcessor","amazonpay","_createSignInButton","_walletButton","_getAmazonPayV2ButtonOptions","amazonButtonOptions","shopPath","features","checkoutLanguage","ledgerCurrency","checkoutSessionMethod","extractAmazonCheckoutSessionId","createCheckoutSession","sandbox","productType","PayOnly","PayAndShip","Cart","DefaultLabels","_remoteCheckoutActionCreator","_sessionFactory","_onAuthorizeCallback","_subTotalLabel","Subtotal","_shippingLabel","Shipping","applepay","buttonClassName","onPaymentAuthorize","_paymentMethod","_applePayButton","_createButton","addEventListener","_handleWalletButtonClick","classList","add","button","preventDefault","_getBaseRequest","applePaySession","_handleApplePayEvents","begin","storeCountryCode","storeName","merchantCapabilities","supportedNetworks","requiresShipping","requiredBillingContactFields","requiredShippingContactFields","tax","onvalidatemerchant","_onValidateMerchant","merchantSession","completeMerchantValidation","onshippingcontactselected","_handleShippingContactSelected","onshippingmethodselected","_handleShippingMethodSelected","oncancel","onpaymentauthorized","_onPaymentAuthorized","_transformContactToAddress","shippingContact","abort","selectionShippingOptionId","availableOptions","availableShippingOptions","selectedOption","unselectedOptions","shippingOptions","additionalDescription","identifier","completeShippingContactSelection","STATUS_INVALID_SHIPPING_POSTAL_ADDRESS","recommendedOption","optionId","selectedOptionId","_updateShippingOption","newShippingMethods","newTotal","newLineItems","_getUpdatedLineItems","completeShippingMethodSelection","validationURL","location","hostname","bigPayEndpoint","paymentsUrl","billingContact","apple_pay_token","payment_data","payment_method","transaction_id","transactionIdentifier","transformedBillingAddress","transformedShippingAddress","emailAddress","completePayment","STATUS_SUCCESS","STATUS_FAILURE","contact","givenName","familyName","addressLines","mapToBraintreeShippingAddressOverride","recipientName","line1","line2","getValidButtonStyle","fundingicons","validStyles","getValidHeight","mapToLegacyBillingAddress","first_name","last_name","phone_number","address_line_1","address_line_2","country_code","postal_code","mapToLegacyShippingAddress","_formPoster","messagingContainerId","updatedMethodId","paypalCheckoutOptions","paypalCheckoutSuccessCallback","_renderPayPalComponents","paypalCheckoutErrorCallback","_handleError","_renderPayPalMessages","_renderPayPalButton","shouldProcessPayment","onAuthorizeError","onPaymentError","PAYPAL","validButtonStyle","paypalButtonRender","env","commit","onApprove","authorizeData","_tokenizePayment","_removeElement","isMessageContainerAvailable","isMessagesRenderingFeatureOn","checkoutSettings","shippingAddressOverride","createPayment","flow","enableShippingAddress","shippingAddressEditable","offerCredit","tokenizePayment","postForm","device_data","billing_address","shipping_address","buttonContainerId","onErrorCallback","elementId","remove","PaypalButtonStyleLayoutOption","PaypalButtonStyleSizeOption","PaypalButtonStyleColorOption","PaypalButtonStyleLabelOption","PaypalButtonStyleShapeOption","braintreepaypalcredit","hasRenderedSmartButton","fundingSources","buttonStyle","venmoButtonStyle","backgroundColor","backgroundPosition","backgroundSize","backgroundImage","backgroundRepeat","borderRadius","cursor","transition","minHeight","minWidth","width","_onError","braintreevenmo","_handleInitializationVenmoSuccess","_handleInitializationVenmoError","parentContainerId","_renderVenmoButton","_removeVenmoContainer","buttonContainer","venmoButton","tokenize","removeAttribute","_handlePostForm","_googlePayPaymentProcessor","googlePayOptions","_getGooglePayOptions","buttonOptions","googlePayButton","googlepayadyenv2","googlepayadyenv3","googlepayauthorizenet","googlepaybraintree","googlepaycheckoutcom","googlepaycybersourcev2","googlepayorbital","googlepaystripe","googlepaystripeupe","hasPhysicalItems","_onPaymentSelectComplete","supportedLocales","es","en","pt","zu","ar","zh","ms","uk","sv","hr","pl","nl","it","de","fr","formatLocale","localeLanguage","toLowerCase","formattedLocale","countryLocales","_masterpassScriptLoader","_locale","masterpassScriptLoaderParams","isMasterpassSrcEnabled","_masterpassClient","_signInButton","removeEventListener","subdomain","src","_createMasterpassPayload","allowedCardTypes","origin","CheckoutButtonNotInitialized","_host","paypalOptions","clientId","fundingCreditOption","allowedSources","allowCredit","disallowedSources","Button","funding","allowed","disallowed","RECT","RESPONSIVE","onAuthorize","res","paymentID","payerID","payerId","payerInfo","payer","payer_info","_paypalCommercePaymentProcessor","_handleClickButtonProvider","paypalCommerce","messagingContainer","isMessagesAvailable","_getParamsScript","_isCredit","_isVenmo","orderID","intent","isPayPalCreditAvailable","attributionId","availableAlternativePaymentMethods","enabledAlternativePaymentMethods","disableFunding","enableFunding","apm","createCheckoutButtonInitializer","host","locale","paymentClient","setHost","paymentSettings","bigpayBaseUrl","createPaymentClient","formPoster","createFormPoster","registry","checkoutActionCreator","checkoutRequestSender","paymentMethodActionCreator","remoteCheckoutRequestSender","remoteCheckoutActionCreator","checkoutValidator","orderActionCreator","paymentRequestSender","paymentRequestTransformer","paymentHumanVerificationHandler","createScriptLoader","paymentActionCreator","paypalCommercePaymentProcessor","paypalScriptLoader","paypalCommerceRequestSender","createPaypalCommercePaymentProcessor","braintreeSdkCreator","createCheckoutButtonRegistry"],"sourceRoot":""}
|