• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-java / #16380

30 Aug 2024 07:54PM UTC coverage: 12.882% (-0.004%) from 12.886%
#16380

push

github

web-flow
Merge from master after the changes to not pass api_mode from individual methods (#1857)

* Generate SDK for OpenAPI spec version 1230 (#1856)

* Bump version to 26.9.0

* No need for APIMode to be passed around from individual API methods (#1855)

* Generated code

* Update the code around raw request

* Update the v2 tests to use v2 path

16 of 23 new or added lines in 7 files covered. (69.57%)

706 existing lines in 213 files now uncovered.

18468 of 143365 relevant lines covered (12.88%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

39.47
/src/main/java/com/stripe/model/CustomerBalanceTransaction.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.net.ApiRequest;
7
import com.stripe.net.ApiRequestParams;
8
import com.stripe.net.ApiResource;
9
import com.stripe.net.BaseAddress;
10
import com.stripe.net.RequestOptions;
11
import com.stripe.net.StripeResponseGetter;
12
import com.stripe.param.CustomerBalanceTransactionUpdateParams;
13
import java.util.Map;
14
import lombok.EqualsAndHashCode;
15
import lombok.Getter;
16
import lombok.Setter;
17

18
/**
19
 * Each customer has a <a
20
 * href="https://stripe.com/docs/api/customers/object#customer_object-balance">Balance</a> value,
21
 * which denotes a debit or credit that's automatically applied to their next invoice upon
22
 * finalization. You may modify the value directly by using the <a
23
 * href="https://stripe.com/docs/api/customers/update">update customer API</a>, or by creating a
24
 * Customer Balance Transaction, which increments or decrements the customer's {@code balance} by
25
 * the specified {@code amount}.
26
 *
27
 * <p>Related guide: <a href="https://stripe.com/docs/billing/customer/balance">Customer balance</a>
28
 */
29
@Getter
30
@Setter
31
@EqualsAndHashCode(callSuper = false)
32
public class CustomerBalanceTransaction extends ApiResource
1✔
33
    implements HasId, MetadataStore<CustomerBalanceTransaction> {
34
  /**
35
   * The amount of the transaction. A negative value is a credit for the customer's balance, and a
36
   * positive value is a debit to the customer's {@code balance}.
37
   */
38
  @SerializedName("amount")
39
  Long amount;
40

41
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
42
  @SerializedName("created")
43
  Long created;
44

45
  /** The ID of the credit note (if any) related to the transaction. */
46
  @SerializedName("credit_note")
47
  @Getter(lombok.AccessLevel.NONE)
48
  @Setter(lombok.AccessLevel.NONE)
49
  ExpandableField<CreditNote> creditNote;
50

51
  /**
52
   * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
53
   * in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
54
   */
55
  @SerializedName("currency")
56
  String currency;
57

58
  /** The ID of the customer the transaction belongs to. */
59
  @SerializedName("customer")
60
  @Getter(lombok.AccessLevel.NONE)
61
  @Setter(lombok.AccessLevel.NONE)
62
  ExpandableField<Customer> customer;
63

64
  /** An arbitrary string attached to the object. Often useful for displaying to users. */
65
  @SerializedName("description")
66
  String description;
67

68
  /**
69
   * The customer's {@code balance} after the transaction was applied. A negative value decreases
70
   * the amount due on the customer's next invoice. A positive value increases the amount due on the
71
   * customer's next invoice.
72
   */
73
  @SerializedName("ending_balance")
74
  Long endingBalance;
75

76
  /** Unique identifier for the object. */
77
  @Getter(onMethod_ = {@Override})
78
  @SerializedName("id")
79
  String id;
80

81
  /** The ID of the invoice (if any) related to the transaction. */
82
  @SerializedName("invoice")
83
  @Getter(lombok.AccessLevel.NONE)
84
  @Setter(lombok.AccessLevel.NONE)
85
  ExpandableField<Invoice> invoice;
86

87
  /**
88
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
89
   * object exists in test mode.
90
   */
91
  @SerializedName("livemode")
92
  Boolean livemode;
93

94
  /**
95
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
96
   * to an object. This can be useful for storing additional information about the object in a
97
   * structured format.
98
   */
99
  @Getter(onMethod_ = {@Override})
100
  @SerializedName("metadata")
101
  Map<String, String> metadata;
102

103
  /**
104
   * String representing the object's type. Objects of the same type share the same value.
105
   *
106
   * <p>Equal to {@code customer_balance_transaction}.
107
   */
108
  @SerializedName("object")
109
  String object;
110

111
  /**
112
   * Transaction type: {@code adjustment}, {@code applied_to_invoice}, {@code credit_note}, {@code
113
   * initial}, {@code invoice_overpaid}, {@code invoice_too_large}, {@code invoice_too_small},
114
   * {@code unspent_receiver_credit}, or {@code unapplied_from_invoice}. See the <a
115
   * href="https://stripe.com/docs/billing/customer/balance#types">Customer Balance page</a> to
116
   * learn more about transaction types.
117
   *
118
   * <p>One of {@code adjustment}, {@code applied_to_invoice}, {@code credit_note}, {@code initial},
119
   * {@code invoice_overpaid}, {@code invoice_too_large}, {@code invoice_too_small}, {@code
120
   * migration}, {@code unapplied_from_invoice}, or {@code unspent_receiver_credit}.
121
   */
122
  @SerializedName("type")
123
  String type;
124

125
  /** Get ID of expandable {@code creditNote} object. */
126
  public String getCreditNote() {
127
    return (this.creditNote != null) ? this.creditNote.getId() : null;
×
128
  }
129

130
  public void setCreditNote(String id) {
131
    this.creditNote = ApiResource.setExpandableFieldId(id, this.creditNote);
×
132
  }
×
133

134
  /** Get expanded {@code creditNote}. */
135
  public CreditNote getCreditNoteObject() {
136
    return (this.creditNote != null) ? this.creditNote.getExpanded() : null;
×
137
  }
138

139
  public void setCreditNoteObject(CreditNote expandableObject) {
140
    this.creditNote = new ExpandableField<CreditNote>(expandableObject.getId(), expandableObject);
×
141
  }
×
142

143
  /** Get ID of expandable {@code customer} object. */
144
  public String getCustomer() {
145
    return (this.customer != null) ? this.customer.getId() : null;
1✔
146
  }
147

148
  public void setCustomer(String id) {
149
    this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
150
  }
×
151

152
  /** Get expanded {@code customer}. */
153
  public Customer getCustomerObject() {
154
    return (this.customer != null) ? this.customer.getExpanded() : null;
×
155
  }
156

157
  public void setCustomerObject(Customer expandableObject) {
158
    this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
159
  }
×
160

161
  /** Get ID of expandable {@code invoice} object. */
162
  public String getInvoice() {
163
    return (this.invoice != null) ? this.invoice.getId() : null;
×
164
  }
165

166
  public void setInvoice(String id) {
167
    this.invoice = ApiResource.setExpandableFieldId(id, this.invoice);
×
168
  }
×
169

170
  /** Get expanded {@code invoice}. */
171
  public Invoice getInvoiceObject() {
172
    return (this.invoice != null) ? this.invoice.getExpanded() : null;
×
173
  }
174

175
  public void setInvoiceObject(Invoice expandableObject) {
176
    this.invoice = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
×
177
  }
×
178

179
  /**
180
   * Most credit balance transaction fields are immutable, but you may update its {@code
181
   * description} and {@code metadata}.
182
   */
183
  @Override
184
  public CustomerBalanceTransaction update(Map<String, Object> params) throws StripeException {
185
    return update(params, (RequestOptions) null);
×
186
  }
187

188
  /**
189
   * Most credit balance transaction fields are immutable, but you may update its {@code
190
   * description} and {@code metadata}.
191
   */
192
  @Override
193
  public CustomerBalanceTransaction update(Map<String, Object> params, RequestOptions options)
194
      throws StripeException {
195
    String path =
×
196
        String.format(
×
197
            "/v1/customers/%s/balance_transactions/%s",
198
            ApiResource.urlEncodeId(this.getCustomer()), ApiResource.urlEncodeId(this.getId()));
×
199
    ApiRequest request =
×
200
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
201
    return getResponseGetter().request(request, CustomerBalanceTransaction.class);
×
202
  }
203

204
  /**
205
   * Most credit balance transaction fields are immutable, but you may update its {@code
206
   * description} and {@code metadata}.
207
   */
208
  public CustomerBalanceTransaction update(CustomerBalanceTransactionUpdateParams params)
209
      throws StripeException {
210
    return update(params, (RequestOptions) null);
1✔
211
  }
212

213
  /**
214
   * Most credit balance transaction fields are immutable, but you may update its {@code
215
   * description} and {@code metadata}.
216
   */
217
  public CustomerBalanceTransaction update(
218
      CustomerBalanceTransactionUpdateParams params, RequestOptions options)
219
      throws StripeException {
220
    String path =
1✔
221
        String.format(
1✔
222
            "/v1/customers/%s/balance_transactions/%s",
223
            ApiResource.urlEncodeId(this.getCustomer()), ApiResource.urlEncodeId(this.getId()));
1✔
224
    ApiResource.checkNullTypedParams(path, params);
1✔
225
    ApiRequest request =
1✔
226
        new ApiRequest(
227
            BaseAddress.API,
228
            ApiResource.RequestMethod.POST,
229
            path,
230
            ApiRequestParams.paramsToMap(params),
1✔
231
            options);
232
    return getResponseGetter().request(request, CustomerBalanceTransaction.class);
1✔
233
  }
234

235
  @Override
236
  public void setResponseGetter(StripeResponseGetter responseGetter) {
237
    super.setResponseGetter(responseGetter);
1✔
238
    trySetResponseGetter(creditNote, responseGetter);
1✔
239
    trySetResponseGetter(customer, responseGetter);
1✔
240
    trySetResponseGetter(invoice, responseGetter);
1✔
241
  }
1✔
242
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc