/// Set of tests to extract billing details from payment method data
/// These are required for backwards compatibility
#[cfg(test)]
mod billing_from_payment_method_data {
#![allow(clippy::unwrap_used)]
use common_enums::CountryAlpha2;
use masking::ExposeOptionInterface;
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[cfg(feature = "v2")]
pub struct BillingConnectorPaymentDetails {
/// Payment Processor Token to process the Revenue Recovery Payment
pub payment_processor_token: String,
/// Billing Connector's Customer Id
pub connector_customer_id: String,
}
// Serialize is required because the api event requires Serialize to be implemented
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
#[cfg(feature = "v2")]
pub struct PaymentsAttemptRecordRequest {
/// The amount details for the payment attempt.
pub amount_details: PaymentAttemptAmountDetails,
code
#[schema(value_type = AttemptStatus, example = "charged")]
pub status: enums::AttemptStatus,
/// The billing details of the payment attempt. This address will be used for invoicing.
pub billing: Option<Address>,
/// The shipping address for the payment attempt.
pub shipping: Option<Address>,
/// Error details provided by the billing processor.
pub error: Option<RecordAttemptErrorDetails>,
/// A description for the payment attempt.
#[schema(example = "It's my first payment request", value_type = Option<String>)]
pub description: Option<common_utils::types::Description>,
/// A unique identifier for a payment provided by the connector.
pub connector_transaction_id: Option<common_utils::types::ConnectorTransactionId>,
/// The payment method type used for payment attempt.
#[schema(value_type = PaymentMethod, example = "bank_transfer")]
pub payment_method_type: api_enums::PaymentMethod,
/// The name of the payment connector through which the payment attempt was made.
#[schema(value_type = Option<Connector>, example = "stripe")]
pub connector: Option<common_enums::connector_enums::Connector>,
/// Billing connector id to update the invoices.
#[schema(value_type = String, example = "mca_1234567890")]
pub billing_connector_id: id_type::MerchantConnectorAccountId,
/// Billing connector id to update the invoices.
#[schema(value_type = String, example = "mca_1234567890")]
pub payment_merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
/// The payment method subtype to be used for the payment. This should match with the `payment_method_data` provided
#[schema(value_type = PaymentMethodType, example = "apple_pay")]
pub payment_method_subtype: api_enums::PaymentMethodType,
/// The payment instrument data to be used for the payment attempt.
pub payment_method_data: Option<PaymentMethodDataRequest>,
/// Metadata is useful for storing additional, unstructured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "udf1": "some-value", "udf2": "some-value" }"#)]
pub metadata: Option<pii::SecretSerdeValue>,
/// Additional data that might be required by hyperswitch based on the requested features by the merchants.
pub feature_metadata: Option<PaymentAttemptFeatureMetadata>,
/// The time at which payment attempt was created.
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub transaction_created_at: Option<PrimitiveDateTime>,
/// payment method token at payment processor end.
#[schema(value_type = String, example = "1234567890")]
pub processor_payment_method_token: String,
/// customer id at payment connector for which mandate is attached.
#[schema(value_type = String, example = "cust_12345")]
pub connector_customer_id: String,
/// Number of attempts made for invoice
#[schema(value_type = Option<u16>, example = 1)]
pub retry_count: Option<u16>,
/// Next Billing time of the Invoice
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub invoice_next_billing_time: Option<PrimitiveDateTime>,
/// source where the payment was triggered by
#[schema(value_type = TriggeredBy, example = "internal" )]
pub triggered_by: common_enums::TriggeredBy,
#[schema(value_type = CardNetwork, example = "Visa" )]
/// card_network
pub card_network: Option<common_enums::CardNetwork>,
#[schema(example = "Chase")]
/// Card Issuer
pub card_issuer: Option<String>,
}
/// Error details for the payment
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
pub struct RecordAttemptErrorDetails {
/// error code sent by billing connector.
pub code: String,
/// error message sent by billing connector.
pub message: String,
/// This field can be returned for both approved and refused Mastercard payments.
/// This code provides additional information about the type of transaction or the reason why the payment failed.
/// If the payment failed, the network advice code gives guidance on if and when you can retry the payment.
pub network_advice_code: Option,
/// For card errors resulting from a card issuer decline, a brand specific 2, 3, or 4 digit code which indicates the reason the authorization failed.
pub network_decline_code: Option,
/// A string indicating how to proceed with an network error if payment gateway provide one. This is used to understand the network error code better.
pub network_error_message: Option,
}