Skip to content

Commit

Permalink
Added early return for binLookup and binValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Mar 5, 2025
1 parent 03aec32 commit 1e4def1
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions lib/src/drop_in/drop_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ class DropIn {
dropInConfiguration.storedPaymentMethodConfiguration,
);
case CheckoutEventType.binLookup:
_handleOnBinLookup(event, dropInConfiguration.cardConfiguration);
_handleOnBinLookup(
event,
dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinLookup,
);
case CheckoutEventType.binValue:
_handleOnBinValue(event, dropInConfiguration.cardConfiguration);
_handleOnBinValue(
event,
dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinValue,
);
default:
}
});
Expand Down Expand Up @@ -128,9 +134,15 @@ class DropIn {
case CheckoutEventType.cancelOrder:
_handleOrderCancel(event, advancedCheckout.partialPayment);
case CheckoutEventType.binLookup:
_handleOnBinLookup(event, dropInConfiguration.cardConfiguration);
_handleOnBinLookup(
event,
dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinLookup,
);
case CheckoutEventType.binValue:
_handleOnBinValue(event, dropInConfiguration.cardConfiguration);
_handleOnBinValue(
event,
dropInConfiguration.cardConfiguration?.cardCallbacks?.onBinValue,
);
}
});

Expand Down Expand Up @@ -347,23 +359,31 @@ class DropIn {

void _handleOnBinLookup(
CheckoutEvent event,
CardConfiguration? cardConfiguration,
Function? binLookupCallback,
) {
if (binLookupCallback == null) {
return;
}

if (event.data case List<Object?> binLookupDataDTOList) {
final List<BinLookupData> binLookupDataList = binLookupDataDTOList
.whereType<BinLookupDataDTO>()
.map((entry) => BinLookupData(brand: entry.brand))
.toList();
cardConfiguration?.cardCallbacks?.onBinLookup?.call(binLookupDataList);
binLookupCallback.call(binLookupDataList);
}
}

void _handleOnBinValue(
CheckoutEvent event,
CardConfiguration? cardConfiguration,
Function? binValueCallback,
) {
if (binValueCallback == null) {
return;
}

if (event.data case String binValue) {
cardConfiguration?.cardCallbacks?.onBinValue?.call(binValue);
binValueCallback.call(binValue);
}
}
}

0 comments on commit 1e4def1

Please sign in to comment.