Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Coupon for subscriptions on Checkout #1015

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/com/stripe/model/billingportal/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ public class Session extends ApiResource implements HasId {
@SerializedName("url")
String url;

/** Creates a session of the Self-service Portal. */
/** Creates a session of the self-serve Portal. */
public static Session create(Map<String, Object> params) throws StripeException {
return create(params, (RequestOptions) null);
}

/** Creates a session of the Self-service Portal. */
/** Creates a session of the self-serve Portal. */
public static Session create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/billing_portal/sessions");
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Session.class, options);
}

/** Creates a session of the Self-service Portal. */
/** Creates a session of the self-serve Portal. */
public static Session create(SessionCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}

/** Creates a session of the Self-service Portal. */
/** Creates a session of the self-serve Portal. */
public static Session create(SessionCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/billing_portal/sessions");
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/stripe/param/checkout/SessionCreateParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,13 @@ public static class SubscriptionData {
@SerializedName("application_fee_percent")
BigDecimal applicationFeePercent;

/**
* The code of the coupon to apply to this subscription. A coupon applied to a subscription will
* only affect invoices created for that particular subscription.
*/
@SerializedName("coupon")
String coupon;

/**
* The tax rates that will apply to any subscription item that does not have {@code tax_rates}
* set. Invoices created will have their {@code default_tax_rates} populated from the
Expand Down Expand Up @@ -2459,6 +2466,7 @@ public static class SubscriptionData {

private SubscriptionData(
BigDecimal applicationFeePercent,
String coupon,
List<String> defaultTaxRates,
Map<String, Object> extraParams,
List<Item> items,
Expand All @@ -2467,6 +2475,7 @@ private SubscriptionData(
Boolean trialFromPlan,
Long trialPeriodDays) {
this.applicationFeePercent = applicationFeePercent;
this.coupon = coupon;
this.defaultTaxRates = defaultTaxRates;
this.extraParams = extraParams;
this.items = items;
Expand All @@ -2483,6 +2492,8 @@ public static Builder builder() {
public static class Builder {
private BigDecimal applicationFeePercent;

private String coupon;

private List<String> defaultTaxRates;

private Map<String, Object> extraParams;
Expand All @@ -2501,6 +2512,7 @@ public static class Builder {
public SubscriptionData build() {
return new SubscriptionData(
this.applicationFeePercent,
this.coupon,
this.defaultTaxRates,
this.extraParams,
this.items,
Expand All @@ -2523,6 +2535,15 @@ public Builder setApplicationFeePercent(BigDecimal applicationFeePercent) {
return this;
}

/**
* The code of the coupon to apply to this subscription. A coupon applied to a subscription
* will only affect invoices created for that particular subscription.
*/
public Builder setCoupon(String coupon) {
this.coupon = coupon;
return this;
}

/**
* Add an element to `defaultTaxRates` list. A list is initialized for the first `add/addAll`
* call, and subsequent calls adds additional elements to the original list. See {@link
Expand Down