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

stripe / stripe-java / #16380

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

push

github

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

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

* Bump version to 26.9.0

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

* Generated code

* Update the code around raw request

* Update the v2 tests to use v2 path

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

706 existing lines in 213 files now uncovered.

18468 of 143365 relevant lines covered (12.88%)

0.13 hits per line

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

33.33
/src/main/java/com/stripe/model/billingportal/Session.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model.billingportal;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.model.ExpandableField;
7
import com.stripe.model.HasId;
8
import com.stripe.model.StripeObject;
9
import com.stripe.net.ApiRequest;
10
import com.stripe.net.ApiRequestParams;
11
import com.stripe.net.ApiResource;
12
import com.stripe.net.BaseAddress;
13
import com.stripe.net.RequestOptions;
14
import com.stripe.net.StripeResponseGetter;
15
import com.stripe.param.billingportal.SessionCreateParams;
16
import java.util.List;
17
import java.util.Map;
18
import lombok.EqualsAndHashCode;
19
import lombok.Getter;
20
import lombok.Setter;
21

22
/**
23
 * The Billing customer portal is a Stripe-hosted UI for subscription and billing management.
24
 *
25
 * <p>A portal configuration describes the functionality and features that you want to provide to
26
 * your customers through the portal.
27
 *
28
 * <p>A portal session describes the instantiation of the customer portal for a particular customer.
29
 * By visiting the session's URL, the customer can manage their subscriptions and billing details.
30
 * For security reasons, sessions are short-lived and will expire if the customer does not visit the
31
 * URL. Create sessions on-demand when customers intend to manage their subscriptions and billing
32
 * details.
33
 *
34
 * <p>Related guide: <a href="https://stripe.com/customer-management">Customer management</a>
35
 */
36
@Getter
37
@Setter
38
@EqualsAndHashCode(callSuper = false)
39
public class Session extends ApiResource implements HasId {
1✔
40
  /** The configuration used by this session, describing the features available. */
41
  @SerializedName("configuration")
42
  @Getter(lombok.AccessLevel.NONE)
43
  @Setter(lombok.AccessLevel.NONE)
44
  ExpandableField<Configuration> configuration;
45

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

50
  /** The ID of the customer for this session. */
51
  @SerializedName("customer")
52
  String customer;
53

54
  /**
55
   * Information about a specific flow for the customer to go through. See the <a
56
   * href="https://stripe.com/docs/customer-management/portal-deep-links">docs</a> to learn more
57
   * about using customer portal deep links and flows.
58
   */
59
  @SerializedName("flow")
60
  Flow flow;
61

62
  /** Unique identifier for the object. */
63
  @Getter(onMethod_ = {@Override})
64
  @SerializedName("id")
65
  String id;
66

67
  /**
68
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
69
   * object exists in test mode.
70
   */
71
  @SerializedName("livemode")
72
  Boolean livemode;
73

74
  /**
75
   * The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the
76
   * customer’s {@code preferred_locales} or browser’s locale is used.
77
   *
78
   * <p>One of {@code auto}, {@code bg}, {@code cs}, {@code da}, {@code de}, {@code el}, {@code en},
79
   * {@code en-AU}, {@code en-CA}, {@code en-GB}, {@code en-IE}, {@code en-IN}, {@code en-NZ},
80
   * {@code en-SG}, {@code es}, {@code es-419}, {@code et}, {@code fi}, {@code fil}, {@code fr},
81
   * {@code fr-CA}, {@code hr}, {@code hu}, {@code id}, {@code it}, {@code ja}, {@code ko}, {@code
82
   * lt}, {@code lv}, {@code ms}, {@code mt}, {@code nb}, {@code nl}, {@code pl}, {@code pt}, {@code
83
   * pt-BR}, {@code ro}, {@code ru}, {@code sk}, {@code sl}, {@code sv}, {@code th}, {@code tr},
84
   * {@code vi}, {@code zh}, {@code zh-HK}, or {@code zh-TW}.
85
   */
86
  @SerializedName("locale")
87
  String locale;
88

89
  /**
90
   * String representing the object's type. Objects of the same type share the same value.
91
   *
92
   * <p>Equal to {@code billing_portal.session}.
93
   */
94
  @SerializedName("object")
95
  String object;
96

97
  /**
98
   * The account for which the session was created on behalf of. When specified, only subscriptions
99
   * and invoices with this {@code on_behalf_of} account appear in the portal. For more information,
100
   * see the <a
101
   * href="https://stripe.com/docs/connect/separate-charges-and-transfers#settlement-merchant">docs</a>.
102
   * Use the <a
103
   * href="https://stripe.com/docs/api/accounts/object#account_object-settings-branding">Accounts
104
   * API</a> to modify the {@code on_behalf_of} account's branding settings, which the portal
105
   * displays.
106
   */
107
  @SerializedName("on_behalf_of")
108
  String onBehalfOf;
109

110
  /**
111
   * The URL to redirect customers to when they click on the portal's link to return to your
112
   * website.
113
   */
114
  @SerializedName("return_url")
115
  String returnUrl;
116

117
  /** The short-lived URL of the session that gives customers access to the customer portal. */
118
  @SerializedName("url")
119
  String url;
120

121
  /** Get ID of expandable {@code configuration} object. */
122
  public String getConfiguration() {
123
    return (this.configuration != null) ? this.configuration.getId() : null;
×
124
  }
125

126
  public void setConfiguration(String id) {
127
    this.configuration = ApiResource.setExpandableFieldId(id, this.configuration);
×
128
  }
×
129

130
  /** Get expanded {@code configuration}. */
131
  public Configuration getConfigurationObject() {
132
    return (this.configuration != null) ? this.configuration.getExpanded() : null;
×
133
  }
134

135
  public void setConfigurationObject(Configuration expandableObject) {
136
    this.configuration =
×
137
        new ExpandableField<Configuration>(expandableObject.getId(), expandableObject);
×
138
  }
×
139

140
  /** Creates a session of the customer portal. */
141
  public static Session create(Map<String, Object> params) throws StripeException {
142
    return create(params, (RequestOptions) null);
×
143
  }
144

145
  /** Creates a session of the customer portal. */
146
  public static Session create(Map<String, Object> params, RequestOptions options)
147
      throws StripeException {
148
    String path = "/v1/billing_portal/sessions";
×
149
    ApiRequest request =
×
150
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
151
    return getGlobalResponseGetter().request(request, Session.class);
×
152
  }
153

154
  /** Creates a session of the customer portal. */
155
  public static Session create(SessionCreateParams params) throws StripeException {
156
    return create(params, (RequestOptions) null);
1✔
157
  }
158

159
  /** Creates a session of the customer portal. */
160
  public static Session create(SessionCreateParams params, RequestOptions options)
161
      throws StripeException {
162
    String path = "/v1/billing_portal/sessions";
1✔
163
    ApiResource.checkNullTypedParams(path, params);
1✔
164
    ApiRequest request =
1✔
165
        new ApiRequest(
166
            BaseAddress.API,
167
            ApiResource.RequestMethod.POST,
168
            path,
169
            ApiRequestParams.paramsToMap(params),
1✔
170
            options);
171
    return getGlobalResponseGetter().request(request, Session.class);
1✔
172
  }
173

174
  @Getter
175
  @Setter
176
  @EqualsAndHashCode(callSuper = false)
177
  public static class Flow extends StripeObject {
×
178
    @SerializedName("after_completion")
179
    AfterCompletion afterCompletion;
180

181
    /** Configuration when {@code flow.type=subscription_cancel}. */
182
    @SerializedName("subscription_cancel")
183
    SubscriptionCancel subscriptionCancel;
184

185
    /** Configuration when {@code flow.type=subscription_update}. */
186
    @SerializedName("subscription_update")
187
    SubscriptionUpdate subscriptionUpdate;
188

189
    /** Configuration when {@code flow.type=subscription_update_confirm}. */
190
    @SerializedName("subscription_update_confirm")
191
    SubscriptionUpdateConfirm subscriptionUpdateConfirm;
192

193
    /**
194
     * Type of flow that the customer will go through.
195
     *
196
     * <p>One of {@code payment_method_update}, {@code subscription_cancel}, {@code
197
     * subscription_update}, or {@code subscription_update_confirm}.
198
     */
199
    @SerializedName("type")
200
    String type;
201

202
    @Getter
203
    @Setter
204
    @EqualsAndHashCode(callSuper = false)
205
    public static class AfterCompletion extends StripeObject {
×
206
      /** Configuration when {@code after_completion.type=hosted_confirmation}. */
207
      @SerializedName("hosted_confirmation")
208
      HostedConfirmation hostedConfirmation;
209

210
      /** Configuration when {@code after_completion.type=redirect}. */
211
      @SerializedName("redirect")
212
      Redirect redirect;
213

214
      /**
215
       * The specified type of behavior after the flow is completed.
216
       *
217
       * <p>One of {@code hosted_confirmation}, {@code portal_homepage}, or {@code redirect}.
218
       */
219
      @SerializedName("type")
220
      String type;
221

222
      @Getter
223
      @Setter
224
      @EqualsAndHashCode(callSuper = false)
225
      public static class HostedConfirmation extends StripeObject {
×
226
        /** A custom message to display to the customer after the flow is completed. */
227
        @SerializedName("custom_message")
228
        String customMessage;
229
      }
230

231
      @Getter
232
      @Setter
233
      @EqualsAndHashCode(callSuper = false)
234
      public static class Redirect extends StripeObject {
×
235
        /** The URL the customer will be redirected to after the flow is completed. */
236
        @SerializedName("return_url")
237
        String returnUrl;
238
      }
239
    }
240

241
    @Getter
242
    @Setter
243
    @EqualsAndHashCode(callSuper = false)
244
    public static class SubscriptionCancel extends StripeObject {
×
245
      /** Specify a retention strategy to be used in the cancellation flow. */
246
      @SerializedName("retention")
247
      Retention retention;
248

249
      /** The ID of the subscription to be canceled. */
250
      @SerializedName("subscription")
251
      String subscription;
252

253
      @Getter
254
      @Setter
255
      @EqualsAndHashCode(callSuper = false)
256
      public static class Retention extends StripeObject {
×
257
        /** Configuration when {@code retention.type=coupon_offer}. */
258
        @SerializedName("coupon_offer")
259
        CouponOffer couponOffer;
260

261
        /**
262
         * Type of retention strategy that will be used.
263
         *
264
         * <p>Equal to {@code coupon_offer}.
265
         */
266
        @SerializedName("type")
267
        String type;
268

269
        @Getter
270
        @Setter
271
        @EqualsAndHashCode(callSuper = false)
272
        public static class CouponOffer extends StripeObject {
×
273
          /** The ID of the coupon to be offered. */
274
          @SerializedName("coupon")
275
          String coupon;
276
        }
277
      }
278
    }
279

280
    @Getter
281
    @Setter
282
    @EqualsAndHashCode(callSuper = false)
283
    public static class SubscriptionUpdate extends StripeObject {
×
284
      /** The ID of the subscription to be updated. */
285
      @SerializedName("subscription")
286
      String subscription;
287
    }
288

289
    @Getter
290
    @Setter
291
    @EqualsAndHashCode(callSuper = false)
292
    public static class SubscriptionUpdateConfirm extends StripeObject {
×
293
      /**
294
       * The coupon or promotion code to apply to this subscription update. Currently, only up to
295
       * one may be specified.
296
       */
297
      @SerializedName("discounts")
298
      List<Session.Flow.SubscriptionUpdateConfirm.Discount> discounts;
299

300
      /**
301
       * The <a href="https://stripe.com/docs/api/subscription_items">subscription item</a> to be
302
       * updated through this flow. Currently, only up to one may be specified and subscriptions
303
       * with multiple items are not updatable.
304
       */
305
      @SerializedName("items")
306
      List<Session.Flow.SubscriptionUpdateConfirm.Item> items;
307

308
      /** The ID of the subscription to be updated. */
309
      @SerializedName("subscription")
310
      String subscription;
311

312
      @Getter
313
      @Setter
314
      @EqualsAndHashCode(callSuper = false)
315
      public static class Discount extends StripeObject {
×
316
        /** The ID of the coupon to apply to this subscription update. */
317
        @SerializedName("coupon")
318
        String coupon;
319

320
        /** The ID of a promotion code to apply to this subscription update. */
321
        @SerializedName("promotion_code")
322
        String promotionCode;
323
      }
324

325
      @Getter
326
      @Setter
327
      @EqualsAndHashCode(callSuper = false)
328
      public static class Item extends StripeObject implements HasId {
×
329
        /**
330
         * The ID of the <a
331
         * href="https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id">subscription
332
         * item</a> to be updated.
333
         */
334
        @Getter(onMethod_ = {@Override})
335
        @SerializedName("id")
336
        String id;
337

338
        /**
339
         * The price the customer should subscribe to through this flow. The price must also be
340
         * included in the configuration's <a
341
         * href="https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products">{@code
342
         * features.subscription_update.products}</a>.
343
         */
344
        @SerializedName("price")
345
        String price;
346

347
        /**
348
         * <a href="https://stripe.com/docs/subscriptions/quantities">Quantity</a> for this item
349
         * that the customer should subscribe to through this flow.
350
         */
351
        @SerializedName("quantity")
352
        Long quantity;
353
      }
354
    }
355
  }
356

357
  @Override
358
  public void setResponseGetter(StripeResponseGetter responseGetter) {
359
    super.setResponseGetter(responseGetter);
1✔
360
    trySetResponseGetter(configuration, responseGetter);
1✔
361
    trySetResponseGetter(flow, responseGetter);
1✔
362
  }
1✔
363
}
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