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

refactor(fix): [DLocal] Fix bug in DLocal (#1423)

AkshayaFoiger4626ad1707bb
diff --git a/crates/router/src/connector/dlocal/transformers.rs b/crates/router/src/connector/dlocal/transformers.rs
index 8e084635f0..a330a74662 100644
--- a/crates/router/src/connector/dlocal/transformers.rs
+++ b/crates/router/src/connector/dlocal/transformers.rs
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
- connector::utils::{AddressDetailsData, RouterData},
+ connector::utils::{AddressDetailsData, PaymentsAuthorizeRequestData, RouterData},
core::errors,
services,
types::{self, api, storage::enums},
@@ -63,6 +63,7 @@ pub struct DlocalPaymentsRequest {
pub order_id: String,
pub three_dsecure: Option<ThreeDSecureReqData>,
pub callback_url: Option<String>,
+ pub description: Option<String>,
}
impl TryFrom<&types::PaymentsAuthorizeRouterData> for DlocalPaymentsRequest {
@@ -112,7 +113,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for DlocalPaymentsRequest {
}
storage_models::enums::AuthenticationType::NoThreeDs => None,
},
- callback_url: item.return_url.clone(),
+ callback_url: Some(item.request.get_router_return_url()?),
+ description: item.description.clone(),
};
Ok(payment_request)
}
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 873a3c1492..33c92bbb93 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -249,7 +249,7 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
fn get_router_return_url(&self) -> Result<String, Error> {
self.router_return_url
.clone()
- .ok_or_else(missing_field_err("webhook_url"))
+ .ok_or_else(missing_field_err("return_url"))
}
fn is_wallet(&self) -> bool {
matches!(self.payment_method_data, api::PaymentMethodData::Wallet(_))
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 0edc8b1eda..44cfaa9984 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -187,7 +187,8 @@ impl Payments {
)
.service(
web::resource("/{payment_id}/{merchant_id}/redirect/response/{connector}")
- .route(web::get().to(payments_redirect_response)),
+ .route(web::get().to(payments_redirect_response))
+ .route(web::post().to(payments_redirect_response))
)
.service(
web::resource("/{payment_id}/{merchant_id}/redirect/complete/{connector}")
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index 49935c1488..d81cef5171 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -479,6 +479,7 @@ pub async fn payments_connector_session(
pub async fn payments_redirect_response(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
+ json_payload: Option<web::Form<serde_json::Value>>,
path: web::Path<(String, String, String)>,
) -> impl Responder {
let flow = Flow::PaymentsRedirect;
@@ -489,7 +490,7 @@ pub async fn payments_redirect_response(
resource_id: payment_types::PaymentIdType::PaymentIntentId(payment_id),
merchant_id: Some(merchant_id.clone()),
force_sync: true,
- json_payload: None,
+ json_payload: json_payload.map(|payload| payload.0),
param: Some(param_string.to_string()),
connector: Some(connector),
creds_identifier: None,