Skip to content

Commit 223840e

Browse files
author
Jacob Kessler
committed
Merging in checkout-ach-support branch
1 parent c809801 commit 223840e

17 files changed

+108
-17
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ build.xml
1111
sources.txt
1212
test
1313
/target/
14+
15+
# IDE files #
16+
#############
17+
.idea/
18+
*.iml

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2016-04-15
2+
* Released v5.1.0, updating API support to 2016-03-30
3+
* Added support for several new data fields in /checkout: payment_error, non-profit org data, and bank information for ACH payments
4+
15
2016-01-25
26
* Released v5.0.0 (includes changes from v4.0.4 that was never released)
37
* Removed transactionAmount and transactionCurrency from EmvReceiptData

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ WePay-Java-SDK
33

44
Note
55
================================
6-
This WePay-Java-SDK is for <a href = "https://www.wepay.com/developer/version/2015-11-18">WePay Api Version 2015-11-18</a>. The jar for the previous API versions can be found in the lib folder.
6+
This WePay-Java-SDK is for <a href = "https://www.wepay.com/developer/version/2015-03-30">WePay Api Version 2015-03-30</a>. The jar for the previous API versions can be found in the lib folder.
77

88
Building
99
================================

lib/wepay-2015-11-18.jar

52.9 KB
Binary file not shown.

lib/wepay.jar

2.09 KB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.wepay</groupId>
1010
<artifactId>wepay-java-sdk</artifactId>
11-
<version>5.0.0</version>
11+
<version>5.1.0</version>
1212

1313
<name>wepay-java-sdk</name>
1414
<description>WePay Java SDK</description>

src/main/java/com/wepay/model/Checkout.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import java.io.IOException;
44
import java.math.BigDecimal;
55

6+
import com.wepay.model.data.BankAccountPaymentErrorData;
7+
import com.wepay.model.data.NPOInformationData;
8+
import com.wepay.model.data.PaymentErrorData;
69
import org.json.JSONArray;
710
import org.json.JSONException;
811
import org.json.JSONObject;
@@ -92,7 +95,7 @@ public static Checkout create(CheckoutData data, String accessToken) throws JSON
9295

9396
if (data.hostedCheckout != null) params.put("hosted_checkout", HostedCheckoutData.build_hosted_checkout(data.hostedCheckout));
9497

95-
if (data.paymentMethod != null) params.put("payment_method", PaymentMethodData.build_payment_method(data.paymentMethod));
98+
if (data.paymentMethod != null) params.put("payment_method", data.paymentMethod.toJSON());
9699

97100
if (data.deliveryType != null) params.put("delivery_type", data.deliveryType);
98101

@@ -346,4 +349,22 @@ public Long[] getPayerRbitIds() {
346349
public Long[] getTransactionRbitIds() {
347350
return transactionRbitIds;
348351
}
352+
353+
public PaymentErrorData getPaymentErrorData() {
354+
return checkoutData.paymentError;
355+
}
356+
357+
public PaymentMethodData getPaymentMethodData() {
358+
return checkoutData.paymentMethod;
359+
}
360+
361+
public NPOInformationData getNPOInformation() {
362+
return checkoutData.npoInformation;
363+
}
364+
365+
public CheckoutData getAllCheckoutData() {
366+
return checkoutData;
367+
}
368+
369+
349370
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.wepay.model.data;
2+
3+
public class BankAccountPaymentErrorData {
4+
5+
public String code;
6+
public String description;
7+
8+
// This object may be present in the response, but should never be in the request.
9+
10+
}

src/main/java/com/wepay/model/data/CheckoutData.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ public class CheckoutData {
2929
public String callbackUri;
3030
public EmailMessageData emailMessage;
3131
public PaymentMethodData paymentMethod;
32+
public PaymentErrorData paymentError;
33+
public NPOInformationData npoInformation;
34+
3235
}

src/main/java/com/wepay/model/data/CreditCardAdditionalData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public class CreditCardAdditionalData {
1313
public String signatureUrl;
1414
public EmvReceiptData emvReceipt;
1515

16-
public static JSONObject buildCreditCardAdditionalData(CreditCardAdditionalData info) throws JSONException {
16+
public JSONObject toJSON() throws JSONException {
1717
JSONObject o = new JSONObject();
18-
o.put("transaction_token", info.transactionToken);
18+
o.put("transaction_token", transactionToken);
1919
return o;
2020
}
2121
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.wepay.model.data;
2+
3+
import org.json.JSONException;
4+
import org.json.JSONObject;
5+
6+
public class NPOInformationData {
7+
public String legalName;
8+
public String ein;
9+
10+
public JSONObject toJSON() throws JSONException {
11+
JSONObject o = new JSONObject();
12+
if (legalName != null) o.put("legal_name", legalName);
13+
if (ein != null) o.put("ein", ein);
14+
return o;
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.wepay.model.data;
2+
3+
import org.json.JSONException;
4+
import org.json.JSONObject;
5+
6+
public class PMBankAccountData {
7+
public Long id;
8+
public String bankName;
9+
public String type;
10+
11+
public JSONObject toJSON() throws JSONException{
12+
JSONObject o = new JSONObject(); // Responses may contain the bank name and account type, but requests never should
13+
if (id != null) o.put("id", id);
14+
return o;
15+
}
16+
17+
}

src/main/java/com/wepay/model/data/PMCreditCardData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ public class PMCreditCardData {
55
public Long id;
66
public CreditCardAdditionalData data;
77

8-
public static JSONObject buildCreditCard(PMCreditCardData info) throws JSONException {
8+
public JSONObject toJSON() throws JSONException {
99
JSONObject o = new JSONObject();
10-
o.put("id", info.id);
11-
if (info.data != null) {
12-
o.put("data", CreditCardAdditionalData.buildCreditCardAdditionalData(info.data));
10+
o.put("id", id);
11+
if (data != null) {
12+
o.put("data", data.toJSON());
1313
}
1414
return o;
1515
}

src/main/java/com/wepay/model/data/PMPreapprovalData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
public class PMPreapprovalData {
55
public Long id;
66

7-
public static JSONObject buildPreapproval(PMPreapprovalData info) throws JSONException {
7+
public JSONObject toJSON() throws JSONException {
88
JSONObject o = new JSONObject();
9-
o.put("id", info.id);
9+
o.put("id", id);
1010
return o;
1111
}
1212
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.wepay.model.data;
2+
3+
import org.json.JSONException;
4+
import org.json.JSONObject;
5+
6+
public class PaymentErrorData {
7+
8+
public String type;
9+
public BankAccountPaymentErrorData bankAccount;
10+
11+
// This object may be present in the response, but should never be passed in as part of the request
12+
}

src/main/java/com/wepay/model/data/PaymentMethodData.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ public class PaymentMethodData {
66
public String type;
77
public PMCreditCardData creditCard;
88
public PMPreapprovalData preapproval;
9+
public PMBankAccountData bankAccount;
910

10-
public static JSONObject build_payment_method(PaymentMethodData info) throws JSONException {
11+
12+
public JSONObject toJSON() throws JSONException {
1113
JSONObject o = new JSONObject();
12-
o.put("type", info.type);
13-
if (info.creditCard != null) o.put("credit_card", PMCreditCardData.buildCreditCard(info.creditCard));
14-
if (info.preapproval != null) o.put("preapproval", PMPreapprovalData.buildPreapproval(info.preapproval));
14+
o.put("type", type);
15+
if (creditCard != null) o.put("credit_card", creditCard.toJSON()); // Only one of credit card, preapproval, or bank account can be present
16+
else if (preapproval != null) o.put("preapproval", preapproval.toJSON());
17+
else if (bankAccount != null) o.put("bank_account", bankAccount.toJSON());
1518
return o;
1619
}
1720
}

src/main/java/com/wepay/net/WePayResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ protected static javax.net.ssl.HttpsURLConnection httpsConnect(String call, Stri
5454
connection.setDoInput(true);
5555
connection.setRequestMethod("POST");
5656
connection.setRequestProperty("Content-Type", "application/json");
57-
connection.setRequestProperty("Api-Version", "2015-11-18");
58-
connection.setRequestProperty("User-Agent", "WePay Java SDK v5.0.0");
57+
connection.setRequestProperty("Api-Version", "2016-03-30");
58+
connection.setRequestProperty("User-Agent", "WePay Java SDK v5.1.0");
5959
if (accessToken != null) {
6060
connection.setRequestProperty("Authorization", "Bearer " + accessToken);
6161
}

0 commit comments

Comments
 (0)