pub struct CreatePreviewInvoice { /* private fields */ }
Expand description
At any time, you can preview the upcoming invoice for a subscription or subscription schedule. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.
You can also preview the effects of creating or updating a subscription or subscription schedule, including a preview of any prorations that will take place.
To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_details.proration_date
parameter when doing the actual subscription update.
The recommended way to get only the prorations being previewed on the invoice is to consider line items where parent.subscription_item_details.proration
is true
.
Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer’s discount.
Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. Learn more.
Implementations§
Source§impl CreatePreviewInvoice
impl CreatePreviewInvoice
Sourcepub fn automatic_tax(
self,
automatic_tax: impl Into<CreatePreviewInvoiceAutomaticTax>,
) -> Self
pub fn automatic_tax( self, automatic_tax: impl Into<CreatePreviewInvoiceAutomaticTax>, ) -> Self
Settings for automatic tax lookup for this invoice preview.
Sourcepub fn currency(self, currency: impl Into<Currency>) -> Self
pub fn currency(self, currency: impl Into<Currency>) -> Self
The currency to preview this invoice in. Defaults to that of customer
if not specified.
Sourcepub fn customer(self, customer: impl Into<String>) -> Self
pub fn customer(self, customer: impl Into<String>) -> Self
The identifier of the customer whose upcoming invoice you’d like to retrieve.
If automatic_tax
is enabled then one of customer
, customer_details
, subscription
, or schedule
must be set.
Sourcepub fn customer_details(
self,
customer_details: impl Into<CreatePreviewInvoiceCustomerDetails>,
) -> Self
pub fn customer_details( self, customer_details: impl Into<CreatePreviewInvoiceCustomerDetails>, ) -> Self
Details about the customer you want to invoice or overrides for an existing customer.
If automatic_tax
is enabled then one of customer
, customer_details
, subscription
, or schedule
must be set.
Sourcepub fn discounts(self, discounts: impl Into<Vec<DiscountsDataParam>>) -> Self
pub fn discounts(self, discounts: impl Into<Vec<DiscountsDataParam>>) -> Self
The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the subscription or customer. This works for both coupons directly applied to an invoice and coupons applied to a subscription. Pass an empty string to avoid inheriting any discounts.
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 invoice_items(
self,
invoice_items: impl Into<Vec<CreatePreviewInvoiceInvoiceItems>>,
) -> Self
pub fn invoice_items( self, invoice_items: impl Into<Vec<CreatePreviewInvoiceInvoiceItems>>, ) -> Self
List of invoice items to add or update in the upcoming invoice preview (up to 250).
Sourcepub fn issuer(self, issuer: impl Into<CreatePreviewInvoiceIssuer>) -> Self
pub fn issuer(self, issuer: impl Into<CreatePreviewInvoiceIssuer>) -> Self
The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
Sourcepub fn on_behalf_of(self, on_behalf_of: impl Into<String>) -> Self
pub fn on_behalf_of(self, on_behalf_of: impl Into<String>) -> Self
The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the Invoices with Connect documentation for details.
Sourcepub fn preview_mode(
self,
preview_mode: impl Into<CreatePreviewInvoicePreviewMode>,
) -> Self
pub fn preview_mode( self, preview_mode: impl Into<CreatePreviewInvoicePreviewMode>, ) -> Self
Customizes the types of values to include when calculating the invoice.
Defaults to next
if unspecified.
Sourcepub fn schedule(self, schedule: impl Into<String>) -> Self
pub fn schedule(self, schedule: impl Into<String>) -> Self
The identifier of the schedule whose upcoming invoice you’d like to retrieve. Cannot be used with subscription or subscription fields.
Sourcepub fn schedule_details(
self,
schedule_details: impl Into<CreatePreviewInvoiceScheduleDetails>,
) -> Self
pub fn schedule_details( self, schedule_details: impl Into<CreatePreviewInvoiceScheduleDetails>, ) -> Self
The schedule creation or modification params to apply as a preview.
Cannot be used with subscription
or subscription_
prefixed fields.
Sourcepub fn subscription(self, subscription: impl Into<String>) -> Self
pub fn subscription(self, subscription: impl Into<String>) -> Self
The identifier of the subscription for which you’d like to retrieve the upcoming invoice.
If not provided, but a subscription_details.items
is provided, you will preview creating a subscription with those items.
If neither subscription
nor subscription_details.items
is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.
Sourcepub fn subscription_details(
self,
subscription_details: impl Into<CreatePreviewInvoiceSubscriptionDetails>,
) -> Self
pub fn subscription_details( self, subscription_details: impl Into<CreatePreviewInvoiceSubscriptionDetails>, ) -> Self
The subscription creation or modification params to apply as a preview.
Cannot be used with schedule
or schedule_details
fields.
Source§impl CreatePreviewInvoice
impl CreatePreviewInvoice
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 CreatePreviewInvoice
impl Clone for CreatePreviewInvoice
Source§fn clone(&self) -> CreatePreviewInvoice
fn clone(&self) -> CreatePreviewInvoice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more