mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +08:00
fix(router): aggregate hotfixes for v0.5.10 (#1204)
Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in> Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com> Co-authored-by: SamraatBansal <samraatbansal7@gmail.com> Co-authored-by: sai-harsha-vardhan <harsha111hero@gmail.com> Co-authored-by: Sangamesh Kulkarni <59434228+Sangamesh26@users.noreply.github.com>
This commit is contained in:
@ -41,7 +41,7 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
|
||||
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
|
||||
IncomingWebhookEvent::PaymentIntentProcessing => Self::Payment,
|
||||
IncomingWebhookEvent::PaymentActionRequired => Self::Payment,
|
||||
IncomingWebhookEvent::EventNotSupported => Self::Payment,
|
||||
IncomingWebhookEvent::EventNotSupported => Self::ReturnResponse,
|
||||
IncomingWebhookEvent::RefundSuccess => Self::Refund,
|
||||
IncomingWebhookEvent::RefundFailure => Self::Refund,
|
||||
IncomingWebhookEvent::DisputeOpened => Self::Dispute,
|
||||
|
||||
@ -1125,7 +1125,7 @@ impl api::IncomingWebhook for Checkout {
|
||||
&self,
|
||||
request: &api::IncomingWebhookRequestDetails<'_>,
|
||||
) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {
|
||||
let details: checkout::CheckoutWebhookBody = request
|
||||
let details: checkout::CheckoutWebhookEventTypeBody = request
|
||||
.body
|
||||
.parse_struct("CheckoutWebhookBody")
|
||||
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
|
||||
|
||||
@ -702,6 +702,12 @@ pub fn is_chargeback_event(event_code: &CheckoutTransactionType) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutWebhookEventTypeBody {
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: CheckoutTransactionType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutWebhookData {
|
||||
pub id: String,
|
||||
@ -710,6 +716,7 @@ pub struct CheckoutWebhookData {
|
||||
pub amount: i32,
|
||||
pub currency: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CheckoutWebhookBody {
|
||||
#[serde(rename = "type")]
|
||||
@ -741,7 +748,10 @@ pub struct CheckoutDisputeWebhookBody {
|
||||
#[derive(Debug, Deserialize, strum::Display, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CheckoutTransactionType {
|
||||
AuthenticationStarted,
|
||||
AuthenticationApproved,
|
||||
PaymentApproved,
|
||||
PaymentCaptured,
|
||||
PaymentDeclined,
|
||||
PaymentRefunded,
|
||||
PaymentRefundDeclined,
|
||||
@ -761,7 +771,10 @@ pub enum CheckoutTransactionType {
|
||||
impl From<CheckoutTransactionType> for api::IncomingWebhookEvent {
|
||||
fn from(transaction_type: CheckoutTransactionType) -> Self {
|
||||
match transaction_type {
|
||||
CheckoutTransactionType::PaymentApproved => Self::PaymentIntentSuccess,
|
||||
CheckoutTransactionType::AuthenticationStarted => Self::EventNotSupported,
|
||||
CheckoutTransactionType::AuthenticationApproved => Self::EventNotSupported,
|
||||
CheckoutTransactionType::PaymentApproved => Self::EventNotSupported,
|
||||
CheckoutTransactionType::PaymentCaptured => Self::PaymentIntentSuccess,
|
||||
CheckoutTransactionType::PaymentDeclined => Self::PaymentIntentFailure,
|
||||
CheckoutTransactionType::PaymentRefunded => Self::RefundSuccess,
|
||||
CheckoutTransactionType::PaymentRefundDeclined => Self::RefundFailure,
|
||||
|
||||
@ -1128,6 +1128,18 @@ pub fn connector_selection<F>(
|
||||
where
|
||||
F: Send + Clone,
|
||||
{
|
||||
if let Some(ref connector_name) = payment_data.payment_attempt.connector {
|
||||
let connector_data = api::ConnectorData::get_connector_by_name(
|
||||
&state.conf.connectors,
|
||||
connector_name,
|
||||
api::GetToken::Connector,
|
||||
)
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("invalid connector name received in payment attempt")?;
|
||||
|
||||
return Ok(api::ConnectorCallType::Single(connector_data));
|
||||
}
|
||||
|
||||
let mut routing_data = storage::RoutingData {
|
||||
routed_through: payment_data.payment_attempt.connector.clone(),
|
||||
algorithm: payment_data
|
||||
|
||||
@ -26,7 +26,7 @@ use crate::{
|
||||
const OUTGOING_WEBHOOK_TIMEOUT_SECS: u64 = 5;
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn payments_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
pub async fn payments_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
state: AppState,
|
||||
merchant_account: storage::MerchantAccount,
|
||||
webhook_details: api::IncomingWebhookDetails,
|
||||
@ -95,7 +95,7 @@ async fn payments_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn refunds_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
pub async fn refunds_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
state: AppState,
|
||||
merchant_account: storage::MerchantAccount,
|
||||
webhook_details: api::IncomingWebhookDetails,
|
||||
@ -196,7 +196,7 @@ async fn refunds_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_payment_attempt_from_object_reference_id(
|
||||
pub async fn get_payment_attempt_from_object_reference_id(
|
||||
state: AppState,
|
||||
object_reference_id: api_models::webhooks::ObjectReferenceId,
|
||||
merchant_account: &storage::MerchantAccount,
|
||||
@ -223,7 +223,7 @@ async fn get_payment_attempt_from_object_reference_id(
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_or_update_dispute_object(
|
||||
pub async fn get_or_update_dispute_object(
|
||||
state: AppState,
|
||||
option_dispute: Option<storage_models::dispute::Dispute>,
|
||||
dispute_details: api::disputes::DisputePayload,
|
||||
@ -295,7 +295,7 @@ async fn get_or_update_dispute_object(
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn disputes_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
pub async fn disputes_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
state: AppState,
|
||||
merchant_account: storage::MerchantAccount,
|
||||
webhook_details: api::IncomingWebhookDetails,
|
||||
@ -361,7 +361,7 @@ async fn disputes_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[instrument(skip_all)]
|
||||
async fn create_event_and_trigger_outgoing_webhook<W: api::OutgoingWebhookType>(
|
||||
pub async fn create_event_and_trigger_outgoing_webhook<W: api::OutgoingWebhookType>(
|
||||
state: AppState,
|
||||
merchant_account: storage::MerchantAccount,
|
||||
event_type: enums::EventType,
|
||||
@ -413,7 +413,7 @@ async fn create_event_and_trigger_outgoing_webhook<W: api::OutgoingWebhookType>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn trigger_webhook_to_merchant<W: api::OutgoingWebhookType>(
|
||||
pub async fn trigger_webhook_to_merchant<W: api::OutgoingWebhookType>(
|
||||
merchant_account: storage::MerchantAccount,
|
||||
webhook: api::OutgoingWebhook,
|
||||
state: &AppState,
|
||||
|
||||
Reference in New Issue
Block a user