Skip to content

Commit

Permalink
Merge pull request #59 from wepay/feature-version-2019-04-03
Browse files Browse the repository at this point in the history
Released v12.0.0, updating API support to 2019-04-03
  • Loading branch information
SharonLingqiongTan authored Jul 8, 2019
2 parents 682cf80 + 390b352 commit cd499d1
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2019-04-30
* Released v12.0.0, updating API support to 2019-04-03
* Added CreditCardModifyData
* Added optional cardOnFile and recurring for CreditCard.modify
* Added getCardOnFile() and getRecurring() for CreditCard

2018-12-13
* Released v11.0.1
* Handled potential NullPointerExceptions
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WePay-Java-SDK

Note
================================
This WePay-Java-SDK is for WePay API Version 2018-10-03. The jars for the previous API versions can be found in the lib folder. From Dec 13, 2018, the default jar name will include the SDK version.
This WePay-Java-SDK is for WePay API Version 2019-04-03. The jars for the previous API versions can be found in the lib folder. From Dec 13, 2018, the default jar name will include the SDK version.

Building
================================
Expand Down
Binary file not shown.
File renamed without changes.
Binary file added lib/wepay.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.wepay</groupId>
<artifactId>wepay-java-sdk</artifactId>
<version>11.0.1</version>
<version>12.0.0</version>

<name>wepay-java-sdk</name>
<description>WePay Java SDK</description>
Expand Down
33 changes: 24 additions & 9 deletions src/main/java/com/wepay/model/CreditCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class CreditCard extends WePayResource {
protected String backingInstrumentName;
protected Boolean autoUpdate;
protected Long[] rbitIds;
protected Boolean cardOnFile;
protected Boolean recurring;

public CreditCard(Long creditCardId) {
this.creditCardId = creditCardId;
Expand All @@ -48,22 +50,28 @@ public static CreditCard fetch(Long creditCardId, HeaderData headerData) throws
return cc;
}

public static CreditCard modify(Long creditCardId, String accessToken, Boolean autoUpdate, String callbackUri) throws JSONException, IOException, WePayException {
public static CreditCard modify(CreditCardModifyData creditCardModifyData, String accessToken) throws JSONException, IOException, WePayException {
HeaderData headerData = new HeaderData();
headerData.accessToken = accessToken;
return CreditCard.modify(creditCardId, headerData, autoUpdate, callbackUri);
return CreditCard.modify(creditCardModifyData, headerData);
}

public static CreditCard modify(Long creditCardId, HeaderData headerData, Boolean autoUpdate, String callbackUri) throws JSONException, IOException, WePayException {
public static CreditCard modify(CreditCardModifyData creditCardModifyData, HeaderData headerData) throws JSONException, IOException, WePayException {
JSONObject params = new JSONObject();
params.put("client_id", WePay.clientId);
params.put("client_secret", WePay.clientSecret);
params.put("credit_card_id", creditCardId);
if (autoUpdate != null) {
params.put("auto_update", autoUpdate);
params.put("credit_card_id", creditCardModifyData.creditCardId);
if (creditCardModifyData.autoUpdate != null) {
params.put("auto_update", creditCardModifyData.autoUpdate);
}
if (creditCardModifyData.callbackUri != null) {
params.put("callback_uri", creditCardModifyData.callbackUri);
}
if (callbackUri != null) {
params.put("callback_uri", callbackUri);
if (creditCardModifyData.cardOnFile != null) {
params.put("card_on_file", creditCardModifyData.cardOnFile);
}
if (creditCardModifyData.recurring != null) {
params.put("recurring", creditCardModifyData.recurring);
}

String response = request("/credit_card/modify", params, headerData);
Expand Down Expand Up @@ -214,5 +222,12 @@ public Boolean getAutoUpdate() {
public Long[] getRbitIds() {
return rbitIds;
}


public Boolean getCardOnFile() {
return cardOnFile;
}

public Boolean getRecurring() {
return recurring;
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/wepay/model/data/CreditCardModifyData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.wepay.model.data;

import org.json.JSONException;
import org.json.JSONObject;

public class CreditCardModifyData {
public Long creditCardId;
public Boolean autoUpdate;
public String callbackUri;
public Boolean cardOnFile;
public Boolean recurring;
}
4 changes: 2 additions & 2 deletions src/main/java/com/wepay/net/WePayResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ protected static javax.net.ssl.HttpsURLConnection httpsConnect(String call, Head
connection.setDoInput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Api-Version", "2018-10-03");
connection.setRequestProperty("User-Agent", "WePay Java SDK v11.0.1");
connection.setRequestProperty("Api-Version", "2019-04-03");
connection.setRequestProperty("User-Agent", "WePay Java SDK v12.0.0");

if (headerData != null) {
if (headerData.accessToken != null) {
Expand Down

0 comments on commit cd499d1

Please sign in to comment.