Skip to main content

ChargeRequest

Struct ChargeRequest 

Source
#[non_exhaustive]
pub struct ChargeRequest { pub order: OrderRef, pub amount: Money, pub customer: Option<Box<str>>, pub description: Option<Box<str>>, pub return_url: Option<Url>, pub idempotency_key: Option<IdempotencyKey>, pub failure_url: Option<Url>, pub buyer: Option<Buyer>, pub billing_address: Option<Address>, pub shipping_address: Option<Address>, pub basket: Vec<BasketItem>, pub metadata: BTreeMap<String, String>, }
Expand description

A charge to create.

Build one with ChargeRequest::builder.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§order: OrderRef

The caller’s reference for the order.

§amount: Money

The amount to take.

§customer: Option<Box<str>>

The payer, in the provider’s own terms, when there is one on file.

§description: Option<Box<str>>

Free text shown on statements or in the provider’s dashboard.

§return_url: Option<Url>

Where the provider should send the payer back to.

§idempotency_key: Option<IdempotencyKey>

A key that makes replaying this request safe.

A provider either sends it or refuses the request with ErrorKind::Unsupported. Accepting a key and dropping it would read as a guarantee against double charges where there is none.

§failure_url: Option<Url>

Where the provider should send the payer when the payment fails.

None means ChargeRequest::return_url serves for both, which is what every provider but PayTR takes anyway — PayTR requires two URLs, and sends the payer to whichever matches the outcome.

§buyer: Option<Buyer>

The person paying, where the provider requires one.

iyzico’s classic API and PayTR both refuse a payment without a buyer; Stripe and Mollie never ask. See Buyer for which of its fields a given provider insists on.

§billing_address: Option<Address>

Where to bill.

None falls back to Buyer::address at the providers that require one, because a shop that gave one address meant it for both.

§shipping_address: Option<Address>

Where to ship, when that is somewhere else.

§basket: Vec<BasketItem>

What is being paid for, line by line.

Required by the providers that build a basket — iyzico refuses an empty one — and ignored by the ones that do not. The lines do not have to sum to ChargeRequest::amount: a surcharge is money the payer is charged rather than a line of the basket. BasketItem::price is what one of the thing costs, not what the line comes to.

§metadata: BTreeMap<String, String>

Key/value pairs handed to the provider and given back unchanged.

Implementations§

Source§

impl ChargeRequest

Source

pub fn builder(order: OrderRef, amount: Money) -> ChargeRequestBuilder

Starts building a charge.

Trait Implementations§

Source§

impl Clone for ChargeRequest

Source§

fn clone(&self) -> ChargeRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ChargeRequest

Source§

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

Formats the value using the given formatter. Read more

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