use crate::ids::{TreasuryOutboundPaymentId};
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{Currency, TreasurySharedResourceBillingDetails, TreasuryTransaction};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryOutboundPayment {
pub id: TreasuryOutboundPaymentId,
pub amount: i64,
pub cancelable: bool,
pub created: Timestamp,
pub currency: Currency,
pub customer: Option<String>,
pub description: Option<String>,
pub destination_payment_method: Option<String>,
pub destination_payment_method_details: Option<OutboundPaymentsPaymentMethodDetails>,
pub end_user_details: Option<TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails>,
pub expected_arrival_date: Timestamp,
pub financial_account: String,
pub hosted_regulatory_receipt_url: Option<String>,
pub livemode: bool,
pub metadata: Metadata,
pub returned_details: Option<TreasuryOutboundPaymentsResourceReturnedStatus>,
pub statement_descriptor: String,
pub status: TreasuryOutboundPaymentStatus,
pub status_transitions: TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions,
pub transaction: Expandable<TreasuryTransaction>,
}
impl Object for TreasuryOutboundPayment {
type Id = TreasuryOutboundPaymentId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"treasury.outbound_payment"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct OutboundPaymentsPaymentMethodDetails {
pub billing_details: TreasurySharedResourceBillingDetails,
#[serde(skip_serializing_if = "Option::is_none")]
pub financial_account: Option<OutboundPaymentsPaymentMethodDetailsFinancialAccount>,
#[serde(rename = "type")]
pub type_: OutboundPaymentsPaymentMethodDetailsType,
#[serde(skip_serializing_if = "Option::is_none")]
pub us_bank_account: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccount>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct OutboundPaymentsPaymentMethodDetailsFinancialAccount {
pub id: String,
pub network: OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccount {
pub account_holder_type: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType>,
pub account_type: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType>,
pub bank_name: Option<String>,
pub fingerprint: Option<String>,
pub last4: Option<String>,
pub network: OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork,
pub routing_number: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails {
pub ip_address: Option<String>,
pub present: bool,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions {
pub canceled_at: Option<Timestamp>,
pub failed_at: Option<Timestamp>,
pub posted_at: Option<Timestamp>,
pub returned_at: Option<Timestamp>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TreasuryOutboundPaymentsResourceReturnedStatus {
pub code: TreasuryOutboundPaymentsResourceReturnedStatusCode,
pub transaction: Expandable<TreasuryTransaction>,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork {
Stripe,
}
impl OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork {
pub fn as_str(self) -> &'static str {
match self {
OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork::Stripe => "stripe",
}
}
}
impl AsRef<str> for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork {
fn default() -> Self {
Self::Stripe
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OutboundPaymentsPaymentMethodDetailsType {
FinancialAccount,
UsBankAccount,
}
impl OutboundPaymentsPaymentMethodDetailsType {
pub fn as_str(self) -> &'static str {
match self {
OutboundPaymentsPaymentMethodDetailsType::FinancialAccount => "financial_account",
OutboundPaymentsPaymentMethodDetailsType::UsBankAccount => "us_bank_account",
}
}
}
impl AsRef<str> for OutboundPaymentsPaymentMethodDetailsType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for OutboundPaymentsPaymentMethodDetailsType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for OutboundPaymentsPaymentMethodDetailsType {
fn default() -> Self {
Self::FinancialAccount
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType {
Company,
Individual,
}
impl OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType {
pub fn as_str(self) -> &'static str {
match self {
OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType::Company => "company",
OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType::Individual => "individual",
}
}
}
impl AsRef<str> for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType {
fn default() -> Self {
Self::Company
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType {
Checking,
Savings,
}
impl OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType {
pub fn as_str(self) -> &'static str {
match self {
OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType::Checking => "checking",
OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType::Savings => "savings",
}
}
}
impl AsRef<str> for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType {
fn default() -> Self {
Self::Checking
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork {
Ach,
UsDomesticWire,
}
impl OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork {
pub fn as_str(self) -> &'static str {
match self {
OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork::Ach => "ach",
OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork::UsDomesticWire => "us_domestic_wire",
}
}
}
impl AsRef<str> for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork {
fn default() -> Self {
Self::Ach
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryOutboundPaymentStatus {
Canceled,
Failed,
Posted,
Processing,
Returned,
}
impl TreasuryOutboundPaymentStatus {
pub fn as_str(self) -> &'static str {
match self {
TreasuryOutboundPaymentStatus::Canceled => "canceled",
TreasuryOutboundPaymentStatus::Failed => "failed",
TreasuryOutboundPaymentStatus::Posted => "posted",
TreasuryOutboundPaymentStatus::Processing => "processing",
TreasuryOutboundPaymentStatus::Returned => "returned",
}
}
}
impl AsRef<str> for TreasuryOutboundPaymentStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryOutboundPaymentStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryOutboundPaymentStatus {
fn default() -> Self {
Self::Canceled
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TreasuryOutboundPaymentsResourceReturnedStatusCode {
AccountClosed,
AccountFrozen,
BankAccountRestricted,
BankOwnershipChanged,
Declined,
IncorrectAccountHolderName,
InvalidAccountNumber,
InvalidCurrency,
NoAccount,
Other,
}
impl TreasuryOutboundPaymentsResourceReturnedStatusCode {
pub fn as_str(self) -> &'static str {
match self {
TreasuryOutboundPaymentsResourceReturnedStatusCode::AccountClosed => "account_closed",
TreasuryOutboundPaymentsResourceReturnedStatusCode::AccountFrozen => "account_frozen",
TreasuryOutboundPaymentsResourceReturnedStatusCode::BankAccountRestricted => "bank_account_restricted",
TreasuryOutboundPaymentsResourceReturnedStatusCode::BankOwnershipChanged => "bank_ownership_changed",
TreasuryOutboundPaymentsResourceReturnedStatusCode::Declined => "declined",
TreasuryOutboundPaymentsResourceReturnedStatusCode::IncorrectAccountHolderName => "incorrect_account_holder_name",
TreasuryOutboundPaymentsResourceReturnedStatusCode::InvalidAccountNumber => "invalid_account_number",
TreasuryOutboundPaymentsResourceReturnedStatusCode::InvalidCurrency => "invalid_currency",
TreasuryOutboundPaymentsResourceReturnedStatusCode::NoAccount => "no_account",
TreasuryOutboundPaymentsResourceReturnedStatusCode::Other => "other",
}
}
}
impl AsRef<str> for TreasuryOutboundPaymentsResourceReturnedStatusCode {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TreasuryOutboundPaymentsResourceReturnedStatusCode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TreasuryOutboundPaymentsResourceReturnedStatusCode {
fn default() -> Self {
Self::AccountClosed
}
}