Skip to content

Commit 244bbb6

Browse files
committed
Add refund resource, add refunds property to charges, fix some balanceTransaction methods
1 parent 2489d71 commit 244bbb6

File tree

6 files changed

+73
-1
lines changed

6 files changed

+73
-1
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.stripe.model;
22

33
import java.util.Map;
4+
import java.util.List;
45

56
import com.stripe.exception.APIConnectionException;
67
import com.stripe.exception.APIException;
@@ -24,6 +25,7 @@ public class Charge extends APIResource {
2425
Integer amountRefunded;
2526
String customer;
2627
String invoice;
28+
List<Refund> refunds;
2729
Card card;
2830
Dispute dispute;
2931
String balanceTransaction;
@@ -156,6 +158,22 @@ public void setDispute(Dispute dispute) {
156158
this.dispute = dispute;
157159
}
158160

161+
public List<Refund> getRefunds() {
162+
return refunds;
163+
}
164+
165+
public void setRefunds(List<Refund> refunds) {
166+
this.refunds = refunds;
167+
}
168+
169+
public String getBalanceTransaction() {
170+
return balanceTransaction;
171+
}
172+
173+
public void setBalanceTransaction(String balanceTransaction) {
174+
this.balanceTransaction = balanceTransaction;
175+
}
176+
159177
public static Charge create(Map<String, Object> params)
160178
throws AuthenticationException, InvalidRequestException,
161179
APIConnectionException, CardException, APIException {

src/main/java/com/stripe/model/Dispute.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Dispute extends StripeObject {
1010
String evidence;
1111
Long evidenceDueBy;
1212
String reason;
13+
String balanceTransaction;
1314

1415
public Integer getAmount() {
1516
return amount;
@@ -65,4 +66,10 @@ public String getReason() {
6566
public void setReason(String reason) {
6667
this.reason = reason;
6768
}
68-
}
69+
public String getBalanceTransaction() {
70+
return balanceTransaction;
71+
}
72+
public void setBalanceTransaction(String balanceTransaction) {
73+
this.balanceTransaction = balanceTransaction;
74+
}
75+
}

src/main/java/com/stripe/model/EventDataDeserializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class EventDataDeserializer implements JsonDeserializer<EventData> {
3131
objectMap.put("coupon", Coupon.class);
3232
objectMap.put("transfer", Transfer.class);
3333
objectMap.put("dispute", Dispute.class);
34+
objectMap.put("refund", Refund.class);
3435
objectMap.put("recipient", Recipient.class);
3536
objectMap.put("summary", Summary.class);
3637
objectMap.put("fee", Fee.class);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.stripe.model;
2+
3+
public class Refund extends StripeObject {
4+
Integer amount;
5+
String currency;
6+
Long created;
7+
String balanceTransaction;
8+
9+
public Integer getAmount() {
10+
return amount;
11+
}
12+
public void setAmount(Integer amount) {
13+
this.amount = amount;
14+
}
15+
public String getCurrency() {
16+
return currency;
17+
}
18+
public void setCurrency(String currency) {
19+
this.currency = currency;
20+
}
21+
public Long getCreated() {
22+
return created;
23+
}
24+
public void setCreated(Long created) {
25+
this.created = created;
26+
}
27+
public String getBalanceTransaction() {
28+
return balanceTransaction;
29+
}
30+
public void setBalanceTransaction(String balanceTransaction) {
31+
this.balanceTransaction = balanceTransaction;
32+
}
33+
}

src/main/java/com/stripe/model/Transfer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Transfer extends APIResource {
2323
List<String> otherTransfers;
2424
String recipient;
2525
BankAccount account;
26+
String balanceTransaction;
2627

2728
public String getId() {
2829
return id;
@@ -120,6 +121,14 @@ public void setOtherTransfers(List<String> otherTransfers) {
120121
this.otherTransfers = otherTransfers;
121122
}
122123

124+
public String getBalanceTransaction() {
125+
return balanceTransaction;
126+
}
127+
128+
public void setBalanceTransaction(String balanceTransaction) {
129+
this.balanceTransaction = balanceTransaction;
130+
}
131+
123132
public static Transfer create(Map<String, Object> params)
124133
throws AuthenticationException, InvalidRequestException,
125134
APIConnectionException, CardException, APIException {

src/test/java/com/stripe/StripeTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.stripe.model.Transfer;
4343
import com.stripe.model.Recipient;
4444
import com.stripe.model.DeletedRecipient;
45+
import com.stripe.model.Refund;
4546

4647
public class StripeTest {
4748
static HashMap<String, Object> defaultCardParams = new HashMap<String, Object>();
@@ -204,6 +205,9 @@ public void testChargeRefund() throws StripeException {
204205
Charge createdCharge = Charge.create(defaultChargeParams);
205206
Charge refundedCharge = createdCharge.refund();
206207
assertTrue(refundedCharge.getRefunded());
208+
assertTrue(refundedCharge.getRefunds() instanceof List);
209+
assertEquals(1, refundedCharge.getRefunds().size());
210+
assertTrue(refundedCharge.getRefunds().get(0) instanceof Refund);
207211
}
208212

209213
@Test

0 commit comments

Comments
 (0)