-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy pathCustomerBalanceTransaction.java
More file actions
276 lines (239 loc) · 10 KB
/
Copy pathCustomerBalanceTransaction.java
File metadata and controls
276 lines (239 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// File generated from our OpenAPI spec
package com.stripe.model;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.checkout.Session;
import com.stripe.net.ApiRequest;
import com.stripe.net.ApiRequestParams;
import com.stripe.net.ApiResource;
import com.stripe.net.BaseAddress;
import com.stripe.net.RequestOptions;
import com.stripe.net.StripeResponseGetter;
import com.stripe.param.CustomerBalanceTransactionUpdateParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* Each customer has a <a
* href="https://docs.stripe.com/api/customers/object#customer_object-balance">Balance</a> value,
* which denotes a debit or credit that's automatically applied to their next invoice upon
* finalization. You may modify the value directly by using the <a
* href="https://docs.stripe.com/api/customers/update">update customer API</a>, or by creating a
* Customer Balance Transaction, which increments or decrements the customer's {@code balance} by
* the specified {@code amount}.
*
* <p>Related guide: <a href="https://docs.stripe.com/billing/customer/balance">Customer balance</a>
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class CustomerBalanceTransaction extends ApiResource
implements HasId, MetadataStore<CustomerBalanceTransaction> {
/**
* The amount of the transaction. A negative value is a credit for the customer's balance, and a
* positive value is a debit to the customer's {@code balance}.
*/
@SerializedName("amount")
Long amount;
/** The ID of the checkout session (if any) that created the transaction. */
@SerializedName("checkout_session")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Session> checkoutSession;
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;
/** The ID of the credit note (if any) related to the transaction. */
@SerializedName("credit_note")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<CreditNote> creditNote;
/**
* Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
* in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
*/
@SerializedName("currency")
String currency;
/** The ID of the customer the transaction belongs to. */
@SerializedName("customer")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Customer> customer;
/** The ID of an Account representing a customer that the transaction belongs to. */
@SerializedName("customer_account")
String customerAccount;
/** An arbitrary string attached to the object. Often useful for displaying to users. */
@SerializedName("description")
String description;
/**
* The customer's {@code balance} after the transaction was applied. A negative value decreases
* the amount due on the customer's next invoice. A positive value increases the amount due on the
* customer's next invoice.
*/
@SerializedName("ending_balance")
Long endingBalance;
/** Unique identifier for the object. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/** The ID of the invoice (if any) related to the transaction. */
@SerializedName("invoice")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Invoice> invoice;
/**
* If the object exists in live mode, the value is {@code true}. If the object exists in test
* mode, the value is {@code false}.
*/
@SerializedName("livemode")
Boolean livemode;
/**
* Set of <a href="https://docs.stripe.com/api/metadata">key-value pairs</a> that you can attach
* to an object. This can be useful for storing additional information about the object in a
* structured format.
*/
@Getter(onMethod_ = {@Override})
@SerializedName("metadata")
Map<String, String> metadata;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* <p>Equal to {@code customer_balance_transaction}.
*/
@SerializedName("object")
String object;
/**
* Transaction type: {@code adjustment}, {@code applied_to_invoice}, {@code credit_note}, {@code
* initial}, {@code invoice_overpaid}, {@code invoice_too_large}, {@code invoice_too_small},
* {@code unspent_receiver_credit}, {@code unapplied_from_invoice}, {@code
* checkout_session_subscription_payment}, or {@code
* checkout_session_subscription_payment_canceled}. See the <a
* href="https://docs.stripe.com/billing/customer/balance#types">Customer Balance page</a> to
* learn more about transaction types.
*
* <p>One of {@code adjustment}, {@code applied_to_invoice}, {@code
* checkout_session_subscription_payment}, {@code checkout_session_subscription_payment_canceled},
* {@code credit_note}, {@code initial}, {@code invoice_overpaid}, {@code invoice_too_large},
* {@code invoice_too_small}, {@code migration}, {@code unapplied_from_invoice}, or {@code
* unspent_receiver_credit}.
*/
@SerializedName("type")
String type;
/** Get ID of expandable {@code checkoutSession} object. */
public String getCheckoutSession() {
return (this.checkoutSession != null) ? this.checkoutSession.getId() : null;
}
public void setCheckoutSession(String id) {
this.checkoutSession = ApiResource.setExpandableFieldId(id, this.checkoutSession);
}
/** Get expanded {@code checkoutSession}. */
public Session getCheckoutSessionObject() {
return (this.checkoutSession != null) ? this.checkoutSession.getExpanded() : null;
}
public void setCheckoutSessionObject(Session expandableObject) {
this.checkoutSession = new ExpandableField<Session>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code creditNote} object. */
public String getCreditNote() {
return (this.creditNote != null) ? this.creditNote.getId() : null;
}
public void setCreditNote(String id) {
this.creditNote = ApiResource.setExpandableFieldId(id, this.creditNote);
}
/** Get expanded {@code creditNote}. */
public CreditNote getCreditNoteObject() {
return (this.creditNote != null) ? this.creditNote.getExpanded() : null;
}
public void setCreditNoteObject(CreditNote expandableObject) {
this.creditNote = new ExpandableField<CreditNote>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code customer} object. */
public String getCustomer() {
return (this.customer != null) ? this.customer.getId() : null;
}
public void setCustomer(String id) {
this.customer = ApiResource.setExpandableFieldId(id, this.customer);
}
/** Get expanded {@code customer}. */
public Customer getCustomerObject() {
return (this.customer != null) ? this.customer.getExpanded() : null;
}
public void setCustomerObject(Customer expandableObject) {
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code invoice} object. */
public String getInvoice() {
return (this.invoice != null) ? this.invoice.getId() : null;
}
public void setInvoice(String id) {
this.invoice = ApiResource.setExpandableFieldId(id, this.invoice);
}
/** Get expanded {@code invoice}. */
public Invoice getInvoiceObject() {
return (this.invoice != null) ? this.invoice.getExpanded() : null;
}
public void setInvoiceObject(Invoice expandableObject) {
this.invoice = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
}
/**
* Most credit balance transaction fields are immutable, but you may update its {@code
* description} and {@code metadata}.
*/
@Override
public CustomerBalanceTransaction update(Map<String, Object> params) throws StripeException {
return update(params, (RequestOptions) null);
}
/**
* Most credit balance transaction fields are immutable, but you may update its {@code
* description} and {@code metadata}.
*/
@Override
public CustomerBalanceTransaction update(Map<String, Object> params, RequestOptions options)
throws StripeException {
String path =
String.format(
"/v1/customers/%s/balance_transactions/%s",
ApiResource.urlEncodeId(this.getCustomer()), ApiResource.urlEncodeId(this.getId()));
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
return getResponseGetter().request(request, CustomerBalanceTransaction.class);
}
/**
* Most credit balance transaction fields are immutable, but you may update its {@code
* description} and {@code metadata}.
*/
public CustomerBalanceTransaction update(CustomerBalanceTransactionUpdateParams params)
throws StripeException {
return update(params, (RequestOptions) null);
}
/**
* Most credit balance transaction fields are immutable, but you may update its {@code
* description} and {@code metadata}.
*/
public CustomerBalanceTransaction update(
CustomerBalanceTransactionUpdateParams params, RequestOptions options)
throws StripeException {
String path =
String.format(
"/v1/customers/%s/balance_transactions/%s",
ApiResource.urlEncodeId(this.getCustomer()), ApiResource.urlEncodeId(this.getId()));
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options);
return getResponseGetter().request(request, CustomerBalanceTransaction.class);
}
@Override
public void setResponseGetter(StripeResponseGetter responseGetter) {
super.setResponseGetter(responseGetter);
trySetResponseGetter(checkoutSession, responseGetter);
trySetResponseGetter(creditNote, responseGetter);
trySetResponseGetter(customer, responseGetter);
trySetResponseGetter(invoice, responseGetter);
}
}