@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.74 kB
JavaScript
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 c,SUPPORTED_LOCALES_US as o,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,n){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||n?.currency,merchantId:e.configuration.merchantId,productType:e.productType,placement:e.placement,sandbox:"TEST"===e.environment}}function s(e){return"US"===e?t:c}function d(e){return"US"===e?o: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,n){const{addressDetails:r,cancelUrl:t,checkoutMode:c,deliverySpecifications:o,returnUrl:u,merchantMetadata:i,chargePermissionType:a,recurringMetadata:l}=e,{storeId:s}=e.configuration,d="ProcessOrder"===c,m=d?f(n):null;return{storeId:s,chargePermissionType:a,webCheckoutDetails:{...d?{checkoutResultReturnUrl:u}:{checkoutReviewReturnUrl:u},...t&&{checkoutCancelUrl:t},...d&&{checkoutMode:c}},...d&&{paymentDetails:{chargeAmount:m,paymentIntent:"Confirm",presentmentCurrency:m.currencyCode,totalOrderAmount:m}},...l&&{recurringMetadata:l},...i&&{merchantMetadata:i},...o&&{deliverySpecifications:o},...r&&{addressDetails:r}}}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