Skip to content

Commit 7643b3a

Browse files
authored
Merge pull request #41 from wepay/autoUpdate
Added support for credit_card/modify and the auto_update param
2 parents 3a206d3 + fdd171a commit 7643b3a

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-07-22
2+
* Released v5.1.2
3+
* Added support for credit_card/modify
4+
* Added support for auto_update field in CreditCard object
5+
16
2016-06-21
27
* Released v5.1.1
38
* Added support for app-level preapprovals

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.1.1</version>
11+
<version>5.1.2</version>
1212

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

sample_calls/CreditCardCalls.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public static void main() {
2424
"state": "authorized",
2525
"user_name": "John Smith",
2626
"email": "john.smith@gmail.com",
27-
"create_time": 1373414206
27+
"create_time": 1373414206,
28+
"auto_update": false
2829
}
2930
*/
3031
/****************************************************************************/
@@ -40,10 +41,28 @@ public static void main() {
4041
"state": "authorized",
4142
"user_name": "John Smith",
4243
"email": "john.smith@gmail.com",
43-
"create_time": 1373414206
44+
"create_time": 1373414206,
45+
"auto_update": false
4446
}
4547
*/
4648
/****************************************************************************/
49+
/**
50+
* FETCH call
51+
*/
52+
CreditCard updatedCreditCard = CreditCard.modify(2476834062, myAccessToken, true, null);
53+
/**
54+
updatedCreditCard:
55+
{
56+
"credit_card_id": 2476834062,
57+
"credit_card_name": "MasterCard xxxxxx0633",
58+
"state": "authorized",
59+
"user_name": "John Smith",
60+
"email": "john.smith@gmail.com",
61+
"create_time": 1373414206,
62+
"auto_update": true
63+
}
64+
*/
65+
/****************************************************************************/
4766
/**
4867
* FIND call
4968
*/
@@ -57,15 +76,17 @@ public static void main() {
5776
"state": "authorized",
5877
"user_name": "John Smith",
5978
"email": "john.smith@gmail.com",
60-
"create_time": 1373414206
79+
"create_time": 1373414206,
80+
"auto_update": false
6181
},
6282
{
6383
"credit_card_id": 6384023873,
6484
"credit_card_name": "MasterCard xxxxxx0381",
6585
"state": "authorized",
6686
"user_name": "John Smith",
6787
"email": "john.smith@gmail.com",
68-
"create_time": 1372493226
88+
"create_time": 1372493226,
89+
"auto_update": false
6990
}
7091
]
7192
*/

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class CreditCard extends WePayResource {
2323
protected Integer expirationMonth;
2424
protected Integer expirationYear;
2525
protected String lastFour;
26+
protected Boolean autoUpdate;
2627
protected Long[] rbitIds;
2728

2829
public CreditCard(Long creditCardId) {
@@ -38,6 +39,23 @@ public static CreditCard fetch(Long creditCardId, String accessToken) throws JSO
3839
CreditCard cc = gson.fromJson(response, CreditCard.class);
3940
return cc;
4041
}
42+
43+
public static CreditCard modify(Long creditCardId, String accessToken, Boolean autoUpdate, String callbackUri) throws JSONException, IOException, WePayException {
44+
JSONObject params = new JSONObject();
45+
params.put("client_id", WePay.clientId);
46+
params.put("client_secret", WePay.clientSecret);
47+
params.put("credit_card_id", creditCardId);
48+
if (autoUpdate != null) {
49+
params.put("auto_update", autoUpdate);
50+
}
51+
if (callbackUri != null) {
52+
params.put("callback_uri", callbackUri);
53+
}
54+
55+
String response = request("/credit_card/modify", params, accessToken);
56+
CreditCard cc = gson.fromJson(response, CreditCard.class);
57+
return cc;
58+
}
4159

4260
public void authorize(String accessToken) throws JSONException, IOException, WePayException {
4361
JSONObject params = new JSONObject();
@@ -121,6 +139,10 @@ public Integer getExpirationYear() {
121139
public String getLastFour() {
122140
return lastFour;
123141
}
142+
143+
public Boolean getAutoUpdate() {
144+
return autoUpdate;
145+
}
124146

125147
public Long[] getRbitIds() {
126148
return rbitIds;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected static javax.net.ssl.HttpsURLConnection httpsConnect(String call, Stri
5555
connection.setRequestMethod("POST");
5656
connection.setRequestProperty("Content-Type", "application/json");
5757
connection.setRequestProperty("Api-Version", "2016-03-30");
58-
connection.setRequestProperty("User-Agent", "WePay Java SDK v5.1.1");
58+
connection.setRequestProperty("User-Agent", "WePay Java SDK v5.1.2");
5959
if (accessToken != null) {
6060
connection.setRequestProperty("Authorization", "Bearer " + accessToken);
6161
}

0 commit comments

Comments
 (0)