CreatePreviewInvoice

Struct CreatePreviewInvoice 

Source
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

Source

pub fn new() -> Self

Construct a new CreatePreviewInvoice.

Source

pub fn automatic_tax( self, automatic_tax: impl Into<CreatePreviewInvoiceAutomaticTax>, ) -> Self

Settings for automatic tax lookup for this invoice preview.

Source

pub fn currency(self, currency: impl Into<Currency>) -> Self

The currency to preview this invoice in. Defaults to that of customer if not specified.

Source

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.

Source

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.

Source

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.

Source

pub fn expand(self, expand: impl Into<Vec<String>>) -> Self

Specifies which fields in the response should be expanded.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

pub async fn send<C: StripeClient>( &self, client: &C, ) -> Result<<Self as StripeRequest>::Output, C::Err>

Send the request and return the deserialized response.

Source

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

Source§

fn clone(&self) -> CreatePreviewInvoice

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreatePreviewInvoice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CreatePreviewInvoice

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Serialize for CreatePreviewInvoice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StripeRequest for CreatePreviewInvoice

Source§

type Output = Invoice

The data returned from the eventual API call.
Source§

fn build(&self) -> RequestBuilder

Convert the struct into library-agnostic data that can be used by compatible clients to make API calls.
Source§

fn customize(&self) -> CustomizableStripeRequest<Self::Output>

Convert to a builder allowing per-request customization.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more