@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 2.7 kB
JavaScript
import{httpPost as e}from"../../../../core/Services/http.js";import{DEFAULT_CARD_GROUP_TYPES as r}from"../lib/constants.js";import{SF_ErrorCodes as n}from"../../../../core/Errors/constants.js";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var o=o=>{let s=null;return p=>{if(!1!==o.props.doBinLookup){if(p.encryptedBin&&o.props.clientKey)s=p.uuid,e({loadingContext:o.props.loadingContext,path:`v3/bin/binLookup?token=${o.props.clientKey}`},{type:o.props.brand,supportedBrands:o.props.brands||r,encryptedBin:p.encryptedBin,requestId:p.uuid}).then(e=>{var d;if((null==e?void 0:e.requestId)===s)if(null===(d=e.brands)||void 0===d?void 0:d.length){const s=e.brands.reduce((e,r)=>(e.detectedBrands.push(r.brand),e.paymentMethodVariants.push(r.paymentMethodVariant),!0===r.supported?(e.supportedBrands.push(r),e):e),{supportedBrands:[],detectedBrands:[],paymentMethodVariants:[]});if(s.supportedBrands.length)return o.processBinLookupResponse(function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(r){t(e,r,n[r])})}return e}({issuingCountryCode:e.issuingCountryCode,supportedBrands:s.supportedBrands},e.showSocialSecurityNumber?{showSocialSecurityNumber:e.showSocialSecurityNumber}:{})),void o.onBinLookup({type:p.type,detectedBrands:s.detectedBrands,supportedBrands:s.supportedBrands.map(e=>e.brand),paymentMethodVariants:s.paymentMethodVariants,supportedBrandsRaw:s.supportedBrands,brands:o.props.brands||r,issuingCountryCode:e.issuingCountryCode});if(s.detectedBrands.length){const e={type:"card",fieldType:"encryptedCardNumber",error:n.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,detectedBrands:s.detectedBrands};return o.handleUnsupportedCard(e),void o.onBinLookup({type:p.type,detectedBrands:s.detectedBrands,supportedBrands:null,paymentMethodVariants:s.paymentMethodVariants,brands:o.props.brands||r})}}else o.onBinLookup({type:p.type,detectedBrands:null,supportedBrands:null,paymentMethodVariants:null,brands:o.props.brands||r}),o.processBinLookupResponse({},!0);else(null==e?void 0:e.requestId)||o.props.onError(e||{errorType:"binLookup",message:"unknownError"})});else if(s){o.processBinLookupResponse(null,!0),s=null;const e={type:"card",fieldType:"encryptedCardNumber",error:""};o.handleUnsupportedCard(e),o.onBinLookup({isReset:!0})}o.props.onBinValue&&o.props.onBinValue(p)}else o.props.onBinValue&&o.props.onBinValue(p)}};export{o as default};
//# sourceMappingURL=triggerBinLookUp.js.map