UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 1.75 kB
import{LEDGER_CURRENCIES_PER_REGION as e,AMAZONPAY_URL_US as n,AMAZONPAY_URL_EU 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(e){return"US"===e?n:r}function l(n){return{...n.buttonColor&&{buttonColor:n.buttonColor},...n.design&&{design:g(n.design)},checkoutLanguage:m(n.locale,n.configuration.region),ledgerCurrency:e[n.configuration.region]||n.currency||n.amount?.currency,merchantId:n.configuration.merchantId,productType:n.productType,placement:n.placement,sandbox:"TEST"===n.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