From f7d369afa8b459a18a5ec0a36caebdb1a4fe72b4 Mon Sep 17 00:00:00 2001 From: Abhishek Marrivagu <68317979+Abhicodes-crypto@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:43:36 +0530 Subject: [PATCH] feat(payments): add client secret in redirect response (#1693) --- crates/router/src/core/payments/helpers.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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>, ) -> RouterResult { // 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()), ], )