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

stripe / stripe-java / #14711

24 Aug 2023 06:24PM UTC coverage: 14.624% (-0.07%) from 14.689%
#14711

push

github-actions

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

Update generated code for beta

722 of 722 new or added lines in 30 files covered. (100.0%)

15206 of 103979 relevant lines covered (14.62%)

0.15 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.ApiMode;
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>Learn more in the <a
35
 * href="https://stripe.com/docs/billing/subscriptions/integrating-customer-portal">integration
36
 * guide</a>.
37
 */
38
@Getter
39
@Setter
40
@EqualsAndHashCode(callSuper = false)
41
public class Session extends ApiResource implements HasId {
1✔
42
  /** The configuration used by this session, describing the features available. */
43
  @SerializedName("configuration")
44
  @Getter(lombok.AccessLevel.NONE)
45
  @Setter(lombok.AccessLevel.NONE)
46
  ExpandableField<Configuration> configuration;
47

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

147
  /** Creates a session of the customer portal. */
148
  public static Session create(Map<String, Object> params, RequestOptions options)
149
      throws StripeException {
150
    String path = "/v1/billing_portal/sessions";
×
151
    return getGlobalResponseGetter()
×
152
        .request(
×
153
            BaseAddress.API,
154
            ApiResource.RequestMethod.POST,
155
            path,
156
            params,
157
            Session.class,
158
            options,
159
            ApiMode.V1);
160
  }
161

162
  /** Creates a session of the customer portal. */
163
  public static Session create(SessionCreateParams params) throws StripeException {
164
    return create(params, (RequestOptions) null);
1✔
165
  }
166

167
  /** Creates a session of the customer portal. */
168
  public static Session create(SessionCreateParams params, RequestOptions options)
169
      throws StripeException {
170
    String path = "/v1/billing_portal/sessions";
1✔
171
    ApiResource.checkNullTypedParams(path, params);
1✔
172
    return getGlobalResponseGetter()
1✔
173
        .request(
1✔
174
            BaseAddress.API,
175
            ApiResource.RequestMethod.POST,
176
            path,
177
            ApiRequestParams.paramsToMap(params),
1✔
178
            Session.class,
179
            options,
180
            ApiMode.V1);
181
  }
182

183
  @Getter
184
  @Setter
185
  @EqualsAndHashCode(callSuper = false)
186
  public static class Flow extends StripeObject {
×
187
    @SerializedName("after_completion")
188
    AfterCompletion afterCompletion;
189

190
    /** Configuration when {@code flow.type=subscription_cancel}. */
191
    @SerializedName("subscription_cancel")
192
    SubscriptionCancel subscriptionCancel;
193

194
    /** Configuration when {@code flow.type=subscription_update}. */
195
    @SerializedName("subscription_update")
196
    SubscriptionUpdate subscriptionUpdate;
197

198
    /** Configuration when {@code flow.type=subscription_update_confirm}. */
199
    @SerializedName("subscription_update_confirm")
200
    SubscriptionUpdateConfirm subscriptionUpdateConfirm;
201

202
    /**
203
     * Type of flow that the customer will go through.
204
     *
205
     * <p>One of {@code payment_method_update}, {@code subscription_cancel}, {@code
206
     * subscription_update}, or {@code subscription_update_confirm}.
207
     */
208
    @SerializedName("type")
209
    String type;
210

211
    @Getter
212
    @Setter
213
    @EqualsAndHashCode(callSuper = false)
214
    public static class AfterCompletion extends StripeObject {
×
215
      /** Configuration when {@code after_completion.type=hosted_confirmation}. */
216
      @SerializedName("hosted_confirmation")
217
      HostedConfirmation hostedConfirmation;
218

219
      /** Configuration when {@code after_completion.type=redirect}. */
220
      @SerializedName("redirect")
221
      Redirect redirect;
222

223
      /**
224
       * The specified type of behavior after the flow is completed.
225
       *
226
       * <p>One of {@code hosted_confirmation}, {@code portal_homepage}, or {@code redirect}.
227
       */
228
      @SerializedName("type")
229
      String type;
230

231
      @Getter
232
      @Setter
233
      @EqualsAndHashCode(callSuper = false)
234
      public static class HostedConfirmation extends StripeObject {
×
235
        /** A custom message to display to the customer after the flow is completed. */
236
        @SerializedName("custom_message")
237
        String customMessage;
238
      }
239

240
      @Getter
241
      @Setter
242
      @EqualsAndHashCode(callSuper = false)
243
      public static class Redirect extends StripeObject {
×
244
        /** The URL the customer will be redirected to after the flow is completed. */
245
        @SerializedName("return_url")
246
        String returnUrl;
247
      }
248
    }
249

250
    @Getter
251
    @Setter
252
    @EqualsAndHashCode(callSuper = false)
253
    public static class SubscriptionCancel extends StripeObject {
×
254
      /** Specify a retention strategy to be used in the cancellation flow. */
255
      @SerializedName("retention")
256
      Retention retention;
257

258
      /** The ID of the subscription to be canceled. */
259
      @SerializedName("subscription")
260
      String subscription;
261

262
      @Getter
263
      @Setter
264
      @EqualsAndHashCode(callSuper = false)
265
      public static class Retention extends StripeObject {
×
266
        /** Configuration when {@code retention.type=coupon_offer}. */
267
        @SerializedName("coupon_offer")
268
        CouponOffer couponOffer;
269

270
        /**
271
         * Type of retention strategy that will be used.
272
         *
273
         * <p>Equal to {@code coupon_offer}.
274
         */
275
        @SerializedName("type")
276
        String type;
277

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

289
    @Getter
290
    @Setter
291
    @EqualsAndHashCode(callSuper = false)
292
    public static class SubscriptionUpdate extends StripeObject {
×
293
      /** The ID of the subscription to be updated. */
294
      @SerializedName("subscription")
295
      String subscription;
296
    }
297

298
    @Getter
299
    @Setter
300
    @EqualsAndHashCode(callSuper = false)
301
    public static class SubscriptionUpdateConfirm extends StripeObject {
×
302
      /**
303
       * The coupon or promotion code to apply to this subscription update. Currently, only up to
304
       * one may be specified.
305
       */
306
      @SerializedName("discounts")
307
      List<Session.Flow.SubscriptionUpdateConfirm.Discount> discounts;
308

309
      /**
310
       * The <a href="https://stripe.com/docs/api/subscription_items">subscription item</a> to be
311
       * updated through this flow. Currently, only up to one may be specified and subscriptions
312
       * with multiple items are not updatable.
313
       */
314
      @SerializedName("items")
315
      List<Session.Flow.SubscriptionUpdateConfirm.Item> items;
316

317
      /** The ID of the subscription to be updated. */
318
      @SerializedName("subscription")
319
      String subscription;
320

321
      @Getter
322
      @Setter
323
      @EqualsAndHashCode(callSuper = false)
324
      public static class Discount extends StripeObject {
×
325
        /** The ID of the coupon to apply to this subscription update. */
326
        @SerializedName("coupon")
327
        String coupon;
328

329
        /** The ID of a promotion code to apply to this subscription update. */
330
        @SerializedName("promotion_code")
331
        String promotionCode;
332
      }
333

334
      @Getter
335
      @Setter
336
      @EqualsAndHashCode(callSuper = false)
337
      public static class Item extends StripeObject implements HasId {
×
338
        /**
339
         * The ID of the <a
340
         * href="https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id">subscription
341
         * item</a> to be updated.
342
         */
343
        @Getter(onMethod_ = {@Override})
344
        @SerializedName("id")
345
        String id;
346

347
        /**
348
         * The price the customer should subscribe to through this flow. The price must also be
349
         * included in the configuration's <a
350
         * href="docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products">{@code
351
         * features.subscription_update.products}</a>.
352
         */
353
        @SerializedName("price")
354
        String price;
355

356
        /**
357
         * <a href="https://stripe.com/docs/subscriptions/quantities">Quantity</a> for this item
358
         * that the customer should subscribe to through this flow.
359
         */
360
        @SerializedName("quantity")
361
        Long quantity;
362
      }
363
    }
364
  }
365

366
  @Override
367
  public void setResponseGetter(StripeResponseGetter responseGetter) {
368
    super.setResponseGetter(responseGetter);
1✔
369
    trySetResponseGetter(configuration, responseGetter);
1✔
370
    trySetResponseGetter(flow, responseGetter);
1✔
371
  }
1✔
372
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc