@atlas-kitchen/adyen-web
Version:
3 lines (2 loc) • 2.59 kB
JavaScript
import{AMAZONPAY_URL_US as e,AMAZONPAY_URL_EU as r,LEDGER_CURRENCIES_PER_REGION as t,FALLBACK_LOCALE_US as n,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,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),n.forEach((function(r){a(e,r,t[r])}))}return e}function s(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function f(t){return"US"===t?e:r}function p(e){var r;return s(l({},e.buttonColor&&{buttonColor:e.buttonColor},e.design&&{design:m(e.design)}),{checkoutLanguage:g(e.locale,e.configuration.region),ledgerCurrency:t[e.configuration.region]||e.currency||(null===(r=e.amount)||void 0===r?void 0:r.currency),merchantId:e.configuration.merchantId,productType:e.productType,placement:e.placement,sandbox:"TEST"===e.environment})}function y(e){return"US"===e?n:o}function d(e){return"US"===e?c:u}function g(e,r){return d(r).includes(e)?e:y(r)}function m(e){return"noTagline"===e?"C0001":null}function b(e){return{amount:String(i(e.value,e.currency)),currencyCode:e.currency}}function O(e){const{addressDetails:r,cancelUrl:t,checkoutMode:n,deliverySpecifications:o,returnUrl:c,merchantMetadata:u,chargePermissionType:i,recurringMetadata:a}=e,{storeId:s}=e.configuration,f="ProcessOrder"===n,p=f?b(e.amount):null;return l({storeId:s,chargePermissionType:i,webCheckoutDetails:l({},f?{checkoutResultReturnUrl:c}:{checkoutReviewReturnUrl:c},t&&{checkoutCancelUrl:t},f&&{checkoutMode:n})},f&&{paymentDetails:{chargeAmount:p,paymentIntent:"Confirm",presentmentCurrency:p.currencyCode,totalOrderAmount:p}},a&&{recurringMetadata:a},u&&{merchantMetadata:u},o&&{deliverySpecifications:o},r&&{addressDetails:r})}export{p as getAmazonPaySettings,f as getAmazonPayUrl,b as getChargeAmount,g as getCheckoutLocale,m as getDesignCode,y as getFallbackLocale,O as getPayloadJSON,d as getSupportedLocales};
//# sourceMappingURL=utils.js.map