Merge pull request #2163 from Adyen/feature/add_paymentMethodVariant_to_onBinLookup

Add a paymentMethodVariants array to the object sent to the onBinLookup callback
This commit is contained in:
sponglord
2023-05-15 13:52:42 +02:00
committed by GitHub
2 changed files with 9 additions and 4 deletions

View File

@@ -211,6 +211,7 @@ export interface BrandObject {
supported: boolean;
brandImageUrl?: string;
panLength?: number;
paymentMethodVariant?: string;
}
export interface BinLookupResponseRaw {

View File

@@ -86,6 +86,8 @@ export default parent => {
(acc, item) => {
// All brand strings end up in the detectedBrands array
acc.detectedBrands.push(item.brand);
// Also add the paymentMethodVariants (more granular description of the txvariant)
acc.paymentMethodVariants.push(item.paymentMethodVariant);
// Add supported brand objects to the supportedBrands array
if (item.supported === true) {
@@ -95,7 +97,7 @@ export default parent => {
return acc;
},
{ supportedBrands: [], detectedBrands: [] }
{ supportedBrands: [], detectedBrands: [], paymentMethodVariants: [] }
);
/**
@@ -113,9 +115,9 @@ export default parent => {
parent.onBinLookup({
type: callbackObj.type,
detectedBrands: mappedResponse.detectedBrands,
supportedBrands: mappedResponse.supportedBrands.map(item => item.brand), // supportedBrands contains the subset of
// this.props.brands that matches the card
// number that the shopper has typed
// supportedBrands contains the subset of this.props.brands that matches the card number that the shopper has typed
supportedBrands: mappedResponse.supportedBrands.map(item => item.brand),
paymentMethodVariants: mappedResponse.paymentMethodVariants,
supportedBrandsRaw: mappedResponse.supportedBrands, // full supportedBrands data (for customCard comp)
brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,
issuingCountryCode: data.issuingCountryCode
@@ -142,6 +144,7 @@ export default parent => {
type: callbackObj.type,
detectedBrands: mappedResponse.detectedBrands,
supportedBrands: null,
paymentMethodVariants: mappedResponse.paymentMethodVariants,
brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES
} as CbObjOnBinLookup);
@@ -155,6 +158,7 @@ export default parent => {
type: callbackObj.type,
detectedBrands: null,
supportedBrands: null,
paymentMethodVariants: null,
brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES
} as CbObjOnBinLookup);