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

stripe / stripe-java / 4462

pending completion
4462

Pull #789

travis-ci

web-flow
[generated] source: spec3.sdk.yaml@spec-a6283af in master
Pull Request #789: [generated] source: spec3.sdk.yaml@spec-a6283af in master

2687 of 21349 relevant lines covered (12.59%)

23.78 hits per line

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

38.27
/src/main/java/com/stripe/model/Customer.java
1
// Generated by com.stripe.generator.entity.SdkBuilder
2

3
package com.stripe.model;
4

5
import com.google.gson.annotations.SerializedName;
6
import com.stripe.Stripe;
7
import com.stripe.exception.StripeException;
8
import com.stripe.net.ApiResource;
9
import com.stripe.net.RequestOptions;
10
import com.stripe.param.CustomerBalanceTransactionsParams;
11
import com.stripe.param.CustomerCreateParams;
12
import com.stripe.param.CustomerListParams;
13
import com.stripe.param.CustomerRetrieveParams;
14
import com.stripe.param.CustomerUpdateParams;
15
import java.util.List;
16
import java.util.Map;
17
import lombok.EqualsAndHashCode;
18
import lombok.Getter;
19
import lombok.Setter;
20

21
@Getter
×
22
@Setter
23
@EqualsAndHashCode(callSuper = false)
24
public class Customer extends ApiResource implements HasId, MetadataStore<Customer> {
25
  /** This field has been renamed to `balance` and will be removed in a future API version. */
26
  @SerializedName("account_balance")
27
  Long accountBalance;
28

29
  /** The customer's address. */
30
  @SerializedName("address")
31
  Address address;
32

33
  /**
34
   * Current balance, if any, being stored on the customer. If negative, the customer has credit to
35
   * apply to their next invoice. If positive, the customer has an amount owed that will be added to
36
   * their next invoice. The balance does not refer to any unpaid invoices; it solely takes into
37
   * account amounts that have yet to be successfully applied to any invoice. This balance is only
38
   * taken into account as invoices are finalized.
39
   */
40
  @SerializedName("balance")
41
  Long balance;
42

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

47
  /**
48
   * Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) the customer can
49
   * be charged in for recurring billing purposes.
50
   */
51
  @SerializedName("currency")
52
  String currency;
53

54
  /** ID of the default payment source for the customer. */
55
  @SerializedName("default_source")
56
  @Getter(lombok.AccessLevel.NONE)
57
  @Setter(lombok.AccessLevel.NONE)
58
  ExpandableField<PaymentSource> defaultSource;
59

60
  /** Always true for a deleted object. */
61
  @SerializedName("deleted")
62
  Boolean deleted;
63

64
  /**
65
   * When the customer's latest invoice is billed by charging automatically, delinquent is true if
66
   * the invoice's latest charge is failed. When the customer's latest invoice is billed by sending
67
   * an invoice, delinquent is true if the invoice is not paid by its due date.
68
   */
69
  @SerializedName("delinquent")
70
  Boolean delinquent;
71

72
  /** An arbitrary string attached to the object. Often useful for displaying to users. */
73
  @SerializedName("description")
74
  String description;
75

76
  /** Describes the current discount active on the customer, if there is one. */
77
  @SerializedName("discount")
78
  Discount discount;
79

80
  /** The customer's email address. */
81
  @SerializedName("email")
82
  String email;
83

84
  /** Unique identifier for the object. */
85
  @Getter(onMethod_ = {@Override})
86
  @SerializedName("id")
87
  String id;
88

89
  /** The prefix for the customer used to generate unique invoice numbers. */
90
  @SerializedName("invoice_prefix")
91
  String invoicePrefix;
92

93
  @SerializedName("invoice_settings")
94
  InvoiceSettings invoiceSettings;
95

96
  /**
97
   * Has the value `true` if the object exists in live mode or the value `false` if the object
98
   * exists in test mode.
99
   */
100
  @SerializedName("livemode")
101
  Boolean livemode;
102

103
  /**
104
   * Set of key-value pairs that you can attach to an object. This can be useful for storing
105
   * additional information about the object in a structured format.
106
   */
107
  @Getter(onMethod_ = {@Override})
108
  @SerializedName("metadata")
109
  Map<String, String> metadata;
110

111
  /** The customer's full name or business name. */
112
  @SerializedName("name")
113
  String name;
114

115
  /** String representing the object's type. Objects of the same type share the same value. */
116
  @SerializedName("object")
117
  String object;
118

119
  /** The customer's phone number. */
120
  @SerializedName("phone")
121
  String phone;
122

123
  /** The customer's preferred locales (languages), ordered by preference. */
124
  @SerializedName("preferred_locales")
125
  List<String> preferredLocales;
126

127
  /**
128
   * Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
129
   */
130
  @SerializedName("shipping")
131
  ShippingDetails shipping;
132

133
  /** The customer's payment sources, if any. */
134
  @SerializedName("sources")
135
  PaymentSourceCollection sources;
136

137
  /** The customer's current subscriptions, if any. */
138
  @SerializedName("subscriptions")
139
  SubscriptionCollection subscriptions;
140

141
  /**
142
   * Describes the customer's tax exemption status. One of `none`, `exempt`, or `reverse`. When set
143
   * to `reverse`, invoice and receipt PDFs include the text **"Reverse charge"**.
144
   */
145
  @SerializedName("tax_exempt")
146
  String taxExempt;
147

148
  /** The customer's tax IDs. */
149
  @SerializedName("tax_ids")
150
  TaxIdCollection taxIds;
151

152
  /**
153
   * The customer's tax information. Appears on invoices emailed to this customer. This field has
154
   * been deprecated and will be removed in a future API version, for further information view the
155
   * [migration
156
   * guide](https://stripe.com/docs/billing/migration/taxes#moving-from-taxinfo-to-customer-tax-ids).
157
   */
158
  @SerializedName("tax_info")
159
  TaxInfo taxInfo;
160

161
  /**
162
   * Describes the status of looking up the tax ID provided in `tax_info`. This field has been
163
   * deprecated and will be removed in a future API version, for further information view the
164
   * [migration
165
   * guide](https://stripe.com/docs/billing/migration/taxes#moving-from-taxinfo-to-customer-tax-ids).
166
   */
167
  @SerializedName("tax_info_verification")
168
  TaxInfoVerification taxInfoVerification;
169

170
  /** Get id of expandable `defaultSource` object. */
171
  public String getDefaultSource() {
172
    return (this.defaultSource != null) ? this.defaultSource.getId() : null;
×
173
  }
174

175
  public void setDefaultSource(String id) {
176
    this.defaultSource = ApiResource.setExpandableFieldId(id, this.defaultSource);
×
177
  }
×
178

179
  /** Get expanded `defaultSource`. */
180
  public PaymentSource getDefaultSourceObject() {
181
    return (this.defaultSource != null) ? this.defaultSource.getExpanded() : null;
×
182
  }
183

184
  public void setDefaultSourceObject(PaymentSource expandableObject) {
185
    this.defaultSource =
×
186
        new ExpandableField<PaymentSource>(expandableObject.getId(), expandableObject);
×
187
  }
×
188

189
  /**
190
   * Returns a list of your customers. The customers are returned sorted by creation date, with the
191
   * most recent customers appearing first.
192
   */
193
  public static CustomerCollection list(Map<String, Object> params) throws StripeException {
194
    return list(params, (RequestOptions) null);
8✔
195
  }
196

197
  /**
198
   * Returns a list of your customers. The customers are returned sorted by creation date, with the
199
   * most recent customers appearing first.
200
   */
201
  public static CustomerCollection list(Map<String, Object> params, RequestOptions options)
202
      throws StripeException {
203
    String url = String.format("%s%s", Stripe.getApiBase(), "/v1/customers");
8✔
204
    return requestCollection(url, params, CustomerCollection.class, options);
8✔
205
  }
206

207
  /**
208
   * Returns a list of your customers. The customers are returned sorted by creation date, with the
209
   * most recent customers appearing first.
210
   */
211
  public static CustomerCollection list(CustomerListParams params) throws StripeException {
212
    return list(params, (RequestOptions) null);
×
213
  }
214

215
  /**
216
   * Returns a list of your customers. The customers are returned sorted by creation date, with the
217
   * most recent customers appearing first.
218
   */
219
  public static CustomerCollection list(CustomerListParams params, RequestOptions options)
220
      throws StripeException {
221
    String url = String.format("%s%s", Stripe.getApiBase(), "/v1/customers");
×
222
    return requestCollection(url, params, CustomerCollection.class, options);
×
223
  }
224

225
  /** Creates a new customer object. */
226
  public static Customer create(Map<String, Object> params) throws StripeException {
227
    return create(params, (RequestOptions) null);
4✔
228
  }
229

230
  /** Creates a new customer object. */
231
  public static Customer create(Map<String, Object> params, RequestOptions options)
232
      throws StripeException {
233
    String url = String.format("%s%s", Stripe.getApiBase(), "/v1/customers");
8✔
234
    return request(ApiResource.RequestMethod.POST, url, params, Customer.class, options);
8✔
235
  }
236

237
  /** Creates a new customer object. */
238
  public static Customer create(CustomerCreateParams params) throws StripeException {
239
    return create(params, (RequestOptions) null);
×
240
  }
241

242
  /** Creates a new customer object. */
243
  public static Customer create(CustomerCreateParams params, RequestOptions options)
244
      throws StripeException {
245
    String url = String.format("%s%s", Stripe.getApiBase(), "/v1/customers");
×
246
    return request(ApiResource.RequestMethod.POST, url, params, Customer.class, options);
×
247
  }
248

249
  /**
250
   * Retrieves the details of an existing customer. You need only supply the unique customer
251
   * identifier that was returned upon customer creation.
252
   */
253
  public static Customer retrieve(String customer) throws StripeException {
254
    return retrieve(customer, (Map<String, Object>) null, (RequestOptions) null);
60✔
255
  }
256

257
  /**
258
   * Retrieves the details of an existing customer. You need only supply the unique customer
259
   * identifier that was returned upon customer creation.
260
   */
261
  public static Customer retrieve(String customer, RequestOptions options) throws StripeException {
262
    return retrieve(customer, (Map<String, Object>) null, options);
4✔
263
  }
264

265
  /**
266
   * Retrieves the details of an existing customer. You need only supply the unique customer
267
   * identifier that was returned upon customer creation.
268
   */
269
  public static Customer retrieve(
270
      String customer, Map<String, Object> params, RequestOptions options) throws StripeException {
271
    String url =
64✔
272
        String.format(
64✔
273
            "%s%s",
274
            Stripe.getApiBase(),
64✔
275
            String.format("/v1/customers/%s", ApiResource.urlEncodeId(customer)));
64✔
276
    return request(ApiResource.RequestMethod.GET, url, params, Customer.class, options);
64✔
277
  }
278

279
  /**
280
   * Retrieves the details of an existing customer. You need only supply the unique customer
281
   * identifier that was returned upon customer creation.
282
   */
283
  public static Customer retrieve(
284
      String customer, CustomerRetrieveParams params, RequestOptions options)
285
      throws StripeException {
286
    String url =
×
287
        String.format(
×
288
            "%s%s",
289
            Stripe.getApiBase(),
×
290
            String.format("/v1/customers/%s", ApiResource.urlEncodeId(customer)));
×
291
    return request(ApiResource.RequestMethod.GET, url, params, Customer.class, options);
×
292
  }
293

294
  /**
295
   * Updates the specified customer by setting the values of the parameters passed. Any parameters
296
   * not provided will be left unchanged. For example, if you pass the <strong>source</strong>
297
   * parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges
298
   * in the future. When you update a customer to a new valid card source by passing the
299
   * <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the
300
   * subscription bills automatically and is in the <code>past_due</code> state, then the latest
301
   * open invoice for the subscription with automatic collection enabled will be retried. This retry
302
   * will not count as an automatic retry, and will not affect the next regularly scheduled payment
303
   * for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger
304
   * this behavior.
305
   *
306
   * <p>This request accepts mostly the same arguments as the customer creation call.
307
   */
308
  @Override
309
  public Customer update(Map<String, Object> params) throws StripeException {
310
    return update(params, (RequestOptions) null);
4✔
311
  }
312

313
  /**
314
   * Updates the specified customer by setting the values of the parameters passed. Any parameters
315
   * not provided will be left unchanged. For example, if you pass the <strong>source</strong>
316
   * parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges
317
   * in the future. When you update a customer to a new valid card source by passing the
318
   * <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the
319
   * subscription bills automatically and is in the <code>past_due</code> state, then the latest
320
   * open invoice for the subscription with automatic collection enabled will be retried. This retry
321
   * will not count as an automatic retry, and will not affect the next regularly scheduled payment
322
   * for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger
323
   * this behavior.
324
   *
325
   * <p>This request accepts mostly the same arguments as the customer creation call.
326
   */
327
  @Override
328
  public Customer update(Map<String, Object> params, RequestOptions options)
329
      throws StripeException {
330
    String url =
4✔
331
        String.format(
4✔
332
            "%s%s",
333
            Stripe.getApiBase(),
4✔
334
            String.format("/v1/customers/%s", ApiResource.urlEncodeId(this.getId())));
4✔
335
    return request(ApiResource.RequestMethod.POST, url, params, Customer.class, options);
4✔
336
  }
337

338
  /**
339
   * Updates the specified customer by setting the values of the parameters passed. Any parameters
340
   * not provided will be left unchanged. For example, if you pass the <strong>source</strong>
341
   * parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges
342
   * in the future. When you update a customer to a new valid card source by passing the
343
   * <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the
344
   * subscription bills automatically and is in the <code>past_due</code> state, then the latest
345
   * open invoice for the subscription with automatic collection enabled will be retried. This retry
346
   * will not count as an automatic retry, and will not affect the next regularly scheduled payment
347
   * for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger
348
   * this behavior.
349
   *
350
   * <p>This request accepts mostly the same arguments as the customer creation call.
351
   */
352
  public Customer update(CustomerUpdateParams params) throws StripeException {
353
    return update(params, (RequestOptions) null);
×
354
  }
355

356
  /**
357
   * Updates the specified customer by setting the values of the parameters passed. Any parameters
358
   * not provided will be left unchanged. For example, if you pass the <strong>source</strong>
359
   * parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges
360
   * in the future. When you update a customer to a new valid card source by passing the
361
   * <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the
362
   * subscription bills automatically and is in the <code>past_due</code> state, then the latest
363
   * open invoice for the subscription with automatic collection enabled will be retried. This retry
364
   * will not count as an automatic retry, and will not affect the next regularly scheduled payment
365
   * for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger
366
   * this behavior.
367
   *
368
   * <p>This request accepts mostly the same arguments as the customer creation call.
369
   */
370
  public Customer update(CustomerUpdateParams params, RequestOptions options)
371
      throws StripeException {
372
    String url =
×
373
        String.format(
×
374
            "%s%s",
375
            Stripe.getApiBase(),
×
376
            String.format("/v1/customers/%s", ApiResource.urlEncodeId(this.getId())));
×
377
    return request(ApiResource.RequestMethod.POST, url, params, Customer.class, options);
×
378
  }
379

380
  /**
381
   * Permanently deletes a customer. It cannot be undone. Also immediately cancels any active
382
   * subscriptions on the customer.
383
   */
384
  public Customer delete() throws StripeException {
385
    return delete((Map<String, Object>) null, (RequestOptions) null);
4✔
386
  }
387

388
  /**
389
   * Permanently deletes a customer. It cannot be undone. Also immediately cancels any active
390
   * subscriptions on the customer.
391
   */
392
  public Customer delete(RequestOptions options) throws StripeException {
393
    return delete((Map<String, Object>) null, options);
×
394
  }
395

396
  /**
397
   * Permanently deletes a customer. It cannot be undone. Also immediately cancels any active
398
   * subscriptions on the customer.
399
   */
400
  public Customer delete(Map<String, Object> params) throws StripeException {
401
    return delete(params, (RequestOptions) null);
×
402
  }
403

404
  /**
405
   * Permanently deletes a customer. It cannot be undone. Also immediately cancels any active
406
   * subscriptions on the customer.
407
   */
408
  public Customer delete(Map<String, Object> params, RequestOptions options)
409
      throws StripeException {
410
    String url =
4✔
411
        String.format(
4✔
412
            "%s%s",
413
            Stripe.getApiBase(),
4✔
414
            String.format("/v1/customers/%s", ApiResource.urlEncodeId(this.getId())));
4✔
415
    return request(ApiResource.RequestMethod.DELETE, url, params, Customer.class, options);
4✔
416
  }
417

418
  /**
419
   * Retrieves the list of transactions that updated the customer’s <a
420
   * href="/docs/api/customers/object#customer_object-balance"><code>balance</code></a>.
421
   */
422
  public CustomerBalanceTransactionCollection balanceTransactions() throws StripeException {
423
    return balanceTransactions((Map<String, Object>) null, (RequestOptions) null);
×
424
  }
425

426
  /**
427
   * Retrieves the list of transactions that updated the customer’s <a
428
   * href="/docs/api/customers/object#customer_object-balance"><code>balance</code></a>.
429
   */
430
  public CustomerBalanceTransactionCollection balanceTransactions(Map<String, Object> params)
431
      throws StripeException {
432
    return balanceTransactions(params, (RequestOptions) null);
×
433
  }
434

435
  /**
436
   * Retrieves the list of transactions that updated the customer’s <a
437
   * href="/docs/api/customers/object#customer_object-balance"><code>balance</code></a>.
438
   */
439
  public CustomerBalanceTransactionCollection balanceTransactions(
440
      Map<String, Object> params, RequestOptions options) throws StripeException {
441
    String url =
×
442
        String.format(
×
443
            "%s%s",
444
            Stripe.getApiBase(),
×
445
            String.format(
×
446
                "/v1/customers/%s/balance_transactions", ApiResource.urlEncodeId(this.getId())));
×
447
    return requestCollection(url, params, CustomerBalanceTransactionCollection.class, options);
×
448
  }
449

450
  /**
451
   * Retrieves the list of transactions that updated the customer’s <a
452
   * href="/docs/api/customers/object#customer_object-balance"><code>balance</code></a>.
453
   */
454
  public CustomerBalanceTransactionCollection balanceTransactions(
455
      CustomerBalanceTransactionsParams params) throws StripeException {
456
    return balanceTransactions(params, (RequestOptions) null);
×
457
  }
458

459
  /**
460
   * Retrieves the list of transactions that updated the customer’s <a
461
   * href="/docs/api/customers/object#customer_object-balance"><code>balance</code></a>.
462
   */
463
  public CustomerBalanceTransactionCollection balanceTransactions(
464
      CustomerBalanceTransactionsParams params, RequestOptions options) throws StripeException {
465
    String url =
×
466
        String.format(
×
467
            "%s%s",
468
            Stripe.getApiBase(),
×
469
            String.format(
×
470
                "/v1/customers/%s/balance_transactions", ApiResource.urlEncodeId(this.getId())));
×
471
    return requestCollection(url, params, CustomerBalanceTransactionCollection.class, options);
×
472
  }
473

474
  /** Removes the currently applied discount on a customer. */
475
  public Discount deleteDiscount() throws StripeException {
476
    return deleteDiscount((Map<String, Object>) null, (RequestOptions) null);
4✔
477
  }
478

479
  /** Removes the currently applied discount on a customer. */
480
  public Discount deleteDiscount(Map<String, Object> params) throws StripeException {
481
    return deleteDiscount(params, (RequestOptions) null);
×
482
  }
483

484
  /** Removes the currently applied discount on a customer. */
485
  public Discount deleteDiscount(Map<String, Object> params, RequestOptions options)
486
      throws StripeException {
487
    String url =
4✔
488
        String.format(
4✔
489
            "%s%s",
490
            Stripe.getApiBase(),
4✔
491
            String.format("/v1/customers/%s/discount", ApiResource.urlEncodeId(this.getId())));
4✔
492
    return request(ApiResource.RequestMethod.DELETE, url, params, Discount.class, options);
4✔
493
  }
494

495
  @Getter
496
  @Setter
497
  @EqualsAndHashCode(callSuper = false)
498
  public static class InvoiceSettings extends StripeObject {
499
    /** Default custom fields to be displayed on invoices for this customer. */
500
    @SerializedName("custom_fields")
501
    List<Invoice.CustomField> customFields;
502

503
    /** ID of the default payment method used for subscriptions and invoices for the customer. */
504
    @SerializedName("default_payment_method")
505
    @Getter(lombok.AccessLevel.NONE)
506
    @Setter(lombok.AccessLevel.NONE)
507
    ExpandableField<PaymentMethod> defaultPaymentMethod;
508

509
    /** Default footer to be displayed on invoices for this customer. */
510
    @SerializedName("footer")
511
    String footer;
512

513
    /** Get id of expandable `defaultPaymentMethod` object. */
514
    public String getDefaultPaymentMethod() {
515
      return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getId() : null;
×
516
    }
517

518
    public void setDefaultPaymentMethod(String id) {
519
      this.defaultPaymentMethod = ApiResource.setExpandableFieldId(id, this.defaultPaymentMethod);
×
520
    }
×
521

522
    /** Get expanded `defaultPaymentMethod`. */
523
    public PaymentMethod getDefaultPaymentMethodObject() {
524
      return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getExpanded() : null;
×
525
    }
526

527
    public void setDefaultPaymentMethodObject(PaymentMethod expandableObject) {
528
      this.defaultPaymentMethod =
×
529
          new ExpandableField<PaymentMethod>(expandableObject.getId(), expandableObject);
×
530
    }
×
531
  }
532

533
  @Getter
534
  @Setter
535
  @EqualsAndHashCode(callSuper = false)
536
  public static class TaxInfo extends StripeObject {
537
    /** The customer's tax ID number. */
538
    @SerializedName("tax_id")
539
    String taxId;
540

541
    /** The type of ID number. */
542
    @SerializedName("type")
543
    String type;
544
  }
545

546
  @Getter
547
  @Setter
548
  @EqualsAndHashCode(callSuper = false)
549
  public static class TaxInfoVerification extends StripeObject {
550
    /**
551
     * The state of verification for this customer. Possible values are `unverified`, `pending`, or
552
     * `verified`.
553
     */
554
    @SerializedName("status")
555
    String status;
556

557
    /** The official name associated with the tax ID returned from the external provider. */
558
    @SerializedName("verified_name")
559
    String verifiedName;
560
  }
561
}
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

© 2025 Coveralls, Inc