mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat(router): add expand attempts support in payments retrieve response (#1678)
This commit is contained in:
committed by
GitHub
parent
a6645bd354
commit
8572f1da8e
@ -293,6 +293,56 @@ pub struct PaymentsRequest {
|
||||
pub feature_metadata: Option<FeatureMetadata>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default, Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema,
|
||||
)]
|
||||
pub struct PaymentAttemptResponse {
|
||||
/// Unique identifier for the attempt
|
||||
pub attempt_id: String,
|
||||
/// The status of the attempt
|
||||
#[schema(value_type = AttemptStatus, example = "charged")]
|
||||
pub status: enums::AttemptStatus,
|
||||
/// The payment attempt amount. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,
|
||||
pub amount: i64,
|
||||
/// The currency of the amount of the payment attempt
|
||||
#[schema(value_type = Option<Currency>, example = "usd")]
|
||||
pub currency: Option<enums::Currency>,
|
||||
/// The connector used for the payment
|
||||
pub connector: Option<String>,
|
||||
/// If there was an error while calling the connector the error message is received here
|
||||
pub error_message: Option<String>,
|
||||
/// The payment method that is to be used
|
||||
#[schema(value_type = Option<PaymentMethod>, example = "bank_transfer")]
|
||||
pub payment_method: Option<enums::PaymentMethod>,
|
||||
/// A unique identifier for a payment provided by the connector
|
||||
pub connector_transaction_id: Option<String>,
|
||||
/// This is the instruction for capture/ debit the money from the users' card. On the other hand authorization refers to blocking the amount on the users' payment method.
|
||||
#[schema(value_type = Option<CaptureMethod>, example = "scheduled")]
|
||||
pub capture_method: Option<enums::CaptureMethod>,
|
||||
/// The transaction authentication can be set to undergo payer authentication. By default, the authentication will be marked as NO_THREE_DS
|
||||
#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "three_ds")]
|
||||
pub authentication_type: Option<enums::AuthenticationType>,
|
||||
/// If the payment was cancelled the reason provided here
|
||||
pub cancellation_reason: Option<String>,
|
||||
/// A unique identifier to link the payment to a mandate, can be use instead of payment_method_data
|
||||
pub mandate_id: Option<String>,
|
||||
/// If there was an error while calling the connectors the code is received here
|
||||
pub error_code: Option<String>,
|
||||
/// Provide a reference to a stored payment method
|
||||
pub payment_token: Option<String>,
|
||||
/// additional data related to some connectors
|
||||
pub connector_metadata: Option<serde_json::Value>,
|
||||
/// Payment Experience for the current payment
|
||||
#[schema(value_type = Option<PaymentExperience>, example = "redirect_to_url")]
|
||||
pub payment_experience: Option<enums::PaymentExperience>,
|
||||
/// Payment Method Type
|
||||
#[schema(value_type = Option<PaymentMethodType>, example = "google_pay")]
|
||||
pub payment_method_type: Option<enums::PaymentMethodType>,
|
||||
/// reference to the payment at connector side
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub reference_id: Option<String>,
|
||||
}
|
||||
|
||||
impl PaymentsRequest {
|
||||
pub fn get_feature_metadata_as_value(
|
||||
&self,
|
||||
@ -1362,6 +1412,11 @@ pub struct PaymentsResponse {
|
||||
#[schema(value_type = Option<Vec<DisputeResponsePaymentsRetrieve>>)]
|
||||
pub disputes: Option<Vec<disputes::DisputeResponsePaymentsRetrieve>>,
|
||||
|
||||
/// List of attempts that happened on this intent
|
||||
#[schema(value_type = Option<Vec<PaymentAttemptResponse>>)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub attempts: Option<Vec<PaymentAttemptResponse>>,
|
||||
|
||||
/// A unique identifier to link the payment to a mandate, can be use instead of payment_method_data
|
||||
#[schema(max_length = 255, example = "mandate_iwer89rnjef349dni3")]
|
||||
pub mandate_id: Option<String>,
|
||||
@ -1771,6 +1826,8 @@ pub struct PaymentsRetrieveRequest {
|
||||
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
|
||||
/// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
|
||||
pub client_secret: Option<String>,
|
||||
/// If enabled provides list of attempts linked to payment intent
|
||||
pub expand_attempts: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
@ -2164,6 +2221,8 @@ pub struct PaymentRetrieveBody {
|
||||
pub force_sync: Option<bool>,
|
||||
/// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
|
||||
pub client_secret: Option<String>,
|
||||
/// If enabled provides list of attempts linked to payment intent
|
||||
pub expand_attempts: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
|
||||
Reference in New Issue
Block a user