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

feat(payments): add client secret in redirect response (#1693)

Abhishek Marrivaguf7d369afa8b4
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 5deda8604d..392c5622b0 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1435,6 +1435,7 @@ pub fn get_handle_response_url(
merchant_account,
redirection_response,
payments_return_url,
+ response.client_secret.as_ref(),
)
.attach_printable("Failed to make merchant url with response")?;
@@ -1445,6 +1446,7 @@ pub fn make_merchant_url_with_response(
merchant_account: &domain::MerchantAccount,
redirection_response: api::PgRedirectResponse,
request_return_url: Option<&String>,
+ client_secret: Option<&masking::Secret<String>>,
) -> RouterResult<String> {
// take return url if provided in the request else use merchant return url
let url = request_return_url
@@ -1453,14 +1455,20 @@ pub fn make_merchant_url_with_response(
let status_check = redirection_response.status;
- let payment_intent_id = redirection_response.payment_id;
+ let payment_client_secret = client_secret
+ .ok_or(errors::ApiErrorResponse::InternalServerError)
+ .into_report()
+ .attach_printable("Expected client secret to be `Some`")?;
let merchant_url_with_response = if merchant_account.redirect_to_merchant_with_http_post {
url::Url::parse_with_params(
url,
&[
("status", status_check.to_string()),
- ("payment_intent_client_secret", payment_intent_id),
+ (
+ "payment_intent_client_secret",
+ payment_client_secret.peek().to_string(),
+ ),
],
)
.into_report()
@@ -1472,7 +1480,10 @@ pub fn make_merchant_url_with_response(
url,
&[
("status", status_check.to_string()),
- ("payment_intent_client_secret", payment_intent_id),
+ (
+ "payment_intent_client_secret",
+ payment_client_secret.peek().to_string(),
+ ),
("amount", amount.to_string()),
],
)