Skip to content

Commit 1c8c342

Browse files
Adding a country parameter to the card request
1 parent e71e559 commit 1c8c342

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/main/java/com/flutterwave/bean/CardRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
public class CardRequest extends Shared{
1313

1414
private String card_number;
15+
private String country;
1516
private String cvv;
1617
private String expiry_month;
1718
private String expiry_year;
1819
private Authorization authorization;
1920

2021
public CardRequest(String card_number,
22+
String country,
2123
String cvv,
2224
String expiry_month,
2325
String expiry_year,
@@ -30,6 +32,7 @@ public CardRequest(String card_number,
3032
Authorization authorization){
3133

3234
this.card_number = card_number;
35+
this.country = country;
3336
this.cvv = cvv;
3437
this.expiry_month = expiry_month;
3538
this.expiry_year = expiry_year;

src/test/java/com/flutterwave/services/CardChargeTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.junit.jupiter.api.Test;
1010

1111
import java.math.BigDecimal;
12+
import java.util.Date;
1213
import java.util.Optional;
1314

1415
import static com.flutterwave.bean.AuthorizationModes.PIN;
@@ -25,22 +26,24 @@ void setUp() {
2526
Environment.setPublicKey(getProperty("PUB_KEY"));
2627
Environment.setEncryptionKey(getProperty("ENCR_KEY"));
2728

28-
cardRequest = new CardRequest("5438898014560229",
29-
"564",
30-
"09",
31-
"32",
32-
"NGN",
33-
new BigDecimal("100.88"),
34-
"Yolande Aglaé Colbert",
35-
"tafchaty@gmail.com",
36-
"javasdk-test",
29+
cardRequest = new CardRequest("4187427415564246",
30+
"NG",
31+
"812",
32+
"10",
33+
"33",
34+
"NGN", new BigDecimal("10000"),
35+
"Tafa Chati",
36+
"test@gmail.io",
37+
"javasdk-test-" + new Date(),
3738
"https://www,flutterwave.ng",
3839
null);
3940
}
4041

4142
@Test
4243
void runTransaction() {
4344
Assertions.assertEquals("success", new CardCharge().runTransaction(cardRequest).getStatus());
45+
//System.out.println(new CardCharge().runTransaction(cardRequest).getData().getId());
46+
//verifyTransaction(new CardCharge().runTransaction(cardRequest).getData().getId());
4447
}
4548

4649
@Test
@@ -57,6 +60,8 @@ void authorizeTransactionPin() {
5760
case REDIRECT -> {
5861
//redirect user
5962
}
63+
case OTP -> cardRequest.setAuthorization(new Authorization().pinAuthorization("3310"));
64+
default -> throw new IllegalArgumentException("Unexpected value: " + response.getMeta().getAuthorization().getMode());
6065
}
6166
Response authorizeResponse = new CardCharge().runTransaction(cardRequest);
6267
System.out.println("authorizeResponse response ==>" + authorizeResponse);

0 commit comments

Comments
 (0)