Skip to content

Commit 953b90f

Browse files
committed
Updates
Ran tests Handled errors
1 parent 649cff4 commit 953b90f

160 files changed

Lines changed: 390 additions & 280 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

documentation/Collections.md

Lines changed: 253 additions & 200 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
<version>5.8.1</version>
1616
<scope>test</scope>
1717
</dependency>
18+
<dependency>
19+
<groupId>org.hibernate.validator</groupId>
20+
<artifactId>hibernate-validator</artifactId>
21+
<version>6.0.21.Final</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>javax.validation</groupId>
25+
<artifactId>validation-api</artifactId>
26+
<version>2.0.1.Final</version>
27+
</dependency>
1828
<dependency>
1929
<groupId>org.json</groupId>
2030
<artifactId>json</artifactId>
@@ -52,6 +62,12 @@
5262
<artifactId>gson</artifactId>
5363
<version>2.9.1</version>
5464
</dependency>
65+
<dependency>
66+
<groupId>org.jetbrains</groupId>
67+
<artifactId>annotations</artifactId>
68+
<version>RELEASE</version>
69+
<scope>compile</scope>
70+
</dependency>
5571
</dependencies>
5672

5773
<properties>

src/.DS_Store

0 Bytes
Binary file not shown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Authorization {
3939

4040
public Authorization pinAuthorization(String pin){
4141
this.pin = pin;
42-
this.mode = PIN.toString().toLowerCase();
42+
this.mode = PIN.name().toLowerCase();
4343
return this;
4444
}
4545

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class Customer extends Shared{
1414
private String name;
1515
private String phone;
1616

17-
1817
public Customer(String name, String email, String phone){
1918
this.name = name;
2019
this.setEmail(email);

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

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
package com.flutterwave.bean;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.google.gson.Gson;
7+
import com.google.gson.GsonBuilder;
38
import lombok.Getter;
49
import lombok.NoArgsConstructor;
510
import lombok.Setter;
11+
import org.json.JSONObject;
12+
import org.json.JSONPropertyName;
613

714
import java.math.BigDecimal;
815

916
@Getter
1017
@Setter
1118
@NoArgsConstructor
19+
@JsonInclude(JsonInclude.Include.NON_NULL)
1220
public class Data {
1321

14-
private Customer customer;
22+
private Object customer;
23+
private Object meta;
1524
private int id;
25+
private int maximum;
26+
private int minimum;
1627
private String tx_ref;
1728
private String flw_ref;
1829
private String device_fingerprint;
1930
private BigDecimal amount;
2031
private BigDecimal charged_amount;
2132
private BigDecimal app_fee;
33+
private BigDecimal app_feefee;
2234
private BigDecimal fee;
2335
private BigDecimal merchant_fee;
2436
private String processor_response;
@@ -64,6 +76,7 @@ public class Data {
6476
private String state;
6577
private String address_1;
6678
private String address_2;
79+
private String address;
6780
private String zip_code;
6881
private String cvv;
6982
private String expiration;
@@ -80,12 +93,50 @@ public class Data {
8093
private String customer_email;
8194
private String settlement_id;
8295
private String transaction_id;
83-
private String meta;
8496
private String subaccount_id;
8597
private String bank_name;
8698
private String split_type;
8799
private BigDecimal split_value;
88100
private int split_ratio;
89101
private BigDecimal amount_settled;
90102
private BigDecimal amount_refunded;
103+
private String response_code;
104+
private String response_message;
105+
private String product_code;
106+
private String email;
107+
108+
private Customer getCustomer(){
109+
try {
110+
return new GsonBuilder().create().
111+
fromJson(new Gson().toJson(this.customer), Customer.class);
112+
}catch (Exception e){
113+
System.out.println(e);
114+
throw new RuntimeException("Please use .getCustomerString()");
115+
}
116+
}
117+
118+
119+
public Meta getMeta(){
120+
try {
121+
return new GsonBuilder().create().
122+
fromJson(new Gson().toJson(this.meta), Meta.class);
123+
}catch (Exception e){
124+
System.out.println(e);
125+
throw new RuntimeException("Please use .getMetaString()");
126+
}
127+
}
128+
129+
public String getMetaString(){
130+
if(this.meta != null){
131+
return this.meta.toString();
132+
}
133+
return null;
134+
}
135+
136+
public String getCustomerString(){
137+
if(this.customer != null){
138+
return this.customer.toString();
139+
}
140+
return null;
141+
}
91142
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package com.flutterwave.bean;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.core.JsonProcessingException;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
36
import lombok.Getter;
47
import lombok.NoArgsConstructor;
58
import lombok.Setter;
9+
import lombok.ToString;
610

711
@Getter
812
@Setter
@@ -20,4 +24,19 @@ public class Meta {
2024
private String random;
2125
private PageInfo page_info;
2226

27+
@Override
28+
public String toString() {
29+
30+
String value = null;
31+
ObjectMapper objectMapper = new ObjectMapper();
32+
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
33+
try {
34+
value = objectMapper.writeValueAsString(this);
35+
} catch (JsonProcessingException e) {
36+
e.printStackTrace();
37+
}
38+
39+
return value;
40+
41+
}
2342
}

src/main/java/com/flutterwave/client/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static String runTransaction(String url, String request, Verb type,
2929
CloseableHttpClient client = HttpClientBuilder.create().build();
3030
CloseableHttpResponse closeableHttpResponse;
3131
// new Thread(() -> send(chargeType)).start();
32-
//send(chargeType);
32+
send(chargeType);
3333

3434
try {
3535
URI uri;

src/main/java/com/flutterwave/services/Charge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class Charge {
1919
*/
2020
public Response runTransaction(String request, ChargeTypes type, boolean encrypyt, Optional<String> urlSuffix){
2121
return Optional.ofNullable(Client.runTransaction(
22-
getProperty("CHARGE_BASE")+(urlSuffix.isEmpty() ?"?type="+type.toString().toLowerCase() : urlSuffix),
22+
getProperty("CHARGE_BASE")+(urlSuffix.isEmpty() ?"?type="+type.toString().toLowerCase() : urlSuffix.get()),
2323
encrypyt?new Request(request).toString():request,
2424
POST, type, null))
2525
.map(Response::toResponse).orElseThrow(() -> new RuntimeException("Error processing request, please check logs"));

src/main/java/com/flutterwave/services/FawryPay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
public class FawryPay extends Charge{
1111

1212
public Response runTransaction(FawryPayRequest fawryPayRequest){
13-
return runTransaction(fawryPayRequest.toString(), FAWRY_PAY, true, Optional.empty());
13+
return runTransaction(fawryPayRequest.toString(), FAWRY_PAY, false, Optional.empty());
1414
}
1515
}

0 commit comments

Comments
 (0)