Skip to content

Commit eb035f8

Browse files
committed
remove old refund method; update example
1 parent 9a90702 commit eb035f8

3 files changed

Lines changed: 3 additions & 31 deletions

File tree

example/PingppExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void refund() {
4747
Map<String, Object> refundMap = new HashMap<String, Object>();
4848
refundMap.put("amount", 100);
4949
refundMap.put("description", "小苹果");
50-
charge.refund(refundMap);
51-
System.out.println(charge);
50+
Refund re = charge.getRefunds().create(refundMap);
51+
System.out.println(re);
5252
} catch (PingppException e) {
5353
e.printStackTrace();
5454
}

src/main/java/com/pingplusplus/model/Charge.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@ public static ChargeCollection all(Map<String, Object> params)
293293
return all(params, null);
294294
}
295295

296-
public Charge refund() throws AuthenticationException,
297-
InvalidRequestException, APIConnectionException,
298-
APIException {
299-
return this.refund(null, null);
300-
}
301-
302-
public Charge refund(Map<String, Object> params)
303-
throws AuthenticationException, InvalidRequestException,
304-
APIConnectionException, APIException {
305-
return this.refund(params, null);
306-
}
307-
308296
public static Charge create(Map<String, Object> params, String apiKey)
309297
throws AuthenticationException, InvalidRequestException,
310298
APIConnectionException, APIException {
@@ -332,20 +320,4 @@ public static ChargeCollection all(Map<String, Object> params, String apiKey)
332320
return request(RequestMethod.GET, classURL(Charge.class), params,
333321
ChargeCollection.class, apiKey);
334322
}
335-
336-
public Charge refund(String apiKey) throws AuthenticationException,
337-
InvalidRequestException, APIConnectionException,
338-
APIException {
339-
return this.refund((Map<String, Object>) null, apiKey); // full refund
340-
}
341-
342-
public Charge refund(Map<String, Object> params, String apiKey)
343-
throws AuthenticationException, InvalidRequestException,
344-
APIConnectionException, APIException {
345-
return request(
346-
RequestMethod.POST,
347-
String.format("%s/refunds",
348-
instanceURL(Charge.class, this.getId())), params,
349-
Charge.class, apiKey);
350-
}
351323
}

src/main/java/com/pingplusplus/model/ChargeDeserializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Charge deserialize(JsonElement jsonElement, Type type, JsonDeserializatio
1919
Charge charge = gson.fromJson(jsonElement, Charge.class);
2020
final JsonObject obj = jsonElement.getAsJsonObject();
2121
final JsonElement appElement = obj.get("app");
22-
if (appElement.isJsonObject()) {
22+
if (appElement != null && appElement.isJsonObject()) {
2323
App app = gson.fromJson(appElement, App.class);
2424
charge.setApp(app);
2525
}

0 commit comments

Comments
 (0)