UNPKG

@atlas-kitchen/adyen-web

Version:
3 lines (2 loc) 1.75 kB
import{AMAZONPAY_URL_US as e,AMAZONPAY_URL_EU as n,LEDGER_CURRENCIES_PER_REGION as r,FALLBACK_LOCALE_US as t,FALLBACK_LOCALE_EU as o,SUPPORTED_LOCALES_US as c,SUPPORTED_LOCALES_EU as u}from"./config.js";import{getDecimalAmount as i}from"../../utils/amount-util.js";function a(r){return"US"===r?e:n}function l(e){return{...e.buttonColor&&{buttonColor:e.buttonColor},...e.design&&{design:g(e.design)},checkoutLanguage:m(e.locale,e.configuration.region),ledgerCurrency:r[e.configuration.region]||e.currency||e.amount?.currency,merchantId:e.configuration.merchantId,productType:e.productType,placement:e.placement,sandbox:"TEST"===e.environment}}function s(e){return"US"===e?t:o}function d(e){return"US"===e?c:u}function m(e,n){return d(n).includes(e)?e:s(n)}function g(e){return"noTagline"===e?"C0001":null}function f(e){return{amount:String(i(e.value,e.currency)),currencyCode:e.currency}}function p(e){const{addressDetails:n,cancelUrl:r,checkoutMode:t,deliverySpecifications:o,returnUrl:c,merchantMetadata:u,chargePermissionType:i,recurringMetadata:a}=e,{storeId:l}=e.configuration,s="ProcessOrder"===t,d=s?f(e.amount):null;return{storeId:l,chargePermissionType:i,webCheckoutDetails:{...s?{checkoutResultReturnUrl:c}:{checkoutReviewReturnUrl:c},...r&&{checkoutCancelUrl:r},...s&&{checkoutMode:t}},...s&&{paymentDetails:{chargeAmount:d,paymentIntent:"Confirm",presentmentCurrency:d.currencyCode,totalOrderAmount:d}},...a&&{recurringMetadata:a},...u&&{merchantMetadata:u},...o&&{deliverySpecifications:o},...n&&{addressDetails:n}}}export{l as getAmazonPaySettings,a as getAmazonPayUrl,f as getChargeAmount,m as getCheckoutLocale,g as getDesignCode,s as getFallbackLocale,p as getPayloadJSON,d as getSupportedLocales}; //# sourceMappingURL=utils.js.map