Struct yapay_sdk_rust::CheckoutPreferences
source · [−]pub struct CheckoutPreferences { /* private fields */ }
Expand description
Preferences to create your checkout.
[notification_url
] is optional, but highly recommended way to receive payment updates.
[available_payment_methods
] is used to restrict payment options, and can be used with the
set_available_payment_methods
builder.
Implementations
sourceimpl CheckoutPreferences
impl CheckoutPreferences
pub fn new(
order_number: String,
products: Vec<YapayProduct>
) -> Result<Self, SDKError>
sourcepub fn set_available_payment_methods<PM>(self, methods: &[PM]) -> Self where
PM: AsPaymentMethod,
pub fn set_available_payment_methods<PM>(self, methods: &[PM]) -> Self where
PM: AsPaymentMethod,
Restricts payment methods to those used on methods
parameter.
Usage
use std::num::NonZeroU8;
use yapay_sdk_rust::checkout::CheckoutPreferences;
use yapay_sdk_rust::common_types::{AsPaymentMethod, PaymentCreditCard, YapayProduct};
let product = YapayProduct::new(
"sample".to_string(),
"a sample product".to_string(),
NonZeroU8(1).unwrap(),
10_f64,
);
let preferences = CheckoutPreferences::new("order_number".to_string(), vec![product])
.unwrap()
.set_available_payment_methods(&[PaymentCreditCard::payment_methods_all()]);
// now you can only pay with credit cards
pub fn set_notification_url<U>(self, url: U) -> Result<Self, SDKError> where
U: IntoUrl,
sourcepub fn set_process_url<U>(self, url: U) -> Result<Self, SDKError> where
U: IntoUrl,
pub fn set_process_url<U>(self, url: U) -> Result<Self, SDKError> where
U: IntoUrl,
Sets the url_process
, which will redirect the user after payment.
This is the standard way of redirecting, it doesn’t matter if the transaction failed, or was
a success.
You can use this to trigger a response to your server that the user has finished a payment, and now needs to wait for a definitive response.
pub fn to_form(self, token: &str) -> String
Trait Implementations
sourceimpl Clone for CheckoutPreferences
impl Clone for CheckoutPreferences
sourcefn clone(&self) -> CheckoutPreferences
fn clone(&self) -> CheckoutPreferences
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for CheckoutPreferences
impl Debug for CheckoutPreferences
sourceimpl Default for CheckoutPreferences
impl Default for CheckoutPreferences
sourcefn default() -> CheckoutPreferences
fn default() -> CheckoutPreferences
Returns the “default value” for a type. Read more
sourceimpl PartialEq<CheckoutPreferences> for CheckoutPreferences
impl PartialEq<CheckoutPreferences> for CheckoutPreferences
sourcefn eq(&self, other: &CheckoutPreferences) -> bool
fn eq(&self, other: &CheckoutPreferences) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &CheckoutPreferences) -> bool
fn ne(&self, other: &CheckoutPreferences) -> bool
This method tests for !=
.
sourceimpl Serialize for CheckoutPreferences
impl Serialize for CheckoutPreferences
sourceimpl Validate for CheckoutPreferences
impl Validate for CheckoutPreferences
fn validate(&self) -> Result<(), ValidationErrors>
sourceimpl<'v_a> ValidateArgs<'v_a> for CheckoutPreferences
impl<'v_a> ValidateArgs<'v_a> for CheckoutPreferences
type Args = ()
fn validate_args(&self, args: Self::Args) -> Result<(), ValidationErrors>
impl StructuralPartialEq for CheckoutPreferences
Auto Trait Implementations
impl RefUnwindSafe for CheckoutPreferences
impl Send for CheckoutPreferences
impl Sync for CheckoutPreferences
impl Unpin for CheckoutPreferences
impl UnwindSafe for CheckoutPreferences
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more