Skip to content

Commit 4abbec8

Browse files
author
Aman Aalam
authored
Merge pull request #25 from trolley/dev
RC v1.1.1
2 parents 72566dc + c4ef471 commit 4abbec8

9 files changed

Lines changed: 62 additions & 58 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ nb-configuration
22
target
33
nbproject
44
.classpath
5+
.idea/*
56
.project
67
.settings
78
.settings/*
@@ -10,4 +11,4 @@ nbproject
1011
.vscode/*
1112
src/main/java/com/trolley/trolley/index.java
1213
/.metadata/
13-
.env
14+
.env

.mvn/jvm.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--add-opens java.base/java.util=ALL-UNNAMED
2+
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
3+
--add-opens java.base/java.text=ALL-UNNAMED
4+
--add-opens java.desktop/java.awt.font=ALL-UNNAMED

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Trolley Java SDK (Previously Payment Rails[^1])
1+
# Trolley Java SDK
22

33
A native Java SDK for Trolley
44

5-
[^1]: [Payment Rails is now Trolley](https://www.trolley.com/payment-rails-is-now-trolley-series-a). We're in the process of updating our SDKs to support the new domain. In this transition phase, you might still see "PaymentRails" at some places.
6-
75
## Installation
86

97
#
@@ -22,21 +20,21 @@ Add this dependency to your project's POM:
2220
<dependency>
2321
<groupId>com.trolley</groupId>
2422
<artifactId>java-sdk</artifactId>
25-
<version>1.0.1</version>
23+
<version>1.1.1</version>
2624
</dependency>
2725
```
2826

29-
The library's source is hosted at [https://github.com/paymentRails/java-sdk](https://github.com/paymentRails/java-sdk)
27+
The library's source is hosted at [https://github.com/paymentRails/java-sdk](https://github.com/trolley/java-sdk)
3028

31-
The library can be found at: [https://central.sonatype.com/artifact/com.trolley/java-sdk/1.0](https://central.sonatype.com/artifact/com.trolley/java-sdk/1.0)
29+
The library can be found at: [https://central.sonatype.com/artifact/com.trolley/java-sdk/](https://central.sonatype.com/artifact/com.trolley/java-sdk/)
3230

3331
## Getting Started
3432

3533
```java
3634
import com.trolley.java-sdk.*;
3735
import com.trolley.Exceptions.*;
3836

39-
public class PaymentRailsExample {
37+
public class TrolleyExample {
4038
public static void main(String[] args) {
4139

4240
Gateway client = new Gateway(new Configuration("YOUR_PUBLIC_KEY","YOUR_PRIVATE_KEY","production"));

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.trolley</groupId>
55
<artifactId>java-sdk</artifactId>
6-
<version>1.1.0</version>
6+
<version>1.1.1</version>
77
<description>Java SDK for Trolley API</description>
88
<packaging>jar</packaging>
99
<name>Trolley Java SDK</name>
10-
<url>https://github.com/PaymentRails/java-sdk</url>
10+
<url>https://github.com/Trolley/java-sdk</url>
1111

1212
<licenses>
1313
<license>
@@ -41,9 +41,9 @@
4141
</developer>
4242
</developers>
4343
<scm>
44-
<connection>scm:git:git://github.com/PaymentRails/java-sdk.git</connection>
45-
<developerConnection>scm:git:git://github.com/PaymentRails/java-sdk.git</developerConnection>
46-
<url>https://github.com/PaymentRails/java-sdk</url>
44+
<connection>scm:git:git://github.com/Trolley/java-sdk.git</connection>
45+
<developerConnection>scm:git:git://github.com/Trolley/java-sdk.git</developerConnection>
46+
<url>https://github.com/Trolley/java-sdk</url>
4747
<tag>HEAD</tag>
4848
</scm>
4949
<properties>
@@ -67,7 +67,7 @@
6767
<plugin>
6868
<groupId>org.sonatype.plugins</groupId>
6969
<artifactId>nexus-staging-maven-plugin</artifactId>
70-
<version>1.6.7</version>
70+
<version>1.6.13</version>
7171
<extensions>true</extensions>
7272
<configuration>
7373
<serverId>ossrh</serverId>

src/main/java/com/trolley/trolley/Client.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.IOException;
2121
import java.io.InputStream;
2222
import java.rmi.UnexpectedException;
23-
import java.io.Reader;
2423
import java.io.BufferedReader;
2524
import java.io.InputStreamReader;
2625
import java.io.DataOutputStream;

src/main/java/com/trolley/trolley/Recipient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Recipient
3434
String payoutMethod;
3535
public Object payout;
3636
String emailAddress;
37+
List<String> contactEmails;
3738
public Object inactiveReasons;
3839
Compliance compliance;
3940
List<RecipientAccount> accounts;
@@ -165,6 +166,14 @@ public String getEmail() {
165166
public void setEmail(final String email) {
166167
this.email = email;
167168
}
169+
170+
public List<String> getContactEmails() {
171+
return this.contactEmails;
172+
}
173+
174+
public void setContactEmails(final List<String> contactEmails) {
175+
this.contactEmails = contactEmails;
176+
}
168177

169178
public String getName() {
170179
return this.name;

src/test/java/com/trolley/sdk/integration/InvoiceTests.java

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,24 @@ public void testInvoices() throws Exception {
4848
}
4949
};
5050

51-
// Create a new invoice
52-
Invoice invoice = client.invoice.create(new Invoice(
53-
recipient.getId(),
54-
"invoice-123",
55-
"test-invoice-create-java-sdk",
56-
"ext-id-"+System.currentTimeMillis(),
57-
null,
58-
null,
59-
null,
60-
invoiceLines));
51+
// Create a new invoice - request body
52+
Invoice invoice = new Invoice();
53+
invoice.setRecipientId(recipient.getId());
54+
invoice.setInvoiceNumber("invoice-123");
55+
invoice.setDescription("test-invoice-create-java-sdk");
56+
invoice.setExternalId("ext-id-"+System.currentTimeMillis());
57+
invoice.setLines(invoiceLines);
58+
59+
// Create a new invoice - receiving response
60+
invoice = client.invoice.create(invoice);
6161
assertEquals(invoice.getRecipientId(), recipient.getId());
6262

6363
//Update an Invoice
64+
Invoice updateInvoiceRequest = new Invoice();
65+
updateInvoiceRequest.setDescription("test-invoice-update-java-sdk");
6466
final Invoice updatedInvoice = client.invoice.update(
6567
invoice.getId(),
66-
new Invoice(
67-
null,
68-
"invoice-123",
69-
"test-invoice-update-java-sdk",
70-
null,
71-
null,
72-
null,
73-
null,
74-
null
75-
));
68+
updateInvoiceRequest);
7669
assertEquals(updatedInvoice.getDescription(),"test-invoice-update-java-sdk");
7770
assertEquals(updatedInvoice.getId(),invoice.getId());
7871

@@ -110,32 +103,29 @@ public void testInvoiceLines() throws Exception {
110103
final Recipient recipient = testHelper.createRecipient();
111104

112105
//Setup - create Invoice
113-
Invoice invoice = client.invoice.create(new Invoice(
114-
recipient.getId(),
115-
"invoice-123",
116-
"test-invoice-create-java-sdk",
117-
"ext-id-"+System.currentTimeMillis(),
118-
null,
119-
null,
120-
null,
121-
null));
106+
Invoice createInvoiceRequest = new Invoice();
107+
createInvoiceRequest.setRecipientId(recipient.getId());
108+
createInvoiceRequest.setInvoiceNumber("invoice-123");
109+
createInvoiceRequest.setDescription("test-invoice-create-java-sdk");
110+
createInvoiceRequest.setExternalId("ext-id-"+System.currentTimeMillis());
111+
112+
Invoice invoice = client.invoice.create(createInvoiceRequest);
122113
assertEquals(invoice.getRecipientId(), recipient.getId());
123114

124115
//Add a new Invoice Line to the Invoice just created
125-
Invoice invoiceWithLines = client.invoiceLine.create(invoice.getId(),
126-
new InvoiceLine(
127-
new Amount("100", "USD"),
128-
InvoiceLine.InvoiceCategories.SERVICES,
129-
"Invoice Line from Java SDK",
130-
"ILine-ExtId-"+System.currentTimeMillis(),
131-
true,
132-
true,
133-
null,
134-
"2",
135-
new Amount("10", "USD"),
136-
new Amount("5", "USD"),
137-
null,
138-
null));
116+
InvoiceLine invoiceLineRequest = new InvoiceLine();
117+
invoiceLineRequest.setUnitAmount(new Amount("100", "USD"));
118+
invoiceLineRequest.setCategory(InvoiceLine.InvoiceCategories.SERVICES);
119+
invoiceLineRequest.setDescription("Invoice Line from Java SDK");
120+
invoiceLineRequest.setExternalId("ILine-ExtId-"+System.currentTimeMillis());
121+
invoiceLineRequest.setTaxReportable(true);
122+
invoiceLineRequest.setForceUsTaxActivity(true);
123+
invoiceLineRequest.setQuantity("2");
124+
invoiceLineRequest.setDiscountAmount(new Amount("10", "USD"));
125+
invoiceLineRequest.setTaxAmount(new Amount("5", "USD"));
126+
127+
Invoice invoiceWithLines = client.invoiceLine.create(invoice.getId(), invoiceLineRequest);
128+
139129
assertEquals(invoiceWithLines.getLines().get(0).getUnitAmount().getValue(), "100.00");
140130

141131
//Add multiple new Invoice Lines to the Invoice created

src/test/java/com/trolley/sdk/integration/RecipientTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.trolley.trolley.RecipientAccount;
1515

1616
import java.util.ArrayList;
17+
import java.util.Arrays;
1718
import java.util.List;
1819

1920
@PrepareForTest(Recipient.class)
@@ -34,6 +35,7 @@ public void testCreateRecipient() throws Exception {
3435
assertEquals(recipient.getFirstName(), "John");
3536
assertEquals(recipient.getLastName(), "Smith");
3637
assertNotNull(recipient.getId());
38+
assertEquals(recipient.getContactEmails(), Arrays.asList("john1@example.com", "john2@example.com"));
3739

3840
//Cleanup
3941
boolean deleteResult = testHelper.deleteRecipient(recipient);

src/test/java/com/trolley/sdk/integration/TestHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public Recipient createRecipient() throws Exception {
3333

3434
String email = "\"create.recipient.java-sdk." + uuid.toString() + "@example.com\"";
3535
String body = "{\"type\": \"individual\",\"firstName\": \"John\",\"lastName\": \"Smith\",\"email\":" + email
36+
+ ",\"contactEmails\": [\"john1@example.com\", \"john2@example.com\"]"
3637
+ ",\"address\":{\"street1\": \"123 Main St\",\"city\": \"San Francisco\",\"region\": \"CA\",\"postalCode\": \"94131\",\"country\": \"DE\",\"phone\" : \"18005551212\"}}";
3738

3839
Recipient recipient = client.recipient.create(body);

0 commit comments

Comments
 (0)