use serde_derive::{Deserialize, Serialize};
use crate::config::{Client, Response};
use crate::ids::{SetupAttemptId, SetupIntentId};
use crate::params::{Expand, Expandable, List, Object, RangeQuery, Timestamp};
use crate::resources::{
Account, ApiErrors, Application, Customer, Mandate, PaymentMethod, SetupIntent,
ThreeDSecureDetails,
};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttempt {
pub id: SetupAttemptId,
#[serde(skip_serializing_if = "Option::is_none")]
pub application: Option<Expandable<Application>>,
pub created: Timestamp,
#[serde(skip_serializing_if = "Option::is_none")]
pub customer: Option<Expandable<Customer>>,
pub livemode: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub on_behalf_of: Option<Expandable<Account>>,
pub payment_method: Expandable<PaymentMethod>,
pub payment_method_details: SetupAttemptPaymentMethodDetails,
#[serde(skip_serializing_if = "Option::is_none")]
pub setup_error: Option<ApiErrors>,
pub setup_intent: Expandable<SetupIntent>,
pub status: String,
pub usage: String,
}
impl SetupAttempt {
pub fn list(client: &Client, params: ListSetupAttempts<'_>) -> Response<List<SetupAttempt>> {
client.get_query("/setup_attempts", ¶ms)
}
}
impl Object for SetupAttempt {
type Id = SetupAttemptId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"setup_attempt"
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetails {
#[serde(skip_serializing_if = "Option::is_none")]
pub au_becs_debit: Option<SetupAttemptPaymentMethodDetailsAuBecsDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bacs_debit: Option<SetupAttemptPaymentMethodDetailsBacsDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bancontact: Option<SetupAttemptPaymentMethodDetailsBancontact>,
#[serde(skip_serializing_if = "Option::is_none")]
pub card: Option<SetupAttemptPaymentMethodDetailsCard>,
#[serde(skip_serializing_if = "Option::is_none")]
pub card_present: Option<SetupAttemptPaymentMethodDetailsCardPresent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ideal: Option<SetupAttemptPaymentMethodDetailsIdeal>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sepa_debit: Option<SetupAttemptPaymentMethodDetailsSepaDebit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sofort: Option<SetupAttemptPaymentMethodDetailsSofort>,
#[serde(rename = "type")]
pub type_: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsAuBecsDebit {}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBacsDebit {}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsBancontact {
#[serde(skip_serializing_if = "Option::is_none")]
pub bank_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bank_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bic: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub iban_last4: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_language: Option<SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsCard {
#[serde(skip_serializing_if = "Option::is_none")]
pub three_d_secure: Option<ThreeDSecureDetails>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsCardPresent {
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_card: Option<Expandable<PaymentMethod>>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsIdeal {
#[serde(skip_serializing_if = "Option::is_none")]
pub bank: Option<SetupAttemptPaymentMethodDetailsIdealBank>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bic: Option<SetupAttemptPaymentMethodDetailsIdealBic>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub iban_last4: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsSepaDebit {}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetupAttemptPaymentMethodDetailsSofort {
#[serde(skip_serializing_if = "Option::is_none")]
pub bank_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bank_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bic: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit: Option<Expandable<PaymentMethod>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_sepa_debit_mandate: Option<Expandable<Mandate>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub iban_last4: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_language: Option<SetupAttemptPaymentMethodDetailsSofortPreferredLanguage>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_name: Option<String>,
}
#[derive(Clone, Debug, Serialize)]
pub struct ListSetupAttempts<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created: Option<RangeQuery<Timestamp>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ending_before: Option<SetupAttemptId>,
#[serde(skip_serializing_if = "Expand::is_empty")]
pub expand: &'a [&'a str],
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,
pub setup_intent: SetupIntentId,
#[serde(skip_serializing_if = "Option::is_none")]
pub starting_after: Option<SetupAttemptId>,
}
impl<'a> ListSetupAttempts<'a> {
pub fn new(setup_intent: SetupIntentId) -> Self {
ListSetupAttempts {
created: Default::default(),
ending_before: Default::default(),
expand: Default::default(),
limit: Default::default(),
setup_intent,
starting_after: Default::default(),
}
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
De,
En,
Fr,
Nl,
}
impl SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::De => "de",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::En => "en",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::Fr => "fr",
SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::Nl => "nl",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsIdealBank {
AbnAmro,
AsnBank,
Bunq,
Handelsbanken,
Ing,
Knab,
Moneyou,
Rabobank,
Regiobank,
Revolut,
SnsBank,
TriodosBank,
VanLanschot,
}
impl SetupAttemptPaymentMethodDetailsIdealBank {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsIdealBank::AbnAmro => "abn_amro",
SetupAttemptPaymentMethodDetailsIdealBank::AsnBank => "asn_bank",
SetupAttemptPaymentMethodDetailsIdealBank::Bunq => "bunq",
SetupAttemptPaymentMethodDetailsIdealBank::Handelsbanken => "handelsbanken",
SetupAttemptPaymentMethodDetailsIdealBank::Ing => "ing",
SetupAttemptPaymentMethodDetailsIdealBank::Knab => "knab",
SetupAttemptPaymentMethodDetailsIdealBank::Moneyou => "moneyou",
SetupAttemptPaymentMethodDetailsIdealBank::Rabobank => "rabobank",
SetupAttemptPaymentMethodDetailsIdealBank::Regiobank => "regiobank",
SetupAttemptPaymentMethodDetailsIdealBank::Revolut => "revolut",
SetupAttemptPaymentMethodDetailsIdealBank::SnsBank => "sns_bank",
SetupAttemptPaymentMethodDetailsIdealBank::TriodosBank => "triodos_bank",
SetupAttemptPaymentMethodDetailsIdealBank::VanLanschot => "van_lanschot",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsIdealBank {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBank {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsIdealBic {
#[serde(rename = "ABNANL2A")]
Abnanl2a,
#[serde(rename = "ASNBNL21")]
Asnbnl21,
#[serde(rename = "BUNQNL2A")]
Bunqnl2a,
#[serde(rename = "FVLBNL22")]
Fvlbnl22,
#[serde(rename = "HANDNL2A")]
Handnl2a,
#[serde(rename = "INGBNL2A")]
Ingbnl2a,
#[serde(rename = "KNABNL2H")]
Knabnl2h,
#[serde(rename = "MOYONL21")]
Moyonl21,
#[serde(rename = "RABONL2U")]
Rabonl2u,
#[serde(rename = "RBRBNL21")]
Rbrbnl21,
#[serde(rename = "REVOLT21")]
Revolt21,
#[serde(rename = "SNSBNL2A")]
Snsbnl2a,
#[serde(rename = "TRIONL2U")]
Trionl2u,
}
impl SetupAttemptPaymentMethodDetailsIdealBic {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsIdealBic::Abnanl2a => "ABNANL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Asnbnl21 => "ASNBNL21",
SetupAttemptPaymentMethodDetailsIdealBic::Bunqnl2a => "BUNQNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Fvlbnl22 => "FVLBNL22",
SetupAttemptPaymentMethodDetailsIdealBic::Handnl2a => "HANDNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Ingbnl2a => "INGBNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Knabnl2h => "KNABNL2H",
SetupAttemptPaymentMethodDetailsIdealBic::Moyonl21 => "MOYONL21",
SetupAttemptPaymentMethodDetailsIdealBic::Rabonl2u => "RABONL2U",
SetupAttemptPaymentMethodDetailsIdealBic::Rbrbnl21 => "RBRBNL21",
SetupAttemptPaymentMethodDetailsIdealBic::Revolt21 => "REVOLT21",
SetupAttemptPaymentMethodDetailsIdealBic::Snsbnl2a => "SNSBNL2A",
SetupAttemptPaymentMethodDetailsIdealBic::Trionl2u => "TRIONL2U",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsIdealBic {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsIdealBic {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
De,
En,
Fr,
Nl,
}
impl SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
pub fn as_str(self) -> &'static str {
match self {
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::De => "de",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::En => "en",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::Fr => "fr",
SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::Nl => "nl",
}
}
}
impl AsRef<str> for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}