Skip to content

Commit

Permalink
Hot fix for card brand - scheme check
Browse files Browse the repository at this point in the history
  • Loading branch information
AhlaamK-tap committed Sep 22, 2024
1 parent b7bd7a3 commit b0fa11d
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 34 deletions.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/modules/library/goSellSDK-AndroidX.library.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -140,49 +140,52 @@ public void updateForCardBrand(CardBrand brand, CardScheme cardScheme, CardCrede

for (PaymentOption option : initialData) {

cardBrands = option.getSupportedCardBrands();

if (cardScheme != null) {
if(cardBrands.contains(cardScheme.getCardBrand()) || cardScheme.name().equalsIgnoreCase("MADA")){
if (comparePaymentOptionWithCardScheme(option, cardScheme)) {
data.add(option);
continue;
}
}else{
if (cardBrands.contains(brand)) {
data.add(option);

}
}
/* if (comparePaymentOptionWithCardScheme(option, cardScheme)) {

if (comparePaymentOptionWithCardScheme(option, cardScheme)) {
data.add(option);
continue;
}*/
} else {
break;
}


}

}

if(data.size()==0) {

for (PaymentOption option : initialData) {

cardBrands = option.getSupportedCardBrands();

if (cardBrands.contains(brand)) {
data.add(option);
break;


}
}


}
}
// &&!cardBrands.contains(brand)
if (data.isEmpty() ) {
/*if (data.isEmpty() ) {
cardCredentialsViewHolder.showDialog(cardCredentialsViewHolder.itemView.getResources().getString(R.string.alert_un_supported_card_title), cardCredentialsViewHolder.itemView.getResources().getString(R.string.alert_un_supported_card_message));
}
}*/

if (data.size() == 0)
data = new ArrayList<>(initialData);

notifyDataSetChanged();
}


private boolean comparePaymentOptionWithCardScheme(@NonNull PaymentOption paymentOption,
@NonNull CardScheme cardScheme) {

if ((paymentOption.getName().equalsIgnoreCase(cardScheme.name()))) {
if ((paymentOption.getName().equalsIgnoreCase(cardScheme.name()))||cardScheme.name().equalsIgnoreCase("MADA")) {
// Log.e("payment option",paymentOption.getName().toString());
// Log.e("card scheme",cardScheme.name().toString());

Expand All @@ -191,13 +194,13 @@ private boolean comparePaymentOptionWithCardScheme(@NonNull PaymentOption paymen
}


if (paymentOption.getName().compareTo(String.valueOf(cardScheme.getCardBrand())) == 0) {
if (paymentOption.getName().toLowerCase().compareTo(String.valueOf(cardScheme.getCardBrand()).toLowerCase()) == 0) {
return true;
}
// stop this check to avoid displaying mada with master in case of scheme is not mada
if (paymentOption.getSupportedCardBrands().contains(cardScheme.getCardBrand())) {
/* if (paymentOption.getSupportedCardBrands().contains(cardScheme.getCardBrand())) {
return true;
}
}*/

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import company.tap.gosellapi.internal.data_managers.payment_options.PaymentOptionsDataManager;
import company.tap.gosellapi.internal.data_managers.payment_options.view_models.card_input_fields_text_handlers.CardNumberTextHandler;
import company.tap.gosellapi.internal.data_managers.payment_options.view_models_data.CardCredentialsViewModelData;
import company.tap.gosellapi.internal.utils.ActivityDataExchanger;
import company.tap.gosellapi.internal.utils.Utils;
import company.tap.gosellapi.internal.viewholders.CardCredentialsViewHolder;
import company.tap.gosellapi.internal.viewholders.PaymentOptionsBaseViewHolder;
Expand Down Expand Up @@ -97,7 +98,7 @@ public String getCardholderNameText() {
private boolean shouldSaveCard;

@Nullable private BINLookupResponse currentBINData;
@Nullable private BINLookupResponse getCurrentBINData() { return currentBINData; }
@Nullable public BINLookupResponse getCurrentBINData() { return currentBINData; }

/**
* Set current bin data.
Expand Down Expand Up @@ -429,7 +430,7 @@ public void setPaymentOption(CardBrand cardBrand,CardScheme cardScheme) {
if(cardBrand!=null){
for(PaymentOption paymentOption: data.getPaymentOptions()){
//Fix added for cases where cardscheme is empty (toLowecase() added)
if(paymentOption.getName().toLowerCase().compareTo(String.valueOf(cardBrand))==0){
if(paymentOption.getName().toLowerCase().compareTo(String.valueOf(cardBrand).toLowerCase())==0){
this.selectedCardPaymentOption = paymentOption;
updatePayButtonWithExtraFees(paymentOption);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {

if (text.length() < BIN_NUMBER_LENGTH || text.length() == 0) {
PaymentDataManager.getInstance().setBinLookupResponse(null);
viewModel.setCurrentBINData(null);
}
}

Expand All @@ -312,13 +313,15 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
@Override
public void run() {
// do your work
BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
// BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
BINLookupResponse binLookupResponse = viewModel.getCurrentBINData();
if(binLookupResponse==null){
viewModel.setPaymentOption(finalCardBrand,null);
}else
{ viewModel.setPaymentOption(finalCardBrand,binLookupResponse.getScheme());
{
viewModel.setPaymentOption(binLookupResponse.getCardBrand(),binLookupResponse.getScheme());
}
handler.postDelayed(this, 1000);
// handler.postDelayed(this, 1000);
}
};
handler.postDelayed(runnable, 1000);
Expand All @@ -327,7 +330,8 @@ public void run() {

@Override
public void afterTextChanged(Editable s) {
if(PaymentDataManager.getInstance().getBinLookupResponse()!=null) {
// if(PaymentDataManager.getInstance().getBinLookupResponse()!=null
if( viewModel.getCurrentBINData()!=null) {
viewModel.cardDetailsFilled(validateCardFields(), viewModel);
viewModel.checkShakingStatus();
}
Expand Down Expand Up @@ -751,6 +755,7 @@ public void updateCardSystemsRecyclerView(CardBrand brand,CardScheme cardScheme)
}
}


private DefinedCardBrand validateCardNumber(String cardNumber) {

cardNumber = cardNumber.replace(" ", "");
Expand All @@ -764,9 +769,17 @@ private DefinedCardBrand validateCardNumber(String cardNumber) {
// update CCVEditText CardType: to set CCV Length according to CardType
updateCCVEditTextCardType(brand.getCardBrand());
// update card types
BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
// BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
BINLookupResponse binLookupResponse = viewModel.getCurrentBINData();
// System.out.println("brand.getCardBrand() in validation "+brand.getCardBrand());
updateCardSystemsRecyclerView( brand.getCardBrand(), binLookupResponse == null ? null : binLookupResponse.getScheme());

if(binLookupResponse==null){
updateCardSystemsRecyclerView( brand.getCardBrand(), null);

}else{
updateCardSystemsRecyclerView(binLookupResponse.getCardBrand(), binLookupResponse.getScheme());

}
// if (binLookupResponse != null && PaymentDataSource.getInstance().getCardType() != null){

if(binLookupResponse != null && PaymentDataSource.getInstance().getCardType()!=null && PaymentDataSource.getInstance().getCardType() == ALL) {
Expand Down Expand Up @@ -1026,6 +1039,7 @@ public void onClick(DialogInterface dialog, int which) {
});

PaymentDataManager.getInstance().setBinLookupResponse(null);
viewModel.setCurrentBINData(null);
// cardNumberField.setText(null);
AlertDialog dialog = dialogBuilder.create();

Expand Down Expand Up @@ -1070,7 +1084,8 @@ private void handleScanbinLookupResponse(){
@Override
public void run() {
// do something after 1s = 1000 miliseconds since set response takes time
BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
// BINLookupResponse binLookupResponse = PaymentDataManager.getInstance().getBinLookupResponse();
BINLookupResponse binLookupResponse = viewModel.getCurrentBINData();
if(binLookupResponse==null){
viewModel.setPaymentOption(cardBrand, null);

Expand All @@ -1097,7 +1112,7 @@ public void run() {
}

}
}, 3000); //Time in mis
}, 1000); //Time in mis


}
Expand Down

0 comments on commit b0fa11d

Please sign in to comment.