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) 2.55 kB
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,r){return s(l({},e.buttonColor&&{buttonColor:e.buttonColor},e.design&&{design:b(e.design)}),{checkoutLanguage:g(e.locale,e.configuration.region),ledgerCurrency:t[e.configuration.region]||e.currency||(null==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 b(e){return"noTagline"===e?"C0001":null}function m(e){return{amount:String(i(e.value,e.currency)),currencyCode:e.currency}}function O(e,r){const{addressDetails:t,cancelUrl:n,checkoutMode:o,deliverySpecifications:c,returnUrl:u,merchantMetadata:i,chargePermissionType:a,recurringMetadata:s}=e,{storeId:f}=e.configuration,p="ProcessOrder"===o,y=p?m(r):null;return l({storeId:f,chargePermissionType:a,webCheckoutDetails:l({},p?{checkoutResultReturnUrl:u}:{checkoutReviewReturnUrl:u},n&&{checkoutCancelUrl:n},p&&{checkoutMode:o})},p&&{paymentDetails:{chargeAmount:y,paymentIntent:"Confirm",presentmentCurrency:y.currencyCode,totalOrderAmount:y}},s&&{recurringMetadata:s},i&&{merchantMetadata:i},c&&{deliverySpecifications:c},t&&{addressDetails:t})}export{p as getAmazonPaySettings,f as getAmazonPayUrl,m as getChargeAmount,g as getCheckoutLocale,b as getDesignCode,y as getFallbackLocale,O as getPayloadJSON,d as getSupportedLocales}; //# sourceMappingURL=utils.js.map