Skip to content

Commit 3b9ead9

Browse files
committed
Update card checks
1 parent ca39696 commit 3b9ead9

File tree

6 files changed

+65
-120
lines changed

6 files changed

+65
-120
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
@@ -32,7 +32,7 @@ public class RaveConstants {
3232
// public static String LIVE_URL = "https://raveapi.azurewebsites.net";
3333
public static String STAGING_URL = "https://ravesandboxapi.flutterwave.com";
3434
public static String LIVE_URL = "https://api.ravepay.co";
35-
public static String CARD_CHECK_URL = "https://lookup.binlist.net";
35+
public static String CARD_CHECK_URL = "https://9wd5x7szl1.execute-api.eu-west-2.amazonaws.com";
3636
public static String EVENT_LOGGING_URL = "https://kgelfdz7mf.execute-api.us-east-1.amazonaws.com/";
3737
public static String FLUTTERWAVE_UK_ACCOUNT = "43271228";
3838
public static String FLUTTERWAVE_UK_SORT_CODE = "04-00-53";

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,24 @@ 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().getAlpha2() != null) {
202-
if (response.getCountry().getAlpha2().equalsIgnoreCase(barterCountry)) {
201+
try{
202+
if (response.getCountry().split(" ")[1].equalsIgnoreCase(barterCountry)){
203203
continueCharge( isDisplayFee, body, encryptionKey);
204204
} else {
205205
mCardInteractor.onPaymentError(cardNotAllowed);
206206
}
207207

208-
} else {
208+
} catch (Exception ignored){
209209
continueCharge(isDisplayFee, body, encryptionKey);
210210
}
211211

212212
}
213213

214214
@Override
215215
public void onError(String message) {
216-
mCardInteractor.showProgressIndicator(false);
217-
mCardInteractor.onPaymentError(message);
216+
continueCharge(isDisplayFee, body, encryptionKey);
217+
// mCardInteractor.showProgressIndicator(false);
218+
// mCardInteractor.onPaymentError(message);
218219
}
219220
});
220221

rave_remote/src/main/java/com/flutterwave/raveandroid/rave_remote/ApiService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import com.flutterwave.raveandroid.rave_java_commons.Payload;
5+
import com.flutterwave.raveandroid.rave_remote.requests.CardCheckRequest;
56
import com.flutterwave.raveandroid.rave_remote.requests.ChargeRequestBody;
67
import com.flutterwave.raveandroid.rave_remote.requests.LookupSavedCardsRequestBody;
78
import com.flutterwave.raveandroid.rave_remote.requests.RemoveSavedCardRequestBody;
@@ -30,8 +31,8 @@ public interface ApiService {
3031
// Call<ChargeResponse> charge(@Body ChargeRequestBody body);
3132
Call<String> charge(@Body ChargeRequestBody body);
3233

33-
@GET("/{card-first-six}")
34-
Call<String> checkCard(@Path("card-first-six") String cardFirstSix);
34+
@POST("/binapi/bin/details")
35+
Call<String> checkCard(@Body() CardCheckRequest body);
3536

3637
@POST("/flwv3-pug/getpaidx/api/charge?use_polling=1")
3738
// Call<ChargeResponse> charge(@Body ChargeRequestBody body);

rave_remote/src/main/java/com/flutterwave/raveandroid/rave_remote/RemoteRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.flutterwave.raveandroid.rave_java_commons.NetworkRequestExecutor;
88
import com.flutterwave.raveandroid.rave_java_commons.Payload;
99
import com.flutterwave.raveandroid.rave_java_commons.RaveConstants;
10+
import com.flutterwave.raveandroid.rave_remote.requests.CardCheckRequest;
1011
import com.flutterwave.raveandroid.rave_remote.requests.ChargeRequestBody;
1112
import com.flutterwave.raveandroid.rave_remote.requests.LookupSavedCardsRequestBody;
1213
import com.flutterwave.raveandroid.rave_remote.requests.RemoveSavedCardRequestBody;
@@ -81,8 +82,7 @@ public void charge(ChargeRequestBody body, final ResultCallback callback) {
8182

8283
public void checkCard(String cardFirstSix, final ResultCallback callback) {
8384

84-
85-
executor.execute(barterService.checkCard(cardFirstSix),
85+
executor.execute(barterService.checkCard(new CardCheckRequest(cardFirstSix)),
8686
new TypeToken<CheckCardResponse>() {
8787
}.getType(),
8888
new GenericNetworkCallback<CheckCardResponse>(callback)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.flutterwave.raveandroid.rave_remote.requests;
2+
3+
public class CardCheckRequest {
4+
String cardbin;
5+
6+
public CardCheckRequest(String cardbin){
7+
this.cardbin = cardbin;
8+
}
9+
10+
}
Lines changed: 43 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,58 @@
11
package com.flutterwave.raveandroid.rave_remote.responses;
22

3-
import androidx.annotation.Nullable;
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
45

56
public class CheckCardResponse {
67

7-
Number number;
8-
String scheme;
9-
String type;
10-
String brand;
11-
boolean prepaid;
12-
@Nullable
13-
Country country;
14-
Bank bank;
15-
16-
public Number getNumber() {
17-
return number;
18-
}
19-
20-
public void setNumber(Number number) {
21-
this.number = number;
22-
}
23-
24-
public String getScheme() {
25-
return scheme;
26-
}
27-
28-
public void setScheme(String scheme) {
29-
this.scheme = scheme;
30-
}
31-
32-
public String getType() {
33-
return type;
34-
}
35-
36-
public void setType(String type) {
37-
this.type = type;
38-
}
39-
40-
public String getBrand() {
41-
return brand;
42-
}
43-
44-
public void setBrand(String brand) {
45-
this.brand = brand;
46-
}
47-
48-
public boolean getPrepaid() {
49-
return prepaid;
50-
}
51-
52-
public void setPrepaid(boolean prepaid) {
53-
this.prepaid = prepaid;
54-
}
55-
56-
@Nullable
57-
public Country getCountry() {
8+
@Expose
9+
@SerializedName("transactionReference")
10+
private String transactionreference;
11+
@Expose
12+
@SerializedName("responseMessage")
13+
private String responsemessage;
14+
@Expose
15+
@SerializedName("responseCode")
16+
private String responsecode;
17+
@Expose
18+
@SerializedName("country")
19+
private String country;
20+
@Expose
21+
@SerializedName("nigeriancard")
22+
private boolean isNigerianCard;
23+
@Expose
24+
@SerializedName("cardName")
25+
private String cardname;
26+
@Expose
27+
@SerializedName("cardBin")
28+
private String cardbin;
29+
30+
public String getTransactionreference() {
31+
return transactionreference;
32+
}
33+
34+
public String getResponsemessage() {
35+
return responsemessage;
36+
}
37+
38+
public String getResponsecode() {
39+
return responsecode;
40+
}
41+
42+
public String getCountry() {
5843
return country;
5944
}
6045

61-
public void setCountry(@Nullable Country country) {
62-
this.country = country;
46+
public boolean getNigerianCard() {
47+
return isNigerianCard;
6348
}
6449

65-
public Bank getBank() {
66-
return bank;
50+
public String getCardname() {
51+
return cardname;
6752
}
6853

69-
public void setBank(Bank bank) {
70-
this.bank = bank;
54+
public String getCardbin() {
55+
return cardbin;
7156
}
72-
73-
public static class Bank { }
74-
75-
public static class Number {
76-
int length;
77-
boolean luhn;
78-
79-
public int getLength() {
80-
return length;
81-
}
82-
83-
public void setLength(int length) {
84-
this.length = length;
85-
}
86-
87-
public boolean isLuhn() {
88-
return luhn;
89-
}
90-
91-
public void setLuhn(boolean luhn) {
92-
this.luhn = luhn;
93-
}
94-
}
95-
96-
public static class Country {
97-
String numeric;
98-
String alpha2;
99-
String name;
100-
String emoji;
101-
@Nullable
102-
String currency;
103-
int latitude;
104-
int longitude;
105-
106-
@Nullable
107-
public String getCurrency() {
108-
return currency;
109-
}
110-
111-
public void setCurrency(@Nullable String currency) {
112-
this.currency = currency;
113-
}
114-
115-
public String getAlpha2() {
116-
return alpha2;
117-
}
118-
119-
public void setAlpha2(String alpha2) {
120-
this.alpha2 = alpha2;
121-
}
122-
}
123-
12457
}
12558

0 commit comments

Comments
 (0)