Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(router): aggregate hotfixes for v0.5.10 (#1204)

ItsMeShashank9cc1ceec6986
diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs
index b9052a754e..0f02e7db3d 100644
--- a/crates/api_models/src/webhooks.rs
+++ b/crates/api_models/src/webhooks.rs
@@ -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,
diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs
index a3eae55705..d5a8ec6f2e 100644
--- a/crates/router/src/connector/checkout.rs
+++ b/crates/router/src/connector/checkout.rs
@@ -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)?;
diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs
index 662a4dfe7c..ce543fcee7 100644
--- a/crates/router/src/connector/checkout/transformers.rs
+++ b/crates/router/src/connector/checkout/transformers.rs
@@ -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,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index ce26fc1fd4..9a5bce92d9 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -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
diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs
index 234128e6dc..3c7b774d3e 100644
--- a/crates/router/src/core/webhooks.rs
+++ b/crates/router/src/core/webhooks.rs
@@ -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,