mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(core): add support for expand attempt list in psync v2 (#7209)
Co-authored-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-N7WRTY72X7.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -656,6 +656,30 @@ pub struct PaymentAmountDetailsResponse {
|
||||
pub amount_captured: Option<MinorUnit>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)]
|
||||
|
||||
pub struct PaymentAttemptAmountDetails {
|
||||
/// The total amount of the order including tax, surcharge and shipping cost
|
||||
pub net_amount: MinorUnit,
|
||||
/// The amount that was requested to be captured for this payment
|
||||
pub amount_to_capture: Option<MinorUnit>,
|
||||
/// Surcharge amount for the payment attempt.
|
||||
/// This is either derived by surcharge rules, or sent by the merchant
|
||||
pub surcharge_amount: Option<MinorUnit>,
|
||||
/// Tax amount for the payment attempt
|
||||
/// This is either derived by surcharge rules, or sent by the merchant
|
||||
pub tax_on_surcharge: Option<MinorUnit>,
|
||||
/// The total amount that can be captured for this payment attempt.
|
||||
pub amount_capturable: MinorUnit,
|
||||
/// Shipping cost for the payment attempt.
|
||||
/// Shipping cost for the payment attempt.
|
||||
pub shipping_cost: Option<MinorUnit>,
|
||||
/// Tax amount for the order.
|
||||
/// This is either derived by calling an external tax processor, or sent by the merchant
|
||||
pub order_tax_amount: Option<MinorUnit>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl AmountDetails {
|
||||
pub fn new(amount_details_setter: AmountDetailsSetter) -> Self {
|
||||
@ -1313,6 +1337,7 @@ impl RequestSurchargeDetails {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
#[derive(Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema)]
|
||||
pub struct PaymentAttemptResponse {
|
||||
/// Unique identifier for the attempt
|
||||
@ -1381,6 +1406,78 @@ pub struct PaymentAttemptResponse {
|
||||
pub client_version: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema)]
|
||||
pub struct PaymentAttemptResponse {
|
||||
/// The global identifier for the payment attempt
|
||||
#[schema(value_type = String)]
|
||||
pub id: id_type::GlobalAttemptId,
|
||||
/// /// The status of the attempt
|
||||
#[schema(value_type = AttemptStatus, example = "charged")]
|
||||
pub status: enums::AttemptStatus,
|
||||
/// Amount related information for this payment and attempt
|
||||
pub amount: PaymentAttemptAmountDetails,
|
||||
/// Name of the connector that was used for the payment attempt.
|
||||
#[schema(example = "stripe")]
|
||||
pub connector: Option<String>,
|
||||
|
||||
/// Error details for the payment if any
|
||||
pub error: Option<ErrorDetails>,
|
||||
|
||||
/// The transaction authentication can be set to undergo payer authentication. By default, the authentication will be marked as NO_THREE_DS, as the 3DS method helps with more robust payer authentication
|
||||
#[schema(value_type = AuthenticationType, example = "no_three_ds", default = "three_ds")]
|
||||
pub authentication_type: api_enums::AuthenticationType,
|
||||
|
||||
/// Date and time of Payment attempt creation
|
||||
#[serde(with = "common_utils::custom_serde::iso8601")]
|
||||
pub created_at: PrimitiveDateTime,
|
||||
|
||||
/// Time at which the payment attempt was last modified
|
||||
#[serde(with = "common_utils::custom_serde::iso8601")]
|
||||
pub modified_at: PrimitiveDateTime,
|
||||
|
||||
/// The reason for the cancellation of the payment attempt. Some connectors will have strict rules regarding the values this can have
|
||||
/// Cancellation reason will be validated at the connector level when building the request
|
||||
pub cancellation_reason: Option<String>,
|
||||
|
||||
/// Payment token is the token used for temporary use in case the payment method is stored in vault
|
||||
#[schema(example = "187282ab-40ef-47a9-9206-5099ba31e432")]
|
||||
pub payment_token: Option<String>,
|
||||
|
||||
/// Additional data related to some connectors
|
||||
#[schema(value_type = Option<ConnectorMetadata>)]
|
||||
pub connector_metadata: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// Payment Experience for the current payment
|
||||
#[schema(value_type = Option<PaymentExperience>, example = "redirect_to_url")]
|
||||
pub payment_experience: Option<enums::PaymentExperience>,
|
||||
|
||||
/// Payment method type for the payment attempt
|
||||
#[schema(value_type = Option<PaymentMethod>, example = "wallet")]
|
||||
pub payment_method_type: common_enums::PaymentMethod,
|
||||
|
||||
/// reference(Identifier) to the payment at connector side
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_reference_id: Option<String>,
|
||||
|
||||
/// The payment method subtype for the payment attempt.
|
||||
#[schema(value_type = Option<PaymentMethodType>, example = "apple_pay")]
|
||||
pub payment_method_subtype: Option<api_enums::PaymentMethodType>,
|
||||
|
||||
/// A unique identifier for a payment provided by the connector
|
||||
#[schema(value_type = Option<String>, example = "993672945374576J")]
|
||||
pub connector_payment_id: Option<String>,
|
||||
|
||||
/// Identifier for Payment Method used for the payment attempt
|
||||
#[schema(value_type = Option<String>, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]
|
||||
pub payment_method_id: Option<id_type::GlobalPaymentMethodId>,
|
||||
|
||||
/// Value passed in X-CLIENT-SOURCE header during payments confirm request by the client
|
||||
pub client_source: Option<String>,
|
||||
/// Value passed in X-CLIENT-VERSION header during payments confirm request by the client
|
||||
pub client_version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default, Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema,
|
||||
)]
|
||||
@ -5069,7 +5166,10 @@ pub struct PaymentsRetrieveRequest {
|
||||
/// If this is set to true, the status will be fetched from the connector
|
||||
#[serde(default)]
|
||||
pub force_sync: bool,
|
||||
|
||||
/// A boolean used to indicate if all the attempts needs to be fetched for the intent.
|
||||
/// If this is set to true, attempts list will be available in the response.
|
||||
#[serde(default)]
|
||||
pub expand_attempts: bool,
|
||||
/// These are the query params that are sent in case of redirect response.
|
||||
/// These can be ingested by the connector to take necessary actions.
|
||||
pub param: Option<String>,
|
||||
@ -5077,7 +5177,7 @@ pub struct PaymentsRetrieveRequest {
|
||||
|
||||
/// Error details for the payment
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
|
||||
#[derive(Debug, serde::Serialize, Clone, PartialEq, ToSchema)]
|
||||
pub struct ErrorDetails {
|
||||
/// The error code
|
||||
pub code: String,
|
||||
@ -5259,6 +5359,9 @@ pub struct PaymentsRetrieveResponse {
|
||||
|
||||
/// The billing address associated with the payment intent
|
||||
pub billing: Option<Address>,
|
||||
|
||||
/// List of payment attempts associated with payment intent
|
||||
pub attempts: Option<Vec<PaymentAttemptResponse>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user