pub struct DiscountCreate<'a> { /* private fields */ }
Expand description
Request builder for creating a discount in Paddle API.
Implementations§
Source§impl<'a> DiscountCreate<'a>
impl<'a> DiscountCreate<'a>
pub fn new( client: &'a Paddle, amount: impl Into<String>, description: impl Into<String>, discount_type: DiscountType, ) -> Self
Sourcepub fn enabled_for_checkout(&mut self, enabled: bool) -> &mut Self
pub fn enabled_for_checkout(&mut self, enabled: bool) -> &mut Self
Whether this discount can be redeemed by customers at checkout (true) or not (false).
Sourcepub fn code(&mut self, code: impl Into<String>) -> &mut Self
pub fn code(&mut self, code: impl Into<String>) -> &mut Self
Unique code that customers can use to redeem this discount at checkout. Use letters and numbers only, up to 32 characters. Not case-sensitive.
If omitted and enabled_for_checkout is true, Paddle generates a random 10-character code.
Sourcepub fn currency_code(&mut self, currency_code: CurrencyCode) -> &mut Self
pub fn currency_code(&mut self, currency_code: CurrencyCode) -> &mut Self
Supported three-letter ISO 4217 currency code. Required where discount type is DiscountType::Flat or DiscountType::FlatPerSeat.
Sourcepub fn recur(&mut self, recur: bool) -> &mut Self
pub fn recur(&mut self, recur: bool) -> &mut Self
Whether this discount applies for multiple subscription billing periods (true
) or not (false
). If omitted, defaults to false
.
Sourcepub fn maximum_recurring_intervals(
&mut self,
maximum_recurring_intervals: u64,
) -> &mut Self
pub fn maximum_recurring_intervals( &mut self, maximum_recurring_intervals: u64, ) -> &mut Self
Number of subscription billing periods that this discount recurs for. Requires recur. null
if this discount recurs forever.
Sourcepub fn usage_limit(&mut self, usage_limit: u64) -> &mut Self
pub fn usage_limit(&mut self, usage_limit: u64) -> &mut Self
Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. null
if this discount can be redeemed an unlimited amount of times.
Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren’t considered a redemption.
Sourcepub fn restrict_to(
&mut self,
restrict_to: impl IntoIterator<Item = impl AsRef<str>>,
) -> &mut Self
pub fn restrict_to( &mut self, restrict_to: impl IntoIterator<Item = impl AsRef<str>>, ) -> &mut Self
Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. null
if this discount applies to all products and prices.
Sourcepub fn expires_at(&mut self, expires_at: DateTime<Utc>) -> &mut Self
pub fn expires_at(&mut self, expires_at: DateTime<Utc>) -> &mut Self
Datetime when this discount expires. Discount can no longer be redeemed after this date has elapsed. null
if this discount can be redeemed forever.
Expired discounts can’t be redeemed against transactions or checkouts, but can be applied when updating subscriptions.
Sourcepub fn custom_data(&mut self, custom_data: HashMap<String, String>) -> &mut Self
pub fn custom_data(&mut self, custom_data: HashMap<String, String>) -> &mut Self
Set custom data for this discount.