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.44 kB
import{filterAllowedPaymentMethods as e,filterRemovedPaymentMethods as t,filterSupportedStoredPaymentMethods as o,filterEcomStoredPaymentMethods as r}from"./filters.js";import n from"../../../utils/uuid.js";function s(e){return{...e,_id:n()}}const a=(o,{allowPaymentMethods:r=[],removePaymentMethods:n=[]})=>o?o.filter(e,r).filter(t,n).map(s):[],d=(n,{allowPaymentMethods:s=[],removePaymentMethods:a=[]},d=[])=>n?n.filter(o).filter(e,s).filter(t,a).filter(r).map(e=>((e,t)=>{const o=function(e,t){if("scheme"!==e.type)return;const o=e.brand;if(!o)return;const r=t.find(e=>"scheme"===e.type&&e.brands?.includes(o));return r?.fundingSource}(e,t);return{...e,storedPaymentMethodId:e.id,isStoredPaymentMethod:!0,...o&&{fundingSource:o}}})(e,d)):[],i=e=>{if("string"==typeof e)throw new Error('paymentMethodsResponse was provided but of an incorrect type (should be an object but a string was provided).Try JSON.parse("{...}") your paymentMethodsResponse.');if(e instanceof Array)throw new Error("paymentMethodsResponse was provided but of an incorrect type (should be an object but an array was provided).Please check you are passing the whole response.");!e||e?.paymentMethods?.length||e?.storedPaymentMethods?.length||console.warn("paymentMethodsResponse was provided but no payment methods were found.")};export{i as checkPaymentMethodsResponse,a as processPaymentMethods,d as processStoredPaymentMethods}; //# sourceMappingURL=utils.js.map