pub struct CreatePlan { /* private fields */ }
Expand description
You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
Implementations§
Source§impl CreatePlan
impl CreatePlan
Sourcepub fn new(
currency: impl Into<Currency>,
interval: impl Into<PlanInterval>,
) -> Self
pub fn new( currency: impl Into<Currency>, interval: impl Into<PlanInterval>, ) -> Self
Construct a new CreatePlan
.
Sourcepub fn active(self, active: impl Into<bool>) -> Self
pub fn active(self, active: impl Into<bool>) -> Self
Whether the plan is currently available for new subscriptions. Defaults to true
.
Sourcepub fn amount(self, amount: impl Into<i64>) -> Self
pub fn amount(self, amount: impl Into<i64>) -> Self
A positive integer in cents (or local equivalent) (or 0 for a free plan) representing how much to charge on a recurring basis.
Sourcepub fn amount_decimal(self, amount_decimal: impl Into<String>) -> Self
pub fn amount_decimal(self, amount_decimal: impl Into<String>) -> Self
Same as amount
, but accepts a decimal value with at most 12 decimal places.
Only one of amount
and amount_decimal
can be set.
Sourcepub fn billing_scheme(
self,
billing_scheme: impl Into<PlanBillingScheme>,
) -> Self
pub fn billing_scheme( self, billing_scheme: impl Into<PlanBillingScheme>, ) -> Self
Describes how to compute the price per period.
Either per_unit
or tiered
.
per_unit
indicates that the fixed amount (specified in amount
) will be charged per unit in quantity
(for plans with usage_type=licensed
), or per unit of total usage (for plans with usage_type=metered
).
tiered
indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers
and tiers_mode
attributes.
Sourcepub fn expand(self, expand: impl Into<Vec<String>>) -> Self
pub fn expand(self, expand: impl Into<Vec<String>>) -> Self
Specifies which fields in the response should be expanded.
Sourcepub fn id(self, id: impl Into<String>) -> Self
pub fn id(self, id: impl Into<String>) -> Self
An identifier randomly generated by Stripe. Used to identify this plan when subscribing a customer. You can optionally override this ID, but the ID must be unique across all plans in your Stripe account. You can, however, use the same plan ID in both live and test modes.
Sourcepub fn interval_count(self, interval_count: impl Into<u64>) -> Self
pub fn interval_count(self, interval_count: impl Into<u64>) -> Self
The number of intervals between subscription billings.
For example, interval=month
and interval_count=3
bills every 3 months.
Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
Sourcepub fn metadata(self, metadata: impl Into<HashMap<String, String>>) -> Self
pub fn metadata(self, metadata: impl Into<HashMap<String, String>>) -> Self
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.
Individual keys can be unset by posting an empty value to them.
All keys can be unset by posting an empty value to metadata
.
Sourcepub fn meter(self, meter: impl Into<String>) -> Self
pub fn meter(self, meter: impl Into<String>) -> Self
The meter tracking the usage of a metered price
Sourcepub fn nickname(self, nickname: impl Into<String>) -> Self
pub fn nickname(self, nickname: impl Into<String>) -> Self
A brief description of the plan, hidden from customers.
pub fn product(self, product: impl Into<CreatePlanProduct>) -> Self
Sourcepub fn tiers(self, tiers: impl Into<Vec<CreatePlanTiers>>) -> Self
pub fn tiers(self, tiers: impl Into<Vec<CreatePlanTiers>>) -> Self
Each element represents a pricing tier.
This parameter requires billing_scheme
to be set to tiered
.
See also the documentation for billing_scheme
.
Sourcepub fn tiers_mode(self, tiers_mode: impl Into<PlanTiersMode>) -> Self
pub fn tiers_mode(self, tiers_mode: impl Into<PlanTiersMode>) -> Self
Defines if the tiering price should be graduated
or volume
based.
In volume
-based tiering, the maximum quantity within a period determines the per unit price, in graduated
tiering pricing can successively change as the quantity grows.
Sourcepub fn transform_usage(
self,
transform_usage: impl Into<CreatePlanTransformUsage>,
) -> Self
pub fn transform_usage( self, transform_usage: impl Into<CreatePlanTransformUsage>, ) -> Self
Apply a transformation to the reported usage or set quantity before computing the billed price.
Cannot be combined with tiers
.
Sourcepub fn trial_period_days(self, trial_period_days: impl Into<u32>) -> Self
pub fn trial_period_days(self, trial_period_days: impl Into<u32>) -> Self
Default number of trial days when subscribing a customer to this plan using trial_from_plan=true
.
Sourcepub fn usage_type(self, usage_type: impl Into<PlanUsageType>) -> Self
pub fn usage_type(self, usage_type: impl Into<PlanUsageType>) -> Self
Configures how the quantity per period should be determined.
Can be either metered
or licensed
.
licensed
automatically bills the quantity
set when adding it to a subscription.
metered
aggregates the total usage based on usage records.
Defaults to licensed
.
Source§impl CreatePlan
impl CreatePlan
Sourcepub async fn send<C: StripeClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err>
pub async fn send<C: StripeClient>( &self, client: &C, ) -> Result<<Self as StripeRequest>::Output, C::Err>
Send the request and return the deserialized response.
Sourcepub fn send_blocking<C: StripeBlockingClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err>
pub fn send_blocking<C: StripeBlockingClient>( &self, client: &C, ) -> Result<<Self as StripeRequest>::Output, C::Err>
Send the request and return the deserialized response, blocking until completion.
Trait Implementations§
Source§impl Clone for CreatePlan
impl Clone for CreatePlan
Source§fn clone(&self) -> CreatePlan
fn clone(&self) -> CreatePlan
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more