Skip to content

Commit 3febd81

Browse files
authored
Merge pull request #254 from mikelis135/checkCardAllowed
check card country not currency
2 parents 079b168 + 10c9580 commit 3febd81

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

rave_android/src/main/java/com/flutterwave/raveandroid/RavePayInitializer.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class RavePayInitializer {
2525
String narration;
2626
String currency;
2727
String country;
28+
String barterCountry;
2829
String fName;
2930
String lName;
3031
String meta;
@@ -41,7 +42,7 @@ public class RavePayInitializer {
4142

4243
public RavePayInitializer(String email, double amount, String publicKey,
4344
String encryptionKey, String txRef, String narration,
44-
String currency, String country, String fName,
45+
String currency, String country, String barterCountry, String fName,
4546
String lName, int theme, String phoneNumber,
4647
boolean isPhoneEditable, boolean saveCardFeatureAllowed, boolean usePhoneAndEmailSuppliedToSaveCards,
4748
boolean isPermanent, int duration, int frequency,
@@ -55,6 +56,7 @@ public RavePayInitializer(String email, double amount, String publicKey,
5556
this.narration = narration;
5657
this.currency = currency;
5758
this.country = country;
59+
this.barterCountry = barterCountry;
5860
this.fName = fName;
5961
this.lName = lName;
6062
this.isPermanent = isPermanent;
@@ -184,6 +186,14 @@ public void setCountry(String country) {
184186
this.country = country;
185187
}
186188

189+
public String getBarterCountry() {
190+
return barterCountry;
191+
}
192+
193+
public void setBarterCountry(String barterCountry) {
194+
this.barterCountry = barterCountry;
195+
}
196+
187197
public String getfName() {
188198
return fName;
189199
}

rave_android/src/main/java/com/flutterwave/raveandroid/RaveUiManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,16 @@ public RaveUiManager setCurrency(String currency) {
128128
return this;
129129
}
130130

131-
@Deprecated
132131
public RaveUiManager setCountry(String country) {
133132
this.country = country;
134133
return this;
135134
}
136135

136+
public RaveUiManager setBarterCountry(String barterCountry) {
137+
this.barterCountry = barterCountry;
138+
return this;
139+
}
140+
137141
public RaveUiManager setfName(String fName) {
138142
this.fName = fName;
139143
return this;
@@ -348,6 +352,7 @@ private RavePayInitializer createRavePayInitializer() {
348352
getNarration(),
349353
getCurrency(),
350354
getCountry(),
355+
getBarterCountry(),
351356
getfName(),
352357
getlName(),
353358
theme,

rave_android/src/main/java/com/flutterwave/raveandroid/card/CardUiPresenter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void processTransaction(HashMap<String, ViewObject> dataHashMap, RavePayI
239239
Payload body = builder.createPayload();
240240

241241
if (ravePayInitializer.getNarration().equalsIgnoreCase("barterRavePay")){
242-
checkCard(cardFirstSix, body, ravePayInitializer.getIsDisplayFee(), ravePayInitializer.getEncryptionKey());
242+
checkCard(cardFirstSix, body, ravePayInitializer.getIsDisplayFee(), ravePayInitializer.getEncryptionKey(), ravePayInitializer.getBarterCountry());
243243
}else{
244244
if (ravePayInitializer.getIsDisplayFee()) {
245245
fetchFee(body);
@@ -287,8 +287,8 @@ public void processSavedCardTransaction(SavedCard savedCard, RavePayInitializer
287287
cardFirstSix = savedCard.getMasked_pan().substring(0, 6);
288288
}
289289

290-
if (ravePayInitializer.getNarration().equalsIgnoreCase("barterRavePay")){
291-
checkCard(cardFirstSix, body, ravePayInitializer.getIsDisplayFee(), ravePayInitializer.getEncryptionKey());
290+
if (ravePayInitializer.getBarterCountry()!= null){
291+
checkCard(cardFirstSix, body, ravePayInitializer.getIsDisplayFee(), ravePayInitializer.getEncryptionKey(), ravePayInitializer.getBarterCountry());
292292
}else{
293293
if (ravePayInitializer.getIsDisplayFee()) {
294294
fetchFee(body);

rave_presentation/src/main/java/com/flutterwave/raveandroid/rave_presentation/RavePayManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ abstract public class RavePayManager {
99
protected String narration = "";
1010
protected String currency = "NGN";
1111
protected String country = "NG";
12+
protected String barterCountry = "NG";
1213
protected String fName = "";
1314
protected String lName = "";
1415
protected String meta = "";
@@ -57,6 +58,10 @@ public String getCountry() {
5758
return country;
5859
}
5960

61+
public String getBarterCountry() {
62+
return barterCountry;
63+
}
64+
6065
public String getfName() {
6166
return fName;
6267
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ interface CardPaymentHandler {
161161

162162
void chargeCard(Payload payload, String encryptionKey);
163163

164-
void checkCard(String cardFirstSix, Payload body, Boolean isDisplayFee, String encryptionKey);
164+
void checkCard(String cardFirstSix, Payload body, Boolean isDisplayFee, String encryptionKey, String barterCountry);
165165

166166
void validateCardCharge(String flwRef, String otp, String publicKey);
167167

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void onError(String message) {
189189
}
190190

191191
@Override
192-
public void checkCard(String cardFirstSix, final Payload body, final Boolean isDisplayFee, final String encryptionKey) {
192+
public void checkCard(String cardFirstSix, final Payload body, final Boolean isDisplayFee, final String encryptionKey, final String barterCountry) {
193193

194194
mCardInteractor.showProgressIndicator(true);
195195

@@ -198,8 +198,8 @@ 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 != null && response.getCountry() != null && response.getCountry().getCurrency() != null) {
202-
if (response.getCountry().getCurrency().equalsIgnoreCase(body.getCurrency())) {
201+
if (response != null && response.getCountry() != null && response.getCountry().getAlpha2() != null) {
202+
if (response.getCountry().getAlpha2().equalsIgnoreCase(barterCountry)) {
203203
continueCharge( isDisplayFee, body, encryptionKey);
204204
} else {
205205
mCardInteractor.onPaymentError(cardNotAllowed);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ public String getCurrency() {
111111
public void setCurrency(@Nullable String currency) {
112112
this.currency = currency;
113113
}
114+
115+
public String getAlpha2() {
116+
return alpha2;
117+
}
118+
119+
public void setAlpha2(String alpha2) {
120+
this.alpha2 = alpha2;
121+
}
114122
}
115123

116124
}

0 commit comments

Comments
 (0)