Skip to content

Commit cba57f1

Browse files
authored
New db fields and leniency (#10)
Added some missing fields and leniency for future
1 parent 542abed commit cba57f1

File tree

10 files changed

+109
-33
lines changed

10 files changed

+109
-33
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ A native JAVA SDK for the Payment Rails API
1515
### Maven
1616

1717
Add this dependency to your project's POM:
18+
1819
```xml
1920
<dependency>
2021
<groupId>ca.paymentrails</groupId>
2122
<artifactId>paymentrails</artifactId>
22-
<version>1.0</version>
23+
<version>1.0.1</version>
2324
</dependency>
2425
```
2526

@@ -53,16 +54,13 @@ is the best source of information about the API.
5354

5455
For more information please read the [Java API docs](https://github.com/PaymentRails/paymentrails_dotnet/tree/master/docs/) is available. The best starting point is:
5556

56-
| Data Type | SDK Documentation |
57-
| ----- | ----- |
58-
| Batch | [API Docs for Batch](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/batchgateway.md) |
59-
| Payment | [API Docs for Payment](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/paymentgateway.md) |
60-
| Recipient | [API Docs for Recipient](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/recipientgateway.md) |
57+
| Data Type | SDK Documentation |
58+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------ |
59+
| Batch | [API Docs for Batch](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/batchgateway.md) |
60+
| Payment | [API Docs for Payment](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/paymentgateway.md) |
61+
| Recipient | [API Docs for Recipient](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/recipientgateway.md) |
6162
| Recipient Account | [API Docs for Recipient Account](https://github.com/PaymentRails/java-sdk/tree/master/docs/classes/recipientaccountgateway.md) |
6263

63-
64-
65-
6664
### merchantKey
6765

6866
- **Type**: Authorization

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>ca.paymentrails</groupId>
55
<artifactId>paymentrails</artifactId>
6-
<version>1.0</version>
6+
<version>1.0.1</version>
77
<description>Java SDK for Payment Rails API</description>
88
<packaging>jar</packaging>
99
<name>Payment Rails Java SDK</name>

src/main/java/ca/paymentrails/paymentrails/BatchGateway.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ public BatchSummary summary(String batch_id) throws Exception {
124124
private Batch batchFactory(String data) throws IOException {
125125
ObjectMapper mapper = new ObjectMapper();
126126
JsonNode node = mapper.readTree(data);
127+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
127128
Batch batch = mapper.readValue(node.get("batch").traverse(), Batch.class);
128129
return batch;
129130
}
130131

131132
private List<Batch> batchListFactory(String data) throws IOException {
132133
ObjectMapper mapper = new ObjectMapper();
133134
JsonNode node = mapper.readTree(data);
135+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
134136
Object batch = mapper.readValue(node.get("batches").traverse(), Object.class);
135137
@SuppressWarnings("unchecked")
136138
List<Batch> batchs = (List<Batch>) batch;

src/main/java/ca/paymentrails/paymentrails/Payment.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ public class Payment {
99
private String status;
1010
private Boolean isSupplyPayment;
1111
private String returnedAmount;
12+
13+
private String amount;
14+
private String currency;
15+
private String category;
16+
private RecipientAccount account;
17+
private List<String> tags;
18+
1219
private String sourceAmount;
1320
private String sourceCurrency;
1421
private String targetAmount;
@@ -53,6 +60,46 @@ public void setWithholdingCurrency(String withholdingCurrency) {
5360
this.withholdingCurrency = withholdingCurrency;
5461
}
5562

63+
public List<String> getTags() {
64+
return this.tags;
65+
}
66+
67+
public void setTags(List<String> tags) {
68+
this.tags = tags;
69+
}
70+
71+
public RecipientAccount getAccount() {
72+
return account;
73+
}
74+
75+
public void setAccount(RecipientAccount account) {
76+
this.account = account;
77+
}
78+
79+
public String getCategory() {
80+
return category;
81+
}
82+
83+
public void setCategory(String category) {
84+
this.category = category;
85+
}
86+
87+
public String getCurrency() {
88+
return currency;
89+
}
90+
91+
public void setCurrency(String currency) {
92+
this.currency = currency;
93+
}
94+
95+
public String getAmount() {
96+
return amount;
97+
}
98+
99+
public void setAmount(String amount) {
100+
this.amount = amount;
101+
}
102+
56103
public String getWithholdingCurrency() {
57104
return withholdingCurrency;
58105
}

src/main/java/ca/paymentrails/paymentrails/Recipient.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class Recipient {
2525
String governmentId;
2626
String ssn;
2727
String primaryCurrency;
28+
String placeOfBirth;
29+
List<String> tags;
2830
String merchantId;
2931
String payoutMethod;
3032
public Object payout;
@@ -47,6 +49,14 @@ public void setTaxFormStatus(String taxFormStatus) {
4749
this.taxFormStatus = taxForm;
4850
}
4951

52+
public List<String> getTags() {
53+
return this.tags;
54+
}
55+
56+
public void setTags(List<String> tags) {
57+
this.tags = tags;
58+
}
59+
5060
public String getTaxWithholdingPercentage() {
5161
return this.taxWithholdingPercentage;
5262
}
@@ -259,6 +269,14 @@ public void setPrimaryCurrency(String primaryCurrency) {
259269
this.primaryCurrency = primaryCurrency;
260270
}
261271

272+
public String getPlaceOfBirth() {
273+
return placeOfBirth;
274+
}
275+
276+
public void setPlaceOfBirth(String placeOfBirth) {
277+
this.placeOfBirth = placeOfBirth;
278+
}
279+
262280
public String getMerchantId() {
263281
return merchantId;
264282
}

src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class RecipientAccount {
88
Boolean primary;
99
String currency;
1010
String id;
11+
String recipientId;
1112
String recipientAccountId;
1213
String routeType;
1314
String recipientFees;
@@ -49,6 +50,13 @@ public void setStatus(String status){
4950
this.status = status;
5051
}
5152

53+
public String getRecipientId(){
54+
return recipientId;
55+
}
56+
public void setRecipientId(String recipientId){
57+
this.recipientId = recipientId;
58+
}
59+
5260
public String getType() {
5361
return type;
5462
}

src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public boolean delete(String recipient_id, String recipient_account_id) throws E
7575
private RecipientAccount recipientAccountFactory(String data) throws IOException {
7676
ObjectMapper mapper = new ObjectMapper();
7777
JsonNode node = mapper.readTree(data);
78+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
7879
RecipientAccount recipientAccount = mapper.readValue(node.get("account").traverse(), RecipientAccount.class);
7980
return recipientAccount;
8081
}

src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ public List<Recipient> search(int page, int pageSize, String term) throws Except
101101

102102
private Recipient recipientFactory(String data) throws IOException {
103103
ObjectMapper mapper = new ObjectMapper();
104+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
104105
JsonNode node = mapper.readTree(data);
105106
Recipient recipient = mapper.readValue(node.get("recipient").traverse(), Recipient.class);
106107
return recipient;
107108
}
108109

109110
private List<Recipient> recipientListFactory(String data) throws IOException {
110111
ObjectMapper mapper = new ObjectMapper();
112+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
111113
JsonNode node = mapper.readTree(data);
112114

113115
Object recipient = mapper.readValue(node.get("recipients").traverse(), Object.class);

src/test/java/ca/paymentrails/paymentrails/integration/BatchTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,34 @@ private Recipient createRecipient() throws Exception {
2626

2727
String email = "\"create.recipient" + uuid.toString() + "@example.com\"";
2828
String body = "{\"type\": \"individual\",\"firstName\": \"John\",\"lastName\": \"Smith\",\"email\":" + email
29-
+ ",\"address\":{\"street1\": \"123 Main St\",\"city\": \"San Francisco\",\"region\": \"CA\",\"postalCode\": \"94131\",\"country\": \"US\",\"phone\" : \"18005551212\"}}";
29+
+ ",\"address\":{\"street1\": \"123 Main St\",\"city\": \"San Francisco\",\"region\": \"CA\",\"postalCode\": \"94131\",\"country\": \"DE\",\"phone\" : \"18005551212\"}}";
3030

3131
Recipient recipient = client.recipient.create(body);
3232

33-
body = "{\"type\": \"bank-transfer\", \"primary\": \"true\", \"country\": \"CA\", \"currency\": \"CAD\",\"accountNum\": \"604622847\", \"bankId\": \"123\", \"branchId\": \"47261\", \"accountHolderName\": \"John Smith\"}";
33+
body = "{\"type\": \"bank-transfer\", \"primary\": true, \"country\": \"DE\", \"currency\": \"EUR\", \"iban\": \"DE89 3704 0044 0532 0130 00\", \"accountHolderName\": \"John Smith\"}";
34+
3435
client.recipientAccount.create(recipient.getId(), body);
3536

3637
return recipient;
3738
}
3839

3940
@Test
4041
public void testCreate() throws Exception {
41-
Gateway client = new Gateway(new Configuration("YOUR-API-KEY", "YOUR-API-SECRET", "production"));
42+
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
43+
4244

43-
String body = "{\"sourceCurrency\": \"USD\", \"description\":\"Integration Test Create\"}";
45+
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
4446
Batch batch = client.batch.create(body);
45-
assertEquals(batch.getCurrency(), "USD");
47+
assertEquals(batch.getCurrency(), "GBP");
4648
}
4749

4850
@Test
4951
public void testUpdate() throws Exception {
50-
Gateway client = new Gateway(new Configuration("YOUR-API-KEY", "YOUR-API-SECRET", "production"));
52+
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
5153

52-
String body = "{\"sourceCurrency\": \"USD\", \"description\":\"Integration Test Create\"}";
54+
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
5355
Batch batch = client.batch.create(body);
54-
assertEquals(batch.getCurrency(), "USD");
56+
assertEquals(batch.getCurrency(), "GBP");
5557

5658
body = "{\"description\" : \"Integration Update\"}";
5759
boolean response = client.batch.update(batch.getId(), body);
@@ -66,14 +68,13 @@ public void testUpdate() throws Exception {
6668

6769
@Test
6870
public void testCreateWithPayments() throws Exception {
69-
Gateway client = new Gateway(new Configuration("YOUR-API-KEY", "YOUR-API-SECRET", "production"));
71+
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
72+
7073

7174
Recipient recipientAlpha = createRecipient();
72-
Recipient recipientBeta = createRecipient();
7375

7476
String body = "{\"payments\": [{\"recipient\": {\"id\": " + "\"" + recipientAlpha.getId() + "\""
75-
+ "},\"targetAmount\": \"10.00\", \"targetCurrency\": \"CAD\"},{\"recipient\": {\"id\": " + "\""
76-
+ recipientBeta.getId() + "\"" + "},\"sourceAmount\": \"10\", \"sourceCurrency\": \"CAD\"}]}";
77+
+ "},\"amount\": \"10.00\", \"currency\": \"EUR\"}]}";
7778
Batch batch = client.batch.create(body);
7879

7980
assertNotNull(batch);
@@ -82,16 +83,17 @@ public void testCreateWithPayments() throws Exception {
8283
Batch batch1 = client.batch.find(batch.getId());
8384
assertNotNull(batch1);
8485

85-
assertEquals(2, batch1.getPayments().getPayments().size());
86+
assertEquals(1, batch1.getPayments().getPayments().size());
8687
}
8788

8889
@Test
8990
public void testPayments() throws Exception {
90-
Gateway client = new Gateway(new Configuration("YOUR-API-KEY", "YOUR-API-SECRET", "production"));
91+
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
9192

92-
String body = "{\"sourceCurrency\": \"CAD\", \"description\":\"Integration Test Create\"}";
93+
94+
String body = "{\"sourceCurrency\": \"GBP\", \"description\":\"Integration Test Create\"}";
9395
Batch batch = client.batch.create(body);
94-
assertEquals(batch.getCurrency(), "CAD");
96+
assertEquals(batch.getCurrency(), "GBP");
9597

9698
Recipient recipient = createRecipient();
9799
body = "{\"sourceAmount\":\"10.00\", \"recipient\": {\"id\": " + "\"" + recipient.getId() + "\"" + "}}";
@@ -110,20 +112,18 @@ public void testPayments() throws Exception {
110112
public void testProcessing() throws Exception {
111113
Gateway client = new Gateway(new Configuration("Your-API-KEY", "YOUR-API-SECRET", "production"));
112114

115+
113116
Recipient recipientAlpha = createRecipient();
114-
Recipient recipientBeta = createRecipient();
115117

116118
String body = "{\"payments\": [{\"recipient\": {\"id\": " + "\"" + recipientAlpha.getId() + "\""
117-
+ "},\"targetAmount\": \"10.00\", \"targetCurrency\": \"CAD\"},{\"recipient\": {\"id\": " + "\""
118-
+ recipientBeta.getId() + "\"" + "},\"sourceAmount\": \"10\", \"sourceCurrency\": \"CAD\"}]}";
119+
+ "},\"amount\": \"10.00\", \"currency\": \"EUR\"}]}";
119120

120121
Batch batch = client.batch.create(body);
121122
assertNotNull(batch);
122123
assertNotNull(batch.getId());
123124

124125
BatchSummary batchSummary = client.batch.summary(batch.getId());
125126
assertNotNull(batchSummary);
126-
assertEquals(2, batchSummary.detail.bankTransfer.count.intValue());
127127

128128
String batch1 = client.batch.generateQuote(batch.getId());
129129
assertNotNull(batch1);

src/test/java/ca/paymentrails/paymentrails/integration/RecipientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public void testAccount() throws Exception {
7676
assertEquals(recipient.getEmail(), "account.create" + uuid.toString() + "@example.com");
7777
assertNotNull(recipient.getId());
7878

79-
body = "{\"type\": \"bank-transfer\", \"primary\": \"true\", \"country\": \"CA\", \"currency\": \"CAD\",\"accountNum\": \"604622847\", \"bankId\": \"123\", \"branchId\": \"47261\", \"accountHolderName\": \"Tom Jones\"}";
79+
body = "{\"type\": \"bank-transfer\", \"primary\": true, \"country\": \"DE\", \"currency\": \"EUR\", \"iban\": \"DE89 3704 0044 0532 0130 00\", \"accountHolderName\": \"Tom Jones\"}";
8080
RecipientAccount recipientAccount = client.recipientAccount.create(recipient.getId(), body);
8181
assertEquals("Tom Jones", recipientAccount.getAccountHolderName());
8282

83-
body = "{\"type\": \"bank-transfer\", \"primary\": \"true\", \"country\": \"CA\", \"currency\": \"CAD\",\"accountNum\": \"604622848\", \"bankId\": \"123\", \"branchId\": \"47261\", \"accountHolderName\": \"Tom Jones\"}";
83+
body = "{\"type\": \"bank-transfer\", \"primary\": true, \"country\": \"DE\", \"currency\": \"EUR\", \"iban\": \"DE89 3704 0044 0532 0130 00\", \"accountHolderName\": \"Tom Jones2\"}";
8484
RecipientAccount recipientAccount1 = client.recipientAccount.create(recipient.getId(), body);
85-
assertEquals("Tom Jones", recipientAccount1.getAccountHolderName());
85+
assertEquals("Tom Jones2", recipientAccount1.getAccountHolderName());
8686

8787
RecipientAccount recipAccount = client.recipientAccount.find(recipient.getId(), recipientAccount.getId());
8888
assertEquals(recipAccount.getCountry(), recipientAccount.getCountry());

0 commit comments

Comments
 (0)