@bigcommerce/checkout-sdk 1.223.1 → 1.226.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"tslib\"","webpack:///external \"lodash\"","webpack:///external \"@bigcommerce/data-store\"","webpack:///external \"rxjs\"","webpack:///external \"@bigcommerce/memoize\"","webpack:///external \"rxjs/operators\"","webpack:///./src/shipping/consignment-actions.ts","webpack:///./src/customer/customer-strategy-actions.ts","webpack:///./src/payment/payment-strategy-type.ts","webpack:///./src/shipping/shipping-strategy-actions.ts","webpack:///./src/payment/payment-strategy-actions.ts","webpack:///./src/common/error/errors/missing-data-error.ts","webpack:///./src/order/order-actions.ts","webpack:///./src/checkout/checkout-actions.ts","webpack:///./src/remote-checkout/remote-checkout-actions.ts","webpack:///./src/common/error/errors/standard-error.ts","webpack:///./src/common/utility/set-prototype-of.ts","webpack:///./src/payment/payment-method-actions.ts","webpack:///./src/billing/billing-address-actions.ts","webpack:///./src/checkout-buttons/checkout-button-actions.ts","webpack:///./src/common/http-request/sdk-version-headers.ts","webpack:///./src/coupon/coupon-actions.ts","webpack:///./src/customer/customer-actions.ts","webpack:///./src/payment/instrument/instrument-actions.ts","webpack:///./src/payment/strategies/googlepay/googlepay.ts","webpack:///./src/coupon/gift-certificate-actions.ts","webpack:///external \"card-validator\"","webpack:///./src/common/http-request/content-type.ts","webpack:///./src/payment/is-vaulted-instrument.ts","webpack:///external \"@bigcommerce/script-loader\"","webpack:///./src/common/error/errors/request-error.ts","webpack:///./src/payment/payment-status-types.ts","webpack:///./src/payment/errors/payment-method-client-unavailable-error.ts","webpack:///./src/config/config-actions.ts","webpack:///./src/form/form-fields-actions.ts","webpack:///./src/common/utility/is-plain-object.ts","webpack:///./src/geography/country-actions.ts","webpack:///./src/shipping/pickup-option-actions.ts","webpack:///./src/shipping/shipping-country-actions.ts","webpack:///./src/signin-email/signin-email-actions.ts","webpack:///external \"@bigcommerce/request-sender\"","webpack:///./src/payment/payment-actions.ts","webpack:///./src/store-credit/store-credit-actions.ts","webpack:///./src/address/map-to-internal-address.ts","webpack:///./src/common/error/errors/invalid-argument-error.ts","webpack:///./src/cart/map-to-internal-line-items.ts","webpack:///./src/cart/map-gift-certificate-to-internal-line-item.ts","webpack:///./src/payment/payment-method-types.ts","webpack:///./src/common/http-request/internal-api-headers.ts","webpack:///./src/common/error/throw-error-action.ts","webpack:///./src/cart/map-to-internal-line-item.ts","webpack:///./src/common/http-request/join-includes.ts","webpack:///./src/shipping/map-to-internal-shipping-option.ts","webpack:///./src/common/utility/amount-transformer.ts","webpack:///./src/spam-protection/spam-protection-actions.ts","webpack:///external \"shallowequal\"","webpack:///./src/common/utility/is-equal.ts","webpack:///external \"@bigcommerce/form-poster\"","webpack:///./src/customer/map-to-internal-customer.ts","webpack:///./src/order/map-to-internal-order.ts","webpack:///./src/cart/map-to-internal-cart.ts","webpack:///./src/promotion/map-to-discount-notifications.ts","webpack:///./src/payment/errors/payment-method-failed-error.ts","webpack:///./src/common/http-request/join-or-merge-includes.ts","webpack:///./src/common/http-request/merge-includes.ts","webpack:///external \"@bigcommerce/bigpay-client\"","webpack:///external \"reselect\"","webpack:///./src/checkout-buttons/strategies/checkout-button-method-type.ts","webpack:///./src/common/selector/with-memoized-combiner.ts","webpack:///./src/common/error/error-actions.ts","webpack:///./src/payment/payment-method-action-creator.ts","webpack:///./src/payment/payment-method-request-sender.ts","webpack:///./src/checkout/checkout-default-includes.ts","webpack:///./src/payment/strategies/apple-pay/is-apple-pay-window.ts","webpack:///./src/hosted-form/iframe-content/card-expiry-formatter.ts","webpack:///./src/hosted-form/iframe-content/card-number-formatter.ts","webpack:///./src/billing/is-billing-address-like.ts","webpack:///./src/coupon/map-to-internal-coupon.ts","webpack:///./src/common/data-store/cache-action.ts","webpack:///./src/common/data-store/is-action-options.ts","webpack:///./src/common/data-store/cachable-action-decorator.ts","webpack:///./src/common/utility/bind-decorator.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2.ts","webpack:///./src/payment/strategies/braintree/braintree-script-loader.ts","webpack:///./src/payment/strategies/braintree/braintree.ts","webpack:///./src/payment/strategies/braintree/braintree-sdk-creator.ts","webpack:///./src/checkout/errors/checkout-not-available-error.ts","webpack:///./src/payment/payment-request-sender.ts","webpack:///./src/payment/payment-request-transformer.ts","webpack:///./src/coupon/map-to-internal-gift-certificate.ts","webpack:///./src/common/utility/omit-deep.ts","webpack:///./src/checkout/checkout-request-sender.ts","webpack:///./src/checkout/checkout-action-creator.ts","webpack:///./src/shipping/consignment-action-creator.ts","webpack:///./src/shipping/consignment-request-sender.ts","webpack:///./src/payment/strategies/masterpass/get-callback-url.ts","webpack:///./src/payment/payment-action-creator.ts","webpack:///./src/common/utility/is-private.ts","webpack:///./src/common/error/errors/unrecoverable-error.ts","webpack:///./src/common/error/errors/map-from-internal-error-response.ts","webpack:///./src/common/error/request-error-factory.ts","webpack:///./src/common/error/errors/map-from-storefront-error-response.ts","webpack:///./src/common/error/clear-error-reducer.ts","webpack:///./src/common/utility/replace.ts","webpack:///./src/common/utility/object-set.ts","webpack:///./src/billing/billing-address-state.ts","webpack:///./src/billing/billing-address-reducer.ts","webpack:///./src/common/utility/array-replace.ts","webpack:///./src/common/utility/object-merge.ts","webpack:///./src/cart/cart-state.ts","webpack:///./src/cart/cart-reducer.ts","webpack:///./src/checkout-buttons/checkout-button-state.ts","webpack:///./src/checkout-buttons/checkout-button-reducer.ts","webpack:///./src/config/config-state.ts","webpack:///./src/config/config-reducer.ts","webpack:///./src/coupon/coupon-state.ts","webpack:///./src/coupon/coupon-reducer.ts","webpack:///./src/coupon/gift-certificate-state.ts","webpack:///./src/coupon/gift-certificate-reducer.ts","webpack:///./src/customer/customer-state.ts","webpack:///./src/customer/customer-reducer.ts","webpack:///./src/customer/customer-strategy-state.ts","webpack:///./src/customer/customer-strategy-reducer.ts","webpack:///./src/form/form-fields-state.ts","webpack:///./src/form/form-fields-reducer.ts","webpack:///./src/geography/country-state.ts","webpack:///./src/geography/country-reducer.ts","webpack:///./src/order/order-state.ts","webpack:///./src/order/order-reducer.ts","webpack:///./src/payment/payment-reducer.ts","webpack:///./src/payment/payment-method-state.ts","webpack:///./src/payment/payment-method-reducer.ts","webpack:///./src/common/utility/merge-or-push.ts","webpack:///./src/payment/payment-strategy-state.ts","webpack:///./src/payment/payment-strategy-reducer.ts","webpack:///./src/payment/instrument/instrument-state.ts","webpack:///./src/payment/instrument/instrument-reducer.ts","webpack:///./src/remote-checkout/remote-checkout-state.ts","webpack:///./src/remote-checkout/remote-checkout-reducer.ts","webpack:///./src/shipping/consignment-state.ts","webpack:///./src/shipping/consignment-reducer.ts","webpack:///./src/common/utility/object-flatten.ts","webpack:///./src/common/utility/object-with-sorted-keys.ts","webpack:///./src/shipping/pickup-option-state.ts","webpack:///./src/shipping/pickup-option-reducer.ts","webpack:///./src/shipping/shipping-country-state.ts","webpack:///./src/shipping/shipping-country-reducer.ts","webpack:///./src/shipping/shipping-strategy-state.ts","webpack:///./src/shipping/shipping-strategy-reducer.ts","webpack:///./src/signin-email/signin-email-state.ts","webpack:///./src/signin-email/signin-email-reducer.ts","webpack:///./src/store-credit/store-credit-reducer.ts","webpack:///./src/subscription/subscriptions-state.ts","webpack:///./src/subscription/subscriptions-reducer.ts","webpack:///./src/checkout/checkout-state.ts","webpack:///./src/checkout/checkout-reducer.ts","webpack:///./src/common/utility/guard.ts","webpack:///./src/common/utility/create-freeze-proxy.ts","webpack:///./src/form/form-selector.ts","webpack:///./src/payment/instrument/supported-payment-instruments.ts","webpack:///./src/address/is-address-equal.ts","webpack:///./src/shipping/consignment-selector.ts","webpack:///./src/store-credit/store-credit-state.ts","webpack:///./src/checkout/create-internal-checkout-selectors.ts","webpack:///./src/billing/billing-address-selector.ts","webpack:///./src/checkout-buttons/checkout-button-selector.ts","webpack:///./src/coupon/coupon-selector.ts","webpack:///./src/customer/customer-selector.ts","webpack:///./src/remote-checkout/remote-checkout-selector.ts","webpack:///./src/shipping/shipping-address-selector.ts","webpack:///./src/payment/payment-selector.ts","webpack:///./src/signin-email/signin-email-selector.ts","webpack:///./src/cart/cart-selector.ts","webpack:///./src/config/config-selector.ts","webpack:///./src/geography/country-selector.ts","webpack:///./src/customer/customer-strategy-selector.ts","webpack:///./src/coupon/gift-certificate-selector.ts","webpack:///./src/payment/instrument/instrument-selector.ts","webpack:///./src/payment/payment-method-selector.ts","webpack:///./src/payment/payment-strategy-selector.ts","webpack:///./src/shipping/pickup-option-selector.ts","webpack:///./src/shipping/shipping-country-selector.ts","webpack:///./src/shipping/shipping-strategy-selector.ts","webpack:///./src/checkout/checkout-selector.ts","webpack:///./src/order/order-selector.ts","webpack:///./src/store-credit/store-credit-selector.ts","webpack:///./src/subscription/subscriptions-selector.ts","webpack:///./src/checkout/create-checkout-store.ts","webpack:///./src/checkout/create-action-transformer.ts","webpack:///./src/common/error/create-request-error-factory.ts","webpack:///./src/checkout/create-checkout-store-reducer.ts","webpack:///./src/cart/cart-comparator.ts","webpack:///./src/cart/errors/cart-changed-error.ts","webpack:///./src/checkout/checkout-validator.ts","webpack:///./src/payment/strategies/masterpass/masterpass-supported-locales.ts","webpack:///./src/payment/strategies/masterpass/format-locale.ts","webpack:///./src/checkout/checkout-params.ts","webpack:///./src/common/selector/selector-decorator.ts","webpack:///./src/checkout-buttons/checkout-button-error-selector.ts","webpack:///./src/checkout-buttons/checkout-button-status-selector.ts","webpack:///./src/checkout-buttons/create-checkout-button-selectors.ts","webpack:///./src/checkout-buttons/checkout-button-initializer.ts","webpack:///./src/checkout-buttons/strategies/apple-pay/apple-pay-button-strategy.ts","webpack:///./src/common/dom/is-element-id.ts","webpack:///./src/common/dom/set-unique-element-id.ts","webpack:///./src/checkout-buttons/checkout-button-strategy-action-creator.ts","webpack:///./src/checkout-buttons/strategies/amazon-pay-v2/amazon-pay-v2-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/braintree/braintree-paypal-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/googlepay/googlepay-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/masterpass/masterpass-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/paypal/paypal-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/paypal-commerce/paypal-commerce-button-strategy.ts","webpack:///./src/checkout-buttons/create-checkout-button-initializer.ts","webpack:///./src/checkout-buttons/create-checkout-button-registry.ts","webpack:///./src/common/utility/cache-key-maps.ts","webpack:///./src/common/utility/cache-key-resolver.ts","webpack:///./src/common/error/errors/map-from-payment-error-response.ts","webpack:///./src/common/error/errors/timeout-error.ts","webpack:///./src/payment/errors/payment-method-invalid-error.ts","webpack:///./src/common/selector/create-selector.ts","webpack:///./src/subscription/subscriptions-actions.ts","webpack:///./src/payment/create-payment-client.ts","webpack:///./src/config/config-action-creator.ts","webpack:///./src/config/config-request-sender.ts","webpack:///./src/spam-protection/errors/spam-protection-failed-error.ts","webpack:///./src/common/error/errors/not-initialized-error.ts","webpack:///./src/spam-protection/errors/spam-protection-challenge-not-completed-error.ts","webpack:///./src/common/dom/mutation-observer.ts","webpack:///./src/subscription/subscriptions-request-sender.ts","webpack:///./src/form/form-fields-action-creator.ts","webpack:///./src/form/form-fields-request-sender.ts","webpack:///./src/billing/billing-address-request-sender.ts","webpack:///./src/common/registry/registry.ts","webpack:///./src/remote-checkout/remote-checkout-request-sender.ts","webpack:///./src/remote-checkout/remote-checkout-action-creator.ts","webpack:///./src/common/error/errors/not-implemented-error.ts","webpack:///./src/remote-checkout/errors/remote-checkout-synchronization-error.ts","webpack:///./src/payment/strategies/googlepay/googlepay-adyenv2-initializer.ts","webpack:///./src/payment/strategies/masterpass/masterpass-script-loader.ts","webpack:///./src/payment/strategies/googlepay/googlepay-authorizenet-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-braintree-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-checkoutcom-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-cybersourcev2-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-orbital-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-stripe-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-stripe-upe-initializer.ts","webpack:///./src/payment/errors/payment-method-cancelled-error.ts","webpack:///./src/payment/strategies/apple-pay/apple-pay-session-factory.ts","webpack:///./src/payment/strategies/paypal/paypal-script-loader.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-request-sender.ts","webpack:///./src/bundles/checkout-button.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-sdk.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-script-loader.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-payment-processor.ts","webpack:///./src/payment/strategies/paypal-commerce/create-paypal-commerce-payment-processor.ts","webpack:///./src/payment/strategies/googlepay/googlepay-get-first-and-last-name.ts","webpack:///./src/payment/strategies/googlepay/googlepay-payment-processor.ts","webpack:///./src/payment/strategies/googlepay/googlepay-script-loader.ts","webpack:///./src/payment/strategies/googlepay/create-googlepay-payment-processor.ts","webpack:///./src/spam-protection/errors/spam-protection-not-loaded-error.ts","webpack:///./src/spam-protection/google-recaptcha.ts","webpack:///./src/spam-protection/google-recaptcha-script-loader.ts","webpack:///./src/spam-protection/create-spam-protection.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2-payment-processor.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2-script-loader.ts","webpack:///./src/payment/strategies/amazon-pay-v2/create-amazon-pay-v2-payment-processor.ts","webpack:///./src/spam-protection/errors/carding-protection-challenge-not-completed-error.ts","webpack:///./src/spam-protection/errors/carding-protection-failed-error.ts","webpack:///./src/spam-protection/payment-human-verification-handler.ts","webpack:///./src/spam-protection/errors/spam-protection-not-completed-error.ts","webpack:///./src/order/order-action-creator.ts","webpack:///./src/shipping/getShippableItemsCount.ts","webpack:///./src/shipping/getLineItemsCount.ts","webpack:///./src/subscription/errors/update-subscriptions-error.ts","webpack:///./src/subscription/subscriptions-action-creator.ts","webpack:///./src/billing/errors/unable-to-continue-as-guest-error.ts","webpack:///./src/billing/billing-address-action-creator.ts","webpack:///./src/order/errors/order-tax-provider-unavailable-error.ts","webpack:///./src/order/order-request-sender.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","ConsignmentActionType","CustomerStrategyActionType","PaymentStrategyType","ShippingStrategyActionType","PaymentStrategyActionType","MissingDataErrorType","subtype","type","MissingBillingAddress","MissingCart","MissingConsignments","MissingCheckout","MissingCustomer","MissingCheckoutConfig","MissingOrderConfig","MissingOrder","MissingOrderId","MissingPayment","MissingPaymentToken","MissingPaymentMethod","MissingShippingAddress","getErrorMessage","OrderActionType","CheckoutActionType","RemoteCheckoutActionType","message","setPrototypeOf","__proto__","Error","captureStackTrace","stack","PaymentMethodActionType","BillingAddressActionType","CheckoutButtonActionType","SDK_VERSION_HEADERS","CouponActionType","CustomerActionType","InstrumentActionType","ButtonType","ButtonColor","BillingAddressFormat","GiftCertificateActionType","ContentType","isVaultedInstrument","instrument","Boolean","instrumentId","isHostedVaultedInstrument","isFormattedVaultedInstrument","formattedInstrument","formattedPayload","bigpay_token","token","DEFAULT_RESPONSE","body","headers","status","response","errors","ACKNOWLEDGE","FINALIZE","ConfigActionType","FormFieldsActionType","isPlainObject","CountryActionType","PickupOptionActionType","ShippingCountryActionType","SignInEmailActionType","PaymentActionType","StoreCreditActionType","mapToInternalAddress","address","consignments","addressId","id","length","firstName","lastName","company","addressLine1","address1","addressLine2","address2","city","province","stateOrProvince","provinceCode","stateOrProvinceCode","postCode","postalCode","country","countryCode","phone","customFields","mapToInternalLineItems","itemMap","decimalPlaces","idKey","keys","reduce","result","map","item","amountTransformer","imageUrl","amount","amountAfterDiscount","discount","integerAmount","toInteger","integerAmountAfterDiscount","integerUnitPrice","integerUnitPriceAfterDiscount","integerDiscount","quantity","sender","recipient","attributes","variantId","mapGiftCertificateToInternalLineItem","mapToInternalLineItemType","HOSTED","OFFLINE","INTERNAL_USE_ONLY","throwErrorAction","error","meta","action","payload","mapToInternalLineItem","extendedListPrice","extendedSalePrice","discountAmount","listPrice","salePrice","downloadsPageUrl","downloadPageUrl","brand","sku","categoryNames","productId","options","option","addedByPromotion","joinIncludes","includes","join","mapToInternalShippingOption","isSelected","description","price","cost","selected","isRecommended","transitTime","_decimalPlaces","Math","round","pow","this","SpamProtectionActionType","isEqual","objectA","objectB","Array","isArray","index","isArrayEqual","Date","getTime","isDateEqual","RegExp","toString","isRegExpEqual","filter","keyFilter","keysA","keysB","isObjectEqual","mapToInternalCustomer","customer","billingAddress","addresses","customerId","isGuest","storeCredit","email","fullName","customerGroupName","customerGroup","mapToInternalOrder","order","orderMeta","payments","items","currency","orderId","lineItems","code","customerCanBeCreated","payment","mapToInternalOrderPayment","subtotal","baseAmount","coupon","discountedAmount","coupons","sum","orderToken","callbackUrl","discountNotifications","giftCertificate","providerId","totalDiscountedAmount","appliedGiftCertificates","detail","remainingBalance","remaining","balance","purchaseDate","socialData","mapToInternalSocialDataList","hasDigitalItems","isDownloadable","isComplete","shipping","shippingCostTotal","amountBeforeDiscount","shippingCostBeforeDiscount","integerAmountBeforeDiscount","mapToStoreCredit","taxes","taxTotal","handling","handlingCostTotal","grandTotal","orderAmount","orderAmountAsInteger","mapToInternalPaymentStatus","isDefaultOrderPayment","step","helpText","instructions","returnUrl","socialDataObject","physicalItems","digitalItems","forEach","lineItem","socialMedia","image","url","link","shareText","text","sharingLink","channelName","channel","channelCode","mapToInternalCart","checkout","promotions","notifications","cart","promotion","banners","banner","push","placeholders","discountType","messageHtml","giftCertificates","certificate","used","required","isShippingRequired","taxSubtotal","joinOrMergeIncludes","baseIncludes","includeDictionaryOrList","includesDictionary","deletions","on","additions","mergeIncludes","CheckoutButtonMethodType","withMemoizedCombiner","creator","combiner","args","pop","combinerArgs","ErrorActionType","_requestSender","loadPaymentMethods","observer","next","LoadPaymentMethodsRequested","then","deviceSessionId","sessionHash","LoadPaymentMethodsSucceeded","_filterApplePay","complete","catch","LoadPaymentMethodsFailed","loadPaymentMethod","methodId","LoadPaymentMethodRequested","undefined","LoadPaymentMethodSucceeded","LoadPaymentMethodFailed","methods","method","window","timeout","Accept","JsonV1","isApplePayWindow","assertApplePayWindow","format","split","month","year","trimmedMonth","slice","trimmedYear","toObject","test","card","maxLength","info","lengths","unformattedValue","unformat","gaps","gapIndex","output","replace","isBillingAddressLike","couponTypes","mapToInternalCoupon","displayName","indexOf","couponType","cacheAction","fn","pipe","store","isActionOptions","param","useCache","cachableActionDecorator","_","descriptor","memoizedMethods","WeakMap","decorateMethod","lastArg","instanceMethods","set","bindMethodDecorator","boundMethod","target","decoratedTarget","getOwnPropertyNames","getOwnPropertyDescriptor","bindClassDecorator","AmazonPayV2Regions","AmazonPayV2CheckoutLanguage","AmazonPayV2Placement","AmazonPayV2LedgerCurrency","AmazonPayV2PayOptions","_scriptLoader","_window","loadClient","loadScript","braintree","client","load3DS","threeDSecure","loadDataCollector","dataCollector","loadPaypal","paypal","loadPaypalCheckout","paypalCheckout","loadVisaCheckout","visaCheckout","loadVenmoCheckout","venmo","loadGooglePayment","googlePayment","loadHostedFields","hostedFields","PAYPAL_COMPONENTS","_braintreeScriptLoader","_dataCollectors","initialize","clientToken","_clientToken","getClient","PaymentNotInitialized","_client","authorization","getPaypal","_paypal","Promise","all","getPaypalCheckout","config","renderButtonCallback","_paypalCheckout","_paypalcheckoutInstance","_error","instance","loadPayPalSDK","components","getVenmoCheckout","getVenmoInstance","isBraintreeVenmoEnabled","_venmoCheckout","allowDesktop","paymentMethodUsage","venmoErr","venmoInstance","_venmoCheckoutInstance","isBrowserSupported","resolve","get3DS","_3ds","version","getDataCollector","cacheKey","cached","kount","deviceData","teardown","getVisaCheckout","_visaCheckout","getGooglePaymentComponent","_googlePay","createHostedFields","_teardown","default","mod","title","submitPayment","reject","_transformResponse","initializeOffsitePayment","data","statusText","_cardExpiryFormatter","_cardNumberFormatter","transform","checkoutState","getBillingAddress","getCheckout","getCustomer","getOrder","paymentMethod","paymentMethods","getPaymentMethod","gatewayId","shippingAddress","getShippingAddress","getConsignments","shippingOption","getShippingOption","storeConfig","getStoreConfig","contextConfig","getContextConfig","instrumentMeta","instruments","getInstrumentsMeta","paymentMeta","getPaymentMethodsMeta","getOrderMeta","internalCustomer","authToken","paymentData","getPaymentToken","vaultAccessToken","additionalAction","_transformPaymentMethod","quoteMeta","request","geoCountryCode","source","storeProfile","transformWithHostedFormData","values","nonce","paymentMethodMeta","consignment","selectedShippingOption","_transformHostedInputValues","context","gateway","initializationData","BRAINTREE_VENMO","BRAINTREE_PAYPAL","ccCvv","cardCodeVerification","ccNumber","cardNumberVerification","hostedFormNonce","cardCode","ccExpiry","cardExpiry","ccName","cardName","cardNumber","mapToInternalGiftCertificate","omitDeep","predicate","loadCheckout","params","include","updateCheckout","put","_checkoutRequestSender","_configActionCreator","_formFieldsActionCreator","LoadCheckoutRequested","loadConfig","loadFormFields","LoadCheckoutSucceeded","LoadCheckoutFailed","loadDefaultCheckout","state","getState","checkoutId","UpdateCheckoutRequested","UpdateCheckoutSucceeded","UpdateCheckoutFailed","loadCurrentCheckout","_consignmentRequestSender","unassignItemsByAddress","existingConsignment","getConsignmentByAddress","_removeLineItems","getCart","updateConsignment","deleteConsignment","assignItemsByAddress","_createOrUpdateConsignment","_addLineItems","selectShippingOption","consignmentUpdateBody","shippingOptionId","consignmentMeta","UpdateShippingOptionRequested","UpdateShippingOptionSucceeded","UpdateShippingOptionFailed","loadShippingOptions","LoadShippingOptionsRequested","AvailableShippingOptions","LoadShippingOptionsSucceeded","LoadShippingOptionsFailed","updateAddress","_getUpdateAddressRequestBody","createConsignments","CreateConsignmentsRequested","CreateConsignmentsSucceeded","CreateConsignmentsFailed","UpdateConsignmentRequested","UpdateConsignmentSucceeded","UpdateConsignmentFailed","consignmentId","DeleteConsignmentRequested","DeleteConsignmentSucceeded","DeleteConsignmentFailed","updateShippingOption","_isUpdateConsignmentRequest","customItems","itemId","_hydrateLineItems","lineItemIds","existingItem","sharedItem","concat","DEFAULT_INCLUDES","post","delete","getCallbackUrl","origin","location","_paymentRequestSender","_orderActionCreator","_paymentRequestTransformer","_paymentHumanVerificationHandler","promise","shouldSaveInstrument","shouldSetAsDefaultInstrument","vault_payment_instrument","set_as_default_stored_instrument","InitializeOffsitePaymentRequested","race","InitializeOffsitePaymentSucceeded","InitializeOffsitePaymentFailed","SubmitPaymentRequested","handle","loadCurrentOrder","SubmitPaymentSucceeded","SubmitPaymentFailed","isPrivate","joinErrors","_factoryMethods","register","mapFromInternalErrorResponse","mapFromStorefrontErrorResponse","factoryMethod","createError","_getType","_isStorefrontErrorResponseBody","_isInternalErrorResponseBody","internalType","errorResponse","storefrontErrorResponse","internalErrorResponse","clearErrorReducer","ClearError","isClearErrorAction","currentValue","newValue","objectSet","DEFAULT_STATE","statuses","billingAddressReducer","dataReducer","errorsReducer","statusesReducer","reducer","UpdateBillingAddressSucceeded","ContinueAsGuestSucceeded","LoadOrderSucceeded","UpdateBillingAddressRequested","UpdateBillingAddressFailed","UpdateSubscriptionsRequested","UpdateSubscriptionsSucceeded","ContinueAsGuestRequested","UpdateSubscriptionsFailed","ContinueAsGuestFailed","arrayReplace","currentArray","newArray","matchObject","a","b","sameAsCurrentCount","sameAsNewCount","countSameAsReplaced","replacedValue","newItem","currentItem","objectMerge","currentObject","newObject","cartReducer","ApplyCouponSucceeded","RemoveCouponSucceeded","ApplyGiftCertificateSucceeded","RemoveGiftCertificateSucceeded","DEFAULT_DATA_STATE","initializedContainers","DEFAULT_ERROR_STATE","DEFAULT_STATUS_STATE","checkoutButtonReducer","InitializeButtonSucceeded","containerId","DeinitializeButtonSucceeded","InitializeButtonRequested","InitializeButtonFailed","DeinitializeButtonRequested","DeinitializeButtonFailed","configReducer","LoadConfigSucceeded","LoadConfigFailed","LoadConfigRequested","couponReducer","ApplyCouponRequested","ApplyCouponFailed","RemoveCouponRequested","RemoveCouponFailed","giftCertificateReducer","ApplyGiftCertificateRequested","ApplyGiftCertificateFailed","RemoveGiftCertificateRequested","RemoveGiftCertificateFailed","customerReducer","CreateCustomerAddressSucceeded","CreateCustomerRequested","CreateCustomerSucceeded","CreateCustomerFailed","CreateCustomerAddressRequested","CreateCustomerAddressFailed","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","formFieldsReducer","LoadFormFieldsSucceeded","LoadFormFieldsFailed","LoadFormFieldsRequested","countryReducer","LoadCountriesSucceeded","LoadCountriesRequested","LoadCountriesFailed","orderReducer","metaReducer","LoadOrderPaymentsSucceeded","FinalizeOrderSucceeded","SubmitOrderSucceeded","LoadOrderRequested","LoadOrderPaymentsRequested","LoadOrderFailed","LoadOrderPaymentsFailed","paymentReducer","paymentMethodReducer","array","defaultPredicate","mergeOrPush","methodA","methodB","loadMethodId","loadMethodError","isLoadingMethod","paymentStrategyReducer","ExecuteRequested","ExecuteSucceeded","executeError","executeMethodId","ExecuteFailed","FinalizeRequested","FinalizeSucceeded","finalizeError","finalizeMethodId","FinalizeFailed","isExecuting","isFinalizing","instrumentReducer","LoadInstrumentsSucceeded","vaultedInstruments","DeleteInstrumentSucceeded","LoadInstrumentsRequested","DeleteInstrumentRequested","deleteError","failedInstrument","LoadInstrumentsFailed","DeleteInstrumentFailed","isDeleting","deletingInstrument","remoteCheckoutReducer","InitializeRemoteBillingSucceeded","billing","InitializeRemoteShippingSucceeded","LoadRemoteSettingsSucceeded","UpdateRemoteCheckout","updateShippingOptionError","updateError","isUpdating","isUpdatingShippingOption","consignmentReducer","SignOutCustomerSucceeded","objectFlatten","parent","flattened","keyString","assign","objectWithSortedKeys","sort","previous","current","pickupOptionReducer","LoadPickupOptionsSucceeded","sortedflattenedMeta","btoa","JSON","stringify","LoadPickupOptionsRequested","LoadPickupOptionsFailed","shippingCountryReducer","LoadShippingCountriesSucceeded","LoadShippingCountriesRequested","LoadShippingCountriesFailed","shippingStrategyReducer","UpdateAddressRequested","UpdateAddressSucceeded","updateAddressError","updateAddressMethodId","UpdateAddressFailed","SelectOptionRequested","SelectOptionSucceeded","selectOptionError","selectOptionMethodId","SelectOptionFailed","isUpdatingAddress","isSelectingOption","signInEmailReducer","SendSignInEmailSucceeded","SendSignInEmailRequested","SendSignInEmailFailed","storeCreditReducer","ApplyStoreCreditRequested","ApplyStoreCreditSucceeded","ApplyStoreCreditFailed","subscriptionsReducer","checkoutReducer","VerifyCheckoutSucceeded","guard","errorFactory","createFreezeProxy","trap","proxy","iteratee","getPrototypeOf","traversePrototypeOf","charAt","createProxy","createFormSelectorFactory","getShippingAddressFields","formFields","countries","selectedCountry","field","processField","getBillingAddressFields","getCustomerAccountFields","customerAccount","getLoadError","loadError","isLoading","label","fieldType","itemtype","processCountry","subdivisions","requiresState","processProvince","hasPostalCodes","processsPostCode","provider","barclays","braintreepaypal","authorizenet","elavon","checkoutcom","stripe","cybersource","cybersourcev2","converge","bluesnapv2","orbital","paymetric","bolt","digitalriver","moneris","normalize","createConsignmentSelectorFactory","getConsignmentById","addressA","addressB","getCreateError","getLoadShippingOptionsError","loadShippingOptionsError","getUnassignedItems","assignedLineItemIds","itemIds","getUpdateError","getDeleteError","getItemAssignmentError","getUpdateShippingOptionError","isLoadingShippingOptions","isCreating","isAssigningItems","createInternalCheckoutSelectorsFactory","getBillingAddressOrThrow","getContinueAsGuestError","isContinuingAsGuest","getInitializeError","getDeinitializeError","getCoupons","getRemoveError","getApplyError","isApplying","isRemoving","getCustomerOrThrow","getCreateAccountError","isCreatingCustomerAccount","getCreateAddressError","isCreatingCustomerAddress","getInternalPayment","getGatewayPayment","getHostedPayment","getPaymentId","getPaymentStatus","getPaymentRedirectUrl","isPaymentDataRequired","isPaymentDataSubmitted","getEmail","getSendError","isSending","createBillingAddressSelector","continueAsGuestError","createCartSelector","getCartOrThrow","createCartSelectorFactory","createCheckoutButtonSelector","createConfigSelector","getConfig","getFlashMessages","filterType","flashMessages","formState","getStoreConfigOrThrow","getExternalSource","externalSource","getVariantIdentificationToken","variantIdentificationToken","createConfigSelectorFactory","createCountrySelector","getCountries","createCountrySelectorFactory","createCouponSelector","removeCouponError","applyCouponError","isApplyingCoupon","isRemovingCoupon","createCustomerSelector","createAddressError","isCreatingAddress","createCustomerStrategySelector","getSignInError","getSignOutError","getExecutePaymentMethodCheckoutError","getWidgetInteractionError","createCustomerStrategySelectorFactory","createGiftCertificateSelector","getGiftCertificates","removeGiftCertificateError","applyGiftCertificateError","isApplyingGiftCertificate","isRemovingGiftCertificate","createGiftCertificateSelectorFactory","createInstrumentSelector","getInstrumentsByPaymentMethod","paymentMethodKey","currentMethod","getCardInstrument","cards","find","bigpayToken","some","getInstruments","supportedProvider","createInstrumentSelectorFactory","createFormSelector","createPaymentMethodSelector","getPaymentMethods","getPaymentMethodOrThrow","getLoadMethodError","createPaymentMethodSelectorFactory","createPaymentStrategySelector","getExecuteError","getFinalizeError","getWidgetInteractingError","createPaymentStrategySelectorFactory","createPickupOptionSelector","getPickupOptions","pickupOptions","searchArea","sortedFlattenedParams","createPickupOptionSelectorFactory","createRemoteCheckoutSelector","createShippingAddressSelector","createShippingCountrySelector","getShippingCountries","createShippingCountrySelectorFactory","createShippingStrategySelector","getUpdateAddressError","getSelectOptionError","createShippingStrategySelectorFactory","createConsignmentSelector","createCheckoutSelector","getCheckoutOrThrow","getOutstandingBalance","useStoreCredit","max","outstandingBalance","isExecutingSpamCheck","createCheckoutSelectorFactory","createOrderSelector","getOrderOrThrow","currentPayment","paymentId","createOrderSelectorFactory","createPaymentSelector","internalPayment","redirectUrl","createStoreCreditSelector","applyError","createStoreCreditSelectorFactory","createSubscriptionsSelector","createSubscriptionsSelectorFactory","createSignInEmailSelector","signInEmail","sendError","checkoutButton","customerStrategies","form","paymentStrategies","remoteCheckout","shippingCountries","shippingStrategies","subscriptions","selectors","shouldWarnMutation","createCheckoutStore","initialState","requestErrorFactory","factory","actionTransformer","action$","every","createInternalCheckoutSelectors","stateTransformer","cartA","cartB","_normalize","cartAmount","itemA","itemB","localeCompare","giftWrapping","updated","validate","comparator","_compareCoupons","_compareGiftCertificates","_getComparableCheckout","couponsA","couponsB","giftCertificatesA","giftCertificatesB","supportedLocales","es","en","pt","zu","ar","zh","ms","uk","sv","hr","pl","nl","it","de","fr","formatLocale","localeLanguage","toLowerCase","language","formattedLocale","countryLocales","CheckoutIncludes","selectorDecorator","resolver","memoizedMethod","cachedValue","getUsedCount","cache","getKey","selectorMethodDecorator","_checkoutButton","getInitializeButtonError","getDeinitializeButtonError","CheckoutButtonErrorSelector","isInitializingButton","isDeinitializingButton","CheckoutButtonStatusSelector","createCheckoutButtonSelectors","DefaultLabels","_store","_buttonStrategyActionCreator","_state","subscribe","subscriber","filters","initializeButton","containerIds","selector","idPrefix","containers","document","querySelectorAll","container","setUniqueElementId","queueId","dispatch","deinitializeButton","deinitialize","CheckoutButtonInitializer","_registry","_paymentMethodActionCreator","_checkoutActionCreator","_amazonPayV2PaymentProcessor","amazonpay","_createSignInButton","_walletButton","parentNode","removeChild","getElementById","_getAmazonPayV2ButtonOptions","amazonButtonOptions","createButton","shopPath","merchantId","testMode","checkoutLanguage","ledgerCurrency","checkoutSessionMethod","extractAmazonCheckoutSessionId","createCheckoutSession","sandbox","productType","getShippableItemsCount","PayOnly","PayAndShip","placement","Cart","_consignmentActionCreator","_billingAddressActionCreator","_paymentActionCreator","_remoteCheckoutActionCreator","_sessionFactory","_onAuthorizeCallback","_subTotalLabel","Subtotal","_shippingLabel","Shipping","applepay","buttonClassName","onPaymentAuthorize","_paymentMethod","_applePayButton","_createButton","addEventListener","_handleWalletButtonClick","button","createElement","classList","add","setAttribute","appendChild","event","preventDefault","_getBaseRequest","applePaySession","_handleApplePayEvents","begin","storeCountryCode","storeName","merchantCapabilities","supportedNetworks","requiresShipping","requiredBillingContactFields","requiredShippingContactFields","currencyCode","total","toFixed","tax","onvalidatemerchant","_onValidateMerchant","merchantSession","completeMerchantValidation","onshippingcontactselected","_handleShippingContactSelected","onshippingmethodselected","_handleShippingMethodSelected","oncancel","signOut","onpaymentauthorized","_onPaymentAuthorized","_transformContactToAddress","shippingContact","abort","availableOptions","availableShippingOptions","shippingOptions","additionalDescription","identifier","recommendedOption","optionId","_updateShippingOption","completeShippingContactSelection","newShippingMethods","newTotal","newLineItems","_getUpdatedLineItems","completeShippingMethodSelection","validationURL","hostname","bigPayEndpoint","paymentsUrl","credentials","billingContact","apple_pay_token","payment_data","payment_method","transaction_id","transactionIdentifier","transformedBillingAddress","transformedShippingAddress","emailAddress","submitOrder","completePayment","ApplePaySession","STATUS_SUCCESS","STATUS_FAILURE","contact","givenName","familyName","locality","addressLines","phoneNumber","administrativeArea","_braintreeSDKCreator","_formPoster","_offerCredit","_renderButtonsData","paypalOptions","braintreepaypalcredit","isVenmoEnabled","storeState","shopperCurrency","messagingContainerId","venmoParentContainer","paypalCheckoutInstance","_renderButtons","venmoCheckoutInstance","_renderVenmoButton","updatedPaypalOptions","isMessageContainerAvailable","ppsdkFeatureOn","checkoutSettings","features","FUNDING_SOURCES","fundingKey","FUNDING","skipCreditSource","allowCredit","_validateHeight","Buttons","env","fundingSource","commit","style","shape","createOrder","_setupPayment","onPaymentError","onApprove","_tokenizePayment","shouldProcessPayment","onAuthorizeError","isEligible","render","_renderMessages","venmoContainer","venmoButton","buttonContainer","tokenize","tokenizeErr","removeAttribute","_handleVenmoError","_handleSuccess","postForm","payment_type","device_data","shipping_address","_mapToLegacyShippingAddress","billing_address","_mapToLegacyBillingAddress","err","Messages","height","onError","createPayment","flow","enableShippingAddress","shippingAddressEditable","shippingAddressOverride","_mapToBraintreeAddress","offerCredit","CheckoutButtonNotInitialized","tokenizePayment","details","recipientName","first_name","last_name","phone_number","address_line_1","line1","address_line_2","line2","country_code","postal_code","_googlePayPaymentProcessor","googlePayOptions","_getGooglePayOptions","_methodId","_getMethodId","buttonOptions","buttonType","buttonColor","googlePayButton","GOOGLEPAY_ADYENV2","googlepayadyenv2","GOOGLEPAY_AUTHORIZENET","googlepayauthorizenet","GOOGLEPAY_BRAINTREE","googlepaybraintree","GOOGLEPAY_CHECKOUTCOM","googlepaycheckoutcom","GOOGLEPAY_CYBERSOURCEV2","googlepaycybersourcev2","GOOGLEPAY_ORBITAL","googlepayorbital","GOOGLEPAY_STRIPE","googlepaystripe","GOOGLEPAY_STRIPEUPE","googlepaystripeupe","hasPhysicalItems","displayWallet","handleSuccess","updateShippingAddress","_onPaymentSelectComplete","_masterpassScriptLoader","_locale","masterpassScriptLoaderParams","useMasterpassSrc","isMasterpassSrcEnabled","load","masterpass","_masterpassClient","_signInButton","removeEventListener","subdomain","src","_createMasterpassPayload","allowedCardTypes","cartId","_paypalScriptLoader","_host","clientId","allowedSources","disallowedSources","CREDIT","Button","funding","allowed","disallowed","size","actions","onAuthorize","res","_onError","paymentID","payerID","payerId","payerInfo","payer","payer_info","_paypalCommercePaymentProcessor","buttonParams","onClick","_handleClickButtonProvider","paypalCommerce","messagingContainer","isMessagesAvailable","_getParamsScript","renderButtons","renderMessages","_isCredit","orderID","order_id","intent","isPayPalCreditAvailable","attributionId","availableAlternativePaymentMethods","enabledAlternativePaymentMethods","disableFunding","enableFunding","apm","createCheckoutButtonInitializer","host","locale","paymentClient","requestSender","formPoster","registry","scriptLoader","checkoutActionCreator","checkoutRequestSender","paymentMethodActionCreator","remoteCheckoutRequestSender","remoteCheckoutActionCreator","paypalCommercePaymentProcessor","APPLEPAY","BRAINTREE_PAYPAL_CREDIT","MASTERPASS","PAYPALEXPRESS","PAYPALCOMMERCE","AMAZON_PAY_V2","createCheckoutButtonRegistry","isTerminalCacheKeyMap","_lastId","_map","maps","_usedMaps","_options","maxSize","onExpire","_resolveMap","parentMap","usedCount","_generateMap","_removeLeastUsedMap","isMatched","mapIndex","unshift","splice","terminalMap","recentlyUsedMap","_removeMap","isRootCacheKeyMap","mapFromPaymentErrorResponse","SubscriptionsActionType","createPaymentClient","setHost","paymentSettings","bigpayBaseUrl","_configRequestSender","NotInitializedErrorType","CustomerNotInitialized","ShippingNotInitialized","SpamProtectionNotInitialized","callback","MutationObserver","updateSubscriptions","_formFieldsRequestSender","loadFields","DEFAULT_PARAMS","createAddress","_factories","_instances","defaultToken","cacheToken","_getInstance","_hasFactory","_hasInstance","initializeBilling","methodName","initializeShipping","initializePayment","loadSettings","generateToken","trackAuthorizationEvent","forgetCheckout","_remoteCheckoutRequestSender","InitializeRemoteBillingRequested","InitializeRemoteBillingFailed","InitializeRemoteShippingRequested","InitializeRemoteShippingFailed","InitializeRemotePaymentRequested","InitializeRemotePaymentSucceeded","InitializeRemotePaymentFailed","LoadRemoteSettingsRequested","LoadRemoteSettingsFailed","SignOutRemoteCustomerRequested","SignOutRemoteCustomerSucceeded","SignOutRemoteCustomerFailed","ForgetCheckoutRemoteCustomerRequested","ForgetCheckoutRemoteCustomerSucceeded","ForgetCheckoutRemoteCustomerFailed","hasShippingAddress","_getGooglePayPaymentDataRequest","parseResponse","cardType","lastFour","gatewayMerchantId","merchantName","apiVersion","apiVersionMinor","merchantInfo","authJwt","allowedPaymentMethods","parameters","allowedAuthMethods","allowedCardNetworks","billingAddressRequired","billingAddressParameters","Full","phoneNumberRequired","tokenizationSpecification","transactionInfo","totalPriceStatus","totalPrice","emailRequired","shippingAddressRequired","shippingAddressParameters","sourceUrl","baseRequest","_getGooglePaymentDataRequest","supportedCards","paymentGatewaySpecification","_getPaymentGatewaySpecification","cardPaymentMethod","_getCardPaymentMethod","googleBraintreePaymentInstance","_googlePaymentInstance","_createGooglePayPayload","parse","paymentMethodData","tokenizationData","androidPayCards","lastTwo","binData","platformToken","googlePayBraintreePaymentDataRequest","googleMerchantName","googleMerchantId","cardRequirements","billingAddressFormat","_mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2","createPaymentDataRequest","googlePayBraintreeDataRequestV1","paymentMethodTokenizationParameters","_publishableKey","_testMode","checkoutcomkey","_mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2","signature","protocolVersion","signedMessage","_convertToken","cardNetwork","cardDetails","_requestCheckoutcomTokenize","token_data","checkoutcomToken","checkoutcomKey","Json","Authorization","last4","stripeVersion","stripePublishableKey","stripeConnectedAccount","scriptSrc","async","setupPayment","isCredit","isCheckout","isCreditCard","isAPM","getOrderStatus","StyleButtonLabel","StyleButtonLayout","StyleButtonColor","StyleButtonShape","loadPaypalCommerce","isProgressiveOnboardingAvailable","_validateParams","paypalLoadScript","_paypalCommerceRequestSender","_validateStyleParams","updatedStyle","color","layout","tagline","horizontal","paramsScript","_gatewayId","optionalParams","paramsForProvider","onRenderButton","_fundingSource","_paypalButtons","_processNotEligible","renderFields","apmFieldsContainer","apmFieldsStyles","PaymentFields","fieldsParams","fields","_paypalFields","fieldContainerElement","querySelector","innerHTML","getOrderId","_orderId","cartTotal","_paypalMessages","renderHostedFields","events","HostedFields","styles","paymentsSDK","_hostedFields","submitHostedFields","submit","getHostedFieldsValidationState","isValid","close","PAYPAL_COMMERCE_ALTERNATIVE_METHODS","toUpperCase","PAYLATER","createPaypalCommercePaymentProcessor","paypalScriptLoader","paypalCommerceRequestSender","getFirstAndLastName","nameParts","_googlePayScriptLoader","_googlePayInitializer","_configureWallet","Short","Default","_googlePayClient","loadPaymentData","_getPaymentDataRequest","tokenizePayload","_postForm","_updateBillingAddress","_mapGooglePayAddressToShippingAddress","googlePay","paymentDataRequest","_getGooglePayClient","_paymentDataRequest","isReadyToPay","_getCardInformation","cardInformation","number","google","environment","api","PaymentsClient","_mapGooglePayAddressToBillingAddress","customerEmail","companyName","address3","postPaymentData","card_information","remoteBillingAddress","googlePayAddressMapped","createGooglePayPaymentProcessor","initializer","googleRecaptchaScriptLoader","mutationObserverFactory","_memoized","recaptcha","sitekey","event$","_widgetId","getResponse","reset","_event$","_recaptcha","execute","element","TIMEOUT","_watchRecaptchaChallengeWindow","iframeContainer","parentElement","visibility","observe","attributeFilter","_loadPromise","_loadScript","grecaptcha","createSpamProtection","_amazonPayV2ScriptLoader","_amazonPayV2SDK","bindButton","buttonId","sessionId","changeAction","_getAmazonPayV2SDK","Pay","bindChangeAction","amazonCheckoutSessionId","renderButton","signout","region","amazonPayV2Region","amazon","createAmazonPayV2PaymentProcessor","_googleRecaptcha","_isPaymentHumanVerificationRequest","_initialize","additional_action_required","human_verification_token","toPromise","recaptchaSitekey","cardingProtectionElement","_orderRequestSender","_checkoutValidator","loadOrder","loadOrderPayments","_getCurrentOrderId","SubmitOrderRequested","shouldExecuteSpamCheck","_mapToOrderRequestBody","customerMessage","checkoutVariant","SubmitOrderFailed","finalizeOrder","FinalizeOrderRequested","FinalizeOrderFailed","_subscriptionsRequestSender","_subscriptionActionCreator","continueAsGuest","billingAddressRequestBody","existingBillingAddressRequestBody","_createOrUpdateBillingAddress","_updateCustomerConsent","acceptsAbandonedCartEmails","acceptsMarketingNewsletter"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,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D,QAAUkC,QAAQ,W,cCAzBjC,EAAOD,QAAUkC,QAAQ,4B,cCAzBjC,EAAOD,QAAUkC,QAAQ,S,eCAzBjC,EAAOD,QAAUkC,QAAQ,yB,cCAzBjC,EAAOD,QAAUkC,QAAQ,mB,8BCMzB,IAAYC,EAAZ,2CAAYA,GACR,8DACA,8DACA,wDAEA,4DACA,4DACA,sDAEA,4DACA,4DACA,sDAEA,mEACA,mEACA,6DAEA,iEACA,iEACA,2DAnBJ,CAAYA,MAAqB,M,6BCJjC,IAAYC,EAAZ,2CAAYA,GACR,kDACA,wDACA,wDACA,oDACA,0DACA,0DACA,gGACA,sGACA,sGACA,yDACA,+DACA,+DACA,6DACA,mEACA,mEACA,0EACA,4EACA,wEAlBJ,CAAYA,MAA0B,M,6BCFtC,IAAKC,GAAL,SAAKA,GACD,oBACA,uCACA,kBACA,sBACA,kBACA,kDACA,0BACA,sBACA,sBACA,0BACA,cACA,4BACA,mCACA,uCACA,qCACA,uCACA,2BACA,gDACA,sBACA,sBACA,4BACA,gCACA,8BACA,oDACA,cACA,kBACA,sBACA,kBACA,kBACA,kBACA,oBACA,mDACA,oBACA,oBACA,YACA,wCACA,kBACA,iCACA,8CACA,mCACA,gDACA,0DACA,yEACA,2BACA,oBACA,qBACA,oBACA,sBACA,yBACA,6CACA,wBACA,qCACA,mCACA,kDACA,kDACA,4CACA,uBACA,iBACA,0BACA,sCACA,kBACA,YA9DJ,CAAKA,MAAmB,KAiET,O,6BC/Df,IAAYC,EAAZ,2CAAYA,GACR,gEACA,sEACA,sEACA,8DACA,oEACA,oEACA,yDACA,+DACA,+DACA,6DACA,mEACA,mEACA,0EACA,4EACA,wEAfJ,CAAYA,MAA0B,M,6BCEtC,IAAYC,EAAZ,2CAAYA,GACR,kDACA,wDACA,wDACA,oDACA,0DACA,0DACA,wDACA,8DACA,8DACA,4DACA,kEACA,kEACA,yEACA,2EACA,uEAfJ,CAAYA,MAAyB,M,oECFzBC,E,gBAAZ,SAAYA,GACR,q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C,G,IAAA,aAAkD,GAAE,EAAlDC,EAAO,UAAEoQ,EAAO,UAG1D,OAAO5J,KAAKsI,eAAeoS,KAFf,iCAEoD,CAC5DnhB,KAAI,EACJC,QAAS,iBAAO,oBACZ,qBAAsBA,GAAWA,EAAQiqD,iBACtC,KACJ,SACH75C,QAAO,IACRX,OAAM,SAAAnL,GACL,GAAwB,6BAApBA,EAAMvE,KAAK/C,KACX,MAAM,IAAI,EAGd,MAAMsH,MAId,YAAA6lD,cAAA,SAActhD,EAAiB,G,IAAEuH,QAAO,MAAqB,GAAE,WACrDhE,EAAM,kCAAkCvD,EAE9C,OAAOrC,KAAKsI,eAAeoS,KAAK9U,EAAK,CAAEgE,QAAO,EAAEpQ,QAAS,OAEjE,EAvDA,G","file":"checkout-button.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 223);\n","module.exports = require(\"tslib\");","module.exports = require(\"lodash\");","module.exports = require(\"@bigcommerce/data-store\");","module.exports = require(\"rxjs\");","module.exports = require(\"@bigcommerce/memoize\");","module.exports = require(\"rxjs/operators\");","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 { 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","enum PaymentStrategyType {\n ADYENV2 = 'adyenv2',\n ADYENV2_GOOGLEPAY = 'googlepayadyenv2',\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 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 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","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 { 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 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 MissingPaymentInstrument,\n MissingPaymentMethod,\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","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 { 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\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 { 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 { 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 { 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 { 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","export const SDK_VERSION_HEADERS = { 'X-Checkout-SDK-Version': LIBRARY_VERSION };\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 { 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 { 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 { Checkout } 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 GooglePayCreator extends 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 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","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","module.exports = require(\"card-validator\");","enum ContentType {\n Json = 'application/json',\n JsonV1 = 'application/vnd.bc.v1+json',\n}\n\nexport default ContentType;\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 !instrument.hasOwnProperty('ccNumber') &&\n !instrument.hasOwnProperty('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","module.exports = require(\"@bigcommerce/script-loader\");","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","export const ACKNOWLEDGE = 'ACKNOWLEDGE';\nexport const FINALIZE = 'FINALIZE';\nexport const INITIALIZE = 'INITIALIZE';\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","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 { 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 { 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 { 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 { 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 { 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 { 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","module.exports = require(\"@bigcommerce/request-sender\");","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 { 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 { 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 StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import 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","export const HOSTED = 'PAYMENT_TYPE_HOSTED';\nexport const OFFLINE = 'PAYMENT_TYPE_OFFLINE';\n","export const INTERNAL_USE_ONLY = 'This API endpoint is for internal use only and may change in the future';\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","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 { uniq } from 'lodash';\n\nexport default function joinIncludes<T>(includes: T[]): string {\n return uniq(includes).join(',');\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","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 { 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","module.exports = require(\"shallowequal\");","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 (!objectB.hasOwnProperty(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","module.exports = require(\"@bigcommerce/form-poster\");","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 { 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 { 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 { 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 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","module.exports = require(\"@bigcommerce/bigpay-client\");","module.exports = require(\"reselect\");","enum CheckoutButtonMethodType {\n APPLEPAY = 'applepay',\n AMAZON_PAY_V2 = 'amazonpay',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n GOOGLEPAY_ADYENV2 = 'googlepayadyenv2',\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 { 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","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 { 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 { 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\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsSucceeded, this._filterApplePay(response.body), 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 return methods.filter(method => {\n if (method.id === APPLEPAYID && !isApplePayWindow(window)) {\n return false;\n }\n\n return true;\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 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 }: 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 });\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","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 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","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 { 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","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 { 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","/**\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","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 { GooglePayCreator } from '../googlepay';\n\nimport { BraintreeClientCreator, BraintreeDataCollectorCreator, BraintreeHostedFieldsCreator, BraintreeHostWindow, BraintreePaypalCheckoutCreator, BraintreePaypalCreator, BraintreeThreeDSecureCreator, 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\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\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() {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/venmo.min.js`)\n .then(() => {\n if (!this._window.braintree || !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","import { BraintreePaypalButtonInitializeOptions } from '../../../checkout-buttons/strategies/braintree';\nimport { PaymentMethod } from '../../index';\nimport { GooglePaymentData, GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1, GooglePayCreator, TokenizePayload } from '../googlepay';\nimport { PaypalAuthorizeData, PaypalButtonOptions, PaypalButtonRender, PaypalSDK } from '../paypal';\n\nimport { VisaCheckoutInitOptions, VisaCheckoutPaymentSuccessPayload, VisaCheckoutTokenizedPayload } from './visacheckout';\n\nexport const PAYPAL_COMPONENTS = ['buttons', 'messages'];\n\nexport interface BraintreeSDK {\n client?: BraintreeClientCreator;\n dataCollector?: BraintreeDataCollectorCreator;\n hostedFields?: BraintreeHostedFieldsCreator;\n paypal?: BraintreePaypalCreator;\n paypalCheckout?: BraintreePaypalCheckoutCreator;\n venmo?: VenmoInstance;\n threeDSecure?: BraintreeThreeDSecureCreator;\n visaCheckout?: BraintreeVisaCheckoutCreator;\n googlePayment?: GooglePayCreator;\n}\n\nexport interface BraintreeModuleCreator<TInstance, TOptions = BraintreeModuleCreatorConfig> {\n create(config: TOptions, callback?: (error: string, instance: any) => void): Promise<TInstance>;\n}\n\nexport interface BraintreeModuleCreatorConfig {\n client?: BraintreeClient;\n authorization?: string;\n}\n\nexport interface BraintreeDataCollectorCreatorConfig extends BraintreeModuleCreatorConfig {\n kount?: boolean;\n paypal?: boolean;\n}\n\nexport interface BraintreeThreeDSecureCreatorConfig extends BraintreeModuleCreatorConfig {\n version?: number;\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 BraintreeClientCreator extends BraintreeModuleCreator<BraintreeClient> { }\nexport interface BraintreeDataCollectorCreator extends BraintreeModuleCreator<BraintreeDataCollector, BraintreeDataCollectorCreatorConfig> {}\nexport interface BraintreeHostedFieldsCreator extends BraintreeModuleCreator<BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig> {}\nexport interface BraintreeThreeDSecureCreator extends BraintreeModuleCreator<BraintreeThreeDSecure, BraintreeThreeDSecureCreatorConfig> {}\nexport interface BraintreePaypalCreator extends BraintreeModuleCreator<BraintreePaypal> {}\nexport interface BraintreePaypalCheckoutCreator extends BraintreeModuleCreator<BraintreePaypalCheckout> {}\nexport interface BraintreeVisaCheckoutCreator extends BraintreeModuleCreator<BraintreeVisaCheckout> {}\n\nexport interface BraintreeModule {\n teardown(): Promise<void>;\n}\n\nexport interface BraintreeClient {\n request(payload: BraintreeRequestData): Promise<BraintreeTokenizeResponse>;\n getVersion(): string | void;\n}\n\nexport interface BraintreeThreeDSecure extends BraintreeModule {\n verifyCard(options: BraintreeThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n cancelVerifyCard(): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeGooglePayThreeDSecure {\n verifyCard(options: BraintreeGooglePayThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeThreeDSecureOptions {\n nonce: string;\n amount: number;\n showLoader?: boolean;\n addFrame(error: Error | undefined, iframe: HTMLIFrameElement): void;\n removeFrame(): void;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\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 BraintreeDataCollector extends BraintreeModule {\n deviceData?: string;\n}\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 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 authenticationInsight?: {\n merchantAccountId: string;\n };\n fieldsToTokenize?: string[];\n cardholderName?: string;\n billingAddress?: BraintreeBillingAddressRequestData;\n}\n\nexport interface BraintreeHostedFieldsTokenizePayload {\n nonce: string;\n authenticationInsight?: {\n regulationEnvironment: string;\n };\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 BraintreePaypal {\n closeWindow(): void;\n focusWindow(): void;\n tokenize(options: BraintreePaypalRequest): Promise<BraintreeTokenizePayload>;\n Buttons?(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\nexport interface BraintreePaypalCheckout {\n createPayment(options: BraintreePaypalRequest): Promise<string>;\n teardown(): Promise<void>;\n tokenizePayment(options: PaypalAuthorizeData): Promise<BraintreeTokenizePayload>;\n}\n\nexport interface BraintreeVisaCheckout extends BraintreeModule {\n tokenize(payment: VisaCheckoutPaymentSuccessPayload): Promise<VisaCheckoutTokenizedPayload>;\n createInitOptions(options: Partial<VisaCheckoutInitOptions>): VisaCheckoutInitOptions;\n}\n\nexport interface GooglePayBraintreeSDK extends BraintreeModule {\n createPaymentDataRequest(request?: GooglePayBraintreeDataRequest): GooglePayBraintreePaymentDataRequestV1;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\nexport interface BraintreeTokenizeReturn {\n close(): void;\n focus(): void;\n}\n\nexport interface BraintreeHostWindow extends Window {\n braintree?: BraintreeSDK;\n paypal?: PaypalSDK;\n}\n\nexport interface BraintreeTokenizeResponse {\n creditCards: Array<{ nonce: string }>;\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 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}\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 VenmoError {\n code: string;\n details: string;\n message: string;\n type: string;\n name: string;\n}\n\nexport interface VenmoInstance {\n tokenize?(tokenizeCallback: Tokenize): void;\n isBrowserSupported(): boolean;\n create(arg0: VenmoInstanceConfigOptions, arg1: GetVenmoInstance ): void;\n}\n\nexport type VenmoCheckout = Promise<void>;\n\ninterface VenmoInstanceConfigOptions {\n client: BraintreeClient;\n allowDesktop: boolean;\n paymentMethodUsage: string;\n}\n\ntype GetVenmoInstance = (venmoErr: string, venmoInstance: VenmoInstance) => void;\n\ntype Tokenize = (tokenizeError: VenmoError, payload: BraintreeTokenizePayload) => void;\n\nexport interface BraintreeTokenizePayload {\n nonce: string;\n type: 'PaypalAccount' | 'VenmoAccount';\n details: {\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 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 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 message: string;\n}\n\nexport interface BraintreeHostedFormError extends BraintreeError {\n details?: {\n invalidFieldKeys?: string[];\n };\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\nexport interface RenderButtonsData {\n paymentMethod: PaymentMethod;\n paypalOptions: BraintreePaypalButtonInitializeOptions;\n container: string;\n venmoParentContainer: string;\n messagingContainerId?: string;\n}\n\nexport type RenderButtons = (instance: PaypalClientInstance) => void;\nexport type RenderVenmoButtons = (venmoInstance: VenmoInstance) => void;\n\nexport interface PaypalClientInstance {\n loadPayPalSDK(config: Config, callback: RenderButtons): void;\n tokenizePayment(data: PaypalAuthorizeData): BraintreeTokenizePayload;\n createPayment(data: BraintreePaypalRequest): Promise<string>;\n}\n\nexport interface BraintreeComponents {\n components?: string;\n}\n\nexport interface Config extends BraintreeComponents {\n currency?: string;\n}\n\nexport interface GetPaypalConfig {\n currency?: string;\n storeCountry?: string;\n}\n\nexport interface GetVenmoConfig {\n isBraintreeVenmoEnabled: boolean;\n}\n","import { NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\n\nimport { BraintreeClient,\n BraintreeDataCollector,\n BraintreeHostedFields,\n BraintreeHostedFieldsCreatorConfig,\n BraintreeModule,\n BraintreePaypal,\n BraintreePaypalCheckout,\n BraintreeThreeDSecure,\n BraintreeVisaCheckout,\n GetPaypalConfig,\n GetVenmoConfig,\n GooglePayBraintreeSDK,\n PaypalClientInstance,\n PAYPAL_COMPONENTS,\n RenderButtons,\n RenderVenmoButtons,\n VenmoCheckout,\n VenmoInstance } 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 _dataCollectors: {\n default?: Promise<BraintreeDataCollector>;\n paypal?: Promise<BraintreeDataCollector>;\n } = {};\n private _googlePay?: Promise<GooglePayBraintreeSDK>;\n private _paypalcheckoutInstance?: PaypalClientInstance;\n private _venmoCheckoutInstance?: VenmoInstance;\n private _venmoCheckout?: VenmoCheckout;\n\n constructor(\n private _braintreeScriptLoader: BraintreeScriptLoader\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 getPaypalCheckout(config: GetPaypalConfig, renderButtonCallback: RenderButtons): Promise<BraintreePaypalCheckout> {\n if (!this._paypalCheckout) {\n this._paypalCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadPaypalCheckout(),\n ])\n .then(([client, paypalCheckout]) => paypalCheckout.create({ client }, (_error: string, instance: PaypalClientInstance) => {\n this._paypalcheckoutInstance = instance;\n instance.loadPayPalSDK({\n currency: config.currency,\n components: PAYPAL_COMPONENTS.toString(),\n }, () => {\n renderButtonCallback(instance);\n });\n }));\n } else if (this._paypalcheckoutInstance) {\n renderButtonCallback(this._paypalcheckoutInstance);\n }\n\n return this._paypalCheckout;\n }\n\n getVenmoCheckout(config: GetVenmoConfig, getVenmoInstance: RenderVenmoButtons): Promise<void> {\n if (!config.isBraintreeVenmoEnabled) {\n return Promise.resolve();\n }\n this._venmoCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadVenmoCheckout(),\n ])\n .then(([client, venmoCheckout]) => venmoCheckout.create({\n client, allowDesktop: true,\n paymentMethodUsage: 'multi_use',\n },\n (venmoErr: string, venmoInstance: VenmoInstance) => {\n this._venmoCheckoutInstance = venmoInstance;\n getVenmoInstance(this._venmoCheckoutInstance);\n if (venmoErr) {\n return;\n }\n\n if (!venmoInstance.isBrowserSupported()) {\n\n return;\n }\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._visaCheckout),\n this._teardown(this._googlePay),\n ]).then(() => {\n this._3ds = undefined;\n this._visaCheckout = undefined;\n this._dataCollectors = {};\n this._googlePay = 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 { 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 { 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 { 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 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 { 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 { 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 { 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 { 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, 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 existingConsignment = state.consignments.getConsignmentByAddress(consignment.shippingAddress);\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 shippingAddress: consignment.shippingAddress,\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 existingConsignment = state.consignments.getConsignmentByAddress(consignment.shippingAddress);\n\n return this._createOrUpdateConsignment({\n id: existingConsignment && existingConsignment.id,\n shippingAddress: consignment.shippingAddress,\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 shippingAddress: 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 shippingAddress,\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","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","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 { 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","export default function isPrivate(key: string): boolean {\n return `${key}`.indexOf('$$') === 0 || `${key}`.indexOf('_') === 0;\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","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';\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","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","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.hasOwnProperty(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 { 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 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 flattenedMeta = objectFlatten(action.meta);\n const sortedflattenedMeta = objectWithSortedKeys(flattenedMeta);\n const keyString = btoa(`${JSON.stringify(sortedflattenedMeta)}`);\n\n return objectSet(data, keyString , action.payload);\n }\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 { 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 { 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 { 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 { 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","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 { 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 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 '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 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};\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 { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { isAddressEqual, AddressRequestBody } from '../address';\nimport { CartSelector, PhysicalItem } from '../cart';\nimport { createSelector } from '../common/selector';\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 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 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 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 { 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 { createSelector } from '../common/selector';\n\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\n\nexport default interface ShippingAddressSelector {\n getShippingAddress(): Address | undefined;\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 if (!consignments || !consignments[0]) {\n return;\n }\n\n return consignments[0].shippingAddress;\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE\n ): ShippingAddressSelector => {\n return {\n getShippingAddress: getShippingAddress(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { CheckoutSelector } from '../checkout';\nimport { createSelector } from '../common/selector';\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 getPaymentStatus(): string | undefined;\n getPaymentToken(): string | undefined;\n getPaymentRedirectUrl(): string | undefined;\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 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 getPaymentToken = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.token;\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 isPaymentDataRequired = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getOutstandingBalance,\n getOutstandingBalance => (useStoreCredit: boolean = 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 getPaymentStatus: getPaymentStatus({ checkout, order }),\n getPaymentToken: getPaymentToken({ checkout, order }),\n getPaymentRedirectUrl: getPaymentRedirectUrl({ 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 { createSelector } from '../../common/selector';\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 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 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 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 { 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';\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","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 { 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.hasOwnProperty(key)\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 { 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","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","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","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 { 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","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 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: string = '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 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 availableOptions = checkout.consignments[0].availableShippingOptions;\n const shippingOptions = availableOptions?.map(option => ({\n label: option.description,\n amount: `${option.cost.toFixed(decimalPlaces)}`,\n detail: option.additionalDescription,\n identifier: option.id,\n }));\n\n if (!isShippingOptions(availableOptions)) {\n throw new Error('Shipping options not available.');\n } else {\n const recommendedOption = availableOptions.find(\n option => option.isRecommended\n );\n\n const optionId = recommendedOption ? recommendedOption.id : availableOptions[0].id;\n try {\n await this._updateShippingOption(optionId);\n } catch (error) {\n throw new Error('Shipping options update failed');\n }\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","export 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 { 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 { CheckoutButtonStrategy } from './strategies';\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(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","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 } } = 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 url: `${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 { FormPoster } from '@bigcommerce/form-poster';\nimport { pick } from 'lodash';\n\nimport { Address, LegacyAddress } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType, StandardError } from '../../../common/error/errors';\nimport { PaymentMethod } from '../../../payment';\nimport { BraintreeError,\n BraintreePaypalCheckout,\n BraintreeShippingAddressOverride,\n BraintreeSDKCreator,\n BraintreeTokenizePayload,\n PaypalClientInstance,\n RenderButtonsData,\n VenmoError,\n VenmoInstance } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalButtonStyleOptions, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\nimport { CheckoutButtonMethodType } from '../index';\n\nimport { BraintreePaypalButtonInitializeOptions } from './braintree-paypal-button-options';\n\nexport default class BraintreePaypalButtonStrategy implements CheckoutButtonStrategy {\n private _paypalCheckout?: BraintreePaypalCheckout;\n private _paymentMethod?: PaymentMethod;\n\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 private _renderButtonsData?: RenderButtonsData\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const paypalOptions = (this._offerCredit ? options.braintreepaypalcredit : options.braintreepaypal) || {};\n const state = this._store.getState();\n const paymentMethod = this._paymentMethod = state.paymentMethods.getPaymentMethod(options.methodId);\n const isVenmoEnabled = paymentMethod?.initializationData?.isBraintreeVenmoEnabled;\n const storeState = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const currency = storeState.config.getStoreConfig()?.shopperCurrency;\n\n if (!paymentMethod || !paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n const container = `#${options.containerId}`;\n const messagingContainerId = options.braintreepaypal?.messagingContainerId;\n const venmoParentContainer = options.containerId;\n\n this._renderButtonsData = {\n paymentMethod,\n paypalOptions,\n container,\n messagingContainerId,\n venmoParentContainer,\n };\n\n return Promise.all([\n this._braintreeSDKCreator.getPaypalCheckout({currency: currency?.code}, (paypalCheckoutInstance: PaypalClientInstance) => this._renderButtons(paypalCheckoutInstance)),\n this._braintreeSDKCreator.getVenmoCheckout({isBraintreeVenmoEnabled: !!isVenmoEnabled}, (venmoCheckoutInstance: VenmoInstance): Promise<VenmoInstance> | void => this._renderVenmoButton(venmoCheckoutInstance)),\n this._braintreeSDKCreator.getPaypal(),\n ])\n .then(([paypalCheckout]) => {\n if (!this._paypalCheckout) {\n this._paypalCheckout = paypalCheckout;\n }\n });\n }\n\n deinitialize(): Promise<void> {\n this._paymentMethod = undefined;\n this._paypalCheckout = undefined;\n\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderButtons(paypalCheckoutInstance: PaypalClientInstance) {\n const { paypalOptions, paymentMethod, container, messagingContainerId } = this._renderButtonsData as RenderButtonsData;\n const { paypal } = this._window;\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const storeConfig = state.config.getStoreConfigOrThrow();\n let updatedPaypalOptions: BraintreePaypalButtonInitializeOptions;\n const isMessageContainerAvailable = Boolean(messagingContainerId && document.getElementById(messagingContainerId));\n const ppsdkFeatureOn = storeConfig?.checkoutSettings.features['PAYPAL-1149.braintree-new-card-below-totals-banner-placement'];\n\n if (paypal) {\n const FUNDING_SOURCES = [];\n for (const fundingKey in paypal.FUNDING) {\n if (paypal.FUNDING.hasOwnProperty(fundingKey)) {\n const skipCreditSource = (fundingKey === 'CREDIT' || fundingKey === 'PAYLATER') && !paypalOptions.allowCredit;\n if (fundingKey === 'CARD' || skipCreditSource) {\n continue;\n }\n FUNDING_SOURCES.push(fundingKey.toLowerCase());\n }\n }\n\n if (paypalOptions) {\n updatedPaypalOptions = this._validateHeight(paypalOptions);\n }\n\n FUNDING_SOURCES.forEach(source => {\n const button = paypal.Buttons({\n env: paymentMethod.config.testMode ? 'sandbox' : 'production',\n fundingSource: source,\n commit: false,\n style: {\n shape: 'rect',\n label: this._offerCredit ? 'credit' : undefined,\n ...pick(updatedPaypalOptions.style, 'layout', 'size', 'color', 'label', 'shape', 'tagline', 'fundingicons', 'height'),\n },\n createOrder: () => this._setupPayment(paypalCheckoutInstance, paypalOptions.shippingAddress, paypalOptions.onPaymentError),\n onApprove: (data: PaypalAuthorizeData) => this._tokenizePayment(data, paypalCheckoutInstance, paypalOptions.shouldProcessPayment, paypalOptions.onAuthorizeError),\n });\n\n if (button.isEligible()) {\n button.render(container);\n }\n });\n if (isMessageContainerAvailable && ppsdkFeatureOn && messagingContainerId) {\n this._renderMessages(cart.cartAmount, messagingContainerId);\n }\n }\n }\n\n private _renderVenmoButton(venmoInstance: VenmoInstance) {\n const venmoContainer = this._renderButtonsData?.venmoParentContainer;\n const venmoButton = document.createElement('div');\n if (venmoContainer) {\n const buttonContainer = document.getElementById(venmoContainer);\n buttonContainer?.appendChild(venmoButton);\n venmoButton.setAttribute('id', 'venmo-button');\n venmoButton.addEventListener('click', () => {\n venmoButton.setAttribute('disabled', 'true');\n if (venmoInstance.tokenize) {\n venmoInstance.tokenize((tokenizeErr: VenmoError, payload: BraintreeTokenizePayload) => {\n venmoButton.removeAttribute('disabled');\n if (tokenizeErr) {\n return this._handleVenmoError(tokenizeErr);\n }\n\n return this._handleSuccess(payload);\n });\n }\n });\n }\n }\n\n private _handleSuccess(payload: BraintreeTokenizePayload) {\n Promise.all([\n this._braintreeSDKCreator.getDataCollector(),\n ]).then(([{ deviceData }]) => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: CheckoutButtonMethodType.BRAINTREE_VENMO,\n action: false ? 'process_payment' : 'set_external_checkout',\n nonce: payload.nonce,\n device_data: deviceData,\n shipping_address: JSON.stringify(this._mapToLegacyShippingAddress(payload)),\n billing_address: JSON.stringify(this._mapToLegacyBillingAddress(payload)),\n });\n });\n\n return payload;\n }\n\n private _handleVenmoError(err: any) {\n throw new Error(err.message);\n }\n\n private _renderMessages(amount: number, containerId: string) {\n const { paypal } = this._window;\n if (!paypal?.Messages) {\n return;\n }\n\n return paypal.Messages({\n amount,\n placement: 'cart',\n }).render(`#${containerId}`);\n }\n\n private _validateHeight(paypalOptions: BraintreePaypalButtonInitializeOptions): BraintreePaypalButtonInitializeOptions {\n const updatedPaypalOptions = {...paypalOptions};\n const { style } = updatedPaypalOptions;\n const { height } = style as PaypalButtonStyleOptions;\n\n if (updatedPaypalOptions.style) {\n if (typeof height === 'number') {\n updatedPaypalOptions.style.height = height < 25\n ? 25\n : (height > 55 ? 55 : height);\n } else {\n delete updatedPaypalOptions.style.height;\n }\n }\n\n return updatedPaypalOptions;\n }\n\n private _setupPayment(\n paypalCheckoutInstance: PaypalClientInstance,\n address?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const checkout = state.checkout.getCheckout();\n const config = state.config.getStoreConfig();\n const customer = state.customer.getCustomer();\n const shippingAddress = address === undefined ?\n customer && customer.addresses && customer.addresses[0] :\n address;\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!config) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckoutConfig);\n }\n\n return paypalCheckoutInstance.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride: shippingAddress ? this._mapToBraintreeAddress(shippingAddress) : undefined,\n amount: checkout?.outstandingBalance,\n currency: config?.currency.code,\n offerCredit: this._offerCredit,\n });\n })\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _tokenizePayment(\n data: PaypalAuthorizeData,\n paypalCheckoutInstance: PaypalClientInstance,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n if (!this._paymentMethod || !paypalCheckoutInstance) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n const methodId = this._paymentMethod.id;\n\n return Promise.all([\n paypalCheckoutInstance.tokenizePayment(data),\n this._braintreeSDKCreator.getDataCollector({ paypal: true }),\n ])\n .then(([payload, { deviceData }]) => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce: payload.nonce,\n device_data: deviceData,\n shipping_address: JSON.stringify(this._mapToLegacyShippingAddress(payload)),\n billing_address: JSON.stringify(this._mapToLegacyBillingAddress(payload)),\n });\n\n return payload;\n })\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _mapToLegacyShippingAddress(payload: BraintreeTokenizePayload): Partial<LegacyAddress> {\n const shippingAddress = payload.details.shippingAddress;\n const recipientName = shippingAddress && shippingAddress.recipientName || '';\n const [firstName, lastName] = recipientName.split(' ');\n\n return {\n email: payload.details.email,\n first_name: firstName,\n last_name: lastName,\n phone_number: payload.details.phone,\n address_line_1: shippingAddress && shippingAddress.line1,\n address_line_2: shippingAddress && shippingAddress.line2,\n city: shippingAddress && shippingAddress.city,\n state: shippingAddress && shippingAddress.state,\n country_code: shippingAddress && shippingAddress.countryCode,\n postal_code: shippingAddress && shippingAddress.postalCode,\n };\n }\n\n private _mapToLegacyBillingAddress(payload: BraintreeTokenizePayload): Partial<LegacyAddress> {\n const billingAddress = payload.details.billingAddress;\n const shippingAddress = payload.details.shippingAddress;\n\n if (billingAddress) {\n return {\n email: payload.details.email,\n first_name: payload.details.firstName,\n last_name: payload.details.lastName,\n phone_number: payload.details.phone,\n address_line_1: billingAddress.line1,\n address_line_2: billingAddress.line2,\n city: billingAddress.city,\n state: billingAddress.state,\n country_code: billingAddress.countryCode,\n postal_code: billingAddress.postalCode,\n };\n }\n\n return {\n email: payload.details.email,\n first_name: payload.details.firstName,\n last_name: payload.details.lastName,\n phone_number: payload.details.phone,\n address_line_1: shippingAddress && shippingAddress.line1,\n address_line_2: shippingAddress && shippingAddress.line2,\n city: shippingAddress && shippingAddress.city,\n state: shippingAddress && shippingAddress.state,\n country_code: shippingAddress && shippingAddress.countryCode,\n postal_code: shippingAddress && shippingAddress.postalCode,\n };\n }\n\n private _mapToBraintreeAddress(address: Address): BraintreeShippingAddressOverride {\n return {\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 recipientName: `${address.firstName} ${address.lastName}`,\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_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","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","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, 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 allowedSources = [];\n const disallowedSources = [];\n\n if (paypalOptions.allowCredit) {\n allowedSources.push(paypal.FUNDING.CREDIT);\n } else {\n disallowedSources.push(paypal.FUNDING.CREDIT);\n }\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: 'rect',\n ...pick(paypalOptions.style, 'layout', 'color', 'label', 'shape', 'tagline', 'fundingicons'),\n size: (paymentMethod.id === 'paypalexpress' && paypalOptions.style?.size === 'small') ? '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\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 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));\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\n return Promise.resolve();\n }\n\n private _handleClickButtonProvider({ fundingSource }: ClickDataOptions): void {\n this._isCredit = fundingSource === 'credit' || fundingSource === 'paylater';\n }\n\n private _tokenizePayment({ orderID }: ApproveDataOptions) {\n if (!orderID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n\n return this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n action: 'set_external_checkout',\n provider: this._isCredit ? 'paypalcommercecredit' : 'paypalcommerce',\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 } = 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 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","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,\n PaymentMethodActionCreator,\n PaymentMethodRequestSender,\n PaymentRequestSender,\n 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, 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 } 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 paypalCommercePaymentProcessor = createPaypalCommercePaymentProcessor(scriptLoader, requestSender);\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 new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader)),\n formPoster,\n undefined,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, () =>\n new BraintreePaypalButtonStrategy(\n store,\n checkoutActionCreator,\n new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader)),\n formPoster,\n true,\n window\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_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(\n new BraintreeSDKCreator(\n new BraintreeScriptLoader(scriptLoader)\n )\n )\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","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 map.hasOwnProperty('cacheKey');\n}\n\nexport function isRootCacheKeyMap(map: RootCacheKeyMap | ChildCacheKeyMap): map is RootCacheKeyMap {\n return map.hasOwnProperty('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","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';\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 { 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 { 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","// tslint:disable-next-line:no-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 { 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 { 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 './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 { 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","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 { 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 { 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 { 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 { 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 { 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 './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","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 { 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 { 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 { 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 { 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: string = '';\n private _testMode: boolean = true;\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('Unable to parse response from Google Pay.');\n }\n\n if (!token.signature || !token.protocolVersion || !token.signedMessage) {\n throw new PaymentMethodFailedError('Unable to parse response from Google Pay.');\n }\n const finalToken = await this._convertToken(this._testMode, this._publishableKey, token);\n\n return {\n nonce: finalToken,\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\n private async _convertToken(testMode: boolean, checkoutcomkey: string, token: CheckoutcomGooglePayToken): Promise<string> {\n if (!token || !token.protocolVersion) {\n throw new PaymentMethodFailedError('Unable to parse response from GooglePay.');\n }\n\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.token;\n }\n\n private async _requestCheckoutcomTokenize(testMode: boolean, checkoutcomKey: string, data = {}): Promise<CheckoutcomToken> {\n const TEST_URL: string = 'https://api.sandbox.checkout.com/tokens';\n const LIVE_URL: string = '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 { 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 { 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 { 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: string = ''): 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 { 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}\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 } = 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\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","export { createTimeout } from '@bigcommerce/request-sender';\n\nexport { createCheckoutButtonInitializer } from '../checkout-buttons';\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 SOFORT: string;\n SEPA: string;\n BLIK: string;\n TRUSTLY: string;\n VERKKOPANKKI: string;\n VENMO: string;\n}\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}\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 { 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@1.0.2/dist/paypal.browser.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 { isNil, omitBy } from 'lodash';\n\nimport { NotImplementedError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentStrategyType from '../../payment-strategy-type';\n\nimport { ButtonsOptions, FieldsOptions, 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\n constructor(\n private _paypalScriptLoader: PaypalCommerceScriptLoader,\n private _paypalCommerceRequestSender: PaypalCommerceRequestSender\n ) {}\n\n async initialize(paramsScript: PaypalCommerceScriptParams, isProgressiveOnboardingAvailable?: boolean, gatewayId?: string): Promise<PaypalCommerceSDK> {\n this._paypal = await this._paypalScriptLoader.loadPaypalCommerce(paramsScript, isProgressiveOnboardingAvailable);\n this._gatewayId = gatewayId;\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 { orderId } = await this._paypalCommerceRequestSender.setupPayment(cartId, {...paramsForProvider, isAPM});\n this._orderId = orderId;\n\n return orderId;\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}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaypalCommercePaymentProcessor, PaypalCommerceRequestSender, PaypalCommerceScriptLoader } from './index';\n\nexport default function createPaypalCommercePaymentProcessor(scriptLoader: ScriptLoader, requestSender: RequestSender) {\n const paypalScriptLoader = new PaypalCommerceScriptLoader(scriptLoader);\n const paypalCommerceRequestSender = new PaypalCommerceRequestSender(requestSender);\n\n return new PaypalCommercePaymentProcessor(paypalScriptLoader, paypalCommerceRequestSender);\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 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 { 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 { 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 { 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 { 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","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 async handle(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._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","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.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 customerMessage: string,\n externalSource?: string\n ): InternalOrderRequestBody {\n const { payment, ...order } = payload;\n\n if (!payment) {\n return {\n ...order,\n customerMessage,\n externalSource,\n };\n }\n\n return {\n ...order,\n customerMessage,\n externalSource,\n payment: {\n paymentData: payment.paymentData,\n name: payment.methodId,\n gateway: payment.gatewayId,\n },\n };\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 { 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 { 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 { 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"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"tslib\"","webpack:///external \"lodash\"","webpack:///external \"@bigcommerce/data-store\"","webpack:///external \"rxjs\"","webpack:///external \"@bigcommerce/memoize\"","webpack:///external \"rxjs/operators\"","webpack:///./src/shipping/consignment-actions.ts","webpack:///./src/customer/customer-strategy-actions.ts","webpack:///./src/payment/payment-strategy-type.ts","webpack:///./src/shipping/shipping-strategy-actions.ts","webpack:///./src/payment/payment-strategy-actions.ts","webpack:///./src/common/error/errors/missing-data-error.ts","webpack:///./src/order/order-actions.ts","webpack:///./src/checkout/checkout-actions.ts","webpack:///./src/remote-checkout/remote-checkout-actions.ts","webpack:///./src/common/error/errors/standard-error.ts","webpack:///./src/common/utility/set-prototype-of.ts","webpack:///./src/payment/payment-method-actions.ts","webpack:///./src/billing/billing-address-actions.ts","webpack:///./src/checkout-buttons/checkout-button-actions.ts","webpack:///./src/common/http-request/sdk-version-headers.ts","webpack:///./src/coupon/coupon-actions.ts","webpack:///./src/customer/customer-actions.ts","webpack:///./src/payment/instrument/instrument-actions.ts","webpack:///./src/payment/strategies/googlepay/googlepay.ts","webpack:///./src/coupon/gift-certificate-actions.ts","webpack:///external \"card-validator\"","webpack:///./src/common/http-request/content-type.ts","webpack:///./src/payment/is-vaulted-instrument.ts","webpack:///external \"@bigcommerce/script-loader\"","webpack:///./src/common/error/errors/request-error.ts","webpack:///./src/payment/payment-status-types.ts","webpack:///./src/payment/errors/payment-method-client-unavailable-error.ts","webpack:///./src/config/config-actions.ts","webpack:///./src/form/form-fields-actions.ts","webpack:///./src/common/utility/is-plain-object.ts","webpack:///./src/geography/country-actions.ts","webpack:///./src/shipping/pickup-option-actions.ts","webpack:///./src/shipping/shipping-country-actions.ts","webpack:///./src/signin-email/signin-email-actions.ts","webpack:///external \"@bigcommerce/request-sender\"","webpack:///./src/payment/payment-actions.ts","webpack:///./src/store-credit/store-credit-actions.ts","webpack:///./src/address/map-to-internal-address.ts","webpack:///./src/common/error/errors/invalid-argument-error.ts","webpack:///./src/cart/map-to-internal-line-items.ts","webpack:///./src/cart/map-gift-certificate-to-internal-line-item.ts","webpack:///./src/payment/payment-method-types.ts","webpack:///./src/common/http-request/internal-api-headers.ts","webpack:///./src/common/error/throw-error-action.ts","webpack:///./src/cart/map-to-internal-line-item.ts","webpack:///./src/common/http-request/join-includes.ts","webpack:///./src/shipping/map-to-internal-shipping-option.ts","webpack:///./src/common/utility/amount-transformer.ts","webpack:///./src/spam-protection/spam-protection-actions.ts","webpack:///external \"shallowequal\"","webpack:///./src/common/utility/is-equal.ts","webpack:///external \"@bigcommerce/form-poster\"","webpack:///./src/customer/map-to-internal-customer.ts","webpack:///./src/order/map-to-internal-order.ts","webpack:///./src/cart/map-to-internal-cart.ts","webpack:///./src/promotion/map-to-discount-notifications.ts","webpack:///./src/payment/errors/payment-method-failed-error.ts","webpack:///./src/common/http-request/join-or-merge-includes.ts","webpack:///./src/common/http-request/merge-includes.ts","webpack:///external \"@bigcommerce/bigpay-client\"","webpack:///external \"reselect\"","webpack:///./src/checkout-buttons/strategies/checkout-button-method-type.ts","webpack:///./src/common/selector/with-memoized-combiner.ts","webpack:///./src/common/error/error-actions.ts","webpack:///./src/payment/payment-method-action-creator.ts","webpack:///./src/payment/payment-method-request-sender.ts","webpack:///./src/checkout/checkout-default-includes.ts","webpack:///./src/payment/strategies/apple-pay/is-apple-pay-window.ts","webpack:///./src/hosted-form/iframe-content/card-expiry-formatter.ts","webpack:///./src/hosted-form/iframe-content/card-number-formatter.ts","webpack:///./src/billing/is-billing-address-like.ts","webpack:///./src/coupon/map-to-internal-coupon.ts","webpack:///./src/common/data-store/cache-action.ts","webpack:///./src/common/data-store/is-action-options.ts","webpack:///./src/common/data-store/cachable-action-decorator.ts","webpack:///./src/common/utility/bind-decorator.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2.ts","webpack:///./src/payment/strategies/braintree/braintree-script-loader.ts","webpack:///./src/payment/strategies/braintree/braintree.ts","webpack:///./src/payment/strategies/braintree/braintree-sdk-creator.ts","webpack:///./src/checkout/errors/checkout-not-available-error.ts","webpack:///./src/payment/payment-request-sender.ts","webpack:///./src/payment/payment-request-transformer.ts","webpack:///./src/coupon/map-to-internal-gift-certificate.ts","webpack:///./src/common/utility/omit-deep.ts","webpack:///./src/checkout/checkout-request-sender.ts","webpack:///./src/checkout/checkout-action-creator.ts","webpack:///./src/shipping/consignment-action-creator.ts","webpack:///./src/shipping/consignment-request-sender.ts","webpack:///./src/payment/strategies/masterpass/get-callback-url.ts","webpack:///./src/payment/payment-action-creator.ts","webpack:///./src/common/utility/is-private.ts","webpack:///./src/common/error/errors/unrecoverable-error.ts","webpack:///./src/common/error/errors/map-from-internal-error-response.ts","webpack:///./src/common/error/request-error-factory.ts","webpack:///./src/common/error/errors/map-from-storefront-error-response.ts","webpack:///./src/common/error/clear-error-reducer.ts","webpack:///./src/common/utility/replace.ts","webpack:///./src/common/utility/object-set.ts","webpack:///./src/billing/billing-address-state.ts","webpack:///./src/billing/billing-address-reducer.ts","webpack:///./src/common/utility/array-replace.ts","webpack:///./src/common/utility/object-merge.ts","webpack:///./src/cart/cart-state.ts","webpack:///./src/cart/cart-reducer.ts","webpack:///./src/checkout-buttons/checkout-button-state.ts","webpack:///./src/checkout-buttons/checkout-button-reducer.ts","webpack:///./src/config/config-state.ts","webpack:///./src/config/config-reducer.ts","webpack:///./src/coupon/coupon-state.ts","webpack:///./src/coupon/coupon-reducer.ts","webpack:///./src/coupon/gift-certificate-state.ts","webpack:///./src/coupon/gift-certificate-reducer.ts","webpack:///./src/customer/customer-state.ts","webpack:///./src/customer/customer-reducer.ts","webpack:///./src/customer/customer-strategy-state.ts","webpack:///./src/customer/customer-strategy-reducer.ts","webpack:///./src/form/form-fields-state.ts","webpack:///./src/form/form-fields-reducer.ts","webpack:///./src/geography/country-state.ts","webpack:///./src/geography/country-reducer.ts","webpack:///./src/order/order-state.ts","webpack:///./src/order/order-reducer.ts","webpack:///./src/payment/payment-reducer.ts","webpack:///./src/payment/payment-method-state.ts","webpack:///./src/payment/payment-method-reducer.ts","webpack:///./src/common/utility/merge-or-push.ts","webpack:///./src/payment/payment-strategy-state.ts","webpack:///./src/payment/payment-strategy-reducer.ts","webpack:///./src/payment/instrument/instrument-state.ts","webpack:///./src/payment/instrument/instrument-reducer.ts","webpack:///./src/remote-checkout/remote-checkout-state.ts","webpack:///./src/remote-checkout/remote-checkout-reducer.ts","webpack:///./src/shipping/consignment-state.ts","webpack:///./src/shipping/consignment-reducer.ts","webpack:///./src/common/utility/object-flatten.ts","webpack:///./src/common/utility/object-with-sorted-keys.ts","webpack:///./src/shipping/pickup-option-state.ts","webpack:///./src/shipping/pickup-option-reducer.ts","webpack:///./src/shipping/shipping-country-state.ts","webpack:///./src/shipping/shipping-country-reducer.ts","webpack:///./src/shipping/shipping-strategy-state.ts","webpack:///./src/shipping/shipping-strategy-reducer.ts","webpack:///./src/signin-email/signin-email-state.ts","webpack:///./src/signin-email/signin-email-reducer.ts","webpack:///./src/store-credit/store-credit-reducer.ts","webpack:///./src/subscription/subscriptions-state.ts","webpack:///./src/subscription/subscriptions-reducer.ts","webpack:///./src/checkout/checkout-state.ts","webpack:///./src/checkout/checkout-reducer.ts","webpack:///./src/common/utility/guard.ts","webpack:///./src/common/utility/create-freeze-proxy.ts","webpack:///./src/form/form-selector.ts","webpack:///./src/payment/instrument/supported-payment-instruments.ts","webpack:///./src/address/is-address-equal.ts","webpack:///./src/shipping/consignment-selector.ts","webpack:///./src/store-credit/store-credit-state.ts","webpack:///./src/checkout/create-internal-checkout-selectors.ts","webpack:///./src/billing/billing-address-selector.ts","webpack:///./src/checkout-buttons/checkout-button-selector.ts","webpack:///./src/coupon/coupon-selector.ts","webpack:///./src/customer/customer-selector.ts","webpack:///./src/remote-checkout/remote-checkout-selector.ts","webpack:///./src/shipping/shipping-address-selector.ts","webpack:///./src/payment/payment-selector.ts","webpack:///./src/signin-email/signin-email-selector.ts","webpack:///./src/cart/cart-selector.ts","webpack:///./src/config/config-selector.ts","webpack:///./src/geography/country-selector.ts","webpack:///./src/customer/customer-strategy-selector.ts","webpack:///./src/coupon/gift-certificate-selector.ts","webpack:///./src/payment/instrument/instrument-selector.ts","webpack:///./src/payment/payment-method-selector.ts","webpack:///./src/payment/payment-strategy-selector.ts","webpack:///./src/shipping/pickup-option-selector.ts","webpack:///./src/shipping/shipping-country-selector.ts","webpack:///./src/shipping/shipping-strategy-selector.ts","webpack:///./src/checkout/checkout-selector.ts","webpack:///./src/order/order-selector.ts","webpack:///./src/store-credit/store-credit-selector.ts","webpack:///./src/subscription/subscriptions-selector.ts","webpack:///./src/checkout/create-checkout-store.ts","webpack:///./src/checkout/create-action-transformer.ts","webpack:///./src/common/error/create-request-error-factory.ts","webpack:///./src/checkout/create-checkout-store-reducer.ts","webpack:///./src/cart/cart-comparator.ts","webpack:///./src/cart/errors/cart-changed-error.ts","webpack:///./src/checkout/checkout-validator.ts","webpack:///./src/payment/strategies/masterpass/masterpass-supported-locales.ts","webpack:///./src/payment/strategies/masterpass/format-locale.ts","webpack:///./src/checkout/checkout-params.ts","webpack:///./src/common/selector/selector-decorator.ts","webpack:///./src/checkout-buttons/checkout-button-error-selector.ts","webpack:///./src/checkout-buttons/checkout-button-status-selector.ts","webpack:///./src/checkout-buttons/create-checkout-button-selectors.ts","webpack:///./src/checkout-buttons/checkout-button-initializer.ts","webpack:///./src/checkout-buttons/strategies/apple-pay/apple-pay-button-strategy.ts","webpack:///./src/common/dom/is-element-id.ts","webpack:///./src/common/dom/set-unique-element-id.ts","webpack:///./src/checkout-buttons/checkout-button-strategy-action-creator.ts","webpack:///./src/checkout-buttons/strategies/amazon-pay-v2/amazon-pay-v2-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/braintree/braintree-paypal-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/googlepay/googlepay-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/masterpass/masterpass-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/paypal/paypal-button-strategy.ts","webpack:///./src/checkout-buttons/strategies/paypal-commerce/paypal-commerce-button-strategy.ts","webpack:///./src/checkout-buttons/create-checkout-button-initializer.ts","webpack:///./src/checkout-buttons/create-checkout-button-registry.ts","webpack:///./src/common/utility/cache-key-maps.ts","webpack:///./src/common/utility/cache-key-resolver.ts","webpack:///./src/common/error/errors/map-from-payment-error-response.ts","webpack:///./src/common/error/errors/timeout-error.ts","webpack:///./src/payment/errors/payment-method-invalid-error.ts","webpack:///./src/common/selector/create-selector.ts","webpack:///./src/subscription/subscriptions-actions.ts","webpack:///./src/payment/create-payment-client.ts","webpack:///./src/config/config-action-creator.ts","webpack:///./src/config/config-request-sender.ts","webpack:///./src/spam-protection/errors/spam-protection-failed-error.ts","webpack:///./src/common/error/errors/not-initialized-error.ts","webpack:///./src/spam-protection/errors/spam-protection-challenge-not-completed-error.ts","webpack:///./src/common/dom/mutation-observer.ts","webpack:///./src/subscription/subscriptions-request-sender.ts","webpack:///./src/form/form-fields-action-creator.ts","webpack:///./src/form/form-fields-request-sender.ts","webpack:///./src/billing/billing-address-request-sender.ts","webpack:///./src/common/registry/registry.ts","webpack:///./src/remote-checkout/remote-checkout-request-sender.ts","webpack:///./src/remote-checkout/remote-checkout-action-creator.ts","webpack:///./src/common/error/errors/not-implemented-error.ts","webpack:///./src/remote-checkout/errors/remote-checkout-synchronization-error.ts","webpack:///./src/payment/strategies/googlepay/googlepay-adyenv2-initializer.ts","webpack:///./src/payment/strategies/masterpass/masterpass-script-loader.ts","webpack:///./src/payment/strategies/googlepay/googlepay-authorizenet-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-braintree-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-checkoutcom-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-cybersourcev2-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-orbital-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-stripe-initializer.ts","webpack:///./src/payment/strategies/googlepay/googlepay-stripe-upe-initializer.ts","webpack:///./src/payment/errors/payment-method-cancelled-error.ts","webpack:///./src/payment/strategies/apple-pay/apple-pay-session-factory.ts","webpack:///./src/payment/strategies/paypal/paypal-script-loader.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-request-sender.ts","webpack:///./src/bundles/checkout-button.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-sdk.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-script-loader.ts","webpack:///./src/payment/strategies/paypal-commerce/paypal-commerce-payment-processor.ts","webpack:///./src/payment/strategies/paypal-commerce/create-paypal-commerce-payment-processor.ts","webpack:///./src/payment/strategies/googlepay/googlepay-get-first-and-last-name.ts","webpack:///./src/payment/strategies/googlepay/googlepay-payment-processor.ts","webpack:///./src/payment/strategies/googlepay/googlepay-script-loader.ts","webpack:///./src/payment/strategies/googlepay/create-googlepay-payment-processor.ts","webpack:///./src/spam-protection/errors/spam-protection-not-loaded-error.ts","webpack:///./src/spam-protection/google-recaptcha.ts","webpack:///./src/spam-protection/google-recaptcha-script-loader.ts","webpack:///./src/spam-protection/create-spam-protection.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2-payment-processor.ts","webpack:///./src/payment/strategies/amazon-pay-v2/amazon-pay-v2-script-loader.ts","webpack:///./src/payment/strategies/amazon-pay-v2/create-amazon-pay-v2-payment-processor.ts","webpack:///./src/spam-protection/errors/carding-protection-challenge-not-completed-error.ts","webpack:///./src/spam-protection/errors/carding-protection-failed-error.ts","webpack:///./src/spam-protection/payment-human-verification-handler.ts","webpack:///./src/spam-protection/errors/spam-protection-not-completed-error.ts","webpack:///./src/order/order-action-creator.ts","webpack:///./src/shipping/getShippableItemsCount.ts","webpack:///./src/shipping/getLineItemsCount.ts","webpack:///./src/subscription/errors/update-subscriptions-error.ts","webpack:///./src/subscription/subscriptions-action-creator.ts","webpack:///./src/billing/errors/unable-to-continue-as-guest-error.ts","webpack:///./src/billing/billing-address-action-creator.ts","webpack:///./src/order/errors/order-tax-provider-unavailable-error.ts","webpack:///./src/order/order-request-sender.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","ConsignmentActionType","CustomerStrategyActionType","PaymentStrategyType","ShippingStrategyActionType","PaymentStrategyActionType","MissingDataErrorType","subtype","type","MissingBillingAddress","MissingCart","MissingConsignments","MissingCheckout","MissingCustomer","MissingCheckoutConfig","MissingOrderConfig","MissingOrder","MissingOrderId","MissingPayment","MissingPaymentToken","MissingPaymentMethod","MissingShippingAddress","getErrorMessage","OrderActionType","CheckoutActionType","RemoteCheckoutActionType","message","setPrototypeOf","__proto__","Error","captureStackTrace","stack","PaymentMethodActionType","BillingAddressActionType","CheckoutButtonActionType","SDK_VERSION_HEADERS","CouponActionType","CustomerActionType","InstrumentActionType","ButtonType","ButtonColor","BillingAddressFormat","GiftCertificateActionType","ContentType","isVaultedInstrument","instrument","Boolean","instrumentId","isHostedVaultedInstrument","isFormattedVaultedInstrument","formattedInstrument","formattedPayload","bigpay_token","token","DEFAULT_RESPONSE","body","headers","status","response","errors","ACKNOWLEDGE","FINALIZE","ConfigActionType","FormFieldsActionType","isPlainObject","CountryActionType","PickupOptionActionType","ShippingCountryActionType","SignInEmailActionType","PaymentActionType","StoreCreditActionType","mapToInternalAddress","address","consignments","addressId","id","length","firstName","lastName","company","addressLine1","address1","addressLine2","address2","city","province","stateOrProvince","provinceCode","stateOrProvinceCode","postCode","postalCode","country","countryCode","phone","customFields","mapToInternalLineItems","itemMap","decimalPlaces","idKey","keys","reduce","result","map","item","amountTransformer","imageUrl","amount","amountAfterDiscount","discount","integerAmount","toInteger","integerAmountAfterDiscount","integerUnitPrice","integerUnitPriceAfterDiscount","integerDiscount","quantity","sender","recipient","attributes","variantId","mapGiftCertificateToInternalLineItem","mapToInternalLineItemType","HOSTED","OFFLINE","INTERNAL_USE_ONLY","throwErrorAction","error","meta","action","payload","mapToInternalLineItem","extendedListPrice","extendedSalePrice","discountAmount","listPrice","salePrice","downloadsPageUrl","downloadPageUrl","brand","sku","categoryNames","productId","options","option","addedByPromotion","joinIncludes","includes","join","mapToInternalShippingOption","isSelected","description","price","cost","selected","isRecommended","transitTime","_decimalPlaces","Math","round","pow","this","SpamProtectionActionType","isEqual","objectA","objectB","Array","isArray","index","isArrayEqual","Date","getTime","isDateEqual","RegExp","toString","isRegExpEqual","filter","keyFilter","keysA","keysB","isObjectEqual","mapToInternalCustomer","customer","billingAddress","addresses","customerId","isGuest","storeCredit","email","fullName","customerGroupName","customerGroup","mapToInternalOrder","order","orderMeta","payments","items","currency","orderId","lineItems","code","customerCanBeCreated","payment","mapToInternalOrderPayment","subtotal","baseAmount","coupon","discountedAmount","coupons","sum","orderToken","callbackUrl","discountNotifications","giftCertificate","providerId","totalDiscountedAmount","appliedGiftCertificates","detail","remainingBalance","remaining","balance","purchaseDate","socialData","mapToInternalSocialDataList","hasDigitalItems","isDownloadable","isComplete","shipping","shippingCostTotal","amountBeforeDiscount","shippingCostBeforeDiscount","integerAmountBeforeDiscount","mapToStoreCredit","taxes","taxTotal","handling","handlingCostTotal","grandTotal","orderAmount","orderAmountAsInteger","mapToInternalPaymentStatus","isDefaultOrderPayment","step","helpText","instructions","returnUrl","socialDataObject","physicalItems","digitalItems","forEach","lineItem","socialMedia","image","url","link","shareText","text","sharingLink","channelName","channel","channelCode","mapToInternalCart","checkout","promotions","notifications","cart","promotion","banners","banner","push","placeholders","discountType","messageHtml","giftCertificates","certificate","used","required","isShippingRequired","taxSubtotal","joinOrMergeIncludes","baseIncludes","includeDictionaryOrList","includesDictionary","deletions","on","additions","mergeIncludes","CheckoutButtonMethodType","withMemoizedCombiner","creator","combiner","args","pop","combinerArgs","ErrorActionType","_requestSender","loadPaymentMethods","observer","next","LoadPaymentMethodsRequested","then","deviceSessionId","sessionHash","LoadPaymentMethodsSucceeded","_filterApplePay","complete","catch","LoadPaymentMethodsFailed","loadPaymentMethod","methodId","LoadPaymentMethodRequested","undefined","LoadPaymentMethodSucceeded","LoadPaymentMethodFailed","methods","method","window","timeout","Accept","JsonV1","isApplePayWindow","assertApplePayWindow","format","split","month","year","trimmedMonth","slice","trimmedYear","toObject","test","card","maxLength","info","lengths","unformattedValue","unformat","gaps","gapIndex","output","replace","isBillingAddressLike","couponTypes","mapToInternalCoupon","displayName","indexOf","couponType","cacheAction","fn","pipe","store","isActionOptions","param","useCache","cachableActionDecorator","_","descriptor","memoizedMethods","WeakMap","decorateMethod","lastArg","instanceMethods","set","bindMethodDecorator","boundMethod","target","decoratedTarget","getOwnPropertyNames","getOwnPropertyDescriptor","bindClassDecorator","AmazonPayV2Regions","AmazonPayV2CheckoutLanguage","AmazonPayV2Placement","AmazonPayV2LedgerCurrency","AmazonPayV2PayOptions","_scriptLoader","_window","loadClient","loadScript","braintree","client","load3DS","threeDSecure","loadDataCollector","dataCollector","loadPaypal","paypal","loadPaypalCheckout","paypalCheckout","loadVisaCheckout","visaCheckout","loadVenmoCheckout","venmo","loadGooglePayment","googlePayment","loadHostedFields","hostedFields","PAYPAL_COMPONENTS","_braintreeScriptLoader","_dataCollectors","initialize","clientToken","_clientToken","getClient","PaymentNotInitialized","_client","authorization","getPaypal","_paypal","Promise","all","getPaypalCheckout","config","renderButtonCallback","_paypalCheckout","_paypalcheckoutInstance","_error","instance","loadPayPalSDK","components","getVenmoCheckout","getVenmoInstance","isBraintreeVenmoEnabled","_venmoCheckout","allowDesktop","paymentMethodUsage","venmoErr","venmoInstance","_venmoCheckoutInstance","isBrowserSupported","resolve","get3DS","_3ds","version","getDataCollector","cacheKey","cached","kount","deviceData","teardown","getVisaCheckout","_visaCheckout","getGooglePaymentComponent","_googlePay","createHostedFields","_teardown","default","mod","title","submitPayment","reject","_transformResponse","initializeOffsitePayment","data","statusText","_cardExpiryFormatter","_cardNumberFormatter","transform","checkoutState","getBillingAddress","getCheckout","getCustomer","getOrder","paymentMethod","paymentMethods","getPaymentMethod","gatewayId","shippingAddress","getShippingAddress","getConsignments","shippingOption","getShippingOption","storeConfig","getStoreConfig","contextConfig","getContextConfig","instrumentMeta","instruments","getInstrumentsMeta","paymentMeta","getPaymentMethodsMeta","getOrderMeta","internalCustomer","authToken","paymentData","getPaymentToken","vaultAccessToken","additionalAction","_transformPaymentMethod","quoteMeta","request","geoCountryCode","source","storeProfile","transformWithHostedFormData","values","nonce","paymentMethodMeta","consignment","selectedShippingOption","_transformHostedInputValues","context","gateway","initializationData","BRAINTREE_VENMO","BRAINTREE_PAYPAL","ccCvv","cardCodeVerification","ccNumber","cardNumberVerification","hostedFormNonce","cardCode","ccExpiry","cardExpiry","ccName","cardName","cardNumber","mapToInternalGiftCertificate","omitDeep","predicate","loadCheckout","params","include","updateCheckout","put","_checkoutRequestSender","_configActionCreator","_formFieldsActionCreator","LoadCheckoutRequested","loadConfig","loadFormFields","LoadCheckoutSucceeded","LoadCheckoutFailed","loadDefaultCheckout","state","getState","checkoutId","UpdateCheckoutRequested","UpdateCheckoutSucceeded","UpdateCheckoutFailed","loadCurrentCheckout","_consignmentRequestSender","unassignItemsByAddress","existingConsignment","getConsignmentByAddress","_removeLineItems","getCart","updateConsignment","deleteConsignment","assignItemsByAddress","_createOrUpdateConsignment","_addLineItems","selectShippingOption","consignmentUpdateBody","shippingOptionId","consignmentMeta","UpdateShippingOptionRequested","UpdateShippingOptionSucceeded","UpdateShippingOptionFailed","loadShippingOptions","LoadShippingOptionsRequested","AvailableShippingOptions","LoadShippingOptionsSucceeded","LoadShippingOptionsFailed","updateAddress","_getUpdateAddressRequestBody","createConsignments","CreateConsignmentsRequested","CreateConsignmentsSucceeded","CreateConsignmentsFailed","UpdateConsignmentRequested","UpdateConsignmentSucceeded","UpdateConsignmentFailed","consignmentId","DeleteConsignmentRequested","DeleteConsignmentSucceeded","DeleteConsignmentFailed","updateShippingOption","_isUpdateConsignmentRequest","customItems","itemId","_hydrateLineItems","lineItemIds","existingItem","sharedItem","concat","DEFAULT_INCLUDES","post","delete","getCallbackUrl","origin","location","_paymentRequestSender","_orderActionCreator","_paymentRequestTransformer","_paymentHumanVerificationHandler","promise","shouldSaveInstrument","shouldSetAsDefaultInstrument","vault_payment_instrument","set_as_default_stored_instrument","InitializeOffsitePaymentRequested","race","InitializeOffsitePaymentSucceeded","InitializeOffsitePaymentFailed","SubmitPaymentRequested","handle","loadCurrentOrder","SubmitPaymentSucceeded","SubmitPaymentFailed","isPrivate","joinErrors","_factoryMethods","register","mapFromInternalErrorResponse","mapFromStorefrontErrorResponse","factoryMethod","createError","_getType","_isStorefrontErrorResponseBody","_isInternalErrorResponseBody","internalType","errorResponse","storefrontErrorResponse","internalErrorResponse","clearErrorReducer","ClearError","isClearErrorAction","currentValue","newValue","objectSet","DEFAULT_STATE","statuses","billingAddressReducer","dataReducer","errorsReducer","statusesReducer","reducer","UpdateBillingAddressSucceeded","ContinueAsGuestSucceeded","LoadOrderSucceeded","UpdateBillingAddressRequested","UpdateBillingAddressFailed","UpdateSubscriptionsRequested","UpdateSubscriptionsSucceeded","ContinueAsGuestRequested","UpdateSubscriptionsFailed","ContinueAsGuestFailed","arrayReplace","currentArray","newArray","matchObject","a","b","sameAsCurrentCount","sameAsNewCount","countSameAsReplaced","replacedValue","newItem","currentItem","objectMerge","currentObject","newObject","cartReducer","ApplyCouponSucceeded","RemoveCouponSucceeded","ApplyGiftCertificateSucceeded","RemoveGiftCertificateSucceeded","DEFAULT_DATA_STATE","initializedContainers","DEFAULT_ERROR_STATE","DEFAULT_STATUS_STATE","checkoutButtonReducer","InitializeButtonSucceeded","containerId","DeinitializeButtonSucceeded","InitializeButtonRequested","InitializeButtonFailed","DeinitializeButtonRequested","DeinitializeButtonFailed","configReducer","LoadConfigSucceeded","LoadConfigFailed","LoadConfigRequested","couponReducer","ApplyCouponRequested","ApplyCouponFailed","RemoveCouponRequested","RemoveCouponFailed","giftCertificateReducer","ApplyGiftCertificateRequested","ApplyGiftCertificateFailed","RemoveGiftCertificateRequested","RemoveGiftCertificateFailed","customerReducer","CreateCustomerAddressSucceeded","CreateCustomerRequested","CreateCustomerSucceeded","CreateCustomerFailed","CreateCustomerAddressRequested","CreateCustomerAddressFailed","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","formFieldsReducer","LoadFormFieldsSucceeded","LoadFormFieldsFailed","LoadFormFieldsRequested","countryReducer","LoadCountriesSucceeded","LoadCountriesRequested","LoadCountriesFailed","orderReducer","metaReducer","LoadOrderPaymentsSucceeded","FinalizeOrderSucceeded","SubmitOrderSucceeded","LoadOrderRequested","LoadOrderPaymentsRequested","LoadOrderFailed","LoadOrderPaymentsFailed","paymentReducer","paymentMethodReducer","array","defaultPredicate","mergeOrPush","methodA","methodB","loadMethodId","loadMethodError","isLoadingMethod","paymentStrategyReducer","ExecuteRequested","ExecuteSucceeded","executeError","executeMethodId","ExecuteFailed","FinalizeRequested","FinalizeSucceeded","finalizeError","finalizeMethodId","FinalizeFailed","isExecuting","isFinalizing","instrumentReducer","LoadInstrumentsSucceeded","vaultedInstruments","DeleteInstrumentSucceeded","LoadInstrumentsRequested","DeleteInstrumentRequested","deleteError","failedInstrument","LoadInstrumentsFailed","DeleteInstrumentFailed","isDeleting","deletingInstrument","remoteCheckoutReducer","InitializeRemoteBillingSucceeded","billing","InitializeRemoteShippingSucceeded","LoadRemoteSettingsSucceeded","UpdateRemoteCheckout","updateShippingOptionError","updateError","isUpdating","isUpdatingShippingOption","consignmentReducer","SignOutCustomerSucceeded","objectFlatten","parent","flattened","keyString","assign","objectWithSortedKeys","sort","previous","current","pickupOptionReducer","LoadPickupOptionsSucceeded","sortedflattenedMeta","btoa","JSON","stringify","LoadPickupOptionsRequested","LoadPickupOptionsFailed","shippingCountryReducer","LoadShippingCountriesSucceeded","LoadShippingCountriesRequested","LoadShippingCountriesFailed","shippingStrategyReducer","UpdateAddressRequested","UpdateAddressSucceeded","updateAddressError","updateAddressMethodId","UpdateAddressFailed","SelectOptionRequested","SelectOptionSucceeded","selectOptionError","selectOptionMethodId","SelectOptionFailed","isUpdatingAddress","isSelectingOption","signInEmailReducer","SendSignInEmailSucceeded","SendSignInEmailRequested","SendSignInEmailFailed","storeCreditReducer","ApplyStoreCreditRequested","ApplyStoreCreditSucceeded","ApplyStoreCreditFailed","subscriptionsReducer","checkoutReducer","VerifyCheckoutSucceeded","guard","errorFactory","createFreezeProxy","trap","proxy","iteratee","getPrototypeOf","traversePrototypeOf","charAt","createProxy","createFormSelectorFactory","getShippingAddressFields","formFields","countries","selectedCountry","field","processField","getBillingAddressFields","getCustomerAccountFields","customerAccount","getLoadError","loadError","isLoading","label","fieldType","itemtype","processCountry","subdivisions","requiresState","processProvince","hasPostalCodes","processsPostCode","provider","barclays","braintreepaypal","authorizenet","elavon","checkoutcom","sagepay","stripe","cybersource","cybersourcev2","converge","bluesnapv2","orbital","paymetric","bolt","digitalriver","moneris","normalize","createConsignmentSelectorFactory","getConsignmentById","addressA","addressB","getCreateError","getLoadShippingOptionsError","loadShippingOptionsError","getUnassignedItems","assignedLineItemIds","itemIds","getUpdateError","getDeleteError","getItemAssignmentError","getUpdateShippingOptionError","isLoadingShippingOptions","isCreating","isAssigningItems","createInternalCheckoutSelectorsFactory","getBillingAddressOrThrow","getContinueAsGuestError","isContinuingAsGuest","getInitializeError","getDeinitializeError","getCoupons","getRemoveError","getApplyError","isApplying","isRemoving","getCustomerOrThrow","getCreateAccountError","isCreatingCustomerAccount","getCreateAddressError","isCreatingCustomerAddress","getInternalPayment","getGatewayPayment","getHostedPayment","getPaymentId","getPaymentStatus","getPaymentRedirectUrl","isPaymentDataRequired","isPaymentDataSubmitted","getEmail","getSendError","isSending","createBillingAddressSelector","continueAsGuestError","createCartSelector","getCartOrThrow","createCartSelectorFactory","createCheckoutButtonSelector","createConfigSelector","getConfig","getFlashMessages","filterType","flashMessages","formState","getStoreConfigOrThrow","getExternalSource","externalSource","getVariantIdentificationToken","variantIdentificationToken","createConfigSelectorFactory","createCountrySelector","getCountries","createCountrySelectorFactory","createCouponSelector","removeCouponError","applyCouponError","isApplyingCoupon","isRemovingCoupon","createCustomerSelector","createAddressError","isCreatingAddress","createCustomerStrategySelector","getSignInError","getSignOutError","getExecutePaymentMethodCheckoutError","getWidgetInteractionError","createCustomerStrategySelectorFactory","createGiftCertificateSelector","getGiftCertificates","removeGiftCertificateError","applyGiftCertificateError","isApplyingGiftCertificate","isRemovingGiftCertificate","createGiftCertificateSelectorFactory","createInstrumentSelector","getInstrumentsByPaymentMethod","paymentMethodKey","currentMethod","getCardInstrument","cards","find","bigpayToken","some","getInstruments","supportedProvider","createInstrumentSelectorFactory","createFormSelector","createPaymentMethodSelector","getPaymentMethods","getPaymentMethodOrThrow","getLoadMethodError","createPaymentMethodSelectorFactory","createPaymentStrategySelector","getExecuteError","getFinalizeError","getWidgetInteractingError","createPaymentStrategySelectorFactory","createPickupOptionSelector","getPickupOptions","pickupOptions","searchArea","sortedFlattenedParams","createPickupOptionSelectorFactory","createRemoteCheckoutSelector","createShippingAddressSelector","createShippingCountrySelector","getShippingCountries","createShippingCountrySelectorFactory","createShippingStrategySelector","getUpdateAddressError","getSelectOptionError","createShippingStrategySelectorFactory","createConsignmentSelector","createCheckoutSelector","getCheckoutOrThrow","getOutstandingBalance","useStoreCredit","max","outstandingBalance","isExecutingSpamCheck","createCheckoutSelectorFactory","createOrderSelector","getOrderOrThrow","currentPayment","paymentId","createOrderSelectorFactory","createPaymentSelector","internalPayment","redirectUrl","createStoreCreditSelector","applyError","createStoreCreditSelectorFactory","createSubscriptionsSelector","createSubscriptionsSelectorFactory","createSignInEmailSelector","signInEmail","sendError","checkoutButton","customerStrategies","form","paymentStrategies","remoteCheckout","shippingCountries","shippingStrategies","subscriptions","selectors","shouldWarnMutation","createCheckoutStore","initialState","requestErrorFactory","factory","actionTransformer","action$","every","createInternalCheckoutSelectors","stateTransformer","cartA","cartB","_normalize","cartAmount","itemA","itemB","localeCompare","giftWrapping","updated","validate","comparator","_compareCoupons","_compareGiftCertificates","_getComparableCheckout","couponsA","couponsB","giftCertificatesA","giftCertificatesB","supportedLocales","es","en","pt","zu","ar","zh","ms","uk","sv","hr","pl","nl","it","de","fr","formatLocale","localeLanguage","toLowerCase","language","formattedLocale","countryLocales","CheckoutIncludes","selectorDecorator","resolver","memoizedMethod","cachedValue","getUsedCount","cache","getKey","selectorMethodDecorator","_checkoutButton","getInitializeButtonError","getDeinitializeButtonError","CheckoutButtonErrorSelector","isInitializingButton","isDeinitializingButton","CheckoutButtonStatusSelector","createCheckoutButtonSelectors","DefaultLabels","_store","_buttonStrategyActionCreator","_state","subscribe","subscriber","filters","initializeButton","containerIds","selector","idPrefix","containers","document","querySelectorAll","container","setUniqueElementId","queueId","dispatch","deinitializeButton","deinitialize","CheckoutButtonInitializer","_registry","_paymentMethodActionCreator","_checkoutActionCreator","_amazonPayV2PaymentProcessor","amazonpay","_createSignInButton","_walletButton","parentNode","removeChild","getElementById","_getAmazonPayV2ButtonOptions","amazonButtonOptions","createButton","shopPath","merchantId","testMode","checkoutLanguage","ledgerCurrency","checkoutSessionMethod","extractAmazonCheckoutSessionId","createCheckoutSession","sandbox","productType","getShippableItemsCount","PayOnly","PayAndShip","placement","Cart","_consignmentActionCreator","_billingAddressActionCreator","_paymentActionCreator","_remoteCheckoutActionCreator","_sessionFactory","_onAuthorizeCallback","_subTotalLabel","Subtotal","_shippingLabel","Shipping","applepay","buttonClassName","onPaymentAuthorize","_paymentMethod","_applePayButton","_createButton","addEventListener","_handleWalletButtonClick","button","createElement","classList","add","setAttribute","appendChild","event","preventDefault","_getBaseRequest","applePaySession","_handleApplePayEvents","begin","storeCountryCode","storeName","merchantCapabilities","supportedNetworks","requiresShipping","requiredBillingContactFields","requiredShippingContactFields","currencyCode","total","toFixed","tax","onvalidatemerchant","_onValidateMerchant","merchantSession","completeMerchantValidation","onshippingcontactselected","_handleShippingContactSelected","onshippingmethodselected","_handleShippingMethodSelected","oncancel","signOut","onpaymentauthorized","_onPaymentAuthorized","_transformContactToAddress","shippingContact","abort","availableOptions","availableShippingOptions","shippingOptions","additionalDescription","identifier","recommendedOption","optionId","_updateShippingOption","completeShippingContactSelection","newShippingMethods","newTotal","newLineItems","_getUpdatedLineItems","completeShippingMethodSelection","validationURL","hostname","bigPayEndpoint","paymentsUrl","credentials","billingContact","apple_pay_token","payment_data","payment_method","transaction_id","transactionIdentifier","transformedBillingAddress","transformedShippingAddress","emailAddress","submitOrder","completePayment","ApplePaySession","STATUS_SUCCESS","STATUS_FAILURE","contact","givenName","familyName","locality","addressLines","phoneNumber","administrativeArea","_braintreeSDKCreator","_formPoster","_offerCredit","_renderButtonsData","paypalOptions","braintreepaypalcredit","isVenmoEnabled","storeState","shopperCurrency","messagingContainerId","venmoParentContainer","paypalCheckoutInstance","_renderButtons","venmoCheckoutInstance","_renderVenmoButton","updatedPaypalOptions","isMessageContainerAvailable","ppsdkFeatureOn","checkoutSettings","features","FUNDING_SOURCES","fundingKey","FUNDING","skipCreditSource","allowCredit","_validateHeight","Buttons","env","fundingSource","commit","style","shape","createOrder","_setupPayment","onPaymentError","onApprove","_tokenizePayment","shouldProcessPayment","onAuthorizeError","isEligible","render","_renderMessages","venmoContainer","venmoButton","buttonContainer","tokenize","tokenizeErr","removeAttribute","_handleVenmoError","_handleSuccess","postForm","payment_type","device_data","shipping_address","_mapToLegacyShippingAddress","billing_address","_mapToLegacyBillingAddress","err","Messages","height","onError","createPayment","flow","enableShippingAddress","shippingAddressEditable","shippingAddressOverride","_mapToBraintreeAddress","offerCredit","CheckoutButtonNotInitialized","tokenizePayment","details","recipientName","first_name","last_name","phone_number","address_line_1","line1","address_line_2","line2","country_code","postal_code","_googlePayPaymentProcessor","googlePayOptions","_getGooglePayOptions","_methodId","_getMethodId","buttonOptions","buttonType","buttonColor","googlePayButton","GOOGLEPAY_ADYENV2","googlepayadyenv2","GOOGLEPAY_AUTHORIZENET","googlepayauthorizenet","GOOGLEPAY_BRAINTREE","googlepaybraintree","GOOGLEPAY_CHECKOUTCOM","googlepaycheckoutcom","GOOGLEPAY_CYBERSOURCEV2","googlepaycybersourcev2","GOOGLEPAY_ORBITAL","googlepayorbital","GOOGLEPAY_STRIPE","googlepaystripe","GOOGLEPAY_STRIPEUPE","googlepaystripeupe","hasPhysicalItems","displayWallet","handleSuccess","updateShippingAddress","_onPaymentSelectComplete","_masterpassScriptLoader","_locale","masterpassScriptLoaderParams","useMasterpassSrc","isMasterpassSrcEnabled","load","masterpass","_masterpassClient","_signInButton","removeEventListener","subdomain","src","_createMasterpassPayload","allowedCardTypes","cartId","_paypalScriptLoader","_host","clientId","allowedSources","disallowedSources","CREDIT","Button","funding","allowed","disallowed","size","actions","onAuthorize","res","_onError","paymentID","payerID","payerId","payerInfo","payer","payer_info","_paypalCommercePaymentProcessor","buttonParams","onClick","_handleClickButtonProvider","paypalCommerce","messagingContainer","isMessagesAvailable","_getParamsScript","renderButtons","renderMessages","_isCredit","orderID","order_id","intent","isPayPalCreditAvailable","attributionId","availableAlternativePaymentMethods","enabledAlternativePaymentMethods","disableFunding","enableFunding","apm","createCheckoutButtonInitializer","host","locale","paymentClient","requestSender","formPoster","registry","scriptLoader","checkoutActionCreator","checkoutRequestSender","paymentMethodActionCreator","remoteCheckoutRequestSender","remoteCheckoutActionCreator","paypalCommercePaymentProcessor","APPLEPAY","BRAINTREE_PAYPAL_CREDIT","MASTERPASS","PAYPALEXPRESS","PAYPALCOMMERCE","AMAZON_PAY_V2","createCheckoutButtonRegistry","isTerminalCacheKeyMap","_lastId","_map","maps","_usedMaps","_options","maxSize","onExpire","_resolveMap","parentMap","usedCount","_generateMap","_removeLeastUsedMap","isMatched","mapIndex","unshift","splice","terminalMap","recentlyUsedMap","_removeMap","isRootCacheKeyMap","mapFromPaymentErrorResponse","SubscriptionsActionType","createPaymentClient","setHost","paymentSettings","bigpayBaseUrl","_configRequestSender","NotInitializedErrorType","CustomerNotInitialized","ShippingNotInitialized","SpamProtectionNotInitialized","callback","MutationObserver","updateSubscriptions","_formFieldsRequestSender","loadFields","DEFAULT_PARAMS","createAddress","_factories","_instances","defaultToken","cacheToken","_getInstance","_hasFactory","_hasInstance","initializeBilling","methodName","initializeShipping","initializePayment","loadSettings","generateToken","trackAuthorizationEvent","forgetCheckout","_remoteCheckoutRequestSender","InitializeRemoteBillingRequested","InitializeRemoteBillingFailed","InitializeRemoteShippingRequested","InitializeRemoteShippingFailed","InitializeRemotePaymentRequested","InitializeRemotePaymentSucceeded","InitializeRemotePaymentFailed","LoadRemoteSettingsRequested","LoadRemoteSettingsFailed","SignOutRemoteCustomerRequested","SignOutRemoteCustomerSucceeded","SignOutRemoteCustomerFailed","ForgetCheckoutRemoteCustomerRequested","ForgetCheckoutRemoteCustomerSucceeded","ForgetCheckoutRemoteCustomerFailed","hasShippingAddress","_getGooglePayPaymentDataRequest","parseResponse","cardType","lastFour","gatewayMerchantId","merchantName","apiVersion","apiVersionMinor","merchantInfo","authJwt","allowedPaymentMethods","parameters","allowedAuthMethods","allowedCardNetworks","billingAddressRequired","billingAddressParameters","Full","phoneNumberRequired","tokenizationSpecification","transactionInfo","totalPriceStatus","totalPrice","emailRequired","shippingAddressRequired","shippingAddressParameters","sourceUrl","baseRequest","_getGooglePaymentDataRequest","supportedCards","paymentGatewaySpecification","_getPaymentGatewaySpecification","cardPaymentMethod","_getCardPaymentMethod","googleBraintreePaymentInstance","_googlePaymentInstance","_createGooglePayPayload","parse","paymentMethodData","tokenizationData","androidPayCards","lastTwo","binData","platformToken","googlePayBraintreePaymentDataRequest","googleMerchantName","googleMerchantId","cardRequirements","billingAddressFormat","_mapGooglePayBraintreeDataRequestToGooglePayDataRequestV2","createPaymentDataRequest","googlePayBraintreeDataRequestV1","paymentMethodTokenizationParameters","_publishableKey","_testMode","checkoutcomkey","_mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2","signature","protocolVersion","signedMessage","_convertToken","cardNetwork","cardDetails","_requestCheckoutcomTokenize","token_data","checkoutcomToken","checkoutcomKey","Json","Authorization","last4","stripeVersion","stripePublishableKey","stripeConnectedAccount","scriptSrc","async","setupPayment","isCredit","isCheckout","isCreditCard","isAPM","getOrderStatus","StyleButtonLabel","StyleButtonLayout","StyleButtonColor","StyleButtonShape","loadPaypalCommerce","isProgressiveOnboardingAvailable","_validateParams","paypalLoadScript","_paypalCommerceRequestSender","_validateStyleParams","updatedStyle","color","layout","tagline","horizontal","paramsScript","_gatewayId","optionalParams","paramsForProvider","onRenderButton","_fundingSource","_paypalButtons","_processNotEligible","renderFields","apmFieldsContainer","apmFieldsStyles","PaymentFields","fieldsParams","fields","_paypalFields","fieldContainerElement","querySelector","innerHTML","getOrderId","_orderId","cartTotal","_paypalMessages","renderHostedFields","events","HostedFields","styles","paymentsSDK","_hostedFields","submitHostedFields","submit","getHostedFieldsValidationState","isValid","close","PAYPAL_COMMERCE_ALTERNATIVE_METHODS","toUpperCase","PAYLATER","createPaypalCommercePaymentProcessor","paypalScriptLoader","paypalCommerceRequestSender","getFirstAndLastName","nameParts","_googlePayScriptLoader","_googlePayInitializer","_configureWallet","Short","Default","_googlePayClient","loadPaymentData","_getPaymentDataRequest","tokenizePayload","_postForm","_updateBillingAddress","_mapGooglePayAddressToShippingAddress","googlePay","paymentDataRequest","_getGooglePayClient","_paymentDataRequest","isReadyToPay","_getCardInformation","cardInformation","number","google","environment","api","PaymentsClient","_mapGooglePayAddressToBillingAddress","customerEmail","companyName","address3","postPaymentData","card_information","remoteBillingAddress","googlePayAddressMapped","createGooglePayPaymentProcessor","initializer","googleRecaptchaScriptLoader","mutationObserverFactory","_memoized","recaptcha","sitekey","event$","_widgetId","getResponse","reset","_event$","_recaptcha","execute","element","TIMEOUT","_watchRecaptchaChallengeWindow","iframeContainer","parentElement","visibility","observe","attributeFilter","_loadPromise","_loadScript","grecaptcha","createSpamProtection","_amazonPayV2ScriptLoader","_amazonPayV2SDK","bindButton","buttonId","sessionId","changeAction","_getAmazonPayV2SDK","Pay","bindChangeAction","amazonCheckoutSessionId","renderButton","signout","region","amazonPayV2Region","amazon","createAmazonPayV2PaymentProcessor","_googleRecaptcha","_isPaymentHumanVerificationRequest","_initialize","additional_action_required","human_verification_token","toPromise","recaptchaSitekey","cardingProtectionElement","_orderRequestSender","_checkoutValidator","loadOrder","loadOrderPayments","_getCurrentOrderId","SubmitOrderRequested","shouldExecuteSpamCheck","_mapToOrderRequestBody","customerMessage","checkoutVariant","SubmitOrderFailed","finalizeOrder","FinalizeOrderRequested","FinalizeOrderFailed","_subscriptionsRequestSender","_subscriptionActionCreator","continueAsGuest","billingAddressRequestBody","existingBillingAddressRequestBody","_createOrUpdateBillingAddress","_updateCustomerConsent","acceptsAbandonedCartEmails","acceptsMarketingNewsletter"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,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UkC,QAAQ,W,cCAzBjC,EAAOD,QAAUkC,QAAQ,4B,cCAzBjC,EAAOD,QAAUkC,QAAQ,S,eCAzBjC,EAAOD,QAAUkC,QAAQ,yB,cCAzBjC,EAAOD,QAAUkC,QAAQ,mB,8BCMzB,IAAYC,EAAZ,2CAAYA,GACR,8DACA,8DACA,wDAEA,4DACA,4DACA,sDAEA,4DACA,4DACA,sDAEA,mEACA,mEACA,6DAEA,iEACA,iEACA,2DAnBJ,CAAYA,MAAqB,M,6BCJjC,IAAYC,EAAZ,2CAAYA,GACR,kDACA,wDACA,wDACA,oDACA,0DACA,0DACA,gGACA,sGACA,sGACA,yDACA,+DACA,+DACA,6DACA,mEACA,mEACA,0EACA,4EACA,wEAlBJ,CAAYA,MAA0B,M,6BCFtC,IAAKC,GAAL,SAAKA,GACD,oBACA,uCACA,kBACA,sBACA,kBACA,kDACA,0BACA,sBACA,sBACA,0BACA,cACA,4BACA,mCACA,uCACA,qCACA,uCACA,2BACA,gDACA,sBACA,sBACA,4BACA,gCACA,8BACA,oDACA,cACA,kBACA,sBACA,kBACA,kBACA,kBACA,oBACA,mDACA,oBACA,oBACA,YACA,wCACA,kBACA,iCACA,8CACA,mCACA,gDACA,0DACA,yEACA,2BACA,oBACA,qBACA,oBACA,sBACA,yBACA,6CACA,wBACA,qCACA,mCACA,kDACA,kDACA,4CACA,uBACA,iBACA,0BACA,sCACA,kBACA,YA9DJ,CAAKA,MAAmB,KAiET,O,6BC/Df,IAAYC,EAAZ,2CAAYA,GACR,gEACA,sEACA,sEACA,8DACA,oEACA,oEACA,yDACA,+DACA,+DACA,6DACA,mEACA,mEACA,0EACA,4EACA,wEAfJ,CAAYA,MAA0B,M,6BCEtC,IAAYC,EAAZ,2CAAYA,GACR,kDACA,wDACA,wDACA,oDACA,0DACA,0DACA,wDACA,8DACA,8DACA,4DACA,kEACA,kEACA,yEACA,2EACA,uEAfJ,CAAYA,MAAyB,M,oECFzBC,E,gBAAZ,SAAYA,GACR,qDACA,i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QAAO,KAIf,YAAA26B,YAAA,SAAYhrC,EAAgC,G,IAAA,aAAkD,GAAE,EAAlDC,EAAO,UAAEoQ,EAAO,UAG1D,OAAO5J,KAAKsI,eAAeoS,KAFf,iCAEoD,CAC5DnhB,KAAI,EACJC,QAAS,iBAAO,oBACZ,qBAAsBA,GAAWA,EAAQkqD,iBACtC,KACJ,SACH95C,QAAO,IACRX,OAAM,SAAAnL,GACL,GAAwB,6BAApBA,EAAMvE,KAAK/C,KACX,MAAM,IAAI,EAGd,MAAMsH,MAId,YAAA8lD,cAAA,SAAcvhD,EAAiB,G,IAAEuH,QAAO,MAAqB,GAAE,WACrDhE,EAAM,kCAAkCvD,EAE9C,OAAOrC,KAAKsI,eAAeoS,KAAK9U,EAAK,CAAEgE,QAAO,EAAEpQ,QAAS,OAEjE,EAvDA,G","file":"checkout-button.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 223);\n","module.exports = require(\"tslib\");","module.exports = require(\"lodash\");","module.exports = require(\"@bigcommerce/data-store\");","module.exports = require(\"rxjs\");","module.exports = require(\"@bigcommerce/memoize\");","module.exports = require(\"rxjs/operators\");","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 { 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","enum PaymentStrategyType {\n ADYENV2 = 'adyenv2',\n ADYENV2_GOOGLEPAY = 'googlepayadyenv2',\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 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 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","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 { 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 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 MissingPaymentInstrument,\n MissingPaymentMethod,\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","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 { 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\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 { 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 { 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 { 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 { 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","export const SDK_VERSION_HEADERS = { 'X-Checkout-SDK-Version': LIBRARY_VERSION };\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 { 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 { 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 { Checkout } 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 GooglePayCreator extends 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 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","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","module.exports = require(\"card-validator\");","enum ContentType {\n Json = 'application/json',\n JsonV1 = 'application/vnd.bc.v1+json',\n}\n\nexport default ContentType;\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 !instrument.hasOwnProperty('ccNumber') &&\n !instrument.hasOwnProperty('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","module.exports = require(\"@bigcommerce/script-loader\");","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","export const ACKNOWLEDGE = 'ACKNOWLEDGE';\nexport const FINALIZE = 'FINALIZE';\nexport const INITIALIZE = 'INITIALIZE';\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","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 { 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 { 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 { 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 { 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 { 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 { 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","module.exports = require(\"@bigcommerce/request-sender\");","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 { 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 { 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 StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import 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","export const HOSTED = 'PAYMENT_TYPE_HOSTED';\nexport const OFFLINE = 'PAYMENT_TYPE_OFFLINE';\n","export const INTERNAL_USE_ONLY = 'This API endpoint is for internal use only and may change in the future';\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","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 { uniq } from 'lodash';\n\nexport default function joinIncludes<T>(includes: T[]): string {\n return uniq(includes).join(',');\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","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 { 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","module.exports = require(\"shallowequal\");","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 (!objectB.hasOwnProperty(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","module.exports = require(\"@bigcommerce/form-poster\");","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 { 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 { 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 { 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 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","module.exports = require(\"@bigcommerce/bigpay-client\");","module.exports = require(\"reselect\");","enum CheckoutButtonMethodType {\n APPLEPAY = 'applepay',\n AMAZON_PAY_V2 = 'amazonpay',\n BRAINTREE_PAYPAL = 'braintreepaypal',\n BRAINTREE_VENMO = 'braintreevenmo',\n BRAINTREE_PAYPAL_CREDIT = 'braintreepaypalcredit',\n GOOGLEPAY_ADYENV2 = 'googlepayadyenv2',\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 { 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","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 { 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 { 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\n observer.next(createAction(PaymentMethodActionType.LoadPaymentMethodsSucceeded, this._filterApplePay(response.body), 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 return methods.filter(method => {\n if (method.id === APPLEPAYID && !isApplePayWindow(window)) {\n return false;\n }\n\n return true;\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 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 }: 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 });\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","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 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","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 { 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","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 { 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","/**\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","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 { GooglePayCreator } from '../googlepay';\n\nimport { BraintreeClientCreator, BraintreeDataCollectorCreator, BraintreeHostedFieldsCreator, BraintreeHostWindow, BraintreePaypalCheckoutCreator, BraintreePaypalCreator, BraintreeThreeDSecureCreator, 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\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\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() {\n return this._scriptLoader\n .loadScript(`//js.braintreegateway.com/web/${version}/js/venmo.min.js`)\n .then(() => {\n if (!this._window.braintree || !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","import { BraintreePaypalButtonInitializeOptions } from '../../../checkout-buttons/strategies/braintree';\nimport { PaymentMethod } from '../../index';\nimport { GooglePaymentData, GooglePayBraintreeDataRequest, GooglePayBraintreePaymentDataRequestV1, GooglePayCreator, TokenizePayload } from '../googlepay';\nimport { PaypalAuthorizeData, PaypalButtonOptions, PaypalButtonRender, PaypalSDK } from '../paypal';\n\nimport { VisaCheckoutInitOptions, VisaCheckoutPaymentSuccessPayload, VisaCheckoutTokenizedPayload } from './visacheckout';\n\nexport const PAYPAL_COMPONENTS = ['buttons', 'messages'];\n\nexport interface BraintreeSDK {\n client?: BraintreeClientCreator;\n dataCollector?: BraintreeDataCollectorCreator;\n hostedFields?: BraintreeHostedFieldsCreator;\n paypal?: BraintreePaypalCreator;\n paypalCheckout?: BraintreePaypalCheckoutCreator;\n venmo?: VenmoInstance;\n threeDSecure?: BraintreeThreeDSecureCreator;\n visaCheckout?: BraintreeVisaCheckoutCreator;\n googlePayment?: GooglePayCreator;\n}\n\nexport interface BraintreeModuleCreator<TInstance, TOptions = BraintreeModuleCreatorConfig> {\n create(config: TOptions, callback?: (error: string, instance: any) => void): Promise<TInstance>;\n}\n\nexport interface BraintreeModuleCreatorConfig {\n client?: BraintreeClient;\n authorization?: string;\n}\n\nexport interface BraintreeDataCollectorCreatorConfig extends BraintreeModuleCreatorConfig {\n kount?: boolean;\n paypal?: boolean;\n}\n\nexport interface BraintreeThreeDSecureCreatorConfig extends BraintreeModuleCreatorConfig {\n version?: number;\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 BraintreeClientCreator extends BraintreeModuleCreator<BraintreeClient> { }\nexport interface BraintreeDataCollectorCreator extends BraintreeModuleCreator<BraintreeDataCollector, BraintreeDataCollectorCreatorConfig> {}\nexport interface BraintreeHostedFieldsCreator extends BraintreeModuleCreator<BraintreeHostedFields, BraintreeHostedFieldsCreatorConfig> {}\nexport interface BraintreeThreeDSecureCreator extends BraintreeModuleCreator<BraintreeThreeDSecure, BraintreeThreeDSecureCreatorConfig> {}\nexport interface BraintreePaypalCreator extends BraintreeModuleCreator<BraintreePaypal> {}\nexport interface BraintreePaypalCheckoutCreator extends BraintreeModuleCreator<BraintreePaypalCheckout> {}\nexport interface BraintreeVisaCheckoutCreator extends BraintreeModuleCreator<BraintreeVisaCheckout> {}\n\nexport interface BraintreeModule {\n teardown(): Promise<void>;\n}\n\nexport interface BraintreeClient {\n request(payload: BraintreeRequestData): Promise<BraintreeTokenizeResponse>;\n getVersion(): string | void;\n}\n\nexport interface BraintreeThreeDSecure extends BraintreeModule {\n verifyCard(options: BraintreeThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n cancelVerifyCard(): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeGooglePayThreeDSecure {\n verifyCard(options: BraintreeGooglePayThreeDSecureOptions): Promise<BraintreeVerifyPayload>;\n}\n\nexport interface BraintreeThreeDSecureOptions {\n nonce: string;\n amount: number;\n showLoader?: boolean;\n addFrame(error: Error | undefined, iframe: HTMLIFrameElement): void;\n removeFrame(): void;\n onLookupComplete(data: BraintreeThreeDSecureVerificationData, next: () => void): void;\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 BraintreeDataCollector extends BraintreeModule {\n deviceData?: string;\n}\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 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 authenticationInsight?: {\n merchantAccountId: string;\n };\n fieldsToTokenize?: string[];\n cardholderName?: string;\n billingAddress?: BraintreeBillingAddressRequestData;\n}\n\nexport interface BraintreeHostedFieldsTokenizePayload {\n nonce: string;\n authenticationInsight?: {\n regulationEnvironment: string;\n };\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 BraintreePaypal {\n closeWindow(): void;\n focusWindow(): void;\n tokenize(options: BraintreePaypalRequest): Promise<BraintreeTokenizePayload>;\n Buttons?(options: PaypalButtonOptions): PaypalButtonRender;\n}\n\nexport interface BraintreePaypalCheckout {\n createPayment(options: BraintreePaypalRequest): Promise<string>;\n teardown(): Promise<void>;\n tokenizePayment(options: PaypalAuthorizeData): Promise<BraintreeTokenizePayload>;\n}\n\nexport interface BraintreeVisaCheckout extends BraintreeModule {\n tokenize(payment: VisaCheckoutPaymentSuccessPayload): Promise<VisaCheckoutTokenizedPayload>;\n createInitOptions(options: Partial<VisaCheckoutInitOptions>): VisaCheckoutInitOptions;\n}\n\nexport interface GooglePayBraintreeSDK extends BraintreeModule {\n createPaymentDataRequest(request?: GooglePayBraintreeDataRequest): GooglePayBraintreePaymentDataRequestV1;\n parseResponse(paymentData: GooglePaymentData): Promise<TokenizePayload>;\n}\n\nexport interface BraintreeTokenizeReturn {\n close(): void;\n focus(): void;\n}\n\nexport interface BraintreeHostWindow extends Window {\n braintree?: BraintreeSDK;\n paypal?: PaypalSDK;\n}\n\nexport interface BraintreeTokenizeResponse {\n creditCards: Array<{ nonce: string }>;\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 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}\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 VenmoError {\n code: string;\n details: string;\n message: string;\n type: string;\n name: string;\n}\n\nexport interface VenmoInstance {\n tokenize?(tokenizeCallback: Tokenize): void;\n isBrowserSupported(): boolean;\n create(arg0: VenmoInstanceConfigOptions, arg1: GetVenmoInstance ): void;\n}\n\nexport type VenmoCheckout = Promise<void>;\n\ninterface VenmoInstanceConfigOptions {\n client: BraintreeClient;\n allowDesktop: boolean;\n paymentMethodUsage: string;\n}\n\ntype GetVenmoInstance = (venmoErr: string, venmoInstance: VenmoInstance) => void;\n\ntype Tokenize = (tokenizeError: VenmoError, payload: BraintreeTokenizePayload) => void;\n\nexport interface BraintreeTokenizePayload {\n nonce: string;\n type: 'PaypalAccount' | 'VenmoAccount';\n details: {\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 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 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 message: string;\n}\n\nexport interface BraintreeHostedFormError extends BraintreeError {\n details?: {\n invalidFieldKeys?: string[];\n };\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\nexport interface RenderButtonsData {\n paymentMethod: PaymentMethod;\n paypalOptions: BraintreePaypalButtonInitializeOptions;\n container: string;\n venmoParentContainer: string;\n messagingContainerId?: string;\n}\n\nexport type RenderButtons = (instance: PaypalClientInstance) => void;\nexport type RenderVenmoButtons = (venmoInstance: VenmoInstance) => void;\n\nexport interface PaypalClientInstance {\n loadPayPalSDK(config: Config, callback: RenderButtons): void;\n tokenizePayment(data: PaypalAuthorizeData): BraintreeTokenizePayload;\n createPayment(data: BraintreePaypalRequest): Promise<string>;\n}\n\nexport interface BraintreeComponents {\n components?: string;\n}\n\nexport interface Config extends BraintreeComponents {\n currency?: string;\n}\n\nexport interface GetPaypalConfig {\n currency?: string;\n storeCountry?: string;\n}\n\nexport interface GetVenmoConfig {\n isBraintreeVenmoEnabled: boolean;\n}\n","import { NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\n\nimport { BraintreeClient,\n BraintreeDataCollector,\n BraintreeHostedFields,\n BraintreeHostedFieldsCreatorConfig,\n BraintreeModule,\n BraintreePaypal,\n BraintreePaypalCheckout,\n BraintreeThreeDSecure,\n BraintreeVisaCheckout,\n GetPaypalConfig,\n GetVenmoConfig,\n GooglePayBraintreeSDK,\n PaypalClientInstance,\n PAYPAL_COMPONENTS,\n RenderButtons,\n RenderVenmoButtons,\n VenmoCheckout,\n VenmoInstance } 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 _dataCollectors: {\n default?: Promise<BraintreeDataCollector>;\n paypal?: Promise<BraintreeDataCollector>;\n } = {};\n private _googlePay?: Promise<GooglePayBraintreeSDK>;\n private _paypalcheckoutInstance?: PaypalClientInstance;\n private _venmoCheckoutInstance?: VenmoInstance;\n private _venmoCheckout?: VenmoCheckout;\n\n constructor(\n private _braintreeScriptLoader: BraintreeScriptLoader\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 getPaypalCheckout(config: GetPaypalConfig, renderButtonCallback: RenderButtons): Promise<BraintreePaypalCheckout> {\n if (!this._paypalCheckout) {\n this._paypalCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadPaypalCheckout(),\n ])\n .then(([client, paypalCheckout]) => paypalCheckout.create({ client }, (_error: string, instance: PaypalClientInstance) => {\n this._paypalcheckoutInstance = instance;\n instance.loadPayPalSDK({\n currency: config.currency,\n components: PAYPAL_COMPONENTS.toString(),\n }, () => {\n renderButtonCallback(instance);\n });\n }));\n } else if (this._paypalcheckoutInstance) {\n renderButtonCallback(this._paypalcheckoutInstance);\n }\n\n return this._paypalCheckout;\n }\n\n getVenmoCheckout(config: GetVenmoConfig, getVenmoInstance: RenderVenmoButtons): Promise<void> {\n if (!config.isBraintreeVenmoEnabled) {\n return Promise.resolve();\n }\n this._venmoCheckout = Promise.all([\n this.getClient(),\n this._braintreeScriptLoader.loadVenmoCheckout(),\n ])\n .then(([client, venmoCheckout]) => venmoCheckout.create({\n client, allowDesktop: true,\n paymentMethodUsage: 'multi_use',\n },\n (venmoErr: string, venmoInstance: VenmoInstance) => {\n this._venmoCheckoutInstance = venmoInstance;\n getVenmoInstance(this._venmoCheckoutInstance);\n if (venmoErr) {\n return;\n }\n\n if (!venmoInstance.isBrowserSupported()) {\n\n return;\n }\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._visaCheckout),\n this._teardown(this._googlePay),\n ]).then(() => {\n this._3ds = undefined;\n this._visaCheckout = undefined;\n this._dataCollectors = {};\n this._googlePay = 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 { 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 { 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 { 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 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 { 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 { 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 { 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 { 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, 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 existingConsignment = state.consignments.getConsignmentByAddress(consignment.shippingAddress);\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 shippingAddress: consignment.shippingAddress,\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 existingConsignment = state.consignments.getConsignmentByAddress(consignment.shippingAddress);\n\n return this._createOrUpdateConsignment({\n id: existingConsignment && existingConsignment.id,\n shippingAddress: consignment.shippingAddress,\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 shippingAddress: 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 shippingAddress,\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","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","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 { 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","export default function isPrivate(key: string): boolean {\n return `${key}`.indexOf('$$') === 0 || `${key}`.indexOf('_') === 0;\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","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';\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","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","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.hasOwnProperty(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 { 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 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 flattenedMeta = objectFlatten(action.meta);\n const sortedflattenedMeta = objectWithSortedKeys(flattenedMeta);\n const keyString = btoa(`${JSON.stringify(sortedflattenedMeta)}`);\n\n return objectSet(data, keyString , action.payload);\n }\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 { 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 { 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 { 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 { 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","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 { 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 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 '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};\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 { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { isAddressEqual, AddressRequestBody } from '../address';\nimport { CartSelector, PhysicalItem } from '../cart';\nimport { createSelector } from '../common/selector';\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 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 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 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 { 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 { createSelector } from '../common/selector';\n\nimport ConsignmentState, { DEFAULT_STATE } from './consignment-state';\n\nexport default interface ShippingAddressSelector {\n getShippingAddress(): Address | undefined;\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 if (!consignments || !consignments[0]) {\n return;\n }\n\n return consignments[0].shippingAddress;\n }\n );\n\n return memoizeOne((\n state: ConsignmentState = DEFAULT_STATE\n ): ShippingAddressSelector => {\n return {\n getShippingAddress: getShippingAddress(state),\n };\n });\n}\n","import { memoizeOne } from '@bigcommerce/memoize';\nimport { find } from 'lodash';\n\nimport { CheckoutSelector } from '../checkout';\nimport { createSelector } from '../common/selector';\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 getPaymentStatus(): string | undefined;\n getPaymentToken(): string | undefined;\n getPaymentRedirectUrl(): string | undefined;\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 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 getPaymentToken = createSelector(\n ({ order }: PaymentSelectorDependencies) => order.getOrderMeta,\n getOrderMeta => () => {\n const meta = getOrderMeta();\n\n return meta && meta.token;\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 isPaymentDataRequired = createSelector(\n ({ checkout }: PaymentSelectorDependencies) => checkout.getOutstandingBalance,\n getOutstandingBalance => (useStoreCredit: boolean = 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 getPaymentStatus: getPaymentStatus({ checkout, order }),\n getPaymentToken: getPaymentToken({ checkout, order }),\n getPaymentRedirectUrl: getPaymentRedirectUrl({ 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 { createSelector } from '../../common/selector';\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 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 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 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 { 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';\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","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 { 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.hasOwnProperty(key)\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 { 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","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","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","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 { 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","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 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: string = '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 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 availableOptions = checkout.consignments[0].availableShippingOptions;\n const shippingOptions = availableOptions?.map(option => ({\n label: option.description,\n amount: `${option.cost.toFixed(decimalPlaces)}`,\n detail: option.additionalDescription,\n identifier: option.id,\n }));\n\n if (!isShippingOptions(availableOptions)) {\n throw new Error('Shipping options not available.');\n } else {\n const recommendedOption = availableOptions.find(\n option => option.isRecommended\n );\n\n const optionId = recommendedOption ? recommendedOption.id : availableOptions[0].id;\n try {\n await this._updateShippingOption(optionId);\n } catch (error) {\n throw new Error('Shipping options update failed');\n }\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","export 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 { 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 { CheckoutButtonStrategy } from './strategies';\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(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","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 } } = 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 url: `${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 { FormPoster } from '@bigcommerce/form-poster';\nimport { pick } from 'lodash';\n\nimport { Address, LegacyAddress } from '../../../address';\nimport { CheckoutActionCreator, CheckoutStore } from '../../../checkout';\nimport { MissingDataError, MissingDataErrorType, NotInitializedError, NotInitializedErrorType, StandardError } from '../../../common/error/errors';\nimport { PaymentMethod } from '../../../payment';\nimport { BraintreeError,\n BraintreePaypalCheckout,\n BraintreeShippingAddressOverride,\n BraintreeSDKCreator,\n BraintreeTokenizePayload,\n PaypalClientInstance,\n RenderButtonsData,\n VenmoError,\n VenmoInstance } from '../../../payment/strategies/braintree';\nimport { PaypalAuthorizeData, PaypalButtonStyleOptions, PaypalHostWindow } from '../../../payment/strategies/paypal';\nimport { CheckoutButtonInitializeOptions } from '../../checkout-button-options';\nimport CheckoutButtonStrategy from '../checkout-button-strategy';\nimport { CheckoutButtonMethodType } from '../index';\n\nimport { BraintreePaypalButtonInitializeOptions } from './braintree-paypal-button-options';\n\nexport default class BraintreePaypalButtonStrategy implements CheckoutButtonStrategy {\n private _paypalCheckout?: BraintreePaypalCheckout;\n private _paymentMethod?: PaymentMethod;\n\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 private _renderButtonsData?: RenderButtonsData\n ) {}\n\n async initialize(options: CheckoutButtonInitializeOptions): Promise<void> {\n const paypalOptions = (this._offerCredit ? options.braintreepaypalcredit : options.braintreepaypal) || {};\n const state = this._store.getState();\n const paymentMethod = this._paymentMethod = state.paymentMethods.getPaymentMethod(options.methodId);\n const isVenmoEnabled = paymentMethod?.initializationData?.isBraintreeVenmoEnabled;\n const storeState = await this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout());\n const currency = storeState.config.getStoreConfig()?.shopperCurrency;\n\n if (!paymentMethod || !paymentMethod.clientToken) {\n throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);\n }\n\n this._braintreeSDKCreator.initialize(paymentMethod.clientToken);\n const container = `#${options.containerId}`;\n const messagingContainerId = options.braintreepaypal?.messagingContainerId;\n const venmoParentContainer = options.containerId;\n\n this._renderButtonsData = {\n paymentMethod,\n paypalOptions,\n container,\n messagingContainerId,\n venmoParentContainer,\n };\n\n return Promise.all([\n this._braintreeSDKCreator.getPaypalCheckout({currency: currency?.code}, (paypalCheckoutInstance: PaypalClientInstance) => this._renderButtons(paypalCheckoutInstance)),\n this._braintreeSDKCreator.getVenmoCheckout({isBraintreeVenmoEnabled: !!isVenmoEnabled}, (venmoCheckoutInstance: VenmoInstance): Promise<VenmoInstance> | void => this._renderVenmoButton(venmoCheckoutInstance)),\n this._braintreeSDKCreator.getPaypal(),\n ])\n .then(([paypalCheckout]) => {\n if (!this._paypalCheckout) {\n this._paypalCheckout = paypalCheckout;\n }\n });\n }\n\n deinitialize(): Promise<void> {\n this._paymentMethod = undefined;\n this._paypalCheckout = undefined;\n\n this._braintreeSDKCreator.teardown();\n\n return Promise.resolve();\n }\n\n private _renderButtons(paypalCheckoutInstance: PaypalClientInstance) {\n const { paypalOptions, paymentMethod, container, messagingContainerId } = this._renderButtonsData as RenderButtonsData;\n const { paypal } = this._window;\n const state = this._store.getState();\n const cart = state.cart.getCartOrThrow();\n const storeConfig = state.config.getStoreConfigOrThrow();\n let updatedPaypalOptions: BraintreePaypalButtonInitializeOptions;\n const isMessageContainerAvailable = Boolean(messagingContainerId && document.getElementById(messagingContainerId));\n const ppsdkFeatureOn = storeConfig?.checkoutSettings.features['PAYPAL-1149.braintree-new-card-below-totals-banner-placement'];\n\n if (paypal) {\n const FUNDING_SOURCES = [];\n for (const fundingKey in paypal.FUNDING) {\n if (paypal.FUNDING.hasOwnProperty(fundingKey)) {\n const skipCreditSource = (fundingKey === 'CREDIT' || fundingKey === 'PAYLATER') && !paypalOptions.allowCredit;\n if (fundingKey === 'CARD' || skipCreditSource) {\n continue;\n }\n FUNDING_SOURCES.push(fundingKey.toLowerCase());\n }\n }\n\n if (paypalOptions) {\n updatedPaypalOptions = this._validateHeight(paypalOptions);\n }\n\n FUNDING_SOURCES.forEach(source => {\n const button = paypal.Buttons({\n env: paymentMethod.config.testMode ? 'sandbox' : 'production',\n fundingSource: source,\n commit: false,\n style: {\n shape: 'rect',\n label: this._offerCredit ? 'credit' : undefined,\n ...pick(updatedPaypalOptions.style, 'layout', 'size', 'color', 'label', 'shape', 'tagline', 'fundingicons', 'height'),\n },\n createOrder: () => this._setupPayment(paypalCheckoutInstance, paypalOptions.shippingAddress, paypalOptions.onPaymentError),\n onApprove: (data: PaypalAuthorizeData) => this._tokenizePayment(data, paypalCheckoutInstance, paypalOptions.shouldProcessPayment, paypalOptions.onAuthorizeError),\n });\n\n if (button.isEligible()) {\n button.render(container);\n }\n });\n if (isMessageContainerAvailable && ppsdkFeatureOn && messagingContainerId) {\n this._renderMessages(cart.cartAmount, messagingContainerId);\n }\n }\n }\n\n private _renderVenmoButton(venmoInstance: VenmoInstance) {\n const venmoContainer = this._renderButtonsData?.venmoParentContainer;\n const venmoButton = document.createElement('div');\n if (venmoContainer) {\n const buttonContainer = document.getElementById(venmoContainer);\n buttonContainer?.appendChild(venmoButton);\n venmoButton.setAttribute('id', 'venmo-button');\n venmoButton.addEventListener('click', () => {\n venmoButton.setAttribute('disabled', 'true');\n if (venmoInstance.tokenize) {\n venmoInstance.tokenize((tokenizeErr: VenmoError, payload: BraintreeTokenizePayload) => {\n venmoButton.removeAttribute('disabled');\n if (tokenizeErr) {\n return this._handleVenmoError(tokenizeErr);\n }\n\n return this._handleSuccess(payload);\n });\n }\n });\n }\n }\n\n private _handleSuccess(payload: BraintreeTokenizePayload) {\n Promise.all([\n this._braintreeSDKCreator.getDataCollector(),\n ]).then(([{ deviceData }]) => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: CheckoutButtonMethodType.BRAINTREE_VENMO,\n action: false ? 'process_payment' : 'set_external_checkout',\n nonce: payload.nonce,\n device_data: deviceData,\n shipping_address: JSON.stringify(this._mapToLegacyShippingAddress(payload)),\n billing_address: JSON.stringify(this._mapToLegacyBillingAddress(payload)),\n });\n });\n\n return payload;\n }\n\n private _handleVenmoError(err: any) {\n throw new Error(err.message);\n }\n\n private _renderMessages(amount: number, containerId: string) {\n const { paypal } = this._window;\n if (!paypal?.Messages) {\n return;\n }\n\n return paypal.Messages({\n amount,\n placement: 'cart',\n }).render(`#${containerId}`);\n }\n\n private _validateHeight(paypalOptions: BraintreePaypalButtonInitializeOptions): BraintreePaypalButtonInitializeOptions {\n const updatedPaypalOptions = {...paypalOptions};\n const { style } = updatedPaypalOptions;\n const { height } = style as PaypalButtonStyleOptions;\n\n if (updatedPaypalOptions.style) {\n if (typeof height === 'number') {\n updatedPaypalOptions.style.height = height < 25\n ? 25\n : (height > 55 ? 55 : height);\n } else {\n delete updatedPaypalOptions.style.height;\n }\n }\n\n return updatedPaypalOptions;\n }\n\n private _setupPayment(\n paypalCheckoutInstance: PaypalClientInstance,\n address?: Address | null,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<string> {\n return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())\n .then(state => {\n const checkout = state.checkout.getCheckout();\n const config = state.config.getStoreConfig();\n const customer = state.customer.getCustomer();\n const shippingAddress = address === undefined ?\n customer && customer.addresses && customer.addresses[0] :\n address;\n\n if (!checkout) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckout);\n }\n\n if (!config) {\n throw new MissingDataError(MissingDataErrorType.MissingCheckoutConfig);\n }\n\n return paypalCheckoutInstance.createPayment({\n flow: 'checkout',\n enableShippingAddress: true,\n shippingAddressEditable: false,\n shippingAddressOverride: shippingAddress ? this._mapToBraintreeAddress(shippingAddress) : undefined,\n amount: checkout?.outstandingBalance,\n currency: config?.currency.code,\n offerCredit: this._offerCredit,\n });\n })\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _tokenizePayment(\n data: PaypalAuthorizeData,\n paypalCheckoutInstance: PaypalClientInstance,\n shouldProcessPayment?: boolean,\n onError?: (error: BraintreeError | StandardError) => void\n ): Promise<BraintreeTokenizePayload> {\n if (!this._paymentMethod || !paypalCheckoutInstance) {\n throw new NotInitializedError(NotInitializedErrorType.CheckoutButtonNotInitialized);\n }\n\n const methodId = this._paymentMethod.id;\n\n return Promise.all([\n paypalCheckoutInstance.tokenizePayment(data),\n this._braintreeSDKCreator.getDataCollector({ paypal: true }),\n ])\n .then(([payload, { deviceData }]) => {\n this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n provider: methodId,\n action: shouldProcessPayment ? 'process_payment' : 'set_external_checkout',\n nonce: payload.nonce,\n device_data: deviceData,\n shipping_address: JSON.stringify(this._mapToLegacyShippingAddress(payload)),\n billing_address: JSON.stringify(this._mapToLegacyBillingAddress(payload)),\n });\n\n return payload;\n })\n .catch(error => {\n if (onError) {\n onError(error);\n }\n\n throw error;\n });\n }\n\n private _mapToLegacyShippingAddress(payload: BraintreeTokenizePayload): Partial<LegacyAddress> {\n const shippingAddress = payload.details.shippingAddress;\n const recipientName = shippingAddress && shippingAddress.recipientName || '';\n const [firstName, lastName] = recipientName.split(' ');\n\n return {\n email: payload.details.email,\n first_name: firstName,\n last_name: lastName,\n phone_number: payload.details.phone,\n address_line_1: shippingAddress && shippingAddress.line1,\n address_line_2: shippingAddress && shippingAddress.line2,\n city: shippingAddress && shippingAddress.city,\n state: shippingAddress && shippingAddress.state,\n country_code: shippingAddress && shippingAddress.countryCode,\n postal_code: shippingAddress && shippingAddress.postalCode,\n };\n }\n\n private _mapToLegacyBillingAddress(payload: BraintreeTokenizePayload): Partial<LegacyAddress> {\n const billingAddress = payload.details.billingAddress;\n const shippingAddress = payload.details.shippingAddress;\n\n if (billingAddress) {\n return {\n email: payload.details.email,\n first_name: payload.details.firstName,\n last_name: payload.details.lastName,\n phone_number: payload.details.phone,\n address_line_1: billingAddress.line1,\n address_line_2: billingAddress.line2,\n city: billingAddress.city,\n state: billingAddress.state,\n country_code: billingAddress.countryCode,\n postal_code: billingAddress.postalCode,\n };\n }\n\n return {\n email: payload.details.email,\n first_name: payload.details.firstName,\n last_name: payload.details.lastName,\n phone_number: payload.details.phone,\n address_line_1: shippingAddress && shippingAddress.line1,\n address_line_2: shippingAddress && shippingAddress.line2,\n city: shippingAddress && shippingAddress.city,\n state: shippingAddress && shippingAddress.state,\n country_code: shippingAddress && shippingAddress.countryCode,\n postal_code: shippingAddress && shippingAddress.postalCode,\n };\n }\n\n private _mapToBraintreeAddress(address: Address): BraintreeShippingAddressOverride {\n return {\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 recipientName: `${address.firstName} ${address.lastName}`,\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_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","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","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, 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 allowedSources = [];\n const disallowedSources = [];\n\n if (paypalOptions.allowCredit) {\n allowedSources.push(paypal.FUNDING.CREDIT);\n } else {\n disallowedSources.push(paypal.FUNDING.CREDIT);\n }\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: 'rect',\n ...pick(paypalOptions.style, 'layout', 'color', 'label', 'shape', 'tagline', 'fundingicons'),\n size: (paymentMethod.id === 'paypalexpress' && paypalOptions.style?.size === 'small') ? '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\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 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));\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\n return Promise.resolve();\n }\n\n private _handleClickButtonProvider({ fundingSource }: ClickDataOptions): void {\n this._isCredit = fundingSource === 'credit' || fundingSource === 'paylater';\n }\n\n private _tokenizePayment({ orderID }: ApproveDataOptions) {\n if (!orderID) {\n throw new MissingDataError(MissingDataErrorType.MissingPayment);\n }\n\n return this._formPoster.postForm('/checkout.php', {\n payment_type: 'paypal',\n action: 'set_external_checkout',\n provider: this._isCredit ? 'paypalcommercecredit' : 'paypalcommerce',\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 } = 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 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","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,\n PaymentMethodActionCreator,\n PaymentMethodRequestSender,\n PaymentRequestSender,\n 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, 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 } 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 paypalCommercePaymentProcessor = createPaypalCommercePaymentProcessor(scriptLoader, requestSender);\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 new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader)),\n formPoster,\n undefined,\n window\n )\n );\n\n registry.register(CheckoutButtonMethodType.BRAINTREE_PAYPAL_CREDIT, () =>\n new BraintreePaypalButtonStrategy(\n store,\n checkoutActionCreator,\n new BraintreeSDKCreator(new BraintreeScriptLoader(scriptLoader)),\n formPoster,\n true,\n window\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_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(\n new BraintreeSDKCreator(\n new BraintreeScriptLoader(scriptLoader)\n )\n )\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","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 map.hasOwnProperty('cacheKey');\n}\n\nexport function isRootCacheKeyMap(map: RootCacheKeyMap | ChildCacheKeyMap): map is RootCacheKeyMap {\n return map.hasOwnProperty('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","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';\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 { 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 { 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","// tslint:disable-next-line:no-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 { 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 { 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 './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 { 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","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 { 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 { 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 { 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 { 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 { 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 './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","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 { 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 { 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 { 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 { 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: string = '';\n private _testMode: boolean = true;\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('Unable to parse response from Google Pay.');\n }\n\n if (!token.signature || !token.protocolVersion || !token.signedMessage) {\n throw new PaymentMethodFailedError('Unable to parse response from Google Pay.');\n }\n const finalToken = await this._convertToken(this._testMode, this._publishableKey, token);\n\n return {\n nonce: finalToken,\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\n private async _convertToken(testMode: boolean, checkoutcomkey: string, token: CheckoutcomGooglePayToken): Promise<string> {\n if (!token || !token.protocolVersion) {\n throw new PaymentMethodFailedError('Unable to parse response from GooglePay.');\n }\n\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.token;\n }\n\n private async _requestCheckoutcomTokenize(testMode: boolean, checkoutcomKey: string, data = {}): Promise<CheckoutcomToken> {\n const TEST_URL: string = 'https://api.sandbox.checkout.com/tokens';\n const LIVE_URL: string = '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 { 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 { 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 { 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: string = ''): 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 { 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}\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 } = 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\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","export { createTimeout } from '@bigcommerce/request-sender';\n\nexport { createCheckoutButtonInitializer } from '../checkout-buttons';\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 SOFORT: string;\n SEPA: string;\n BLIK: string;\n TRUSTLY: string;\n VERKKOPANKKI: string;\n VENMO: string;\n}\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}\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 { 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@1.0.2/dist/paypal.browser.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 { isNil, omitBy } from 'lodash';\n\nimport { NotImplementedError, NotInitializedError, NotInitializedErrorType } from '../../../common/error/errors';\nimport { PaymentMethodClientUnavailableError } from '../../errors';\nimport PaymentStrategyType from '../../payment-strategy-type';\n\nimport { ButtonsOptions, FieldsOptions, 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\n constructor(\n private _paypalScriptLoader: PaypalCommerceScriptLoader,\n private _paypalCommerceRequestSender: PaypalCommerceRequestSender\n ) {}\n\n async initialize(paramsScript: PaypalCommerceScriptParams, isProgressiveOnboardingAvailable?: boolean, gatewayId?: string): Promise<PaypalCommerceSDK> {\n this._paypal = await this._paypalScriptLoader.loadPaypalCommerce(paramsScript, isProgressiveOnboardingAvailable);\n this._gatewayId = gatewayId;\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 { orderId } = await this._paypalCommerceRequestSender.setupPayment(cartId, {...paramsForProvider, isAPM});\n this._orderId = orderId;\n\n return orderId;\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}\n","import { RequestSender } from '@bigcommerce/request-sender';\nimport { ScriptLoader } from '@bigcommerce/script-loader';\n\nimport { PaypalCommercePaymentProcessor, PaypalCommerceRequestSender, PaypalCommerceScriptLoader } from './index';\n\nexport default function createPaypalCommercePaymentProcessor(scriptLoader: ScriptLoader, requestSender: RequestSender) {\n const paypalScriptLoader = new PaypalCommerceScriptLoader(scriptLoader);\n const paypalCommerceRequestSender = new PaypalCommerceRequestSender(requestSender);\n\n return new PaypalCommercePaymentProcessor(paypalScriptLoader, paypalCommerceRequestSender);\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 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 { 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 { 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 { 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 { 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","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 async handle(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._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","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.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 customerMessage: string,\n externalSource?: string\n ): InternalOrderRequestBody {\n const { payment, ...order } = payload;\n\n if (!payment) {\n return {\n ...order,\n customerMessage,\n externalSource,\n };\n }\n\n return {\n ...order,\n customerMessage,\n externalSource,\n payment: {\n paymentData: payment.paymentData,\n name: payment.methodId,\n gateway: payment.gatewayId,\n },\n };\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 { 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 { 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 { 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"],"sourceRoot":""}