• 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

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

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

19
/**
20
 * A Customer Session allows you to grant Stripe's frontend SDKs (like Stripe.js) client-side access
21
 * control over a Customer.
22
 *
23
 * <p>Related guides: <a
24
 * href="https://stripe.com/payments/accept-a-payment-deferred?platform=web&amp;type=payment#save-payment-methods">Customer
25
 * Session with the Payment Element</a>, <a
26
 * href="https://stripe.com/payments/checkout/pricing-table#customer-session">Customer Session with
27
 * the Pricing Table</a>, <a
28
 * href="https://stripe.com/payment-links/buy-button#pass-an-existing-customer">Customer Session
29
 * with the Buy Button</a>.
30
 */
31
@Getter
32
@Setter
33
@EqualsAndHashCode(callSuper = false)
34
public class CustomerSession extends ApiResource {
1✔
35
  /**
36
   * The client secret of this Customer Session. Used on the client to set up secure access to the
37
   * given {@code customer}.
38
   *
39
   * <p>The client secret can be used to provide access to {@code customer} from your frontend. It
40
   * should not be stored, logged, or exposed to anyone other than the relevant customer. Make sure
41
   * that you have TLS enabled on any page that includes the client secret.
42
   */
43
  @SerializedName("client_secret")
44
  String clientSecret;
45

46
  /** Configuration for the components supported by this Customer Session. */
47
  @SerializedName("components")
48
  Components components;
49

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

54
  /** The Customer the Customer Session was created for. */
55
  @SerializedName("customer")
56
  @Getter(lombok.AccessLevel.NONE)
57
  @Setter(lombok.AccessLevel.NONE)
58
  ExpandableField<Customer> customer;
59

60
  /** The timestamp at which this Customer Session will expire. */
61
  @SerializedName("expires_at")
62
  Long expiresAt;
63

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

71
  /**
72
   * String representing the object's type. Objects of the same type share the same value.
73
   *
74
   * <p>Equal to {@code customer_session}.
75
   */
76
  @SerializedName("object")
77
  String object;
78

79
  /** Get ID of expandable {@code customer} object. */
80
  public String getCustomer() {
81
    return (this.customer != null) ? this.customer.getId() : null;
×
82
  }
83

84
  public void setCustomer(String id) {
85
    this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
86
  }
×
87

88
  /** Get expanded {@code customer}. */
89
  public Customer getCustomerObject() {
90
    return (this.customer != null) ? this.customer.getExpanded() : null;
×
91
  }
92

93
  public void setCustomerObject(Customer expandableObject) {
94
    this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
95
  }
×
96

97
  /**
98
   * Creates a Customer Session object that includes a single-use client secret that you can use on
99
   * your front-end to grant client-side API access for certain customer resources.
100
   */
101
  public static CustomerSession create(Map<String, Object> params) throws StripeException {
102
    return create(params, (RequestOptions) null);
×
103
  }
104

105
  /**
106
   * Creates a Customer Session object that includes a single-use client secret that you can use on
107
   * your front-end to grant client-side API access for certain customer resources.
108
   */
109
  public static CustomerSession create(Map<String, Object> params, RequestOptions options)
110
      throws StripeException {
111
    String path = "/v1/customer_sessions";
×
112
    ApiRequest request =
×
113
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
UNCOV
114
    return getGlobalResponseGetter().request(request, CustomerSession.class);
×
115
  }
116

117
  /**
118
   * Creates a Customer Session object that includes a single-use client secret that you can use on
119
   * your front-end to grant client-side API access for certain customer resources.
120
   */
121
  public static CustomerSession create(CustomerSessionCreateParams params) throws StripeException {
122
    return create(params, (RequestOptions) null);
1✔
123
  }
124

125
  /**
126
   * Creates a Customer Session object that includes a single-use client secret that you can use on
127
   * your front-end to grant client-side API access for certain customer resources.
128
   */
129
  public static CustomerSession create(CustomerSessionCreateParams params, RequestOptions options)
130
      throws StripeException {
131
    String path = "/v1/customer_sessions";
1✔
132
    ApiResource.checkNullTypedParams(path, params);
1✔
133
    ApiRequest request =
1✔
134
        new ApiRequest(
135
            BaseAddress.API,
136
            ApiResource.RequestMethod.POST,
137
            path,
138
            ApiRequestParams.paramsToMap(params),
1✔
139
            options);
140
    return getGlobalResponseGetter().request(request, CustomerSession.class);
1✔
141
  }
142

143
  /** Configuration for the components supported by this Customer Session. */
144
  @Getter
145
  @Setter
146
  @EqualsAndHashCode(callSuper = false)
147
  public static class Components extends StripeObject {
1✔
148
    /** This hash contains whether the buy button is enabled. */
149
    @SerializedName("buy_button")
150
    BuyButton buyButton;
151

152
    /** This hash contains whether the Payment Element is enabled and the features it supports. */
153
    @SerializedName("payment_element")
154
    PaymentElement paymentElement;
155

156
    /** This hash contains whether the pricing table is enabled. */
157
    @SerializedName("pricing_table")
158
    PricingTable pricingTable;
159

160
    /** This hash contains whether the buy button is enabled. */
161
    @Getter
162
    @Setter
163
    @EqualsAndHashCode(callSuper = false)
164
    public static class BuyButton extends StripeObject {
1✔
165
      /** Whether the buy button is enabled. */
166
      @SerializedName("enabled")
167
      Boolean enabled;
168
    }
169

170
    /** This hash contains whether the Payment Element is enabled and the features it supports. */
171
    @Getter
172
    @Setter
173
    @EqualsAndHashCode(callSuper = false)
174
    public static class PaymentElement extends StripeObject {
1✔
175
      /** Whether the Payment Element is enabled. */
176
      @SerializedName("enabled")
177
      Boolean enabled;
178

179
      /** This hash defines whether the Payment Element supports certain features. */
180
      @SerializedName("features")
181
      Features features;
182

183
      /** This hash contains the features the Payment Element supports. */
184
      @Getter
185
      @Setter
186
      @EqualsAndHashCode(callSuper = false)
187
      public static class Features extends StripeObject {
×
188
        /**
189
         * A list of <a
190
         * href="https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay">{@code
191
         * allow_redisplay}</a> values that controls which saved payment methods the Payment Element
192
         * displays by filtering to only show payment methods with an {@code allow_redisplay} value
193
         * that is present in this list.
194
         *
195
         * <p>If not specified, defaults to [&quot;always&quot;]. In order to display all saved
196
         * payment methods, specify [&quot;always&quot;, &quot;limited&quot;,
197
         * &quot;unspecified&quot;].
198
         */
199
        @SerializedName("payment_method_allow_redisplay_filters")
200
        List<String> paymentMethodAllowRedisplayFilters;
201

202
        /**
203
         * Controls whether or not the Payment Element shows saved payment methods. This parameter
204
         * defaults to {@code disabled}.
205
         *
206
         * <p>One of {@code disabled}, or {@code enabled}.
207
         */
208
        @SerializedName("payment_method_redisplay")
209
        String paymentMethodRedisplay;
210

211
        /**
212
         * Determines the max number of saved payment methods for the Payment Element to display.
213
         * This parameter defaults to {@code 3}.
214
         */
215
        @SerializedName("payment_method_redisplay_limit")
216
        Long paymentMethodRedisplayLimit;
217

218
        /**
219
         * Controls whether the Payment Element displays the option to remove a saved payment
220
         * method. This parameter defaults to {@code disabled}.
221
         *
222
         * <p>Allowing buyers to remove their saved payment methods impacts subscriptions that
223
         * depend on that payment method. Removing the payment method detaches the <a
224
         * href="https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer">{@code
225
         * customer} object</a> from that <a
226
         * href="https://docs.stripe.com/api/payment_methods">PaymentMethod</a>.
227
         *
228
         * <p>One of {@code disabled}, or {@code enabled}.
229
         */
230
        @SerializedName("payment_method_remove")
231
        String paymentMethodRemove;
232

233
        /**
234
         * Controls whether the Payment Element displays a checkbox offering to save a new payment
235
         * method. This parameter defaults to {@code disabled}.
236
         *
237
         * <p>If a customer checks the box, the <a
238
         * href="https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay">{@code
239
         * allow_redisplay}</a> value on the PaymentMethod is set to {@code 'always'} at
240
         * confirmation time. For PaymentIntents, the <a
241
         * href="https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage">{@code
242
         * setup_future_usage}</a> value is also set to the value defined in {@code
243
         * payment_method_save_usage}.
244
         *
245
         * <p>One of {@code disabled}, or {@code enabled}.
246
         */
247
        @SerializedName("payment_method_save")
248
        String paymentMethodSave;
249

250
        /**
251
         * When using PaymentIntents and the customer checks the save checkbox, this field
252
         * determines the <a
253
         * href="https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage">{@code
254
         * setup_future_usage}</a> value used to confirm the PaymentIntent.
255
         *
256
         * <p>When using SetupIntents, directly configure the <a
257
         * href="https://docs.stripe.com/api/setup_intents/object#setup_intent_object-usage">{@code
258
         * usage}</a> value on SetupIntent creation.
259
         *
260
         * <p>One of {@code off_session}, or {@code on_session}.
261
         */
262
        @SerializedName("payment_method_save_usage")
263
        String paymentMethodSaveUsage;
264
      }
265
    }
266

267
    /** This hash contains whether the pricing table is enabled. */
268
    @Getter
269
    @Setter
270
    @EqualsAndHashCode(callSuper = false)
271
    public static class PricingTable extends StripeObject {
1✔
272
      /** Whether the pricing table is enabled. */
273
      @SerializedName("enabled")
274
      Boolean enabled;
275
    }
276
  }
277

278
  @Override
279
  public void setResponseGetter(StripeResponseGetter responseGetter) {
280
    super.setResponseGetter(responseGetter);
1✔
281
    trySetResponseGetter(components, responseGetter);
1✔
282
    trySetResponseGetter(customer, responseGetter);
1✔
283
  }
1✔
284
}
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