Skip to content

Commit c219328

Browse files
committed
update balancetransaction and subscription
1 parent 2f11dd2 commit c219328

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

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

Lines changed: 52 additions & 1 deletion
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.Stripe;
67
import com.stripe.exception.APIConnectionException;
@@ -11,6 +12,7 @@
1112
import com.stripe.net.APIResource;
1213

1314
public class BalanceTransaction extends APIResource {
15+
String id;
1416
String source;
1517
Integer amount;
1618
String currency;
@@ -19,6 +21,17 @@ public class BalanceTransaction extends APIResource {
1921
Long created;
2022
Long availableOn;
2123
String status;
24+
Long fee;
25+
List<Fee> feeDetails;
26+
String description;
27+
28+
public String getId() {
29+
return id;
30+
}
31+
32+
public void setId(String id) {
33+
this.id = id;
34+
}
2235

2336
public String getSource() {
2437
return source;
@@ -84,16 +97,54 @@ public void setStatus(String status) {
8497
this.status = status;
8598
}
8699

100+
public Long getFee() {
101+
return fee;
102+
}
103+
104+
public void setFee(Long fee) {
105+
this.fee = fee;
106+
}
107+
108+
public List<Fee> getFeeDetails() {
109+
return feeDetails;
110+
}
111+
112+
public void setFeeDetails(List<Fee> feeDetails) {
113+
this.feeDetails = feeDetails;
114+
}
115+
116+
public String getDescription() {
117+
return description;
118+
}
119+
120+
public void setDescription(String description) {
121+
this.description = description;
122+
}
123+
124+
public static BalanceTransaction retrieve(String id) throws AuthenticationException,
125+
InvalidRequestException, APIConnectionException, CardException,
126+
APIException {
127+
return retrieve(id, null);
128+
}
129+
87130
public static BalanceTransactionCollection all(Map<String, Object> params)
88131
throws AuthenticationException, InvalidRequestException,
89132
APIConnectionException, CardException, APIException {
90133
return all(params, null);
91134
}
92135

136+
public static BalanceTransaction retrieve(String id, String apiKey)
137+
throws AuthenticationException, InvalidRequestException,
138+
APIConnectionException, CardException, APIException {
139+
String url = String.format("%s/%s/%s", Stripe.API_BASE, "v1/balance/history", id);
140+
return request(RequestMethod.GET, url, null,
141+
BalanceTransaction.class, apiKey);
142+
}
143+
93144
public static BalanceTransactionCollection all(Map<String, Object> params, String apiKey)
94145
throws AuthenticationException, InvalidRequestException,
95146
APIConnectionException, CardException, APIException {
96-
String url = String.format("%s%s", Stripe.API_BASE, "/v1/balance/history");
147+
String url = String.format("%s/%s", Stripe.API_BASE, "v1/balance/history");
97148
return request(RequestMethod.GET, url, params,
98149
BalanceTransactionCollection.class, apiKey);
99150
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
public class Subscription extends APIResource {
7+
String id;
78
Long currentPeriodEnd;
89
Long currentPeriodStart;
910
Boolean cancelAtPeriodEnd;
@@ -16,7 +17,15 @@ public class Subscription extends APIResource {
1617
Long canceledAt;
1718
Long endedAt;
1819
Integer quantity;
19-
20+
21+
public String getId() {
22+
return id;
23+
}
24+
25+
public void setId(String id) {
26+
this.id = id;
27+
}
28+
2029
public Long getCurrentPeriodEnd() {
2130
return currentPeriodEnd;
2231
}
@@ -89,4 +98,4 @@ public Integer getQuantity() {
8998
public void setQuantity(Integer quantity) {
9099
this.quantity = quantity;
91100
}
92-
}
101+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void testChargeCreate() throws StripeException {
179179
}
180180

181181
@Test
182-
public void testBalanceTransactionRetrieve() throws StripeException {
182+
public void testBalanceTransactionRetrieval() throws StripeException {
183183
Charge.create(defaultChargeParams);
184184
BalanceTransactionCollection balanceTransactions = BalanceTransaction.all(null);
185185
assertTrue(balanceTransactions.getCount() > 0);
@@ -190,6 +190,10 @@ public void testBalanceTransactionRetrieve() throws StripeException {
190190
HashMap<String, Object> fetchParams = new HashMap<String, Object>();
191191
fetchParams.put("count", 2);
192192
assertEquals(BalanceTransaction.all(fetchParams).getData().size(), 2);
193+
194+
BalanceTransaction retrieved = BalanceTransaction.retrieve(first.getId());
195+
assertEquals(retrieved.getId(), first.getId());
196+
assertEquals(retrieved.getSource(), first.getSource());
193197
}
194198

195199
@Test

0 commit comments

Comments
 (0)