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

stripe / stripe-java / #16599

29 Oct 2024 11:04PM UTC coverage: 12.519% (-0.1%) from 12.62%
#16599

push

github

web-flow
Merge pull request #1914 from stripe/latest-codegen-beta

Update generated code for beta

40 of 1580 new or added lines in 51 files covered. (2.53%)

19 existing lines in 15 files now uncovered.

18843 of 150513 relevant lines covered (12.52%)

0.13 hits per line

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

34.41
/src/main/java/com/stripe/model/Subscription.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.model.testhelpers.TestClock;
7
import com.stripe.net.ApiRequest;
8
import com.stripe.net.ApiRequestParams;
9
import com.stripe.net.ApiResource;
10
import com.stripe.net.BaseAddress;
11
import com.stripe.net.RequestOptions;
12
import com.stripe.net.StripeResponseGetter;
13
import com.stripe.param.SubscriptionCancelParams;
14
import com.stripe.param.SubscriptionCreateParams;
15
import com.stripe.param.SubscriptionListParams;
16
import com.stripe.param.SubscriptionResumeParams;
17
import com.stripe.param.SubscriptionRetrieveParams;
18
import com.stripe.param.SubscriptionSearchParams;
19
import com.stripe.param.SubscriptionUpdateParams;
20
import java.math.BigDecimal;
21
import java.util.List;
22
import java.util.Map;
23
import java.util.stream.Collectors;
24
import lombok.EqualsAndHashCode;
25
import lombok.Getter;
26
import lombok.Setter;
27

28
/**
29
 * Subscriptions allow you to charge a customer on a recurring basis.
30
 *
31
 * <p>Related guide: <a href="https://stripe.com/docs/billing/subscriptions/creating">Creating
32
 * subscriptions</a>
33
 */
34
@Getter
35
@Setter
36
@EqualsAndHashCode(callSuper = false)
37
public class Subscription extends ApiResource implements HasId, MetadataStore<Subscription> {
1✔
38
  /** ID of the Connect Application that created the subscription. */
39
  @SerializedName("application")
40
  @Getter(lombok.AccessLevel.NONE)
41
  @Setter(lombok.AccessLevel.NONE)
42
  ExpandableField<Application> application;
43

44
  /**
45
   * A non-negative decimal between 0 and 100, with at most two decimal places. This represents the
46
   * percentage of the subscription invoice total that will be transferred to the application
47
   * owner's Stripe account.
48
   */
49
  @SerializedName("application_fee_percent")
50
  BigDecimal applicationFeePercent;
51

52
  @SerializedName("automatic_tax")
53
  AutomaticTax automaticTax;
54

55
  /**
56
   * The reference point that aligns future <a
57
   * href="https://stripe.com/docs/subscriptions/billing-cycle">billing cycle</a> dates. It sets the
58
   * day of week for {@code week} intervals, the day of month for {@code month} and {@code year}
59
   * intervals, and the month of year for {@code year} intervals. The timestamp is in UTC format.
60
   */
61
  @SerializedName("billing_cycle_anchor")
62
  Long billingCycleAnchor;
63

64
  /** The fixed values used to calculate the {@code billing_cycle_anchor}. */
65
  @SerializedName("billing_cycle_anchor_config")
66
  BillingCycleAnchorConfig billingCycleAnchorConfig;
67

68
  /**
69
   * Define thresholds at which an invoice will be sent, and the subscription advanced to a new
70
   * billing period.
71
   */
72
  @SerializedName("billing_thresholds")
73
  BillingThresholds billingThresholds;
74

75
  /** A date in the future at which the subscription will automatically get canceled. */
76
  @SerializedName("cancel_at")
77
  Long cancelAt;
78

79
  /**
80
   * Whether this subscription will (if {@code status=active}) or did (if {@code status=canceled})
81
   * cancel at the end of the current billing period.
82
   */
83
  @SerializedName("cancel_at_period_end")
84
  Boolean cancelAtPeriodEnd;
85

86
  /**
87
   * If the subscription has been canceled, the date of that cancellation. If the subscription was
88
   * canceled with {@code cancel_at_period_end}, {@code canceled_at} will reflect the time of the
89
   * most recent update request, not the end of the subscription period when the subscription is
90
   * automatically moved to a canceled state.
91
   */
92
  @SerializedName("canceled_at")
93
  Long canceledAt;
94

95
  /** Details about why this subscription was cancelled. */
96
  @SerializedName("cancellation_details")
97
  CancellationDetails cancellationDetails;
98

99
  /**
100
   * Either {@code charge_automatically}, or {@code send_invoice}. When charging automatically,
101
   * Stripe will attempt to pay this subscription at the end of the cycle using the default source
102
   * attached to the customer. When sending an invoice, Stripe will email your customer an invoice
103
   * with payment instructions and mark the subscription as {@code active}.
104
   *
105
   * <p>One of {@code charge_automatically}, or {@code send_invoice}.
106
   */
107
  @SerializedName("collection_method")
108
  String collectionMethod;
109

110
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
111
  @SerializedName("created")
112
  Long created;
113

114
  /**
115
   * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
116
   * in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
117
   */
118
  @SerializedName("currency")
119
  String currency;
120

121
  /**
122
   * End of the current period that the subscription has been invoiced for. At the end of this
123
   * period, a new invoice will be created.
124
   */
125
  @SerializedName("current_period_end")
126
  Long currentPeriodEnd;
127

128
  /** Start of the current period that the subscription has been invoiced for. */
129
  @SerializedName("current_period_start")
130
  Long currentPeriodStart;
131

132
  /** ID of the customer who owns the subscription. */
133
  @SerializedName("customer")
134
  @Getter(lombok.AccessLevel.NONE)
135
  @Setter(lombok.AccessLevel.NONE)
136
  ExpandableField<Customer> customer;
137

138
  /**
139
   * Number of days a customer has to pay invoices generated by this subscription. This value will
140
   * be {@code null} for subscriptions where {@code collection_method=charge_automatically}.
141
   */
142
  @SerializedName("days_until_due")
143
  Long daysUntilDue;
144

145
  /**
146
   * ID of the default payment method for the subscription. It must belong to the customer
147
   * associated with the subscription. This takes precedence over {@code default_source}. If neither
148
   * are set, invoices will use the customer's <a
149
   * href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method</a>
150
   * or <a
151
   * href="https://stripe.com/docs/api/customers/object#customer_object-default_source">default_source</a>.
152
   */
153
  @SerializedName("default_payment_method")
154
  @Getter(lombok.AccessLevel.NONE)
155
  @Setter(lombok.AccessLevel.NONE)
156
  ExpandableField<PaymentMethod> defaultPaymentMethod;
157

158
  /**
159
   * ID of the default payment source for the subscription. It must belong to the customer
160
   * associated with the subscription and be in a chargeable state. If {@code
161
   * default_payment_method} is also set, {@code default_payment_method} will take precedence. If
162
   * neither are set, invoices will use the customer's <a
163
   * href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method</a>
164
   * or <a
165
   * href="https://stripe.com/docs/api/customers/object#customer_object-default_source">default_source</a>.
166
   */
167
  @SerializedName("default_source")
168
  @Getter(lombok.AccessLevel.NONE)
169
  @Setter(lombok.AccessLevel.NONE)
170
  ExpandableField<PaymentSource> defaultSource;
171

172
  /**
173
   * The tax rates that will apply to any subscription item that does not have {@code tax_rates}
174
   * set. Invoices created will have their {@code default_tax_rates} populated from the
175
   * subscription.
176
   */
177
  @SerializedName("default_tax_rates")
178
  List<TaxRate> defaultTaxRates;
179

180
  /**
181
   * The subscription's description, meant to be displayable to the customer. Use this field to
182
   * optionally store an explanation of the subscription for rendering in Stripe surfaces and
183
   * certain local payment methods UIs.
184
   */
185
  @SerializedName("description")
186
  String description;
187

188
  /**
189
   * Describes the current discount applied to this subscription, if there is one. When billing, a
190
   * discount applied to a subscription overrides a discount applied on a customer-wide basis. This
191
   * field has been deprecated and will be removed in a future API version. Use {@code discounts}
192
   * instead.
193
   */
194
  @SerializedName("discount")
195
  Discount discount;
196

197
  /**
198
   * The discounts applied to the subscription. Subscription item discounts are applied before
199
   * subscription discounts. Use {@code expand[]=discounts} to expand each discount.
200
   */
201
  @SerializedName("discounts")
202
  List<ExpandableField<Discount>> discounts;
203

204
  /** If the subscription has ended, the date the subscription ended. */
205
  @SerializedName("ended_at")
206
  Long endedAt;
207

208
  /** Unique identifier for the object. */
209
  @Getter(onMethod_ = {@Override})
210
  @SerializedName("id")
211
  String id;
212

213
  @SerializedName("invoice_settings")
214
  InvoiceSettings invoiceSettings;
215

216
  /** List of subscription items, each with an attached price. */
217
  @SerializedName("items")
218
  SubscriptionItemCollection items;
219

220
  /** Details of the most recent price migration that failed for the subscription. */
221
  @SerializedName("last_price_migration_error")
222
  LastPriceMigrationError lastPriceMigrationError;
223

224
  /** The most recent invoice this subscription has generated. */
225
  @SerializedName("latest_invoice")
226
  @Getter(lombok.AccessLevel.NONE)
227
  @Setter(lombok.AccessLevel.NONE)
228
  ExpandableField<Invoice> latestInvoice;
229

230
  /**
231
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
232
   * object exists in test mode.
233
   */
234
  @SerializedName("livemode")
235
  Boolean livemode;
236

237
  /**
238
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
239
   * to an object. This can be useful for storing additional information about the object in a
240
   * structured format.
241
   */
242
  @Getter(onMethod_ = {@Override})
243
  @SerializedName("metadata")
244
  Map<String, String> metadata;
245

246
  /**
247
   * Specifies the approximate timestamp on which any pending invoice items will be billed according
248
   * to the schedule provided at {@code pending_invoice_item_interval}.
249
   */
250
  @SerializedName("next_pending_invoice_item_invoice")
251
  Long nextPendingInvoiceItemInvoice;
252

253
  /**
254
   * String representing the object's type. Objects of the same type share the same value.
255
   *
256
   * <p>Equal to {@code subscription}.
257
   */
258
  @SerializedName("object")
259
  String object;
260

261
  /**
262
   * The account (if any) the charge was made on behalf of for charges associated with this
263
   * subscription. See the Connect documentation for details.
264
   */
265
  @SerializedName("on_behalf_of")
266
  @Getter(lombok.AccessLevel.NONE)
267
  @Setter(lombok.AccessLevel.NONE)
268
  ExpandableField<Account> onBehalfOf;
269

270
  /**
271
   * If specified, payment collection for this subscription will be paused. Note that the
272
   * subscription status will be unchanged and will not be updated to {@code paused}. Learn more
273
   * about <a href="https://stripe.com/billing/subscriptions/pause-payment">pausing collection</a>.
274
   */
275
  @SerializedName("pause_collection")
276
  PauseCollection pauseCollection;
277

278
  /** Payment settings passed on to invoices created by the subscription. */
279
  @SerializedName("payment_settings")
280
  PaymentSettings paymentSettings;
281

282
  /**
283
   * Specifies an interval for how often to bill for any pending invoice items. It is analogous to
284
   * calling <a href="https://stripe.com/docs/api#create_invoice">Create an invoice</a> for the
285
   * given subscription at the specified interval.
286
   */
287
  @SerializedName("pending_invoice_item_interval")
288
  PendingInvoiceItemInterval pendingInvoiceItemInterval;
289

290
  /**
291
   * You can use this <a href="https://stripe.com/docs/api/setup_intents">SetupIntent</a> to collect
292
   * user authentication when creating a subscription without immediate payment or updating a
293
   * subscription's payment method, allowing you to optimize for off-session payments. Learn more in
294
   * the <a
295
   * href="https://stripe.com/docs/billing/migration/strong-customer-authentication#scenario-2">SCA
296
   * Migration Guide</a>.
297
   */
298
  @SerializedName("pending_setup_intent")
299
  @Getter(lombok.AccessLevel.NONE)
300
  @Setter(lombok.AccessLevel.NONE)
301
  ExpandableField<SetupIntent> pendingSetupIntent;
302

303
  /**
304
   * If specified, <a href="https://stripe.com/docs/billing/subscriptions/pending-updates">pending
305
   * updates</a> that will be applied to the subscription once the {@code latest_invoice} has been
306
   * paid.
307
   */
308
  @SerializedName("pending_update")
309
  PendingUpdate pendingUpdate;
310

311
  /** Time period and invoice for a Subscription billed in advance. */
312
  @SerializedName("prebilling")
313
  Prebilling prebilling;
314

315
  /** The schedule attached to the subscription. */
316
  @SerializedName("schedule")
317
  @Getter(lombok.AccessLevel.NONE)
318
  @Setter(lombok.AccessLevel.NONE)
319
  ExpandableField<SubscriptionSchedule> schedule;
320

321
  /**
322
   * Date when the subscription was first created. The date might differ from the {@code created}
323
   * date due to backdating.
324
   */
325
  @SerializedName("start_date")
326
  Long startDate;
327

328
  /**
329
   * Possible values are {@code incomplete}, {@code incomplete_expired}, {@code trialing}, {@code
330
   * active}, {@code past_due}, {@code canceled}, {@code unpaid}, or {@code paused}.
331
   *
332
   * <p>For {@code collection_method=charge_automatically} a subscription moves into {@code
333
   * incomplete} if the initial payment attempt fails. A subscription in this status can only have
334
   * metadata and default_source updated. Once the first invoice is paid, the subscription moves
335
   * into an {@code active} status. If the first invoice is not paid within 23 hours, the
336
   * subscription transitions to {@code incomplete_expired}. This is a terminal status, the open
337
   * invoice will be voided and no further invoices will be generated.
338
   *
339
   * <p>A subscription that is currently in a trial period is {@code trialing} and moves to {@code
340
   * active} when the trial period is over.
341
   *
342
   * <p>A subscription can only enter a {@code paused} status <a
343
   * href="https://stripe.com/billing/subscriptions/trials#create-free-trials-without-payment">when
344
   * a trial ends without a payment method</a>. A {@code paused} subscription doesn't generate
345
   * invoices and can be resumed after your customer adds their payment method. The {@code paused}
346
   * status is different from <a
347
   * href="https://stripe.com/billing/subscriptions/pause-payment">pausing collection</a>, which
348
   * still generates invoices and leaves the subscription's status unchanged.
349
   *
350
   * <p>If subscription {@code collection_method=charge_automatically}, it becomes {@code past_due}
351
   * when payment is required but cannot be paid (due to failed payment or awaiting additional user
352
   * actions). Once Stripe has exhausted all payment retry attempts, the subscription will become
353
   * {@code canceled} or {@code unpaid} (depending on your subscriptions settings).
354
   *
355
   * <p>If subscription {@code collection_method=send_invoice} it becomes {@code past_due} when its
356
   * invoice is not paid by the due date, and {@code canceled} or {@code unpaid} if it is still not
357
   * paid by an additional deadline after that. Note that when a subscription has a status of {@code
358
   * unpaid}, no subsequent invoices will be attempted (invoices will be created, but then
359
   * immediately automatically closed). After receiving updated payment information from a customer,
360
   * you may choose to reopen and pay their closed invoices.
361
   *
362
   * <p>One of {@code active}, {@code canceled}, {@code incomplete}, {@code incomplete_expired},
363
   * {@code past_due}, {@code paused}, {@code trialing}, or {@code unpaid}.
364
   */
365
  @SerializedName("status")
366
  String status;
367

368
  /** ID of the test clock this subscription belongs to. */
369
  @SerializedName("test_clock")
370
  @Getter(lombok.AccessLevel.NONE)
371
  @Setter(lombok.AccessLevel.NONE)
372
  ExpandableField<TestClock> testClock;
373

374
  /**
375
   * The account (if any) the subscription's payments will be attributed to for tax reporting, and
376
   * where funds from each payment will be transferred to for each of the subscription's invoices.
377
   */
378
  @SerializedName("transfer_data")
379
  TransferData transferData;
380

381
  /** If the subscription has a trial, the end of that trial. */
382
  @SerializedName("trial_end")
383
  Long trialEnd;
384

385
  /** Settings related to subscription trials. */
386
  @SerializedName("trial_settings")
387
  TrialSettings trialSettings;
388

389
  /** If the subscription has a trial, the beginning of that trial. */
390
  @SerializedName("trial_start")
391
  Long trialStart;
392

393
  /** Get ID of expandable {@code application} object. */
394
  public String getApplication() {
395
    return (this.application != null) ? this.application.getId() : null;
×
396
  }
397

398
  public void setApplication(String id) {
399
    this.application = ApiResource.setExpandableFieldId(id, this.application);
×
400
  }
×
401

402
  /** Get expanded {@code application}. */
403
  public Application getApplicationObject() {
404
    return (this.application != null) ? this.application.getExpanded() : null;
×
405
  }
406

407
  public void setApplicationObject(Application expandableObject) {
408
    this.application = new ExpandableField<Application>(expandableObject.getId(), expandableObject);
×
409
  }
×
410

411
  /** Get ID of expandable {@code customer} object. */
412
  public String getCustomer() {
413
    return (this.customer != null) ? this.customer.getId() : null;
1✔
414
  }
415

416
  public void setCustomer(String id) {
417
    this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
418
  }
×
419

420
  /** Get expanded {@code customer}. */
421
  public Customer getCustomerObject() {
422
    return (this.customer != null) ? this.customer.getExpanded() : null;
1✔
423
  }
424

425
  public void setCustomerObject(Customer expandableObject) {
426
    this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
427
  }
×
428

429
  /** Get ID of expandable {@code defaultPaymentMethod} object. */
430
  public String getDefaultPaymentMethod() {
431
    return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getId() : null;
×
432
  }
433

434
  public void setDefaultPaymentMethod(String id) {
435
    this.defaultPaymentMethod = ApiResource.setExpandableFieldId(id, this.defaultPaymentMethod);
×
436
  }
×
437

438
  /** Get expanded {@code defaultPaymentMethod}. */
439
  public PaymentMethod getDefaultPaymentMethodObject() {
440
    return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getExpanded() : null;
×
441
  }
442

443
  public void setDefaultPaymentMethodObject(PaymentMethod expandableObject) {
444
    this.defaultPaymentMethod =
×
445
        new ExpandableField<PaymentMethod>(expandableObject.getId(), expandableObject);
×
446
  }
×
447

448
  /** Get ID of expandable {@code defaultSource} object. */
449
  public String getDefaultSource() {
450
    return (this.defaultSource != null) ? this.defaultSource.getId() : null;
1✔
451
  }
452

453
  public void setDefaultSource(String id) {
454
    this.defaultSource = ApiResource.setExpandableFieldId(id, this.defaultSource);
×
455
  }
×
456

457
  /** Get expanded {@code defaultSource}. */
458
  public PaymentSource getDefaultSourceObject() {
459
    return (this.defaultSource != null) ? this.defaultSource.getExpanded() : null;
1✔
460
  }
461

462
  public void setDefaultSourceObject(PaymentSource expandableObject) {
463
    this.defaultSource =
×
464
        new ExpandableField<PaymentSource>(expandableObject.getId(), expandableObject);
×
465
  }
×
466

467
  /** Get ID of expandable {@code latestInvoice} object. */
468
  public String getLatestInvoice() {
469
    return (this.latestInvoice != null) ? this.latestInvoice.getId() : null;
1✔
470
  }
471

472
  public void setLatestInvoice(String id) {
473
    this.latestInvoice = ApiResource.setExpandableFieldId(id, this.latestInvoice);
×
474
  }
×
475

476
  /** Get expanded {@code latestInvoice}. */
477
  public Invoice getLatestInvoiceObject() {
478
    return (this.latestInvoice != null) ? this.latestInvoice.getExpanded() : null;
1✔
479
  }
480

481
  public void setLatestInvoiceObject(Invoice expandableObject) {
482
    this.latestInvoice = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
×
483
  }
×
484

485
  /** Get ID of expandable {@code onBehalfOf} object. */
486
  public String getOnBehalfOf() {
487
    return (this.onBehalfOf != null) ? this.onBehalfOf.getId() : null;
×
488
  }
489

490
  public void setOnBehalfOf(String id) {
491
    this.onBehalfOf = ApiResource.setExpandableFieldId(id, this.onBehalfOf);
×
492
  }
×
493

494
  /** Get expanded {@code onBehalfOf}. */
495
  public Account getOnBehalfOfObject() {
496
    return (this.onBehalfOf != null) ? this.onBehalfOf.getExpanded() : null;
×
497
  }
498

499
  public void setOnBehalfOfObject(Account expandableObject) {
500
    this.onBehalfOf = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
×
501
  }
×
502

503
  /** Get ID of expandable {@code pendingSetupIntent} object. */
504
  public String getPendingSetupIntent() {
505
    return (this.pendingSetupIntent != null) ? this.pendingSetupIntent.getId() : null;
×
506
  }
507

508
  public void setPendingSetupIntent(String id) {
509
    this.pendingSetupIntent = ApiResource.setExpandableFieldId(id, this.pendingSetupIntent);
×
510
  }
×
511

512
  /** Get expanded {@code pendingSetupIntent}. */
513
  public SetupIntent getPendingSetupIntentObject() {
514
    return (this.pendingSetupIntent != null) ? this.pendingSetupIntent.getExpanded() : null;
×
515
  }
516

517
  public void setPendingSetupIntentObject(SetupIntent expandableObject) {
518
    this.pendingSetupIntent =
×
519
        new ExpandableField<SetupIntent>(expandableObject.getId(), expandableObject);
×
520
  }
×
521

522
  /** Get ID of expandable {@code schedule} object. */
523
  public String getSchedule() {
524
    return (this.schedule != null) ? this.schedule.getId() : null;
×
525
  }
526

527
  public void setSchedule(String id) {
528
    this.schedule = ApiResource.setExpandableFieldId(id, this.schedule);
×
529
  }
×
530

531
  /** Get expanded {@code schedule}. */
532
  public SubscriptionSchedule getScheduleObject() {
533
    return (this.schedule != null) ? this.schedule.getExpanded() : null;
×
534
  }
535

536
  public void setScheduleObject(SubscriptionSchedule expandableObject) {
537
    this.schedule =
×
538
        new ExpandableField<SubscriptionSchedule>(expandableObject.getId(), expandableObject);
×
539
  }
×
540

541
  /** Get ID of expandable {@code testClock} object. */
542
  public String getTestClock() {
543
    return (this.testClock != null) ? this.testClock.getId() : null;
×
544
  }
545

546
  public void setTestClock(String id) {
547
    this.testClock = ApiResource.setExpandableFieldId(id, this.testClock);
×
548
  }
×
549

550
  /** Get expanded {@code testClock}. */
551
  public TestClock getTestClockObject() {
552
    return (this.testClock != null) ? this.testClock.getExpanded() : null;
×
553
  }
554

555
  public void setTestClockObject(TestClock expandableObject) {
556
    this.testClock = new ExpandableField<TestClock>(expandableObject.getId(), expandableObject);
×
557
  }
×
558

559
  /** Get IDs of expandable {@code discounts} object list. */
560
  public List<String> getDiscounts() {
561
    return (this.discounts != null)
×
562
        ? this.discounts.stream().map(x -> x.getId()).collect(Collectors.toList())
×
563
        : null;
×
564
  }
565

566
  public void setDiscounts(List<String> ids) {
567
    if (ids == null) {
×
568
      this.discounts = null;
×
569
      return;
×
570
    }
571
    if (this.discounts != null
×
572
        && this.discounts.stream().map(x -> x.getId()).collect(Collectors.toList()).equals(ids)) {
×
573
      // noop if the ids are equal to what are already present
574
      return;
×
575
    }
576
    this.discounts =
×
577
        (ids != null)
×
578
            ? ids.stream()
×
579
                .map(id -> new ExpandableField<Discount>(id, null))
×
580
                .collect(Collectors.toList())
×
581
            : null;
×
582
  }
×
583

584
  /** Get expanded {@code discounts}. */
585
  public List<Discount> getDiscountObjects() {
586
    return (this.discounts != null)
×
587
        ? this.discounts.stream().map(x -> x.getExpanded()).collect(Collectors.toList())
×
588
        : null;
×
589
  }
590

591
  public void setDiscountObjects(List<Discount> objs) {
592
    this.discounts =
×
593
        objs != null
×
594
            ? objs.stream()
×
595
                .map(x -> new ExpandableField<Discount>(x.getId(), x))
×
596
                .collect(Collectors.toList())
×
597
            : null;
×
598
  }
×
599

600
  /**
601
   * Cancels a customer’s subscription immediately. The customer won’t be charged again for the
602
   * subscription. After it’s canceled, you can no longer update the subscription or its <a
603
   * href="https://stripe.com/metadata">metadata</a>.
604
   *
605
   * <p>Any pending invoice items that you’ve created are still charged at the end of the period,
606
   * unless manually <a href="https://stripe.com/docs/api#delete_invoiceitem">deleted</a>. If you’ve
607
   * set the subscription to cancel at the end of the period, any pending prorations are also left
608
   * in place and collected at the end of the period. But if the subscription is set to cancel
609
   * immediately, pending prorations are removed.
610
   *
611
   * <p>By default, upon subscription cancellation, Stripe stops automatic collection of all
612
   * finalized invoices for the customer. This is intended to prevent unexpected payment attempts
613
   * after the customer has canceled a subscription. However, you can resume automatic collection of
614
   * the invoices manually after subscription cancellation to have us proceed. Or, you could check
615
   * for unpaid invoices before allowing the customer to cancel the subscription at all.
616
   */
617
  public Subscription cancel() throws StripeException {
618
    return cancel((Map<String, Object>) null, (RequestOptions) null);
×
619
  }
620

621
  /**
622
   * Cancels a customer’s subscription immediately. The customer won’t be charged again for the
623
   * subscription. After it’s canceled, you can no longer update the subscription or its <a
624
   * href="https://stripe.com/metadata">metadata</a>.
625
   *
626
   * <p>Any pending invoice items that you’ve created are still charged at the end of the period,
627
   * unless manually <a href="https://stripe.com/docs/api#delete_invoiceitem">deleted</a>. If you’ve
628
   * set the subscription to cancel at the end of the period, any pending prorations are also left
629
   * in place and collected at the end of the period. But if the subscription is set to cancel
630
   * immediately, pending prorations are removed.
631
   *
632
   * <p>By default, upon subscription cancellation, Stripe stops automatic collection of all
633
   * finalized invoices for the customer. This is intended to prevent unexpected payment attempts
634
   * after the customer has canceled a subscription. However, you can resume automatic collection of
635
   * the invoices manually after subscription cancellation to have us proceed. Or, you could check
636
   * for unpaid invoices before allowing the customer to cancel the subscription at all.
637
   */
638
  public Subscription cancel(Map<String, Object> params) throws StripeException {
639
    return cancel(params, (RequestOptions) null);
1✔
640
  }
641

642
  /**
643
   * Cancels a customer’s subscription immediately. The customer won’t be charged again for the
644
   * subscription. After it’s canceled, you can no longer update the subscription or its <a
645
   * href="https://stripe.com/metadata">metadata</a>.
646
   *
647
   * <p>Any pending invoice items that you’ve created are still charged at the end of the period,
648
   * unless manually <a href="https://stripe.com/docs/api#delete_invoiceitem">deleted</a>. If you’ve
649
   * set the subscription to cancel at the end of the period, any pending prorations are also left
650
   * in place and collected at the end of the period. But if the subscription is set to cancel
651
   * immediately, pending prorations are removed.
652
   *
653
   * <p>By default, upon subscription cancellation, Stripe stops automatic collection of all
654
   * finalized invoices for the customer. This is intended to prevent unexpected payment attempts
655
   * after the customer has canceled a subscription. However, you can resume automatic collection of
656
   * the invoices manually after subscription cancellation to have us proceed. Or, you could check
657
   * for unpaid invoices before allowing the customer to cancel the subscription at all.
658
   */
659
  public Subscription cancel(Map<String, Object> params, RequestOptions options)
660
      throws StripeException {
661
    String path = String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(this.getId()));
1✔
662
    ApiRequest request =
1✔
663
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.DELETE, path, params, options);
664
    return getResponseGetter().request(request, Subscription.class);
1✔
665
  }
666

667
  /**
668
   * Cancels a customer’s subscription immediately. The customer won’t be charged again for the
669
   * subscription. After it’s canceled, you can no longer update the subscription or its <a
670
   * href="https://stripe.com/metadata">metadata</a>.
671
   *
672
   * <p>Any pending invoice items that you’ve created are still charged at the end of the period,
673
   * unless manually <a href="https://stripe.com/docs/api#delete_invoiceitem">deleted</a>. If you’ve
674
   * set the subscription to cancel at the end of the period, any pending prorations are also left
675
   * in place and collected at the end of the period. But if the subscription is set to cancel
676
   * immediately, pending prorations are removed.
677
   *
678
   * <p>By default, upon subscription cancellation, Stripe stops automatic collection of all
679
   * finalized invoices for the customer. This is intended to prevent unexpected payment attempts
680
   * after the customer has canceled a subscription. However, you can resume automatic collection of
681
   * the invoices manually after subscription cancellation to have us proceed. Or, you could check
682
   * for unpaid invoices before allowing the customer to cancel the subscription at all.
683
   */
684
  public Subscription cancel(SubscriptionCancelParams params) throws StripeException {
685
    return cancel(params, (RequestOptions) null);
1✔
686
  }
687

688
  /**
689
   * Cancels a customer’s subscription immediately. The customer won’t be charged again for the
690
   * subscription. After it’s canceled, you can no longer update the subscription or its <a
691
   * href="https://stripe.com/metadata">metadata</a>.
692
   *
693
   * <p>Any pending invoice items that you’ve created are still charged at the end of the period,
694
   * unless manually <a href="https://stripe.com/docs/api#delete_invoiceitem">deleted</a>. If you’ve
695
   * set the subscription to cancel at the end of the period, any pending prorations are also left
696
   * in place and collected at the end of the period. But if the subscription is set to cancel
697
   * immediately, pending prorations are removed.
698
   *
699
   * <p>By default, upon subscription cancellation, Stripe stops automatic collection of all
700
   * finalized invoices for the customer. This is intended to prevent unexpected payment attempts
701
   * after the customer has canceled a subscription. However, you can resume automatic collection of
702
   * the invoices manually after subscription cancellation to have us proceed. Or, you could check
703
   * for unpaid invoices before allowing the customer to cancel the subscription at all.
704
   */
705
  public Subscription cancel(SubscriptionCancelParams params, RequestOptions options)
706
      throws StripeException {
707
    String path = String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(this.getId()));
1✔
708
    ApiResource.checkNullTypedParams(path, params);
1✔
709
    ApiRequest request =
1✔
710
        new ApiRequest(
711
            BaseAddress.API,
712
            ApiResource.RequestMethod.DELETE,
713
            path,
714
            ApiRequestParams.paramsToMap(params),
1✔
715
            options);
716
    return getResponseGetter().request(request, Subscription.class);
1✔
717
  }
718

719
  /**
720
   * Creates a new subscription on an existing customer. Each customer can have up to 500 active or
721
   * scheduled subscriptions.
722
   *
723
   * <p>When you create a subscription with {@code collection_method=charge_automatically}, the
724
   * first invoice is finalized as part of the request. The {@code payment_behavior} parameter
725
   * determines the exact behavior of the initial payment.
726
   *
727
   * <p>To start subscriptions where the first invoice always begins in a {@code draft} status, use
728
   * <a
729
   * href="https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing">subscription
730
   * schedules</a> instead. Schedules provide the flexibility to model more complex billing
731
   * configurations that change over time.
732
   */
733
  public static Subscription create(Map<String, Object> params) throws StripeException {
734
    return create(params, (RequestOptions) null);
1✔
735
  }
736

737
  /**
738
   * Creates a new subscription on an existing customer. Each customer can have up to 500 active or
739
   * scheduled subscriptions.
740
   *
741
   * <p>When you create a subscription with {@code collection_method=charge_automatically}, the
742
   * first invoice is finalized as part of the request. The {@code payment_behavior} parameter
743
   * determines the exact behavior of the initial payment.
744
   *
745
   * <p>To start subscriptions where the first invoice always begins in a {@code draft} status, use
746
   * <a
747
   * href="https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing">subscription
748
   * schedules</a> instead. Schedules provide the flexibility to model more complex billing
749
   * configurations that change over time.
750
   */
751
  public static Subscription create(Map<String, Object> params, RequestOptions options)
752
      throws StripeException {
753
    String path = "/v1/subscriptions";
1✔
754
    ApiRequest request =
1✔
755
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
756
    return getGlobalResponseGetter().request(request, Subscription.class);
1✔
757
  }
758

759
  /**
760
   * Creates a new subscription on an existing customer. Each customer can have up to 500 active or
761
   * scheduled subscriptions.
762
   *
763
   * <p>When you create a subscription with {@code collection_method=charge_automatically}, the
764
   * first invoice is finalized as part of the request. The {@code payment_behavior} parameter
765
   * determines the exact behavior of the initial payment.
766
   *
767
   * <p>To start subscriptions where the first invoice always begins in a {@code draft} status, use
768
   * <a
769
   * href="https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing">subscription
770
   * schedules</a> instead. Schedules provide the flexibility to model more complex billing
771
   * configurations that change over time.
772
   */
773
  public static Subscription create(SubscriptionCreateParams params) throws StripeException {
774
    return create(params, (RequestOptions) null);
1✔
775
  }
776

777
  /**
778
   * Creates a new subscription on an existing customer. Each customer can have up to 500 active or
779
   * scheduled subscriptions.
780
   *
781
   * <p>When you create a subscription with {@code collection_method=charge_automatically}, the
782
   * first invoice is finalized as part of the request. The {@code payment_behavior} parameter
783
   * determines the exact behavior of the initial payment.
784
   *
785
   * <p>To start subscriptions where the first invoice always begins in a {@code draft} status, use
786
   * <a
787
   * href="https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing">subscription
788
   * schedules</a> instead. Schedules provide the flexibility to model more complex billing
789
   * configurations that change over time.
790
   */
791
  public static Subscription create(SubscriptionCreateParams params, RequestOptions options)
792
      throws StripeException {
793
    String path = "/v1/subscriptions";
1✔
794
    ApiResource.checkNullTypedParams(path, params);
1✔
795
    ApiRequest request =
1✔
796
        new ApiRequest(
797
            BaseAddress.API,
798
            ApiResource.RequestMethod.POST,
799
            path,
800
            ApiRequestParams.paramsToMap(params),
1✔
801
            options);
802
    return getGlobalResponseGetter().request(request, Subscription.class);
1✔
803
  }
804

805
  /** Removes the currently applied discount on a subscription. */
806
  public Discount deleteDiscount() throws StripeException {
807
    return deleteDiscount((Map<String, Object>) null, (RequestOptions) null);
1✔
808
  }
809

810
  /** Removes the currently applied discount on a subscription. */
811
  public Discount deleteDiscount(Map<String, Object> params) throws StripeException {
812
    return deleteDiscount(params, (RequestOptions) null);
×
813
  }
814

815
  /** Removes the currently applied discount on a subscription. */
816
  public Discount deleteDiscount(Map<String, Object> params, RequestOptions options)
817
      throws StripeException {
818
    String path =
1✔
819
        String.format("/v1/subscriptions/%s/discount", ApiResource.urlEncodeId(this.getId()));
1✔
820
    ApiRequest request =
1✔
821
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.DELETE, path, params, options);
822
    return getResponseGetter().request(request, Discount.class);
1✔
823
  }
824

825
  /**
826
   * By default, returns a list of subscriptions that have not been canceled. In order to list
827
   * canceled subscriptions, specify {@code status=canceled}.
828
   */
829
  public static SubscriptionCollection list(Map<String, Object> params) throws StripeException {
830
    return list(params, (RequestOptions) null);
1✔
831
  }
832

833
  /**
834
   * By default, returns a list of subscriptions that have not been canceled. In order to list
835
   * canceled subscriptions, specify {@code status=canceled}.
836
   */
837
  public static SubscriptionCollection list(Map<String, Object> params, RequestOptions options)
838
      throws StripeException {
839
    String path = "/v1/subscriptions";
1✔
840
    ApiRequest request =
1✔
841
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
842
    return getGlobalResponseGetter().request(request, SubscriptionCollection.class);
1✔
843
  }
844

845
  /**
846
   * By default, returns a list of subscriptions that have not been canceled. In order to list
847
   * canceled subscriptions, specify {@code status=canceled}.
848
   */
849
  public static SubscriptionCollection list(SubscriptionListParams params) throws StripeException {
850
    return list(params, (RequestOptions) null);
1✔
851
  }
852

853
  /**
854
   * By default, returns a list of subscriptions that have not been canceled. In order to list
855
   * canceled subscriptions, specify {@code status=canceled}.
856
   */
857
  public static SubscriptionCollection list(SubscriptionListParams params, RequestOptions options)
858
      throws StripeException {
859
    String path = "/v1/subscriptions";
1✔
860
    ApiResource.checkNullTypedParams(path, params);
1✔
861
    ApiRequest request =
1✔
862
        new ApiRequest(
863
            BaseAddress.API,
864
            ApiResource.RequestMethod.GET,
865
            path,
866
            ApiRequestParams.paramsToMap(params),
1✔
867
            options);
868
    return getGlobalResponseGetter().request(request, SubscriptionCollection.class);
1✔
869
  }
870

871
  /**
872
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
873
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
874
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
875
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
876
   * resumption invoice will void automatically if not paid by the expiration date.
877
   */
878
  public Subscription resume() throws StripeException {
879
    return resume((Map<String, Object>) null, (RequestOptions) null);
×
880
  }
881

882
  /**
883
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
884
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
885
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
886
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
887
   * resumption invoice will void automatically if not paid by the expiration date.
888
   */
889
  public Subscription resume(RequestOptions options) throws StripeException {
890
    return resume((Map<String, Object>) null, options);
×
891
  }
892

893
  /**
894
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
895
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
896
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
897
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
898
   * resumption invoice will void automatically if not paid by the expiration date.
899
   */
900
  public Subscription resume(Map<String, Object> params) throws StripeException {
901
    return resume(params, (RequestOptions) null);
×
902
  }
903

904
  /**
905
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
906
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
907
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
908
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
909
   * resumption invoice will void automatically if not paid by the expiration date.
910
   */
911
  public Subscription resume(Map<String, Object> params, RequestOptions options)
912
      throws StripeException {
913
    String path =
×
914
        String.format("/v1/subscriptions/%s/resume", ApiResource.urlEncodeId(this.getId()));
×
915
    ApiRequest request =
×
916
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
917
    return getResponseGetter().request(request, Subscription.class);
×
918
  }
919

920
  /**
921
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
922
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
923
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
924
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
925
   * resumption invoice will void automatically if not paid by the expiration date.
926
   */
927
  public Subscription resume(SubscriptionResumeParams params) throws StripeException {
928
    return resume(params, (RequestOptions) null);
×
929
  }
930

931
  /**
932
   * Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
933
   * and creating prorations. If a resumption invoice is generated, it must be paid or marked
934
   * uncollectible before the subscription will be unpaused. If payment succeeds the subscription
935
   * will become {@code active}, and if payment fails the subscription will be {@code past_due}. The
936
   * resumption invoice will void automatically if not paid by the expiration date.
937
   */
938
  public Subscription resume(SubscriptionResumeParams params, RequestOptions options)
939
      throws StripeException {
940
    String path =
×
941
        String.format("/v1/subscriptions/%s/resume", ApiResource.urlEncodeId(this.getId()));
×
942
    ApiResource.checkNullTypedParams(path, params);
×
943
    ApiRequest request =
×
944
        new ApiRequest(
945
            BaseAddress.API,
946
            ApiResource.RequestMethod.POST,
947
            path,
948
            ApiRequestParams.paramsToMap(params),
×
949
            options);
950
    return getResponseGetter().request(request, Subscription.class);
×
951
  }
952

953
  /** Retrieves the subscription with the given ID. */
954
  public static Subscription retrieve(String subscriptionExposedId) throws StripeException {
955
    return retrieve(subscriptionExposedId, (Map<String, Object>) null, (RequestOptions) null);
1✔
956
  }
957

958
  /** Retrieves the subscription with the given ID. */
959
  public static Subscription retrieve(String subscriptionExposedId, RequestOptions options)
960
      throws StripeException {
961
    return retrieve(subscriptionExposedId, (Map<String, Object>) null, options);
×
962
  }
963

964
  /** Retrieves the subscription with the given ID. */
965
  public static Subscription retrieve(
966
      String subscriptionExposedId, Map<String, Object> params, RequestOptions options)
967
      throws StripeException {
968
    String path =
1✔
969
        String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(subscriptionExposedId));
1✔
970
    ApiRequest request =
1✔
971
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
972
    return getGlobalResponseGetter().request(request, Subscription.class);
1✔
973
  }
974

975
  /** Retrieves the subscription with the given ID. */
976
  public static Subscription retrieve(
977
      String subscriptionExposedId, SubscriptionRetrieveParams params, RequestOptions options)
978
      throws StripeException {
979
    String path =
×
980
        String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(subscriptionExposedId));
×
981
    ApiResource.checkNullTypedParams(path, params);
×
982
    ApiRequest request =
×
983
        new ApiRequest(
984
            BaseAddress.API,
985
            ApiResource.RequestMethod.GET,
986
            path,
987
            ApiRequestParams.paramsToMap(params),
×
988
            options);
989
    return getGlobalResponseGetter().request(request, Subscription.class);
×
990
  }
991

992
  /**
993
   * Search for subscriptions you’ve previously created using Stripe’s <a
994
   * href="https://stripe.com/docs/search#search-query-language">Search Query Language</a>. Don’t
995
   * use search in read-after-write flows where strict consistency is necessary. Under normal
996
   * operating conditions, data is searchable in less than a minute. Occasionally, propagation of
997
   * new or updated data can be up to an hour behind during outages. Search functionality is not
998
   * available to merchants in India.
999
   */
1000
  public static SubscriptionSearchResult search(Map<String, Object> params) throws StripeException {
1001
    return search(params, (RequestOptions) null);
×
1002
  }
1003

1004
  /**
1005
   * Search for subscriptions you’ve previously created using Stripe’s <a
1006
   * href="https://stripe.com/docs/search#search-query-language">Search Query Language</a>. Don’t
1007
   * use search in read-after-write flows where strict consistency is necessary. Under normal
1008
   * operating conditions, data is searchable in less than a minute. Occasionally, propagation of
1009
   * new or updated data can be up to an hour behind during outages. Search functionality is not
1010
   * available to merchants in India.
1011
   */
1012
  public static SubscriptionSearchResult search(Map<String, Object> params, RequestOptions options)
1013
      throws StripeException {
1014
    String path = "/v1/subscriptions/search";
×
1015
    ApiRequest request =
×
1016
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
1017
    return getGlobalResponseGetter().request(request, SubscriptionSearchResult.class);
×
1018
  }
1019

1020
  /**
1021
   * Search for subscriptions you’ve previously created using Stripe’s <a
1022
   * href="https://stripe.com/docs/search#search-query-language">Search Query Language</a>. Don’t
1023
   * use search in read-after-write flows where strict consistency is necessary. Under normal
1024
   * operating conditions, data is searchable in less than a minute. Occasionally, propagation of
1025
   * new or updated data can be up to an hour behind during outages. Search functionality is not
1026
   * available to merchants in India.
1027
   */
1028
  public static SubscriptionSearchResult search(SubscriptionSearchParams params)
1029
      throws StripeException {
1030
    return search(params, (RequestOptions) null);
1✔
1031
  }
1032

1033
  /**
1034
   * Search for subscriptions you’ve previously created using Stripe’s <a
1035
   * href="https://stripe.com/docs/search#search-query-language">Search Query Language</a>. Don’t
1036
   * use search in read-after-write flows where strict consistency is necessary. Under normal
1037
   * operating conditions, data is searchable in less than a minute. Occasionally, propagation of
1038
   * new or updated data can be up to an hour behind during outages. Search functionality is not
1039
   * available to merchants in India.
1040
   */
1041
  public static SubscriptionSearchResult search(
1042
      SubscriptionSearchParams params, RequestOptions options) throws StripeException {
1043
    String path = "/v1/subscriptions/search";
1✔
1044
    ApiResource.checkNullTypedParams(path, params);
1✔
1045
    ApiRequest request =
1✔
1046
        new ApiRequest(
1047
            BaseAddress.API,
1048
            ApiResource.RequestMethod.GET,
1049
            path,
1050
            ApiRequestParams.paramsToMap(params),
1✔
1051
            options);
1052
    return getGlobalResponseGetter().request(request, SubscriptionSearchResult.class);
1✔
1053
  }
1054

1055
  /**
1056
   * Updates an existing subscription to match the specified parameters. When changing prices or
1057
   * quantities, we optionally prorate the price we charge next month to make up for any price
1058
   * changes. To preview how the proration is calculated, use the <a
1059
   * href="https://stripe.com/docs/api/invoices/create_preview">create preview</a> endpoint.
1060
   *
1061
   * <p>By default, we prorate subscription changes. For example, if a customer signs up on May 1
1062
   * for a 100 price, they’ll be billed 100 immediately. If on May 15 they switch to a 200 price,
1063
   * then on June 1 they’ll be billed 250 (200 for a renewal of her subscription, plus a 50
1064
   * prorating adjustment for half of the previous month’s 100 difference). Similarly, a downgrade
1065
   * generates a credit that is applied to the next invoice. We also prorate when you make quantity
1066
   * changes.
1067
   *
1068
   * <p>Switching prices does not normally change the billing date or generate an immediate charge
1069
   * unless:
1070
   *
1071
   * <p>
1072
   *
1073
   * <ul>
1074
   *   <li>The billing interval is changed (for example, from monthly to yearly).
1075
   *   <li>The subscription moves from free to paid.
1076
   *   <li>A trial starts or ends.
1077
   * </ul>
1078
   *
1079
   * <p>In these cases, we apply a credit for the unused time on the previous price, immediately
1080
   * charge the customer using the new price, and reset the billing date. Learn about how <a
1081
   * href="https://stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment">Stripe
1082
   * immediately attempts payment for subscription changes</a>.
1083
   *
1084
   * <p>If you want to charge for an upgrade immediately, pass {@code proration_behavior} as {@code
1085
   * always_invoice} to create prorations, automatically invoice the customer for those proration
1086
   * adjustments, and attempt to collect payment. If you pass {@code create_prorations}, the
1087
   * prorations are created but not automatically invoiced. If you want to bill the customer for the
1088
   * prorations before the subscription’s renewal date, you need to manually <a
1089
   * href="https://stripe.com/docs/api/invoices/create">invoice the customer</a>.
1090
   *
1091
   * <p>If you don’t want to prorate, set the {@code proration_behavior} option to {@code none}.
1092
   * With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set
1093
   * {@code proration_behavior} to {@code none} when switching between different billing intervals
1094
   * (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s
1095
   * unused time. We still reset the billing date and bill immediately for the new subscription.
1096
   *
1097
   * <p>Updating the quantity on a subscription many times in an hour may result in <a
1098
   * href="https://stripe.com/docs/rate-limits">rate limiting</a>. If you need to bill for a
1099
   * frequently changing quantity, consider integrating <a
1100
   * href="https://stripe.com/docs/billing/subscriptions/usage-based">usage-based billing</a>
1101
   * instead.
1102
   */
1103
  @Override
1104
  public Subscription update(Map<String, Object> params) throws StripeException {
1105
    return update(params, (RequestOptions) null);
1✔
1106
  }
1107

1108
  /**
1109
   * Updates an existing subscription to match the specified parameters. When changing prices or
1110
   * quantities, we optionally prorate the price we charge next month to make up for any price
1111
   * changes. To preview how the proration is calculated, use the <a
1112
   * href="https://stripe.com/docs/api/invoices/create_preview">create preview</a> endpoint.
1113
   *
1114
   * <p>By default, we prorate subscription changes. For example, if a customer signs up on May 1
1115
   * for a 100 price, they’ll be billed 100 immediately. If on May 15 they switch to a 200 price,
1116
   * then on June 1 they’ll be billed 250 (200 for a renewal of her subscription, plus a 50
1117
   * prorating adjustment for half of the previous month’s 100 difference). Similarly, a downgrade
1118
   * generates a credit that is applied to the next invoice. We also prorate when you make quantity
1119
   * changes.
1120
   *
1121
   * <p>Switching prices does not normally change the billing date or generate an immediate charge
1122
   * unless:
1123
   *
1124
   * <p>
1125
   *
1126
   * <ul>
1127
   *   <li>The billing interval is changed (for example, from monthly to yearly).
1128
   *   <li>The subscription moves from free to paid.
1129
   *   <li>A trial starts or ends.
1130
   * </ul>
1131
   *
1132
   * <p>In these cases, we apply a credit for the unused time on the previous price, immediately
1133
   * charge the customer using the new price, and reset the billing date. Learn about how <a
1134
   * href="https://stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment">Stripe
1135
   * immediately attempts payment for subscription changes</a>.
1136
   *
1137
   * <p>If you want to charge for an upgrade immediately, pass {@code proration_behavior} as {@code
1138
   * always_invoice} to create prorations, automatically invoice the customer for those proration
1139
   * adjustments, and attempt to collect payment. If you pass {@code create_prorations}, the
1140
   * prorations are created but not automatically invoiced. If you want to bill the customer for the
1141
   * prorations before the subscription’s renewal date, you need to manually <a
1142
   * href="https://stripe.com/docs/api/invoices/create">invoice the customer</a>.
1143
   *
1144
   * <p>If you don’t want to prorate, set the {@code proration_behavior} option to {@code none}.
1145
   * With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set
1146
   * {@code proration_behavior} to {@code none} when switching between different billing intervals
1147
   * (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s
1148
   * unused time. We still reset the billing date and bill immediately for the new subscription.
1149
   *
1150
   * <p>Updating the quantity on a subscription many times in an hour may result in <a
1151
   * href="https://stripe.com/docs/rate-limits">rate limiting</a>. If you need to bill for a
1152
   * frequently changing quantity, consider integrating <a
1153
   * href="https://stripe.com/docs/billing/subscriptions/usage-based">usage-based billing</a>
1154
   * instead.
1155
   */
1156
  @Override
1157
  public Subscription update(Map<String, Object> params, RequestOptions options)
1158
      throws StripeException {
1159
    String path = String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(this.getId()));
1✔
1160
    ApiRequest request =
1✔
1161
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
1162
    return getResponseGetter().request(request, Subscription.class);
1✔
1163
  }
1164

1165
  /**
1166
   * Updates an existing subscription to match the specified parameters. When changing prices or
1167
   * quantities, we optionally prorate the price we charge next month to make up for any price
1168
   * changes. To preview how the proration is calculated, use the <a
1169
   * href="https://stripe.com/docs/api/invoices/create_preview">create preview</a> endpoint.
1170
   *
1171
   * <p>By default, we prorate subscription changes. For example, if a customer signs up on May 1
1172
   * for a 100 price, they’ll be billed 100 immediately. If on May 15 they switch to a 200 price,
1173
   * then on June 1 they’ll be billed 250 (200 for a renewal of her subscription, plus a 50
1174
   * prorating adjustment for half of the previous month’s 100 difference). Similarly, a downgrade
1175
   * generates a credit that is applied to the next invoice. We also prorate when you make quantity
1176
   * changes.
1177
   *
1178
   * <p>Switching prices does not normally change the billing date or generate an immediate charge
1179
   * unless:
1180
   *
1181
   * <p>
1182
   *
1183
   * <ul>
1184
   *   <li>The billing interval is changed (for example, from monthly to yearly).
1185
   *   <li>The subscription moves from free to paid.
1186
   *   <li>A trial starts or ends.
1187
   * </ul>
1188
   *
1189
   * <p>In these cases, we apply a credit for the unused time on the previous price, immediately
1190
   * charge the customer using the new price, and reset the billing date. Learn about how <a
1191
   * href="https://stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment">Stripe
1192
   * immediately attempts payment for subscription changes</a>.
1193
   *
1194
   * <p>If you want to charge for an upgrade immediately, pass {@code proration_behavior} as {@code
1195
   * always_invoice} to create prorations, automatically invoice the customer for those proration
1196
   * adjustments, and attempt to collect payment. If you pass {@code create_prorations}, the
1197
   * prorations are created but not automatically invoiced. If you want to bill the customer for the
1198
   * prorations before the subscription’s renewal date, you need to manually <a
1199
   * href="https://stripe.com/docs/api/invoices/create">invoice the customer</a>.
1200
   *
1201
   * <p>If you don’t want to prorate, set the {@code proration_behavior} option to {@code none}.
1202
   * With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set
1203
   * {@code proration_behavior} to {@code none} when switching between different billing intervals
1204
   * (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s
1205
   * unused time. We still reset the billing date and bill immediately for the new subscription.
1206
   *
1207
   * <p>Updating the quantity on a subscription many times in an hour may result in <a
1208
   * href="https://stripe.com/docs/rate-limits">rate limiting</a>. If you need to bill for a
1209
   * frequently changing quantity, consider integrating <a
1210
   * href="https://stripe.com/docs/billing/subscriptions/usage-based">usage-based billing</a>
1211
   * instead.
1212
   */
1213
  public Subscription update(SubscriptionUpdateParams params) throws StripeException {
1214
    return update(params, (RequestOptions) null);
1✔
1215
  }
1216

1217
  /**
1218
   * Updates an existing subscription to match the specified parameters. When changing prices or
1219
   * quantities, we optionally prorate the price we charge next month to make up for any price
1220
   * changes. To preview how the proration is calculated, use the <a
1221
   * href="https://stripe.com/docs/api/invoices/create_preview">create preview</a> endpoint.
1222
   *
1223
   * <p>By default, we prorate subscription changes. For example, if a customer signs up on May 1
1224
   * for a 100 price, they’ll be billed 100 immediately. If on May 15 they switch to a 200 price,
1225
   * then on June 1 they’ll be billed 250 (200 for a renewal of her subscription, plus a 50
1226
   * prorating adjustment for half of the previous month’s 100 difference). Similarly, a downgrade
1227
   * generates a credit that is applied to the next invoice. We also prorate when you make quantity
1228
   * changes.
1229
   *
1230
   * <p>Switching prices does not normally change the billing date or generate an immediate charge
1231
   * unless:
1232
   *
1233
   * <p>
1234
   *
1235
   * <ul>
1236
   *   <li>The billing interval is changed (for example, from monthly to yearly).
1237
   *   <li>The subscription moves from free to paid.
1238
   *   <li>A trial starts or ends.
1239
   * </ul>
1240
   *
1241
   * <p>In these cases, we apply a credit for the unused time on the previous price, immediately
1242
   * charge the customer using the new price, and reset the billing date. Learn about how <a
1243
   * href="https://stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment">Stripe
1244
   * immediately attempts payment for subscription changes</a>.
1245
   *
1246
   * <p>If you want to charge for an upgrade immediately, pass {@code proration_behavior} as {@code
1247
   * always_invoice} to create prorations, automatically invoice the customer for those proration
1248
   * adjustments, and attempt to collect payment. If you pass {@code create_prorations}, the
1249
   * prorations are created but not automatically invoiced. If you want to bill the customer for the
1250
   * prorations before the subscription’s renewal date, you need to manually <a
1251
   * href="https://stripe.com/docs/api/invoices/create">invoice the customer</a>.
1252
   *
1253
   * <p>If you don’t want to prorate, set the {@code proration_behavior} option to {@code none}.
1254
   * With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set
1255
   * {@code proration_behavior} to {@code none} when switching between different billing intervals
1256
   * (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s
1257
   * unused time. We still reset the billing date and bill immediately for the new subscription.
1258
   *
1259
   * <p>Updating the quantity on a subscription many times in an hour may result in <a
1260
   * href="https://stripe.com/docs/rate-limits">rate limiting</a>. If you need to bill for a
1261
   * frequently changing quantity, consider integrating <a
1262
   * href="https://stripe.com/docs/billing/subscriptions/usage-based">usage-based billing</a>
1263
   * instead.
1264
   */
1265
  public Subscription update(SubscriptionUpdateParams params, RequestOptions options)
1266
      throws StripeException {
1267
    String path = String.format("/v1/subscriptions/%s", ApiResource.urlEncodeId(this.getId()));
1✔
1268
    ApiResource.checkNullTypedParams(path, params);
1✔
1269
    ApiRequest request =
1✔
1270
        new ApiRequest(
1271
            BaseAddress.API,
1272
            ApiResource.RequestMethod.POST,
1273
            path,
1274
            ApiRequestParams.paramsToMap(params),
1✔
1275
            options);
1276
    return getResponseGetter().request(request, Subscription.class);
1✔
1277
  }
1278

1279
  /**
1280
   * For more details about AutomaticTax, please refer to the <a
1281
   * href="https://docs.stripe.com/api">API Reference.</a>
1282
   */
1283
  @Getter
1284
  @Setter
1285
  @EqualsAndHashCode(callSuper = false)
1286
  public static class AutomaticTax extends StripeObject {
1✔
1287
    /** Whether Stripe automatically computes tax on this subscription. */
1288
    @SerializedName("enabled")
1289
    Boolean enabled;
1290

1291
    /**
1292
     * The account that's liable for tax. If set, the business address and tax registrations
1293
     * required to perform the tax calculation are loaded from this account. The tax transaction is
1294
     * returned in the report of the connected account.
1295
     */
1296
    @SerializedName("liability")
1297
    Liability liability;
1298

1299
    /**
1300
     * For more details about Liability, please refer to the <a
1301
     * href="https://docs.stripe.com/api">API Reference.</a>
1302
     */
1303
    @Getter
1304
    @Setter
1305
    @EqualsAndHashCode(callSuper = false)
1306
    public static class Liability extends StripeObject {
×
1307
      /** The connected account being referenced when {@code type} is {@code account}. */
1308
      @SerializedName("account")
1309
      @Getter(lombok.AccessLevel.NONE)
1310
      @Setter(lombok.AccessLevel.NONE)
1311
      ExpandableField<Account> account;
1312

1313
      /**
1314
       * Type of the account referenced.
1315
       *
1316
       * <p>One of {@code account}, or {@code self}.
1317
       */
1318
      @SerializedName("type")
1319
      String type;
1320

1321
      /** Get ID of expandable {@code account} object. */
1322
      public String getAccount() {
1323
        return (this.account != null) ? this.account.getId() : null;
×
1324
      }
1325

1326
      public void setAccount(String id) {
1327
        this.account = ApiResource.setExpandableFieldId(id, this.account);
×
1328
      }
×
1329

1330
      /** Get expanded {@code account}. */
1331
      public Account getAccountObject() {
1332
        return (this.account != null) ? this.account.getExpanded() : null;
×
1333
      }
1334

1335
      public void setAccountObject(Account expandableObject) {
1336
        this.account = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
×
1337
      }
×
1338
    }
1339
  }
1340

1341
  /**
1342
   * For more details about BillingCycleAnchorConfig, please refer to the <a
1343
   * href="https://docs.stripe.com/api">API Reference.</a>
1344
   */
1345
  @Getter
1346
  @Setter
1347
  @EqualsAndHashCode(callSuper = false)
1348
  public static class BillingCycleAnchorConfig extends StripeObject {
×
1349
    /** The day of the month of the billing_cycle_anchor. */
1350
    @SerializedName("day_of_month")
1351
    Long dayOfMonth;
1352

1353
    /** The hour of the day of the billing_cycle_anchor. */
1354
    @SerializedName("hour")
1355
    Long hour;
1356

1357
    /** The minute of the hour of the billing_cycle_anchor. */
1358
    @SerializedName("minute")
1359
    Long minute;
1360

1361
    /** The month to start full cycle billing periods. */
1362
    @SerializedName("month")
1363
    Long month;
1364

1365
    /** The second of the minute of the billing_cycle_anchor. */
1366
    @SerializedName("second")
1367
    Long second;
1368
  }
1369

1370
  /**
1371
   * For more details about BillingThresholds, please refer to the <a
1372
   * href="https://docs.stripe.com/api">API Reference.</a>
1373
   */
1374
  @Getter
1375
  @Setter
1376
  @EqualsAndHashCode(callSuper = false)
1377
  public static class BillingThresholds extends StripeObject {
×
1378
    /** Monetary threshold that triggers the subscription to create an invoice. */
1379
    @SerializedName("amount_gte")
1380
    Long amountGte;
1381

1382
    /**
1383
     * Indicates if the {@code billing_cycle_anchor} should be reset when a threshold is reached. If
1384
     * true, {@code billing_cycle_anchor} will be updated to the date/time the threshold was last
1385
     * reached; otherwise, the value will remain unchanged. This value may not be {@code true} if
1386
     * the subscription contains items with plans that have {@code aggregate_usage=last_ever}.
1387
     */
1388
    @SerializedName("reset_billing_cycle_anchor")
1389
    Boolean resetBillingCycleAnchor;
1390
  }
1391

1392
  /**
1393
   * For more details about CancellationDetails, please refer to the <a
1394
   * href="https://docs.stripe.com/api">API Reference.</a>
1395
   */
1396
  @Getter
1397
  @Setter
1398
  @EqualsAndHashCode(callSuper = false)
1399
  public static class CancellationDetails extends StripeObject {
1✔
1400
    /**
1401
     * Additional comments about why the user canceled the subscription, if the subscription was
1402
     * canceled explicitly by the user.
1403
     */
1404
    @SerializedName("comment")
1405
    String comment;
1406

1407
    /**
1408
     * The customer submitted reason for why they canceled, if the subscription was canceled
1409
     * explicitly by the user.
1410
     *
1411
     * <p>One of {@code customer_service}, {@code low_quality}, {@code missing_features}, {@code
1412
     * other}, {@code switched_service}, {@code too_complex}, {@code too_expensive}, or {@code
1413
     * unused}.
1414
     */
1415
    @SerializedName("feedback")
1416
    String feedback;
1417

1418
    /**
1419
     * Why this subscription was canceled.
1420
     *
1421
     * <p>One of {@code cancellation_requested}, {@code payment_disputed}, or {@code
1422
     * payment_failed}.
1423
     */
1424
    @SerializedName("reason")
1425
    String reason;
1426
  }
1427

1428
  /**
1429
   * For more details about InvoiceSettings, please refer to the <a
1430
   * href="https://docs.stripe.com/api">API Reference.</a>
1431
   */
1432
  @Getter
1433
  @Setter
1434
  @EqualsAndHashCode(callSuper = false)
1435
  public static class InvoiceSettings extends StripeObject {
1✔
1436
    /**
1437
     * The account tax IDs associated with the subscription. Will be set on invoices generated by
1438
     * the subscription.
1439
     */
1440
    @SerializedName("account_tax_ids")
1441
    List<ExpandableField<TaxId>> accountTaxIds;
1442

1443
    @SerializedName("issuer")
1444
    Issuer issuer;
1445

1446
    /** Get IDs of expandable {@code accountTaxIds} object list. */
1447
    public List<String> getAccountTaxIds() {
1448
      return (this.accountTaxIds != null)
×
1449
          ? this.accountTaxIds.stream().map(x -> x.getId()).collect(Collectors.toList())
×
1450
          : null;
×
1451
    }
1452

1453
    public void setAccountTaxIds(List<String> ids) {
1454
      if (ids == null) {
×
1455
        this.accountTaxIds = null;
×
1456
        return;
×
1457
      }
1458
      if (this.accountTaxIds != null
×
1459
          && this.accountTaxIds.stream()
×
1460
              .map(x -> x.getId())
×
1461
              .collect(Collectors.toList())
×
1462
              .equals(ids)) {
×
1463
        // noop if the ids are equal to what are already present
1464
        return;
×
1465
      }
1466
      this.accountTaxIds =
×
1467
          (ids != null)
×
1468
              ? ids.stream()
×
1469
                  .map(id -> new ExpandableField<TaxId>(id, null))
×
1470
                  .collect(Collectors.toList())
×
1471
              : null;
×
1472
    }
×
1473

1474
    /** Get expanded {@code accountTaxIds}. */
1475
    public List<TaxId> getAccountTaxIdObjects() {
1476
      return (this.accountTaxIds != null)
×
1477
          ? this.accountTaxIds.stream().map(x -> x.getExpanded()).collect(Collectors.toList())
×
1478
          : null;
×
1479
    }
1480

1481
    public void setAccountTaxIdObjects(List<TaxId> objs) {
1482
      this.accountTaxIds =
×
1483
          objs != null
×
1484
              ? objs.stream()
×
1485
                  .map(x -> new ExpandableField<TaxId>(x.getId(), x))
×
1486
                  .collect(Collectors.toList())
×
1487
              : null;
×
1488
    }
×
1489

1490
    /**
1491
     * For more details about Issuer, please refer to the <a href="https://docs.stripe.com/api">API
1492
     * Reference.</a>
1493
     */
1494
    @Getter
1495
    @Setter
1496
    @EqualsAndHashCode(callSuper = false)
1497
    public static class Issuer extends StripeObject {
1✔
1498
      /** The connected account being referenced when {@code type} is {@code account}. */
1499
      @SerializedName("account")
1500
      @Getter(lombok.AccessLevel.NONE)
1501
      @Setter(lombok.AccessLevel.NONE)
1502
      ExpandableField<Account> account;
1503

1504
      /**
1505
       * Type of the account referenced.
1506
       *
1507
       * <p>One of {@code account}, or {@code self}.
1508
       */
1509
      @SerializedName("type")
1510
      String type;
1511

1512
      /** Get ID of expandable {@code account} object. */
1513
      public String getAccount() {
1514
        return (this.account != null) ? this.account.getId() : null;
×
1515
      }
1516

1517
      public void setAccount(String id) {
1518
        this.account = ApiResource.setExpandableFieldId(id, this.account);
×
1519
      }
×
1520

1521
      /** Get expanded {@code account}. */
1522
      public Account getAccountObject() {
1523
        return (this.account != null) ? this.account.getExpanded() : null;
×
1524
      }
1525

1526
      public void setAccountObject(Account expandableObject) {
1527
        this.account = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
×
1528
      }
×
1529
    }
1530
  }
1531

1532
  /**
1533
   * For more details about LastPriceMigrationError, please refer to the <a
1534
   * href="https://docs.stripe.com/api">API Reference.</a>
1535
   */
1536
  @Getter
1537
  @Setter
1538
  @EqualsAndHashCode(callSuper = false)
1539
  public static class LastPriceMigrationError extends StripeObject {
×
1540
    /** The time at which the price migration encountered an error. */
1541
    @SerializedName("errored_at")
1542
    Long erroredAt;
1543

1544
    /** The involved price pairs in each failed transition. */
1545
    @SerializedName("failed_transitions")
1546
    List<Subscription.LastPriceMigrationError.FailedTransition> failedTransitions;
1547

1548
    /**
1549
     * The type of error encountered by the price migration.
1550
     *
1551
     * <p>Equal to {@code price_uniqueness_violation}.
1552
     */
1553
    @SerializedName("type")
1554
    String type;
1555

1556
    /**
1557
     * For more details about FailedTransition, please refer to the <a
1558
     * href="https://docs.stripe.com/api">API Reference.</a>
1559
     */
1560
    @Getter
1561
    @Setter
1562
    @EqualsAndHashCode(callSuper = false)
1563
    public static class FailedTransition extends StripeObject {
×
1564
      /** The original price to be migrated. */
1565
      @SerializedName("source_price")
1566
      String sourcePrice;
1567

1568
      /** The intended resulting price of the migration. */
1569
      @SerializedName("target_price")
1570
      String targetPrice;
1571
    }
1572
  }
1573

1574
  /**
1575
   * The Pause Collection settings determine how we will pause collection for this subscription and
1576
   * for how long the subscription should be paused.
1577
   */
1578
  @Getter
1579
  @Setter
1580
  @EqualsAndHashCode(callSuper = false)
1581
  public static class PauseCollection extends StripeObject {
×
1582
    /**
1583
     * The payment collection behavior for this subscription while paused. One of {@code
1584
     * keep_as_draft}, {@code mark_uncollectible}, or {@code void}.
1585
     */
1586
    @SerializedName("behavior")
1587
    String behavior;
1588

1589
    /** The time after which the subscription will resume collecting payments. */
1590
    @SerializedName("resumes_at")
1591
    Long resumesAt;
1592
  }
1593

1594
  /**
1595
   * For more details about PaymentSettings, please refer to the <a
1596
   * href="https://docs.stripe.com/api">API Reference.</a>
1597
   */
1598
  @Getter
1599
  @Setter
1600
  @EqualsAndHashCode(callSuper = false)
1601
  public static class PaymentSettings extends StripeObject {
1✔
1602
    /** Payment-method-specific configuration to provide to invoices created by the subscription. */
1603
    @SerializedName("payment_method_options")
1604
    PaymentMethodOptions paymentMethodOptions;
1605

1606
    /**
1607
     * The list of payment method types to provide to every invoice created by the subscription. If
1608
     * not set, Stripe attempts to automatically determine the types to use by looking at the
1609
     * invoice’s default payment method, the subscription’s default payment method, the customer’s
1610
     * default payment method, and your <a
1611
     * href="https://dashboard.stripe.com/settings/billing/invoice">invoice template settings</a>.
1612
     */
1613
    @SerializedName("payment_method_types")
1614
    List<String> paymentMethodTypes;
1615

1616
    /**
1617
     * Configure whether Stripe updates {@code subscription.default_payment_method} when payment
1618
     * succeeds. Defaults to {@code off}.
1619
     *
1620
     * <p>One of {@code off}, or {@code on_subscription}.
1621
     */
1622
    @SerializedName("save_default_payment_method")
1623
    String saveDefaultPaymentMethod;
1624

1625
    /**
1626
     * For more details about PaymentMethodOptions, please refer to the <a
1627
     * href="https://docs.stripe.com/api">API Reference.</a>
1628
     */
1629
    @Getter
1630
    @Setter
1631
    @EqualsAndHashCode(callSuper = false)
1632
    public static class PaymentMethodOptions extends StripeObject {
×
1633
      /**
1634
       * This sub-hash contains details about the Canadian pre-authorized debit payment method
1635
       * options to pass to invoices created by the subscription.
1636
       */
1637
      @SerializedName("acss_debit")
1638
      AcssDebit acssDebit;
1639

1640
      /**
1641
       * This sub-hash contains details about the Bancontact payment method options to pass to
1642
       * invoices created by the subscription.
1643
       */
1644
      @SerializedName("bancontact")
1645
      Bancontact bancontact;
1646

1647
      /**
1648
       * This sub-hash contains details about the Card payment method options to pass to invoices
1649
       * created by the subscription.
1650
       */
1651
      @SerializedName("card")
1652
      Card card;
1653

1654
      /**
1655
       * This sub-hash contains details about the Bank transfer payment method options to pass to
1656
       * invoices created by the subscription.
1657
       */
1658
      @SerializedName("customer_balance")
1659
      CustomerBalance customerBalance;
1660

1661
      /**
1662
       * This sub-hash contains details about the Indonesia bank transfer payment method options to
1663
       * pass to invoices created by the subscription.
1664
       */
1665
      @SerializedName("id_bank_transfer")
1666
      IdBankTransfer idBankTransfer;
1667

1668
      /**
1669
       * This sub-hash contains details about the Konbini payment method options to pass to invoices
1670
       * created by the subscription.
1671
       */
1672
      @SerializedName("konbini")
1673
      Konbini konbini;
1674

1675
      /**
1676
       * This sub-hash contains details about the SEPA Direct Debit payment method options to pass
1677
       * to invoices created by the subscription.
1678
       */
1679
      @SerializedName("sepa_debit")
1680
      SepaDebit sepaDebit;
1681

1682
      /**
1683
       * This sub-hash contains details about the ACH direct debit payment method options to pass to
1684
       * invoices created by the subscription.
1685
       */
1686
      @SerializedName("us_bank_account")
1687
      UsBankAccount usBankAccount;
1688

1689
      /**
1690
       * For more details about AcssDebit, please refer to the <a
1691
       * href="https://docs.stripe.com/api">API Reference.</a>
1692
       */
1693
      @Getter
1694
      @Setter
1695
      @EqualsAndHashCode(callSuper = false)
1696
      public static class AcssDebit extends StripeObject {
×
1697
        @SerializedName("mandate_options")
1698
        MandateOptions mandateOptions;
1699

1700
        /**
1701
         * Bank account verification method.
1702
         *
1703
         * <p>One of {@code automatic}, {@code instant}, or {@code microdeposits}.
1704
         */
1705
        @SerializedName("verification_method")
1706
        String verificationMethod;
1707

1708
        /**
1709
         * For more details about MandateOptions, please refer to the <a
1710
         * href="https://docs.stripe.com/api">API Reference.</a>
1711
         */
1712
        @Getter
1713
        @Setter
1714
        @EqualsAndHashCode(callSuper = false)
1715
        public static class MandateOptions extends StripeObject {
×
1716
          /**
1717
           * Transaction type of the mandate.
1718
           *
1719
           * <p>One of {@code business}, or {@code personal}.
1720
           */
1721
          @SerializedName("transaction_type")
1722
          String transactionType;
1723
        }
1724
      }
1725

1726
      /**
1727
       * For more details about Bancontact, please refer to the <a
1728
       * href="https://docs.stripe.com/api">API Reference.</a>
1729
       */
1730
      @Getter
1731
      @Setter
1732
      @EqualsAndHashCode(callSuper = false)
1733
      public static class Bancontact extends StripeObject {
×
1734
        /**
1735
         * Preferred language of the Bancontact authorization page that the customer is redirected
1736
         * to.
1737
         *
1738
         * <p>One of {@code de}, {@code en}, {@code fr}, or {@code nl}.
1739
         */
1740
        @SerializedName("preferred_language")
1741
        String preferredLanguage;
1742
      }
1743

1744
      /**
1745
       * For more details about Card, please refer to the <a href="https://docs.stripe.com/api">API
1746
       * Reference.</a>
1747
       */
1748
      @Getter
1749
      @Setter
1750
      @EqualsAndHashCode(callSuper = false)
1751
      public static class Card extends StripeObject {
×
1752
        @SerializedName("mandate_options")
1753
        MandateOptions mandateOptions;
1754

1755
        /**
1756
         * Selected network to process this Subscription on. Depends on the available networks of
1757
         * the card attached to the Subscription. Can be only set confirm-time.
1758
         */
1759
        @SerializedName("network")
1760
        String network;
1761

1762
        /**
1763
         * We strongly recommend that you rely on our SCA Engine to automatically prompt your
1764
         * customers for authentication based on risk level and <a
1765
         * href="https://stripe.com/docs/strong-customer-authentication">other requirements</a>.
1766
         * However, if you wish to request 3D Secure based on logic from your own fraud engine,
1767
         * provide this option. Read our guide on <a
1768
         * href="https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds">manually
1769
         * requesting 3D Secure</a> for more information on how this configuration interacts with
1770
         * Radar and our SCA Engine.
1771
         *
1772
         * <p>One of {@code any}, {@code automatic}, or {@code challenge}.
1773
         */
1774
        @SerializedName("request_three_d_secure")
1775
        String requestThreeDSecure;
1776

1777
        /**
1778
         * For more details about MandateOptions, please refer to the <a
1779
         * href="https://docs.stripe.com/api">API Reference.</a>
1780
         */
1781
        @Getter
1782
        @Setter
1783
        @EqualsAndHashCode(callSuper = false)
1784
        public static class MandateOptions extends StripeObject {
×
1785
          /** Amount to be charged for future payments. */
1786
          @SerializedName("amount")
1787
          Long amount;
1788

1789
          /**
1790
           * One of {@code fixed} or {@code maximum}. If {@code fixed}, the {@code amount} param
1791
           * refers to the exact amount to be charged in future payments. If {@code maximum}, the
1792
           * amount charged can be up to the value passed for the {@code amount} param.
1793
           */
1794
          @SerializedName("amount_type")
1795
          String amountType;
1796

1797
          /**
1798
           * A description of the mandate or subscription that is meant to be displayed to the
1799
           * customer.
1800
           */
1801
          @SerializedName("description")
1802
          String description;
1803
        }
1804
      }
1805

1806
      /**
1807
       * For more details about CustomerBalance, please refer to the <a
1808
       * href="https://docs.stripe.com/api">API Reference.</a>
1809
       */
1810
      @Getter
1811
      @Setter
1812
      @EqualsAndHashCode(callSuper = false)
1813
      public static class CustomerBalance extends StripeObject {
×
1814
        @SerializedName("bank_transfer")
1815
        BankTransfer bankTransfer;
1816

1817
        /**
1818
         * The funding method type to be used when there are not enough funds in the customer
1819
         * balance. Permitted values include: {@code bank_transfer}.
1820
         *
1821
         * <p>Equal to {@code bank_transfer}.
1822
         */
1823
        @SerializedName("funding_type")
1824
        String fundingType;
1825

1826
        /**
1827
         * For more details about BankTransfer, please refer to the <a
1828
         * href="https://docs.stripe.com/api">API Reference.</a>
1829
         */
1830
        @Getter
1831
        @Setter
1832
        @EqualsAndHashCode(callSuper = false)
1833
        public static class BankTransfer extends StripeObject {
×
1834
          @SerializedName("eu_bank_transfer")
1835
          EuBankTransfer euBankTransfer;
1836

1837
          /**
1838
           * The bank transfer type that can be used for funding. Permitted values include: {@code
1839
           * eu_bank_transfer}, {@code gb_bank_transfer}, {@code jp_bank_transfer}, {@code
1840
           * mx_bank_transfer}, or {@code us_bank_transfer}.
1841
           */
1842
          @SerializedName("type")
1843
          String type;
1844

1845
          /**
1846
           * For more details about EuBankTransfer, please refer to the <a
1847
           * href="https://docs.stripe.com/api">API Reference.</a>
1848
           */
1849
          @Getter
1850
          @Setter
1851
          @EqualsAndHashCode(callSuper = false)
1852
          public static class EuBankTransfer extends StripeObject {
×
1853
            /**
1854
             * The desired country code of the bank account information. Permitted values include:
1855
             * {@code BE}, {@code DE}, {@code ES}, {@code FR}, {@code IE}, or {@code NL}.
1856
             *
1857
             * <p>One of {@code BE}, {@code DE}, {@code ES}, {@code FR}, {@code IE}, or {@code NL}.
1858
             */
1859
            @SerializedName("country")
1860
            String country;
1861
          }
1862
        }
1863
      }
1864

1865
      /**
1866
       * For more details about IdBankTransfer, please refer to the <a
1867
       * href="https://docs.stripe.com/api">API Reference.</a>
1868
       */
1869
      @Getter
1870
      @Setter
1871
      @EqualsAndHashCode(callSuper = false)
NEW
1872
      public static class IdBankTransfer extends StripeObject {}
×
1873

1874
      /**
1875
       * For more details about Konbini, please refer to the <a
1876
       * href="https://docs.stripe.com/api">API Reference.</a>
1877
       */
1878
      @Getter
1879
      @Setter
1880
      @EqualsAndHashCode(callSuper = false)
1881
      public static class Konbini extends StripeObject {}
×
1882

1883
      /**
1884
       * For more details about SepaDebit, please refer to the <a
1885
       * href="https://docs.stripe.com/api">API Reference.</a>
1886
       */
1887
      @Getter
1888
      @Setter
1889
      @EqualsAndHashCode(callSuper = false)
1890
      public static class SepaDebit extends StripeObject {}
×
1891

1892
      /**
1893
       * For more details about UsBankAccount, please refer to the <a
1894
       * href="https://docs.stripe.com/api">API Reference.</a>
1895
       */
1896
      @Getter
1897
      @Setter
1898
      @EqualsAndHashCode(callSuper = false)
1899
      public static class UsBankAccount extends StripeObject {
×
1900
        @SerializedName("financial_connections")
1901
        FinancialConnections financialConnections;
1902

1903
        /**
1904
         * Bank account verification method.
1905
         *
1906
         * <p>One of {@code automatic}, {@code instant}, or {@code microdeposits}.
1907
         */
1908
        @SerializedName("verification_method")
1909
        String verificationMethod;
1910

1911
        /**
1912
         * For more details about FinancialConnections, please refer to the <a
1913
         * href="https://docs.stripe.com/api">API Reference.</a>
1914
         */
1915
        @Getter
1916
        @Setter
1917
        @EqualsAndHashCode(callSuper = false)
1918
        public static class FinancialConnections extends StripeObject {
×
1919
          @SerializedName("filters")
1920
          Filters filters;
1921

1922
          /**
1923
           * The list of permissions to request. The {@code payment_method} permission must be
1924
           * included.
1925
           */
1926
          @SerializedName("permissions")
1927
          List<String> permissions;
1928

1929
          /** Data features requested to be retrieved upon account creation. */
1930
          @SerializedName("prefetch")
1931
          List<String> prefetch;
1932

1933
          /**
1934
           * For more details about Filters, please refer to the <a
1935
           * href="https://docs.stripe.com/api">API Reference.</a>
1936
           */
1937
          @Getter
1938
          @Setter
1939
          @EqualsAndHashCode(callSuper = false)
1940
          public static class Filters extends StripeObject {
×
1941
            /**
1942
             * The account subcategories to use to filter for possible accounts to link. Valid
1943
             * subcategories are {@code checking} and {@code savings}.
1944
             */
1945
            @SerializedName("account_subcategories")
1946
            List<String> accountSubcategories;
1947

1948
            /** The institution to use to filter for possible accounts to link. */
1949
            @SerializedName("institution")
1950
            String institution;
1951
          }
1952
        }
1953
      }
1954
    }
1955
  }
1956

1957
  /**
1958
   * For more details about PendingInvoiceItemInterval, please refer to the <a
1959
   * href="https://docs.stripe.com/api">API Reference.</a>
1960
   */
1961
  @Getter
1962
  @Setter
1963
  @EqualsAndHashCode(callSuper = false)
1964
  public static class PendingInvoiceItemInterval extends StripeObject {
×
1965
    /**
1966
     * Specifies invoicing frequency. Either {@code day}, {@code week}, {@code month} or {@code
1967
     * year}.
1968
     *
1969
     * <p>One of {@code day}, {@code month}, {@code week}, or {@code year}.
1970
     */
1971
    @SerializedName("interval")
1972
    String interval;
1973

1974
    /**
1975
     * The number of intervals between invoices. For example, {@code interval=month} and {@code
1976
     * interval_count=3} bills every 3 months. Maximum of one year interval allowed (1 year, 12
1977
     * months, or 52 weeks).
1978
     */
1979
    @SerializedName("interval_count")
1980
    Long intervalCount;
1981
  }
1982

1983
  /**
1984
   * Pending Updates store the changes pending from a previous update that will be applied to the
1985
   * Subscription upon successful payment.
1986
   */
1987
  @Getter
1988
  @Setter
1989
  @EqualsAndHashCode(callSuper = false)
1990
  public static class PendingUpdate extends StripeObject {
×
1991
    /**
1992
     * If the update is applied, determines the date of the first full invoice, and, for plans with
1993
     * {@code month} or {@code year} intervals, the day of the month for subsequent invoices. The
1994
     * timestamp is in UTC format.
1995
     */
1996
    @SerializedName("billing_cycle_anchor")
1997
    Long billingCycleAnchor;
1998

1999
    /**
2000
     * The point after which the changes reflected by this update will be discarded and no longer
2001
     * applied.
2002
     */
2003
    @SerializedName("expires_at")
2004
    Long expiresAt;
2005

2006
    /** The number of iterations of prebilling to apply. */
2007
    @SerializedName("prebilling_iterations")
2008
    Long prebillingIterations;
2009

2010
    /**
2011
     * List of subscription items, each with an attached plan, that will be set if the update is
2012
     * applied.
2013
     */
2014
    @SerializedName("subscription_items")
2015
    List<SubscriptionItem> subscriptionItems;
2016

2017
    /**
2018
     * Unix timestamp representing the end of the trial period the customer will get before being
2019
     * charged for the first time, if the update is applied.
2020
     */
2021
    @SerializedName("trial_end")
2022
    Long trialEnd;
2023

2024
    /**
2025
     * Indicates if a plan's {@code trial_period_days} should be applied to the subscription.
2026
     * Setting {@code trial_end} per subscription is preferred, and this defaults to {@code false}.
2027
     * Setting this flag to {@code true} together with {@code trial_end} is not allowed. See <a
2028
     * href="https://stripe.com/docs/billing/subscriptions/trials">Using trial periods on
2029
     * subscriptions</a> to learn more.
2030
     */
2031
    @SerializedName("trial_from_plan")
2032
    Boolean trialFromPlan;
2033
  }
2034

2035
  /** Prebilling stores the time period and invoice for a Subscription billed in advance. */
2036
  @Getter
2037
  @Setter
2038
  @EqualsAndHashCode(callSuper = false)
2039
  public static class Prebilling extends StripeObject {
×
2040
    /** ID of the prebilling invoice. */
2041
    @SerializedName("invoice")
2042
    @Getter(lombok.AccessLevel.NONE)
2043
    @Setter(lombok.AccessLevel.NONE)
2044
    ExpandableField<Invoice> invoice;
2045

2046
    /** The end of the last period for which the invoice pre-bills. */
2047
    @SerializedName("period_end")
2048
    Long periodEnd;
2049

2050
    /** The start of the first period for which the invoice pre-bills. */
2051
    @SerializedName("period_start")
2052
    Long periodStart;
2053

2054
    /**
2055
     * Whether to cancel or preserve {@code prebilling} if the subscription is updated during the
2056
     * prebilled period.
2057
     *
2058
     * <p>One of {@code prebill}, or {@code reset}.
2059
     */
2060
    @SerializedName("update_behavior")
2061
    String updateBehavior;
2062

2063
    /** Get ID of expandable {@code invoice} object. */
2064
    public String getInvoice() {
2065
      return (this.invoice != null) ? this.invoice.getId() : null;
×
2066
    }
2067

2068
    public void setInvoice(String id) {
2069
      this.invoice = ApiResource.setExpandableFieldId(id, this.invoice);
×
2070
    }
×
2071

2072
    /** Get expanded {@code invoice}. */
2073
    public Invoice getInvoiceObject() {
2074
      return (this.invoice != null) ? this.invoice.getExpanded() : null;
×
2075
    }
2076

2077
    public void setInvoiceObject(Invoice expandableObject) {
2078
      this.invoice = new ExpandableField<Invoice>(expandableObject.getId(), expandableObject);
×
2079
    }
×
2080
  }
2081

2082
  /**
2083
   * For more details about TransferData, please refer to the <a
2084
   * href="https://docs.stripe.com/api">API Reference.</a>
2085
   */
2086
  @Getter
2087
  @Setter
2088
  @EqualsAndHashCode(callSuper = false)
2089
  public static class TransferData extends StripeObject {
×
2090
    /**
2091
     * A non-negative decimal between 0 and 100, with at most two decimal places. This represents
2092
     * the percentage of the subscription invoice total that will be transferred to the destination
2093
     * account. By default, the entire amount is transferred to the destination.
2094
     */
2095
    @SerializedName("amount_percent")
2096
    BigDecimal amountPercent;
2097

2098
    /** The account where funds from the payment will be transferred to upon payment success. */
2099
    @SerializedName("destination")
2100
    @Getter(lombok.AccessLevel.NONE)
2101
    @Setter(lombok.AccessLevel.NONE)
2102
    ExpandableField<Account> destination;
2103

2104
    /** Get ID of expandable {@code destination} object. */
2105
    public String getDestination() {
2106
      return (this.destination != null) ? this.destination.getId() : null;
×
2107
    }
2108

2109
    public void setDestination(String id) {
2110
      this.destination = ApiResource.setExpandableFieldId(id, this.destination);
×
2111
    }
×
2112

2113
    /** Get expanded {@code destination}. */
2114
    public Account getDestinationObject() {
2115
      return (this.destination != null) ? this.destination.getExpanded() : null;
×
2116
    }
2117

2118
    public void setDestinationObject(Account expandableObject) {
2119
      this.destination = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
×
2120
    }
×
2121
  }
2122

2123
  /** Configures how this subscription behaves during the trial period. */
2124
  @Getter
2125
  @Setter
2126
  @EqualsAndHashCode(callSuper = false)
2127
  public static class TrialSettings extends StripeObject {
1✔
2128
    /** Defines how a subscription behaves when a free trial ends. */
2129
    @SerializedName("end_behavior")
2130
    EndBehavior endBehavior;
2131

2132
    /** Defines how a subscription behaves when a free trial ends. */
2133
    @Getter
2134
    @Setter
2135
    @EqualsAndHashCode(callSuper = false)
2136
    public static class EndBehavior extends StripeObject {
1✔
2137
      /**
2138
       * Indicates how the subscription should change when the trial ends if the user did not
2139
       * provide a payment method.
2140
       *
2141
       * <p>One of {@code cancel}, {@code create_invoice}, or {@code pause}.
2142
       */
2143
      @SerializedName("missing_payment_method")
2144
      String missingPaymentMethod;
2145
    }
2146
  }
2147

2148
  @Override
2149
  public void setResponseGetter(StripeResponseGetter responseGetter) {
2150
    super.setResponseGetter(responseGetter);
1✔
2151
    trySetResponseGetter(application, responseGetter);
1✔
2152
    trySetResponseGetter(automaticTax, responseGetter);
1✔
2153
    trySetResponseGetter(billingCycleAnchorConfig, responseGetter);
1✔
2154
    trySetResponseGetter(billingThresholds, responseGetter);
1✔
2155
    trySetResponseGetter(cancellationDetails, responseGetter);
1✔
2156
    trySetResponseGetter(customer, responseGetter);
1✔
2157
    trySetResponseGetter(defaultPaymentMethod, responseGetter);
1✔
2158
    trySetResponseGetter(defaultSource, responseGetter);
1✔
2159
    trySetResponseGetter(discount, responseGetter);
1✔
2160
    trySetResponseGetter(invoiceSettings, responseGetter);
1✔
2161
    trySetResponseGetter(items, responseGetter);
1✔
2162
    trySetResponseGetter(lastPriceMigrationError, responseGetter);
1✔
2163
    trySetResponseGetter(latestInvoice, responseGetter);
1✔
2164
    trySetResponseGetter(onBehalfOf, responseGetter);
1✔
2165
    trySetResponseGetter(pauseCollection, responseGetter);
1✔
2166
    trySetResponseGetter(paymentSettings, responseGetter);
1✔
2167
    trySetResponseGetter(pendingInvoiceItemInterval, responseGetter);
1✔
2168
    trySetResponseGetter(pendingSetupIntent, responseGetter);
1✔
2169
    trySetResponseGetter(pendingUpdate, responseGetter);
1✔
2170
    trySetResponseGetter(prebilling, responseGetter);
1✔
2171
    trySetResponseGetter(schedule, responseGetter);
1✔
2172
    trySetResponseGetter(testClock, responseGetter);
1✔
2173
    trySetResponseGetter(transferData, responseGetter);
1✔
2174
    trySetResponseGetter(trialSettings, responseGetter);
1✔
2175
  }
1✔
2176
}
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