diff --git a/src/main/java/com/stripe/model/Account.java b/src/main/java/com/stripe/model/Account.java index c260c3c5947..d22aafd628a 100644 --- a/src/main/java/com/stripe/model/Account.java +++ b/src/main/java/com/stripe/model/Account.java @@ -643,7 +643,7 @@ public static class Company extends StripeObject { @SerializedName("name") String name; - /** The Kana variation of the company's legal name Japan only). */ + /** The Kana variation of the company's legal name (Japan only). */ @SerializedName("name_kana") String nameKana; diff --git a/src/main/java/com/stripe/model/Subscription.java b/src/main/java/com/stripe/model/Subscription.java index eb9eca43310..677a5c83240 100644 --- a/src/main/java/com/stripe/model/Subscription.java +++ b/src/main/java/com/stripe/model/Subscription.java @@ -209,6 +209,12 @@ public class Subscription extends ApiResource implements HasId, MetadataStore schedule; + /** * Date of the last substantial change to this subscription. For example, a change to the items * array, or a change of status, will reset this timestamp. @@ -366,6 +372,25 @@ public void setPendingSetupIntentObject(SetupIntent expandableObject) { new ExpandableField(expandableObject.getId(), expandableObject); } + /** Get id of expandable `schedule` object. */ + public String getSchedule() { + return (this.schedule != null) ? this.schedule.getId() : null; + } + + public void setSchedule(String id) { + this.schedule = ApiResource.setExpandableFieldId(id, this.schedule); + } + + /** Get expanded `schedule`. */ + public SubscriptionSchedule getScheduleObject() { + return (this.schedule != null) ? this.schedule.getExpanded() : null; + } + + public void setScheduleObject(SubscriptionSchedule expandableObject) { + this.schedule = + new ExpandableField(expandableObject.getId(), expandableObject); + } + /** * By default, returns a list of subscriptions that have not been canceled. In order to list * canceled subscriptions, specify status=canceled. diff --git a/src/main/java/com/stripe/model/SubscriptionSchedule.java b/src/main/java/com/stripe/model/SubscriptionSchedule.java index 434eb422637..654b1c86cfa 100644 --- a/src/main/java/com/stripe/model/SubscriptionSchedule.java +++ b/src/main/java/com/stripe/model/SubscriptionSchedule.java @@ -561,12 +561,38 @@ public static class Phase extends StripeObject { @SerializedName("application_fee_percent") BigDecimal applicationFeePercent; + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. + */ + @SerializedName("billing_thresholds") + Subscription.BillingThresholds billingThresholds; + + /** + * Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will + * attempt to pay the underlying subscription at the end of each billing cycle using the default + * source attached to the customer. When sending an invoice, Stripe will email your customer an + * invoice with payment instructions. + */ + @SerializedName("collection_method") + String collectionMethod; + /** ID of the coupon to use during this phase of the subscription schedule. */ @SerializedName("coupon") @Getter(lombok.AccessLevel.NONE) @Setter(lombok.AccessLevel.NONE) ExpandableField coupon; + /** + * ID of the default payment method for the subscription schedule. It must belong to the + * customer associated with the subscription schedule. If not set, invoices will use the default + * payment method in the customer's invoice settings. + */ + @SerializedName("default_payment_method") + @Getter(lombok.AccessLevel.NONE) + @Setter(lombok.AccessLevel.NONE) + ExpandableField defaultPaymentMethod; + @SerializedName("default_tax_rates") List defaultTaxRates; @@ -574,6 +600,10 @@ public static class Phase extends StripeObject { @SerializedName("end_date") Long endDate; + /** The subscription schedule's default invoice settings. */ + @SerializedName("invoice_settings") + InvoiceSettings invoiceSettings; + /** Plans to subscribe during this phase of the subscription schedule. */ @SerializedName("plans") List plans; @@ -610,6 +640,25 @@ public Coupon getCouponObject() { public void setCouponObject(Coupon expandableObject) { this.coupon = new ExpandableField(expandableObject.getId(), expandableObject); } + + /** Get id of expandable `defaultPaymentMethod` object. */ + public String getDefaultPaymentMethod() { + return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getId() : null; + } + + public void setDefaultPaymentMethod(String id) { + this.defaultPaymentMethod = ApiResource.setExpandableFieldId(id, this.defaultPaymentMethod); + } + + /** Get expanded `defaultPaymentMethod`. */ + public PaymentMethod getDefaultPaymentMethodObject() { + return (this.defaultPaymentMethod != null) ? this.defaultPaymentMethod.getExpanded() : null; + } + + public void setDefaultPaymentMethodObject(PaymentMethod expandableObject) { + this.defaultPaymentMethod = + new ExpandableField(expandableObject.getId(), expandableObject); + } } @Getter diff --git a/src/main/java/com/stripe/model/checkout/Session.java b/src/main/java/com/stripe/model/checkout/Session.java index b9db6d21a44..d2934c8e270 100644 --- a/src/main/java/com/stripe/model/checkout/Session.java +++ b/src/main/java/com/stripe/model/checkout/Session.java @@ -10,6 +10,7 @@ import com.stripe.model.HasId; import com.stripe.model.PaymentIntent; import com.stripe.model.Plan; +import com.stripe.model.SetupIntent; import com.stripe.model.Sku; import com.stripe.model.StripeObject; import com.stripe.model.Subscription; @@ -88,6 +89,10 @@ public class Session extends ApiResource implements HasId { @SerializedName("locale") String locale; + /** The mode of the Checkout Session. */ + @SerializedName("mode") + String mode; + /** String representing the object's type. Objects of the same type share the same value. */ @SerializedName("object") String object; @@ -104,6 +109,12 @@ public class Session extends ApiResource implements HasId { @SerializedName("payment_method_types") List paymentMethodTypes; + /** The ID of the SetupIntent if mode was set to `setup`. */ + @SerializedName("setup_intent") + @Getter(lombok.AccessLevel.NONE) + @Setter(lombok.AccessLevel.NONE) + ExpandableField setupIntent; + /** * Describes the type of transaction being performed by Checkout in order to customize relevant * text on the page, such as the submit button. `submit_type` can only be specified on Checkout @@ -163,6 +174,24 @@ public void setPaymentIntentObject(PaymentIntent expandableObject) { new ExpandableField(expandableObject.getId(), expandableObject); } + /** Get id of expandable `setupIntent` object. */ + public String getSetupIntent() { + return (this.setupIntent != null) ? this.setupIntent.getId() : null; + } + + public void setSetupIntent(String id) { + this.setupIntent = ApiResource.setExpandableFieldId(id, this.setupIntent); + } + + /** Get expanded `setupIntent`. */ + public SetupIntent getSetupIntentObject() { + return (this.setupIntent != null) ? this.setupIntent.getExpanded() : null; + } + + public void setSetupIntentObject(SetupIntent expandableObject) { + this.setupIntent = new ExpandableField(expandableObject.getId(), expandableObject); + } + /** Get id of expandable `subscription` object. */ public String getSubscription() { return (this.subscription != null) ? this.subscription.getId() : null; diff --git a/src/main/java/com/stripe/param/InvoiceUpcomingParams.java b/src/main/java/com/stripe/param/InvoiceUpcomingParams.java index 2c59dd909b1..2a07c082dbc 100644 --- a/src/main/java/com/stripe/param/InvoiceUpcomingParams.java +++ b/src/main/java/com/stripe/param/InvoiceUpcomingParams.java @@ -44,6 +44,13 @@ public class InvoiceUpcomingParams extends ApiRequestParams { @SerializedName("invoice_items") List invoiceItems; + /** + * The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. Cannot + * be used with subscription or subscription fields. + */ + @SerializedName("schedule") + String schedule; + /** * The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If * not provided, but a `subscription_items` is provided, you will preview creating a subscription @@ -63,6 +70,13 @@ public class InvoiceUpcomingParams extends ApiRequestParams { @SerializedName("subscription_billing_cycle_anchor") Object subscriptionBillingCycleAnchor; + /** + * Boolean indicating when the subscription should be scheduled to cancel. Will prorate if within + * the current period if `prorate=true` + */ + @SerializedName("subscription_cancel_at") + Object subscriptionCancelAt; + /** * Boolean indicating whether this subscription should cancel at the end of the current period. */ @@ -137,8 +151,10 @@ private InvoiceUpcomingParams( List expand, Map extraParams, List invoiceItems, + String schedule, String subscription, Object subscriptionBillingCycleAnchor, + Object subscriptionCancelAt, Boolean subscriptionCancelAtPeriodEnd, Boolean subscriptionCancelNow, Object subscriptionDefaultTaxRates, @@ -154,8 +170,10 @@ private InvoiceUpcomingParams( this.expand = expand; this.extraParams = extraParams; this.invoiceItems = invoiceItems; + this.schedule = schedule; this.subscription = subscription; this.subscriptionBillingCycleAnchor = subscriptionBillingCycleAnchor; + this.subscriptionCancelAt = subscriptionCancelAt; this.subscriptionCancelAtPeriodEnd = subscriptionCancelAtPeriodEnd; this.subscriptionCancelNow = subscriptionCancelNow; this.subscriptionDefaultTaxRates = subscriptionDefaultTaxRates; @@ -183,10 +201,14 @@ public static class Builder { private List invoiceItems; + private String schedule; + private String subscription; private Object subscriptionBillingCycleAnchor; + private Object subscriptionCancelAt; + private Boolean subscriptionCancelAtPeriodEnd; private Boolean subscriptionCancelNow; @@ -215,8 +237,10 @@ public InvoiceUpcomingParams build() { this.expand, this.extraParams, this.invoiceItems, + this.schedule, this.subscription, this.subscriptionBillingCycleAnchor, + this.subscriptionCancelAt, this.subscriptionCancelAtPeriodEnd, this.subscriptionCancelNow, this.subscriptionDefaultTaxRates, @@ -325,6 +349,15 @@ public Builder addAllInvoiceItem(List elements) { return this; } + /** + * The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. + * Cannot be used with subscription or subscription fields. + */ + public Builder setSchedule(String schedule) { + this.schedule = schedule; + return this; + } + /** * The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If * not provided, but a `subscription_items` is provided, you will preview creating a @@ -362,6 +395,24 @@ public Builder setSubscriptionBillingCycleAnchor(Long subscriptionBillingCycleAn return this; } + /** + * Boolean indicating when the subscription should be scheduled to cancel. Will prorate if + * within the current period if `prorate=true` + */ + public Builder setSubscriptionCancelAt(EmptyParam subscriptionCancelAt) { + this.subscriptionCancelAt = subscriptionCancelAt; + return this; + } + + /** + * Boolean indicating when the subscription should be scheduled to cancel. Will prorate if + * within the current period if `prorate=true` + */ + public Builder setSubscriptionCancelAt(Long subscriptionCancelAt) { + this.subscriptionCancelAt = subscriptionCancelAt; + return this; + } + /** * Boolean indicating whether this subscription should cancel at the end of the current period. */ diff --git a/src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java b/src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java index dbf133cc42e..4c92e6d18a1 100644 --- a/src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java +++ b/src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java @@ -594,10 +594,34 @@ public static class Phase { @SerializedName("application_fee_percent") BigDecimal applicationFeePercent; + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + @SerializedName("billing_thresholds") + Object billingThresholds; + + /** + * Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will + * attempt to pay the underlying subscription at the end of each billing cycle using the default + * source attached to the customer. When sending an invoice, Stripe will email your customer an + * invoice with payment instructions. Defaults to `charge_automatically` on creation. + */ + @SerializedName("collection_method") + CollectionMethod collectionMethod; + /** The identifier of the coupon to apply to this phase of the subscription schedule. */ @SerializedName("coupon") String coupon; + /** + * ID of the default payment method for the subscription schedule. It must belong to the + * customer associated with the subscription schedule. If not set, invoices will use the default + * payment method in the customer's invoice settings. + */ + @SerializedName("default_payment_method") + String defaultPaymentMethod; + /** * The tax rates that will apply to any phase that does not have `tax_rates` set. Invoices * created will have their `default_tax_rates` populated from the phase. @@ -621,6 +645,10 @@ public static class Phase { @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) Map extraParams; + /** All invoices will be billed using the specified settings. */ + @SerializedName("invoice_settings") + InvoiceSettings invoiceSettings; + /** * Integer representing the multiplier applied to the plan interval. For example, `iterations=2` * applied to a plan with `interval=month` and `interval_count=3` results in a phase of duration @@ -664,20 +692,28 @@ public static class Phase { private Phase( BigDecimal applicationFeePercent, + Object billingThresholds, + CollectionMethod collectionMethod, String coupon, + String defaultPaymentMethod, Object defaultTaxRates, Long endDate, Map extraParams, + InvoiceSettings invoiceSettings, Long iterations, List plans, BigDecimal taxPercent, Boolean trial, Long trialEnd) { this.applicationFeePercent = applicationFeePercent; + this.billingThresholds = billingThresholds; + this.collectionMethod = collectionMethod; this.coupon = coupon; + this.defaultPaymentMethod = defaultPaymentMethod; this.defaultTaxRates = defaultTaxRates; this.endDate = endDate; this.extraParams = extraParams; + this.invoiceSettings = invoiceSettings; this.iterations = iterations; this.plans = plans; this.taxPercent = taxPercent; @@ -692,14 +728,22 @@ public static Builder builder() { public static class Builder { private BigDecimal applicationFeePercent; + private Object billingThresholds; + + private CollectionMethod collectionMethod; + private String coupon; + private String defaultPaymentMethod; + private Object defaultTaxRates; private Long endDate; private Map extraParams; + private InvoiceSettings invoiceSettings; + private Long iterations; private List plans; @@ -714,10 +758,14 @@ public static class Builder { public Phase build() { return new Phase( this.applicationFeePercent, + this.billingThresholds, + this.collectionMethod, this.coupon, + this.defaultPaymentMethod, this.defaultTaxRates, this.endDate, this.extraParams, + this.invoiceSettings, this.iterations, this.plans, this.taxPercent, @@ -737,12 +785,52 @@ public Builder setApplicationFeePercent(BigDecimal applicationFeePercent) { return this; } + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + public Builder setBillingThresholds(BillingThresholds billingThresholds) { + this.billingThresholds = billingThresholds; + return this; + } + + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + public Builder setBillingThresholds(EmptyParam billingThresholds) { + this.billingThresholds = billingThresholds; + return this; + } + + /** + * Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will + * attempt to pay the underlying subscription at the end of each billing cycle using the + * default source attached to the customer. When sending an invoice, Stripe will email your + * customer an invoice with payment instructions. Defaults to `charge_automatically` on + * creation. + */ + public Builder setCollectionMethod(CollectionMethod collectionMethod) { + this.collectionMethod = collectionMethod; + return this; + } + /** The identifier of the coupon to apply to this phase of the subscription schedule. */ public Builder setCoupon(String coupon) { this.coupon = coupon; return this; } + /** + * ID of the default payment method for the subscription schedule. It must belong to the + * customer associated with the subscription schedule. If not set, invoices will use the + * default payment method in the customer's invoice settings. + */ + public Builder setDefaultPaymentMethod(String defaultPaymentMethod) { + this.defaultPaymentMethod = defaultPaymentMethod; + return this; + } + /** * The tax rates that will apply to any phase that does not have `tax_rates` set. Invoices * created will have their `default_tax_rates` populated from the phase. @@ -796,6 +884,12 @@ public Builder putAllExtraParam(Map map) { return this; } + /** All invoices will be billed using the specified settings. */ + public Builder setInvoiceSettings(InvoiceSettings invoiceSettings) { + this.invoiceSettings = invoiceSettings; + return this; + } + /** * Integer representing the multiplier applied to the plan interval. For example, * `iterations=2` applied to a plan with `interval=month` and `interval_count=3` results in a @@ -865,6 +959,167 @@ public Builder setTrialEnd(Long trialEnd) { } } + public static class BillingThresholds { + /** Monetary threshold that triggers the subscription to advance to a new billing period. */ + @SerializedName("amount_gte") + Long amountGte; + + /** + * Map of extra parameters for custom features not available in this client library. The + * content in this map is not serialized under this field's {@code @SerializedName} value. + * Instead, each key/value pair is serialized as if the key is a root-level field (serialized) + * name in this param object. Effectively, this map is flattened to its parent instance. + */ + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) + Map extraParams; + + /** + * Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If + * true, `billing_cycle_anchor` will be updated to the date/time the threshold was last + * reached; otherwise, the value will remain unchanged. + */ + @SerializedName("reset_billing_cycle_anchor") + Boolean resetBillingCycleAnchor; + + private BillingThresholds( + Long amountGte, Map extraParams, Boolean resetBillingCycleAnchor) { + this.amountGte = amountGte; + this.extraParams = extraParams; + this.resetBillingCycleAnchor = resetBillingCycleAnchor; + } + + public static Builder builder() { + return new com.stripe.param.SubscriptionScheduleCreateParams.Phase.BillingThresholds + .Builder(); + } + + public static class Builder { + private Long amountGte; + + private Map extraParams; + + private Boolean resetBillingCycleAnchor; + + /** Finalize and obtain parameter instance from this builder. */ + public BillingThresholds build() { + return new BillingThresholds( + this.amountGte, this.extraParams, this.resetBillingCycleAnchor); + } + + /** Monetary threshold that triggers the subscription to advance to a new billing period. */ + public Builder setAmountGte(Long amountGte) { + this.amountGte = amountGte; + return this; + } + + /** + * Add a key/value pair to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleCreateParams.Phase.BillingThresholds#extraParams} for + * the field documentation. + */ + public Builder putExtraParam(String key, Object value) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleCreateParams.Phase.BillingThresholds#extraParams} for + * the field documentation. + */ + public Builder putAllExtraParam(Map map) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.putAll(map); + return this; + } + + /** + * Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If + * true, `billing_cycle_anchor` will be updated to the date/time the threshold was last + * reached; otherwise, the value will remain unchanged. + */ + public Builder setResetBillingCycleAnchor(Boolean resetBillingCycleAnchor) { + this.resetBillingCycleAnchor = resetBillingCycleAnchor; + return this; + } + } + } + + public static class InvoiceSettings { + @SerializedName("days_until_due") + Long daysUntilDue; + + /** + * Map of extra parameters for custom features not available in this client library. The + * content in this map is not serialized under this field's {@code @SerializedName} value. + * Instead, each key/value pair is serialized as if the key is a root-level field (serialized) + * name in this param object. Effectively, this map is flattened to its parent instance. + */ + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) + Map extraParams; + + private InvoiceSettings(Long daysUntilDue, Map extraParams) { + this.daysUntilDue = daysUntilDue; + this.extraParams = extraParams; + } + + public static Builder builder() { + return new com.stripe.param.SubscriptionScheduleCreateParams.Phase.InvoiceSettings + .Builder(); + } + + public static class Builder { + private Long daysUntilDue; + + private Map extraParams; + + /** Finalize and obtain parameter instance from this builder. */ + public InvoiceSettings build() { + return new InvoiceSettings(this.daysUntilDue, this.extraParams); + } + + public Builder setDaysUntilDue(Long daysUntilDue) { + this.daysUntilDue = daysUntilDue; + return this; + } + + /** + * Add a key/value pair to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleCreateParams.Phase.InvoiceSettings#extraParams} for + * the field documentation. + */ + public Builder putExtraParam(String key, Object value) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleCreateParams.Phase.InvoiceSettings#extraParams} for + * the field documentation. + */ + public Builder putAllExtraParam(Map map) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.putAll(map); + return this; + } + } + } + public static class Plan { /** * Define thresholds at which an invoice will be sent, and the subscription advanced to a new @@ -1087,6 +1342,21 @@ public Builder setUsageGte(Long usageGte) { } } } + + public enum CollectionMethod implements ApiRequestParams.EnumParam { + @SerializedName("charge_automatically") + CHARGE_AUTOMATICALLY("charge_automatically"), + + @SerializedName("send_invoice") + SEND_INVOICE("send_invoice"); + + @Getter(onMethod_ = {@Override}) + private final String value; + + CollectionMethod(String value) { + this.value = value; + } + } } public static class RenewalInterval { diff --git a/src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java b/src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java index 868b8308e2e..51265946d89 100644 --- a/src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java +++ b/src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java @@ -555,10 +555,34 @@ public static class Phase { @SerializedName("application_fee_percent") BigDecimal applicationFeePercent; + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + @SerializedName("billing_thresholds") + Object billingThresholds; + + /** + * Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will + * attempt to pay the underlying subscription at the end of each billing cycle using the default + * source attached to the customer. When sending an invoice, Stripe will email your customer an + * invoice with payment instructions. Defaults to `charge_automatically` on creation. + */ + @SerializedName("collection_method") + CollectionMethod collectionMethod; + /** The identifier of the coupon to apply to this phase of the subscription schedule. */ @SerializedName("coupon") String coupon; + /** + * ID of the default payment method for the subscription schedule. It must belong to the + * customer associated with the subscription schedule. If not set, invoices will use the default + * payment method in the customer's invoice settings. + */ + @SerializedName("default_payment_method") + String defaultPaymentMethod; + /** * The tax rates that will apply to any phase that does not have `tax_rates` set. Invoices * created will have their `default_tax_rates` populated from the phase. @@ -582,6 +606,10 @@ public static class Phase { @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) Map extraParams; + /** All invoices will be billed using the specified settings. */ + @SerializedName("invoice_settings") + InvoiceSettings invoiceSettings; + /** * Integer representing the multiplier applied to the plan interval. For example, `iterations=2` * applied to a plan with `interval=month` and `interval_count=3` results in a phase of duration @@ -629,10 +657,14 @@ public static class Phase { private Phase( BigDecimal applicationFeePercent, + Object billingThresholds, + CollectionMethod collectionMethod, String coupon, + String defaultPaymentMethod, Object defaultTaxRates, Object endDate, Map extraParams, + InvoiceSettings invoiceSettings, Long iterations, List plans, Object startDate, @@ -640,10 +672,14 @@ private Phase( Boolean trial, Object trialEnd) { this.applicationFeePercent = applicationFeePercent; + this.billingThresholds = billingThresholds; + this.collectionMethod = collectionMethod; this.coupon = coupon; + this.defaultPaymentMethod = defaultPaymentMethod; this.defaultTaxRates = defaultTaxRates; this.endDate = endDate; this.extraParams = extraParams; + this.invoiceSettings = invoiceSettings; this.iterations = iterations; this.plans = plans; this.startDate = startDate; @@ -659,14 +695,22 @@ public static Builder builder() { public static class Builder { private BigDecimal applicationFeePercent; + private Object billingThresholds; + + private CollectionMethod collectionMethod; + private String coupon; + private String defaultPaymentMethod; + private Object defaultTaxRates; private Object endDate; private Map extraParams; + private InvoiceSettings invoiceSettings; + private Long iterations; private List plans; @@ -683,10 +727,14 @@ public static class Builder { public Phase build() { return new Phase( this.applicationFeePercent, + this.billingThresholds, + this.collectionMethod, this.coupon, + this.defaultPaymentMethod, this.defaultTaxRates, this.endDate, this.extraParams, + this.invoiceSettings, this.iterations, this.plans, this.startDate, @@ -707,12 +755,52 @@ public Builder setApplicationFeePercent(BigDecimal applicationFeePercent) { return this; } + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + public Builder setBillingThresholds(BillingThresholds billingThresholds) { + this.billingThresholds = billingThresholds; + return this; + } + + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new + * billing period. Pass an empty string to remove previously-defined thresholds. + */ + public Builder setBillingThresholds(EmptyParam billingThresholds) { + this.billingThresholds = billingThresholds; + return this; + } + + /** + * Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will + * attempt to pay the underlying subscription at the end of each billing cycle using the + * default source attached to the customer. When sending an invoice, Stripe will email your + * customer an invoice with payment instructions. Defaults to `charge_automatically` on + * creation. + */ + public Builder setCollectionMethod(CollectionMethod collectionMethod) { + this.collectionMethod = collectionMethod; + return this; + } + /** The identifier of the coupon to apply to this phase of the subscription schedule. */ public Builder setCoupon(String coupon) { this.coupon = coupon; return this; } + /** + * ID of the default payment method for the subscription schedule. It must belong to the + * customer associated with the subscription schedule. If not set, invoices will use the + * default payment method in the customer's invoice settings. + */ + public Builder setDefaultPaymentMethod(String defaultPaymentMethod) { + this.defaultPaymentMethod = defaultPaymentMethod; + return this; + } + /** * The tax rates that will apply to any phase that does not have `tax_rates` set. Invoices * created will have their `default_tax_rates` populated from the phase. @@ -775,6 +863,12 @@ public Builder putAllExtraParam(Map map) { return this; } + /** All invoices will be billed using the specified settings. */ + public Builder setInvoiceSettings(InvoiceSettings invoiceSettings) { + this.invoiceSettings = invoiceSettings; + return this; + } + /** * Integer representing the multiplier applied to the plan interval. For example, * `iterations=2` applied to a plan with `interval=month` and `interval_count=3` results in a @@ -865,6 +959,167 @@ public Builder setTrialEnd(Long trialEnd) { } } + public static class BillingThresholds { + /** Monetary threshold that triggers the subscription to advance to a new billing period. */ + @SerializedName("amount_gte") + Long amountGte; + + /** + * Map of extra parameters for custom features not available in this client library. The + * content in this map is not serialized under this field's {@code @SerializedName} value. + * Instead, each key/value pair is serialized as if the key is a root-level field (serialized) + * name in this param object. Effectively, this map is flattened to its parent instance. + */ + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) + Map extraParams; + + /** + * Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If + * true, `billing_cycle_anchor` will be updated to the date/time the threshold was last + * reached; otherwise, the value will remain unchanged. + */ + @SerializedName("reset_billing_cycle_anchor") + Boolean resetBillingCycleAnchor; + + private BillingThresholds( + Long amountGte, Map extraParams, Boolean resetBillingCycleAnchor) { + this.amountGte = amountGte; + this.extraParams = extraParams; + this.resetBillingCycleAnchor = resetBillingCycleAnchor; + } + + public static Builder builder() { + return new com.stripe.param.SubscriptionScheduleUpdateParams.Phase.BillingThresholds + .Builder(); + } + + public static class Builder { + private Long amountGte; + + private Map extraParams; + + private Boolean resetBillingCycleAnchor; + + /** Finalize and obtain parameter instance from this builder. */ + public BillingThresholds build() { + return new BillingThresholds( + this.amountGte, this.extraParams, this.resetBillingCycleAnchor); + } + + /** Monetary threshold that triggers the subscription to advance to a new billing period. */ + public Builder setAmountGte(Long amountGte) { + this.amountGte = amountGte; + return this; + } + + /** + * Add a key/value pair to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleUpdateParams.Phase.BillingThresholds#extraParams} for + * the field documentation. + */ + public Builder putExtraParam(String key, Object value) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleUpdateParams.Phase.BillingThresholds#extraParams} for + * the field documentation. + */ + public Builder putAllExtraParam(Map map) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.putAll(map); + return this; + } + + /** + * Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If + * true, `billing_cycle_anchor` will be updated to the date/time the threshold was last + * reached; otherwise, the value will remain unchanged. + */ + public Builder setResetBillingCycleAnchor(Boolean resetBillingCycleAnchor) { + this.resetBillingCycleAnchor = resetBillingCycleAnchor; + return this; + } + } + } + + public static class InvoiceSettings { + @SerializedName("days_until_due") + Long daysUntilDue; + + /** + * Map of extra parameters for custom features not available in this client library. The + * content in this map is not serialized under this field's {@code @SerializedName} value. + * Instead, each key/value pair is serialized as if the key is a root-level field (serialized) + * name in this param object. Effectively, this map is flattened to its parent instance. + */ + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) + Map extraParams; + + private InvoiceSettings(Long daysUntilDue, Map extraParams) { + this.daysUntilDue = daysUntilDue; + this.extraParams = extraParams; + } + + public static Builder builder() { + return new com.stripe.param.SubscriptionScheduleUpdateParams.Phase.InvoiceSettings + .Builder(); + } + + public static class Builder { + private Long daysUntilDue; + + private Map extraParams; + + /** Finalize and obtain parameter instance from this builder. */ + public InvoiceSettings build() { + return new InvoiceSettings(this.daysUntilDue, this.extraParams); + } + + public Builder setDaysUntilDue(Long daysUntilDue) { + this.daysUntilDue = daysUntilDue; + return this; + } + + /** + * Add a key/value pair to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleUpdateParams.Phase.InvoiceSettings#extraParams} for + * the field documentation. + */ + public Builder putExtraParam(String key, Object value) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original + * map. See {@link SubscriptionScheduleUpdateParams.Phase.InvoiceSettings#extraParams} for + * the field documentation. + */ + public Builder putAllExtraParam(Map map) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.putAll(map); + return this; + } + } + } + public static class Plan { /** * Define thresholds at which an invoice will be sent, and the subscription advanced to a new @@ -1088,6 +1343,21 @@ public Builder setUsageGte(Long usageGte) { } } + public enum CollectionMethod implements ApiRequestParams.EnumParam { + @SerializedName("charge_automatically") + CHARGE_AUTOMATICALLY("charge_automatically"), + + @SerializedName("send_invoice") + SEND_INVOICE("send_invoice"); + + @Getter(onMethod_ = {@Override}) + private final String value; + + CollectionMethod(String value) { + this.value = value; + } + } + public enum EndDate implements ApiRequestParams.EnumParam { @SerializedName("now") NOW("now"); diff --git a/src/main/java/com/stripe/param/WebhookEndpointCreateParams.java b/src/main/java/com/stripe/param/WebhookEndpointCreateParams.java index a6eb92567d8..954a8fc3e10 100644 --- a/src/main/java/com/stripe/param/WebhookEndpointCreateParams.java +++ b/src/main/java/com/stripe/param/WebhookEndpointCreateParams.java @@ -855,6 +855,27 @@ public enum EnabledEvent implements ApiRequestParams.EnumParam { @SerializedName("source.transaction.updated") SOURCE__TRANSACTION__UPDATED("source.transaction.updated"), + @SerializedName("subscription_schedule.aborted") + SUBSCRIPTION_SCHEDULE__ABORTED("subscription_schedule.aborted"), + + @SerializedName("subscription_schedule.canceled") + SUBSCRIPTION_SCHEDULE__CANCELED("subscription_schedule.canceled"), + + @SerializedName("subscription_schedule.completed") + SUBSCRIPTION_SCHEDULE__COMPLETED("subscription_schedule.completed"), + + @SerializedName("subscription_schedule.created") + SUBSCRIPTION_SCHEDULE__CREATED("subscription_schedule.created"), + + @SerializedName("subscription_schedule.expiring") + SUBSCRIPTION_SCHEDULE__EXPIRING("subscription_schedule.expiring"), + + @SerializedName("subscription_schedule.released") + SUBSCRIPTION_SCHEDULE__RELEASED("subscription_schedule.released"), + + @SerializedName("subscription_schedule.updated") + SUBSCRIPTION_SCHEDULE__UPDATED("subscription_schedule.updated"), + @SerializedName("tax_rate.created") TAX_RATE__CREATED("tax_rate.created"), diff --git a/src/main/java/com/stripe/param/WebhookEndpointUpdateParams.java b/src/main/java/com/stripe/param/WebhookEndpointUpdateParams.java index 68859209359..62ae38c0285 100644 --- a/src/main/java/com/stripe/param/WebhookEndpointUpdateParams.java +++ b/src/main/java/com/stripe/param/WebhookEndpointUpdateParams.java @@ -548,6 +548,27 @@ public enum EnabledEvent implements ApiRequestParams.EnumParam { @SerializedName("source.transaction.updated") SOURCE__TRANSACTION__UPDATED("source.transaction.updated"), + @SerializedName("subscription_schedule.aborted") + SUBSCRIPTION_SCHEDULE__ABORTED("subscription_schedule.aborted"), + + @SerializedName("subscription_schedule.canceled") + SUBSCRIPTION_SCHEDULE__CANCELED("subscription_schedule.canceled"), + + @SerializedName("subscription_schedule.completed") + SUBSCRIPTION_SCHEDULE__COMPLETED("subscription_schedule.completed"), + + @SerializedName("subscription_schedule.created") + SUBSCRIPTION_SCHEDULE__CREATED("subscription_schedule.created"), + + @SerializedName("subscription_schedule.expiring") + SUBSCRIPTION_SCHEDULE__EXPIRING("subscription_schedule.expiring"), + + @SerializedName("subscription_schedule.released") + SUBSCRIPTION_SCHEDULE__RELEASED("subscription_schedule.released"), + + @SerializedName("subscription_schedule.updated") + SUBSCRIPTION_SCHEDULE__UPDATED("subscription_schedule.updated"), + @SerializedName("tax_rate.created") TAX_RATE__CREATED("tax_rate.created"), diff --git a/src/main/java/com/stripe/param/checkout/SessionCreateParams.java b/src/main/java/com/stripe/param/checkout/SessionCreateParams.java index 698d1bd08df..b0d1abb8752 100644 --- a/src/main/java/com/stripe/param/checkout/SessionCreateParams.java +++ b/src/main/java/com/stripe/param/checkout/SessionCreateParams.java @@ -80,6 +80,10 @@ public class SessionCreateParams extends ApiRequestParams { @SerializedName("locale") Locale locale; + /** The mode of the Checkout Session. */ + @SerializedName("mode") + Mode mode; + /** A subset of parameters to be passed to PaymentIntent creation. */ @SerializedName("payment_intent_data") PaymentIntentData paymentIntentData; @@ -91,6 +95,10 @@ public class SessionCreateParams extends ApiRequestParams { @SerializedName("payment_method_types") List paymentMethodTypes; + /** A subset of parameters to be passed to SetupIntent creation. */ + @SerializedName("setup_intent_data") + SetupIntentData setupIntentData; + /** * Describes the type of transaction being performed by Checkout in order to customize relevant * text on the page, such as the submit button. `submit_type` can only be specified on Checkout @@ -122,8 +130,10 @@ private SessionCreateParams( Map extraParams, List lineItems, Locale locale, + Mode mode, PaymentIntentData paymentIntentData, List paymentMethodTypes, + SetupIntentData setupIntentData, SubmitType submitType, SubscriptionData subscriptionData, String successUrl) { @@ -136,8 +146,10 @@ private SessionCreateParams( this.extraParams = extraParams; this.lineItems = lineItems; this.locale = locale; + this.mode = mode; this.paymentIntentData = paymentIntentData; this.paymentMethodTypes = paymentMethodTypes; + this.setupIntentData = setupIntentData; this.submitType = submitType; this.subscriptionData = subscriptionData; this.successUrl = successUrl; @@ -166,10 +178,14 @@ public static class Builder { private Locale locale; + private Mode mode; + private PaymentIntentData paymentIntentData; private List paymentMethodTypes; + private SetupIntentData setupIntentData; + private SubmitType submitType; private SubscriptionData subscriptionData; @@ -188,8 +204,10 @@ public SessionCreateParams build() { this.extraParams, this.lineItems, this.locale, + this.mode, this.paymentIntentData, this.paymentMethodTypes, + this.setupIntentData, this.submitType, this.subscriptionData, this.successUrl); @@ -333,6 +351,12 @@ public Builder setLocale(Locale locale) { return this; } + /** The mode of the Checkout Session. */ + public Builder setMode(Mode mode) { + this.mode = mode; + return this; + } + /** A subset of parameters to be passed to PaymentIntent creation. */ public Builder setPaymentIntentData(PaymentIntentData paymentIntentData) { this.paymentIntentData = paymentIntentData; @@ -365,6 +389,12 @@ public Builder addAllPaymentMethodType(List elements) { return this; } + /** A subset of parameters to be passed to SetupIntent creation. */ + public Builder setSetupIntentData(SetupIntentData setupIntentData) { + this.setupIntentData = setupIntentData; + return this; + } + /** * Describes the type of transaction being performed by Checkout in order to customize relevant * text on the page, such as the submit button. `submit_type` can only be specified on Checkout @@ -1256,6 +1286,135 @@ public enum SetupFutureUsage implements ApiRequestParams.EnumParam { } } + public static class SetupIntentData { + /** An arbitrary string attached to the object. Often useful for displaying to users. */ + @SerializedName("description") + String description; + + /** + * Map of extra parameters for custom features not available in this client library. The content + * in this map is not serialized under this field's {@code @SerializedName} value. Instead, each + * key/value pair is serialized as if the key is a root-level field (serialized) name in this + * param object. Effectively, this map is flattened to its parent instance. + */ + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) + Map extraParams; + + /** + * Set of key-value pairs that you can attach to an object. This can be useful for storing + * additional information about the object in a structured format. + */ + @SerializedName("metadata") + Map metadata; + + /** + * The Stripe account ID for which these funds are intended. For details, see the PaymentIntents + * [use case for connected + * accounts](/docs/payments/payment-intents/use-cases#connected-accounts). + */ + @SerializedName("on_behalf_of") + String onBehalfOf; + + private SetupIntentData( + String description, + Map extraParams, + Map metadata, + String onBehalfOf) { + this.description = description; + this.extraParams = extraParams; + this.metadata = metadata; + this.onBehalfOf = onBehalfOf; + } + + public static Builder builder() { + return new com.stripe.param.checkout.SessionCreateParams.SetupIntentData.Builder(); + } + + public static class Builder { + private String description; + + private Map extraParams; + + private Map metadata; + + private String onBehalfOf; + + /** Finalize and obtain parameter instance from this builder. */ + public SetupIntentData build() { + return new SetupIntentData( + this.description, this.extraParams, this.metadata, this.onBehalfOf); + } + + /** An arbitrary string attached to the object. Often useful for displaying to users. */ + public Builder setDescription(String description) { + this.description = description; + return this; + } + + /** + * Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll` + * call, and subsequent calls add additional key/value pairs to the original map. See {@link + * SessionCreateParams.SetupIntentData#extraParams} for the field documentation. + */ + public Builder putExtraParam(String key, Object value) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map. + * See {@link SessionCreateParams.SetupIntentData#extraParams} for the field documentation. + */ + public Builder putAllExtraParam(Map map) { + if (this.extraParams == null) { + this.extraParams = new HashMap<>(); + } + this.extraParams.putAll(map); + return this; + } + + /** + * Add a key/value pair to `metadata` map. A map is initialized for the first `put/putAll` + * call, and subsequent calls add additional key/value pairs to the original map. See {@link + * SessionCreateParams.SetupIntentData#metadata} for the field documentation. + */ + public Builder putMetadata(String key, String value) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, value); + return this; + } + + /** + * Add all map key/value pairs to `metadata` map. A map is initialized for the first + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map. + * See {@link SessionCreateParams.SetupIntentData#metadata} for the field documentation. + */ + public Builder putAllMetadata(Map map) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.putAll(map); + return this; + } + + /** + * The Stripe account ID for which these funds are intended. For details, see the + * PaymentIntents [use case for connected + * accounts](/docs/payments/payment-intents/use-cases#connected-accounts). + */ + public Builder setOnBehalfOf(String onBehalfOf) { + this.onBehalfOf = onBehalfOf; + return this; + } + } + } + public static class SubscriptionData { /** * A non-negative decimal between 0 and 100, with at most two decimal places. This represents @@ -1610,6 +1769,24 @@ public enum Locale implements ApiRequestParams.EnumParam { } } + public enum Mode implements ApiRequestParams.EnumParam { + @SerializedName("payment") + PAYMENT("payment"), + + @SerializedName("setup") + SETUP("setup"), + + @SerializedName("subscription") + SUBSCRIPTION("subscription"); + + @Getter(onMethod_ = {@Override}) + private final String value; + + Mode(String value) { + this.value = value; + } + } + public enum PaymentMethodType implements ApiRequestParams.EnumParam { @SerializedName("card") CARD("card");