#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.order: OrderRefThe caller’s reference for the order.
amount: MoneyThe 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
impl ChargeRequest
Sourcepub fn builder(order: OrderRef, amount: Money) -> ChargeRequestBuilder
pub fn builder(order: OrderRef, amount: Money) -> ChargeRequestBuilder
Starts building a charge.
Trait Implementations§
Source§impl Clone for ChargeRequest
impl Clone for ChargeRequest
Source§fn clone(&self) -> ChargeRequest
fn clone(&self) -> ChargeRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more