Skip to content

Commit 5e9f26c

Browse files
Merge upstream and update generated code for v2150 and
2 parents 4997e40 + 11b30cd commit 5e9f26c

6 files changed

Lines changed: 359 additions & 2 deletions

File tree

API_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
499f00588b1b41670a44a1e00598db81222ce169
1+
5abe0e44caedb3474ee672265284096ec89e0fa3

CODEGEN_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
88aa59022b32620f4d66d6196e3b42d5a0f86bbb

OPENAPI_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2149
1+
v2150

src/main/java/com/stripe/model/Subscription.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.stripe.param.SubscriptionCreateParams;
1616
import com.stripe.param.SubscriptionListParams;
1717
import com.stripe.param.SubscriptionMigrateParams;
18+
import com.stripe.param.SubscriptionPauseParams;
1819
import com.stripe.param.SubscriptionResumeParams;
1920
import com.stripe.param.SubscriptionRetrieveParams;
2021
import com.stripe.param.SubscriptionSearchParams;
@@ -967,6 +968,58 @@ public Subscription migrate(SubscriptionMigrateParams params, RequestOptions opt
967968
return getResponseGetter().request(request, Subscription.class);
968969
}
969970

971+
/**
972+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
973+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
974+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
975+
*/
976+
public Subscription pause(Map<String, Object> params) throws StripeException {
977+
return pause(params, (RequestOptions) null);
978+
}
979+
980+
/**
981+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
982+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
983+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
984+
*/
985+
public Subscription pause(Map<String, Object> params, RequestOptions options)
986+
throws StripeException {
987+
String path =
988+
String.format("/v1/subscriptions/%s/pause", ApiResource.urlEncodeId(this.getId()));
989+
ApiRequest request =
990+
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
991+
return getResponseGetter().request(request, Subscription.class);
992+
}
993+
994+
/**
995+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
996+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
997+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
998+
*/
999+
public Subscription pause(SubscriptionPauseParams params) throws StripeException {
1000+
return pause(params, (RequestOptions) null);
1001+
}
1002+
1003+
/**
1004+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
1005+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
1006+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
1007+
*/
1008+
public Subscription pause(SubscriptionPauseParams params, RequestOptions options)
1009+
throws StripeException {
1010+
String path =
1011+
String.format("/v1/subscriptions/%s/pause", ApiResource.urlEncodeId(this.getId()));
1012+
ApiResource.checkNullTypedParams(path, params);
1013+
ApiRequest request =
1014+
new ApiRequest(
1015+
BaseAddress.API,
1016+
ApiResource.RequestMethod.POST,
1017+
path,
1018+
ApiRequestParams.paramsToMap(params),
1019+
options);
1020+
return getResponseGetter().request(request, Subscription.class);
1021+
}
1022+
9701023
/**
9711024
* Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
9721025
* and creating prorations. If a resumption invoice is generated, it must be paid or marked
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.param;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import com.stripe.net.ApiRequestParams;
6+
import java.util.ArrayList;
7+
import java.util.HashMap;
8+
import java.util.List;
9+
import java.util.Map;
10+
import lombok.EqualsAndHashCode;
11+
import lombok.Getter;
12+
13+
@Getter
14+
@EqualsAndHashCode(callSuper = false)
15+
public class SubscriptionPauseParams extends ApiRequestParams {
16+
/** Controls what to bill for when pausing the subscription. */
17+
@SerializedName("bill_for")
18+
BillFor billFor;
19+
20+
/** Specifies which fields in the response should be expanded. */
21+
@SerializedName("expand")
22+
List<String> expand;
23+
24+
/**
25+
* Map of extra parameters for custom features not available in this client library. The content
26+
* in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
27+
* key/value pair is serialized as if the key is a root-level field (serialized) name in this
28+
* param object. Effectively, this map is flattened to its parent instance.
29+
*/
30+
@SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
31+
Map<String, Object> extraParams;
32+
33+
/**
34+
* Determines how to handle debits and credits when pausing. The default is {@code
35+
* pending_invoice_item}.
36+
*/
37+
@SerializedName("invoicing_behavior")
38+
InvoicingBehavior invoicingBehavior;
39+
40+
/** <strong>Required.</strong> The type of pause to apply. */
41+
@SerializedName("type")
42+
Type type;
43+
44+
private SubscriptionPauseParams(
45+
BillFor billFor,
46+
List<String> expand,
47+
Map<String, Object> extraParams,
48+
InvoicingBehavior invoicingBehavior,
49+
Type type) {
50+
this.billFor = billFor;
51+
this.expand = expand;
52+
this.extraParams = extraParams;
53+
this.invoicingBehavior = invoicingBehavior;
54+
this.type = type;
55+
}
56+
57+
public static Builder builder() {
58+
return new Builder();
59+
}
60+
61+
public static class Builder {
62+
private BillFor billFor;
63+
64+
private List<String> expand;
65+
66+
private Map<String, Object> extraParams;
67+
68+
private InvoicingBehavior invoicingBehavior;
69+
70+
private Type type;
71+
72+
/** Finalize and obtain parameter instance from this builder. */
73+
public SubscriptionPauseParams build() {
74+
return new SubscriptionPauseParams(
75+
this.billFor, this.expand, this.extraParams, this.invoicingBehavior, this.type);
76+
}
77+
78+
/** Controls what to bill for when pausing the subscription. */
79+
public Builder setBillFor(SubscriptionPauseParams.BillFor billFor) {
80+
this.billFor = billFor;
81+
return this;
82+
}
83+
84+
/**
85+
* Add an element to `expand` list. A list is initialized for the first `add/addAll` call, and
86+
* subsequent calls adds additional elements to the original list. See {@link
87+
* SubscriptionPauseParams#expand} for the field documentation.
88+
*/
89+
public Builder addExpand(String element) {
90+
if (this.expand == null) {
91+
this.expand = new ArrayList<>();
92+
}
93+
this.expand.add(element);
94+
return this;
95+
}
96+
97+
/**
98+
* Add all elements to `expand` list. A list is initialized for the first `add/addAll` call, and
99+
* subsequent calls adds additional elements to the original list. See {@link
100+
* SubscriptionPauseParams#expand} for the field documentation.
101+
*/
102+
public Builder addAllExpand(List<String> elements) {
103+
if (this.expand == null) {
104+
this.expand = new ArrayList<>();
105+
}
106+
this.expand.addAll(elements);
107+
return this;
108+
}
109+
110+
/**
111+
* Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
112+
* call, and subsequent calls add additional key/value pairs to the original map. See {@link
113+
* SubscriptionPauseParams#extraParams} for the field documentation.
114+
*/
115+
public Builder putExtraParam(String key, Object value) {
116+
if (this.extraParams == null) {
117+
this.extraParams = new HashMap<>();
118+
}
119+
this.extraParams.put(key, value);
120+
return this;
121+
}
122+
123+
/**
124+
* Add all map key/value pairs to `extraParams` map. A map is initialized for the first
125+
* `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
126+
* See {@link SubscriptionPauseParams#extraParams} for the field documentation.
127+
*/
128+
public Builder putAllExtraParam(Map<String, Object> map) {
129+
if (this.extraParams == null) {
130+
this.extraParams = new HashMap<>();
131+
}
132+
this.extraParams.putAll(map);
133+
return this;
134+
}
135+
136+
/**
137+
* Determines how to handle debits and credits when pausing. The default is {@code
138+
* pending_invoice_item}.
139+
*/
140+
public Builder setInvoicingBehavior(
141+
SubscriptionPauseParams.InvoicingBehavior invoicingBehavior) {
142+
this.invoicingBehavior = invoicingBehavior;
143+
return this;
144+
}
145+
146+
/** <strong>Required.</strong> The type of pause to apply. */
147+
public Builder setType(SubscriptionPauseParams.Type type) {
148+
this.type = type;
149+
return this;
150+
}
151+
}
152+
153+
@Getter
154+
@EqualsAndHashCode(callSuper = false)
155+
public static class BillFor {
156+
/**
157+
* Map of extra parameters for custom features not available in this client library. The content
158+
* in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
159+
* key/value pair is serialized as if the key is a root-level field (serialized) name in this
160+
* param object. Effectively, this map is flattened to its parent instance.
161+
*/
162+
@SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
163+
Map<String, Object> extraParams;
164+
165+
/**
166+
* Controls whether to debit for accrued metered usage in the current billing period. The
167+
* default is {@code false}.
168+
*/
169+
@SerializedName("outstanding_usage")
170+
Boolean outstandingUsage;
171+
172+
/**
173+
* Controls whether to credit for licensed items in the current billing period. The default is
174+
* {@code false}.
175+
*/
176+
@SerializedName("unused_time")
177+
Boolean unusedTime;
178+
179+
private BillFor(Map<String, Object> extraParams, Boolean outstandingUsage, Boolean unusedTime) {
180+
this.extraParams = extraParams;
181+
this.outstandingUsage = outstandingUsage;
182+
this.unusedTime = unusedTime;
183+
}
184+
185+
public static Builder builder() {
186+
return new Builder();
187+
}
188+
189+
public static class Builder {
190+
private Map<String, Object> extraParams;
191+
192+
private Boolean outstandingUsage;
193+
194+
private Boolean unusedTime;
195+
196+
/** Finalize and obtain parameter instance from this builder. */
197+
public SubscriptionPauseParams.BillFor build() {
198+
return new SubscriptionPauseParams.BillFor(
199+
this.extraParams, this.outstandingUsage, this.unusedTime);
200+
}
201+
202+
/**
203+
* Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
204+
* call, and subsequent calls add additional key/value pairs to the original map. See {@link
205+
* SubscriptionPauseParams.BillFor#extraParams} for the field documentation.
206+
*/
207+
public Builder putExtraParam(String key, Object value) {
208+
if (this.extraParams == null) {
209+
this.extraParams = new HashMap<>();
210+
}
211+
this.extraParams.put(key, value);
212+
return this;
213+
}
214+
215+
/**
216+
* Add all map key/value pairs to `extraParams` map. A map is initialized for the first
217+
* `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
218+
* See {@link SubscriptionPauseParams.BillFor#extraParams} for the field documentation.
219+
*/
220+
public Builder putAllExtraParam(Map<String, Object> map) {
221+
if (this.extraParams == null) {
222+
this.extraParams = new HashMap<>();
223+
}
224+
this.extraParams.putAll(map);
225+
return this;
226+
}
227+
228+
/**
229+
* Controls whether to debit for accrued metered usage in the current billing period. The
230+
* default is {@code false}.
231+
*/
232+
public Builder setOutstandingUsage(Boolean outstandingUsage) {
233+
this.outstandingUsage = outstandingUsage;
234+
return this;
235+
}
236+
237+
/**
238+
* Controls whether to credit for licensed items in the current billing period. The default is
239+
* {@code false}.
240+
*/
241+
public Builder setUnusedTime(Boolean unusedTime) {
242+
this.unusedTime = unusedTime;
243+
return this;
244+
}
245+
}
246+
}
247+
248+
public enum InvoicingBehavior implements ApiRequestParams.EnumParam {
249+
@SerializedName("invoice")
250+
INVOICE("invoice"),
251+
252+
@SerializedName("pending_invoice_item")
253+
PENDING_INVOICE_ITEM("pending_invoice_item");
254+
255+
@Getter(onMethod_ = {@Override})
256+
private final String value;
257+
258+
InvoicingBehavior(String value) {
259+
this.value = value;
260+
}
261+
}
262+
263+
public enum Type implements ApiRequestParams.EnumParam {
264+
@SerializedName("subscription")
265+
SUBSCRIPTION("subscription");
266+
267+
@Getter(onMethod_ = {@Override})
268+
private final String value;
269+
270+
Type(String value) {
271+
this.value = value;
272+
}
273+
}
274+
}

src/main/java/com/stripe/service/SubscriptionService.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.stripe.param.SubscriptionCreateParams;
2020
import com.stripe.param.SubscriptionListParams;
2121
import com.stripe.param.SubscriptionMigrateParams;
22+
import com.stripe.param.SubscriptionPauseParams;
2223
import com.stripe.param.SubscriptionResumeParams;
2324
import com.stripe.param.SubscriptionRetrieveParams;
2425
import com.stripe.param.SubscriptionSearchParams;
@@ -581,6 +582,34 @@ public Subscription migrate(
581582
options);
582583
return this.request(request, Subscription.class);
583584
}
585+
/**
586+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
587+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
588+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
589+
*/
590+
public Subscription pause(String subscription, SubscriptionPauseParams params)
591+
throws StripeException {
592+
return pause(subscription, params, (RequestOptions) null);
593+
}
594+
/**
595+
* Pauses a subscription by transitioning it to the paused status. A paused subscription does not
596+
* generate invoices and will not advance to new billing periods. The subscription can be resumed
597+
* later using the resume endpoint. Cannot pause subscriptions with attached schedules.
598+
*/
599+
public Subscription pause(
600+
String subscription, SubscriptionPauseParams params, RequestOptions options)
601+
throws StripeException {
602+
String path =
603+
String.format("/v1/subscriptions/%s/pause", ApiResource.urlEncodeId(subscription));
604+
ApiRequest request =
605+
new ApiRequest(
606+
BaseAddress.API,
607+
ApiResource.RequestMethod.POST,
608+
path,
609+
ApiRequestParams.paramsToMap(params),
610+
options);
611+
return this.request(request, Subscription.class);
612+
}
584613
/**
585614
* Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor
586615
* and creating prorations. If a resumption invoice is generated, it must be paid or marked

0 commit comments

Comments
 (0)