use iso_currency::Currency; use rust_decimal::Decimal; use serde::Serialize; //Why are these few in snake_case but rest is camelCase? #[derive(Serialize, Debug, Clone)] pub struct CheckoutCalculateTaxesResponse { #[serde(with = "rust_decimal::serde::float")] pub shipping_price_gross_amount: Decimal, #[serde(with = "rust_decimal::serde::float")] pub shipping_price_net_amount: Decimal, #[serde(with = "rust_decimal::serde::float")] pub shipping_tax_rate: Decimal, pub lines: Vec, } #[derive(Serialize, Debug, Clone)] pub struct LinesResponse { #[serde(with = "rust_decimal::serde::float")] pub total_gross_amount: Decimal, #[serde(with = "rust_decimal::serde::float")] pub total_net_amount: Decimal, #[serde(with = "rust_decimal::serde::float")] pub tax_rate: Decimal, } #[derive(Serialize, Debug, Clone)] pub struct CheckoutFilterShippingMethodsResponse { pub excluded_methods: Vec, } #[derive(Serialize, Debug, Clone)] pub struct ExcludedMethodsResponse { pub id: String, pub reason: Option, } #[derive(Serialize, Debug, Clone)] pub struct OrderCalculateTaxes(CheckoutCalculateTaxesResponse); #[derive(Serialize, Debug, Clone)] pub struct OrderFilterShippingMethods(CheckoutFilterShippingMethodsResponse); #[derive(Serialize, Debug, Clone)] pub struct ShippingListMethodsForCheckout(Vec); #[derive(Serialize, Debug, Clone)] struct ShippingListMethodsForCheckoutVec { pub id: String, pub name: Option, #[serde(with = "rust_decimal::serde::float")] pub amount: Decimal, pub currency: String, pub maximum_delivery_days: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum ChargeRequestedResult { ChargeSuccess, ChargeFailure, } #[derive(Serialize, Debug, Clone)] pub struct TransactionChargeRequestedResponse { pub psp_reference: String, pub result: Option, #[serde(with = "rust_decimal::serde::float_option")] pub amount: Option, pub time: Option, pub external_url: Option, pub message: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum RefundRequestedResult { RefundSuccess, RefundFailure, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct TransactionRefundRequestedResponse { pub psp_reference: String, pub result: Option, #[serde(with = "rust_decimal::serde::float_option")] pub amount: Option, pub time: Option, pub external_url: Option, pub message: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum CancelationRequestedResult { CancelSuccess, CancelFailure, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct TransactionCancelationRequestedResponse { pub psp_reference: String, pub result: Option, #[serde(with = "rust_decimal::serde::float_option")] pub amount: Option, pub time: Option, pub external_url: Option, pub message: Option, } #[derive(Serialize, Debug, Clone)] pub struct PaymentGatewayInitializeSessionResponse { pub data: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum TransactionSessionResult { ChargeSuccess, ChargeFailure, ChargeRequested, ChargeActionRequired, AuthorizationSuccess, AuthorizationFailure, AuthorizationRequested, AuthorizationActionRequired, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct TransactionInitializeSessionResponse { pub psp_reference: Option, pub data: Option, pub result: TransactionSessionResult, #[serde(with = "rust_decimal::serde::float")] pub amount: Decimal, pub time: Option, pub external_url: Option, pub message: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct TransactionProcessSessionResponse { pub psp_reference: Option, pub data: Option, pub result: TransactionSessionResult, #[serde(with = "rust_decimal::serde::float")] pub amount: Decimal, pub time: Option, pub external_url: Option, pub message: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum PaymentMethodTokenizationResult { SucessfullyTokenized, AdditionalActionRequired, Pending, FailedToTokenize, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct PaymentMethodProcessTokenizationSession { pub result: PaymentMethodTokenizationResult, /** Should be present when `PaymentMethodTokenizationResult::{SuccessfullyTokenized && AdditionalActionRequired}` */ pub id: Option, pub data: Option, pub error: Option, } #[derive(Serialize, Debug, Clone)] pub struct PaymentMethodInitializeTokenizationSession( PaymentMethodProcessTokenizationSession, ); #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum PaymentGatewayTokenisationResult { SuccessfullyInitialized, FailedToInitialize, } #[derive(Serialize, Debug, Clone)] pub struct PaymentGatewayInitializeTokenizationSession { pub result: PaymentGatewayTokenisationResult, pub data: Option, pub error: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum StoredPaymentMethodDeleteResult { SucessfullyDeleted, FailedToDelete, } #[derive(Serialize, Debug, Clone)] pub struct StoredPaymentMethodDeleteRequested { pub result: StoredPaymentMethodDeleteResult, pub error: Option, } //TODO: Dahek is Array<"INTERACTIVE"> from app-sdk/../sync-webhook-response-builder.ts:LIST_STORED_PAYMENT_METHODS? #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct PaymentMethod { pub id: String, pub supported_payment_flows: Vec, #[serde(rename = "type")] pub typ: String, pub credit_card_info: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct CreditCardInfo { pub brand: String, pub last_digits: String, pub exp_month: String, pub exp_year: String, pub first_digits: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ListStoredPaymentMethodsResponse { pub payment_methods: Vec>, pub name: Option, pub data: Option, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct PaymentGateway { pub id: String, pub name: String, pub currencies: Vec, pub config: Vec, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ConfigMap { field: String, value: serde_json::Value, } #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct PaymentListGatewaysResponse(pub Vec);