Skip to content

Commit 079b168

Browse files
author
taiwoadebayo
committed
If card check is null, allow user proceed with payment, check for null values
1 parent 1818604 commit 079b168

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

rave_java_commons/src/main/java/com/flutterwave/raveandroid/rave_java_commons/RaveConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class RaveConstants {
7979

8080
public static String success = "success";
8181
public static String noResponse = "No response data was returned";
82-
public static String cardNotAllowed = "Card not allowed, please use a card issued in your country";
82+
public static String cardNotAllowed = "You can’t fund with cards from other countries yet. Please add a card issued in your country to proceed.";
8383
public static String invalidAccountNoMessage = "Enter a valid account number";
8484
public static String invalidDateOfBirthMessage = "Enter a valid date of birth";
8585
public static String invalidBvnMessage = "Enter a valid BVN";

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/card/CardPaymentHandler.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,15 @@ public void checkCard(String cardFirstSix, final Payload body, final Boolean isD
198198
public void onSuccess(CheckCardResponse response) {
199199
mCardInteractor.showProgressIndicator(false);
200200

201-
if (response.getCountry().getCurrency().equalsIgnoreCase(body.getCurrency())){
202-
203-
if (isDisplayFee) {
204-
fetchFee(body);
201+
if (response != null && response.getCountry() != null && response.getCountry().getCurrency() != null) {
202+
if (response.getCountry().getCurrency().equalsIgnoreCase(body.getCurrency())) {
203+
continueCharge( isDisplayFee, body, encryptionKey);
205204
} else {
206-
chargeCard(body, encryptionKey);
205+
mCardInteractor.onPaymentError(cardNotAllowed);
207206
}
208207

209-
}else{
210-
mCardInteractor.onPaymentError(cardNotAllowed);
208+
} else {
209+
continueCharge(isDisplayFee, body, encryptionKey);
211210
}
212211

213212
}
@@ -221,6 +220,14 @@ public void onError(String message) {
221220

222221
}
223222

223+
private void continueCharge(boolean isDisplayFee, Payload body, String encryptionKey) {
224+
if (isDisplayFee) {
225+
fetchFee(body);
226+
} else {
227+
chargeCard(body, encryptionKey);
228+
}
229+
}
230+
224231
@Override
225232
public void chargeSavedCard(Payload payload, String encryptionKey) {
226233
if (payload.getOtp() == null || payload.getOtp() == "") {
@@ -379,7 +386,7 @@ public void onError(String message) {
379386
}
380387

381388
@Override
382-
public void deleteASavedCard(String cardHash, String phoneNumber, String publicKey){
389+
public void deleteASavedCard(String cardHash, String phoneNumber, String publicKey) {
383390
mCardInteractor.showProgressIndicator(true);
384391
RemoveSavedCardRequestBody body = new RemoveSavedCardRequestBody(cardHash, phoneNumber, publicKey);
385392
networkRequest.deleteASavedCard(body, new ResultCallback<SaveCardResponse>() {
@@ -406,7 +413,7 @@ public void lookupSavedCards(String publicKey,
406413
body.setDevice_key(phoneNumber);
407414
body.setPublic_key(publicKey);
408415

409-
if(showLoader)
416+
if (showLoader)
410417
mCardInteractor.showProgressIndicator(true);
411418

412419

rave_remote/src/main/java/com/flutterwave/raveandroid/rave_remote/responses/CheckCardResponse.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.flutterwave.raveandroid.rave_remote.responses;
22

3+
import androidx.annotation.Nullable;
4+
35
public class CheckCardResponse {
46

57
Number number;
68
String scheme;
79
String type;
810
String brand;
911
boolean prepaid;
12+
@Nullable
1013
Country country;
1114
Bank bank;
1215

@@ -50,11 +53,12 @@ public void setPrepaid(boolean prepaid) {
5053
this.prepaid = prepaid;
5154
}
5255

56+
@Nullable
5357
public Country getCountry() {
5458
return country;
5559
}
5660

57-
public void setCountry(Country country) {
61+
public void setCountry(@Nullable Country country) {
5862
this.country = country;
5963
}
6064

@@ -94,15 +98,17 @@ public static class Country {
9498
String alpha2;
9599
String name;
96100
String emoji;
101+
@Nullable
97102
String currency;
98103
int latitude;
99104
int longitude;
100105

106+
@Nullable
101107
public String getCurrency() {
102108
return currency;
103109
}
104110

105-
public void setCurrency(String currency) {
111+
public void setCurrency(@Nullable String currency) {
106112
this.currency = currency;
107113
}
108114
}

0 commit comments

Comments
 (0)