Bug: [BUG] [BRAINTREE] Fix picking of creds identifier during Complete Authorize Flow



### Bug Description

When MCA Create is not done for Braintree, and connector creds are passed in Payment Intent Request, then Complete Authorize Flow fails.

### Expected Behavior

When MCA Create is not done for Braintree, and connector creds are passed in Payment Intent Request, then Complete Authorize Flow should not fail.

### Actual Behavior

When MCA Create is not done for Braintree, and connector creds are passed in Payment Intent Request, then Complete Authorize Flow fails.

### Steps To Reproduce

When MCA Create is not done for Braintree, and connector creds are passed in Payment Intent Request, then Complete Authorize Flow fails.

### Context For The Bug

_No response_

### Environment

Integ, Sandbox, Production

### Have you spent some time checking if this bug has been raised before?

- [x] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [x] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index d072463020a..6ebc5266eba 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -2328,6 +2328,12 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
         let payment_confirm_req = api::PaymentsRequest {
             payment_id: Some(req.resource_id.clone()),
             merchant_id: req.merchant_id.clone(),
+            merchant_connector_details: req.creds_identifier.map(|creds_id| {
+                api::MerchantConnectorDetailsWrap {
+                    creds_identifier: creds_id,
+                    encoded_data: None,
+                }
+            }),
             feature_metadata: Some(api_models::payments::FeatureMetadata {
                 redirect_response: Some(api_models::payments::RedirectResponse {
                     param: req.param.map(Secret::new),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index cdbda13997b..82c9eca97c4 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1262,13 +1262,18 @@ pub fn create_complete_authorize_url(
     router_base_url: &String,
     payment_attempt: &PaymentAttempt,
     connector_name: impl std::fmt::Display,
+    creds_identifier: Option<&str>,
 ) -> String {
+    let creds_identifier = creds_identifier.map_or_else(String::new, |creds_identifier| {
+        format!("/{}", creds_identifier)
+    });
     format!(
-        "{}/payments/{}/{}/redirect/complete/{}",
+        "{}/payments/{}/{}/redirect/complete/{}{}",
         router_base_url,
         payment_attempt.payment_id.get_string_repr(),
         payment_attempt.merchant_id.get_string_repr(),
-        connector_name
+        connector_name,
+        creds_identifier
     )
 }
 
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index d95e92115ad..7befdfc91d3 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -305,6 +305,14 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
                 id: profile_id.get_string_repr().to_owned(),
             })?;
 
+        let creds_identifier =
+            request
+                .merchant_connector_details
+                .as_ref()
+                .map(|merchant_connector_details| {
+                    merchant_connector_details.creds_identifier.to_owned()
+                });
+
         let payment_data = PaymentData {
             flow: PhantomData,
             payment_intent,
@@ -336,7 +344,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
             attempts: None,
             sessions_token: vec![],
             card_cvc: request.card_cvc.clone(),
-            creds_identifier: None,
+            creds_identifier,
             pm_token: None,
             connector_customer_id: None,
             recurring_mandate_payment_data,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 9647a277b0e..f1577f6e10f 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -223,6 +223,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
         router_base_url,
         attempt,
         connector_id,
+        None,
     ));
 
     let webhook_url = Some(helpers::create_webhook_url(
@@ -887,6 +888,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
         router_base_url,
         attempt,
         connector_id,
+        None,
     ));
 
     let webhook_url = Some(helpers::create_webhook_url(
@@ -3115,7 +3117,9 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
             router_base_url,
             attempt,
             connector_name,
+            payment_data.creds_identifier.as_deref(),
         ));
+
         let merchant_connector_account_id_or_connector_name = payment_data
             .payment_attempt
             .merchant_connector_id
@@ -4084,6 +4088,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
             router_base_url,
             attempt,
             connector_name,
+            payment_data.creds_identifier.as_deref(),
         ));
         let braintree_metadata = payment_data
             .payment_intent
@@ -4198,6 +4203,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
             router_base_url,
             attempt,
             connector_name,
+            payment_data.creds_identifier.as_deref(),
         ));
         let browser_info: Option<types::BrowserInformation> = payment_data
             .payment_attempt
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index de5593703d0..5d364d9b923 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -747,6 +747,11 @@ impl Payments {
                         .route(web::get().to(payments::payments_redirect_response))
                         .route(web::post().to(payments::payments_redirect_response))
                 )
+                .service(
+                    web::resource("/{payment_id}/{merchant_id}/redirect/complete/{connector}/{creds_identifier}")
+                        .route(web::get().to(payments::payments_complete_authorize_redirect_with_creds_identifier))
+                        .route(web::post().to(payments::payments_complete_authorize_redirect_with_creds_identifier))
+                )
                 .service(
                     web::resource("/{payment_id}/{merchant_id}/redirect/complete/{connector}")
                         .route(web::get().to(payments::payments_complete_authorize_redirect))
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index 9708f34c53c..cd136ff784f 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -1084,6 +1084,58 @@ pub async fn payments_complete_authorize_redirect(
     .await
 }
 
+#[cfg(feature = "v1")]
+#[instrument(skip_all, fields(flow =? Flow::PaymentsRedirect, payment_id))]
+pub async fn payments_complete_authorize_redirect_with_creds_identifier(
+    state: web::Data<app::AppState>,
+    req: actix_web::HttpRequest,
+    json_payload: Option<web::Form<serde_json::Value>>,
+    path: web::Path<(
+        common_utils::id_type::PaymentId,
+        common_utils::id_type::MerchantId,
+        String,
+        String,
+    )>,
+) -> impl Responder {
+    let flow = Flow::PaymentsRedirect;
+    let (payment_id, merchant_id, connector, creds_identifier) = path.into_inner();
+    let param_string = req.query_string();
+
+    tracing::Span::current().record("payment_id", payment_id.get_string_repr());
+
+    let payload = payments::PaymentsRedirectResponseData {
+        resource_id: payment_types::PaymentIdType::PaymentIntentId(payment_id),
+        merchant_id: Some(merchant_id.clone()),
+        param: Some(param_string.to_string()),
+        json_payload: json_payload.map(|s| s.0),
+        force_sync: false,
+        connector: Some(connector),
+        creds_identifier: Some(creds_identifier),
+    };
+    let locking_action = payload.get_locking_input(flow.clone());
+    Box::pin(api::server_wrap(
+        flow,
+        state,
+        &req,
+        payload,
+        |state, auth: auth::AuthenticationData, req, req_state| {
+
+            <payments::PaymentRedirectCompleteAuthorize as PaymentRedirectFlow>::handle_payments_redirect_response(
+                &payments::PaymentRedirectCompleteAuthorize {},
+                state,
+                req_state,
+                auth.merchant_account,
+                auth.key_store,
+                req,
+                auth.platform_merchant_account,
+            )
+        },
+        &auth::MerchantIdAuth(merchant_id),
+        locking_action,
+    ))
+    .await
+}
+
 #[cfg(feature = "v1")]
 #[instrument(skip_all, fields(flow =? Flow::PaymentsCompleteAuthorize, payment_id))]
 pub async fn payments_complete_authorize(

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->

When MCA Create is not done for Braintree, and connector creds are passed in Payment Intent Request, then Complete Authorize Flow fails. This PR is for fixing that.


### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->

Issue Link: https://github.com/juspay/hyperswitch/issues/7506


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->

**Postman Tests**

**1. Payment Intent Create (Without Braintree MCA Create)**

-Request

```
curl --location 'http://localhost:8080/vs/v1/payment_intents' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'User-Agent: helloMozilla/5.0 (Linux; Android 12; SM-S906N Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.119 Mobile Safari/537.36' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL' \
--data-urlencode 'amount=1200' \
--data-urlencode 'currency=USD' \
--data-urlencode 'confirm=true' \
--data-urlencode 'payment_method_data%5Btype%5D=card' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bnumber%5D=5200000000001096' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bexp_month%5D=10' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bexp_year%5D=26' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bcvc%5D=123' \
--data-urlencode 'connector%5B%5D=braintree' \
--data-urlencode 'capture_method=automatic' \
--data-urlencode 'customer=sahkal' \
--data-urlencode 'statementDescriptorSuffix=merchant_101' \
--data-urlencode 'metadata%5BorderId%5D=1677581650' \
--data-urlencode 'payment_method_options%5Bcard%5D%5Brequest_three_d_secure%5D=any' \
--data-urlencode 'description=Card Payment' \
--data-urlencode 'return_url=https://google.com' \
--data-urlencode 'merchant_connector_details%5Bencoded_data%5D=eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0.2Ef5oJ8MdVY9wdMdVVYHhrjUfY-NzgUc5oN7rKR3IG9jzYWkc9my0bMVQ31H2GjHQGBRuNzR0y-OfzFBHpmpSxA6qt5c-PFs2HaIEV69tXml6u6FcKtPvsMxVTRIiMMN1dJTwxKm9kqBMsXE6rpokDkKOJTU1-33Lz7v0VAT2KsZo7zNc4Tp0SI_tLaBwos4N-Ihws4PGbNy6CkEId0tTArJMg2y7utl759DAnUwwjgNNebMNUa9qAAIX6zCrn0U4n7NGyrpBbKqOu4Cd7sYeysP_jKjE12FexXHcEwHwUZTa453q-DvvvKlbfoACgGjE9ceBMr8kF1d1EnyS2J4DA.Wp1spmaGnWhvvCqY.X5I79LC8PC5AHQy6bT0JCNPrsvqc51iVWu1O5487ihDmCCkwC4eBXgm5STkYtNfttbMHD6-SimAVmtqD0AmhCUoJ7h0qQbcZt4XdB89gH5pdZvaSsmozlYxMG64jvGkXfp22aQZf-SwpcRWslP5CmFGTJDT7OgJTNBOZuoA6tbFIyxoXUh1L6Km4DuJA2dbKPRsw_Cg_5O869Wg5ghQmEtqHToirWLbwtZN32phRLt6L.GooLyxP-9xhU-vvi2vRGdA' \
--data-urlencode 'merchant_connector_details%5Bcreds_identifier%5D=azharamin_noon_1efwedxqwd' \
--data-urlencode 'id=154107184321542' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Bname%5D=Joseph Doe' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Bemail%5D=sahkalplanet@gmail.com' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bcity%5D=siliguri' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bcountry%5D=IN' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bstate%5D=westbengal' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bline1%5D=pritilata' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bzip%5D=734006' \
--data-urlencode 'metadata%5Bmerchant_id%5D=sahkal' \
--data-urlencode 'metadata%5Beuler_merchant_id%5D=global_installment' \
--data-urlencode 'connector_metadata%5Bnoon%5D%5Border_category%5D=pay' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bholder_name%5D=Joseph Doe' \
--data-urlencode 'connector_metadata%5Bbraintree%5D%5Bmerchant_account_id%5D=juspay' \
--data-urlencode 'connector_metadata%5Bbraintree%5D%5Bmerchant_config_currency%5D=USD'
```

-Response

```
{
    "id": "154107184321542",
    "object": "payment_intent",
    "amount": 1200,
    "amount_received": null,
    "amount_capturable": 1200,
    "currency": "usd",
    "status": "requires_action",
    "client_secret": "154107184321542_secret_HE2P7xcJNdGJr061tYZh",
    "created": 1741828281,
    "customer": "sahkal",
    "refunds": null,
    "mandate": null,
    "metadata": {
        "orderId": "1677581650",
        "merchant_id": "sahkal",
        "euler_merchant_id": "global_installment"
    },
    "charges": {
        "object": "list",
        "data": [],
        "has_more": false,
        "total_count": 0,
        "url": "http://placeholder"
    },
    "connector": "braintree",
    "description": "Card Payment",
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "authentication_type": "three_ds",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": {
            "return_url": "https://google.com/",
            "url": "http://localhost:8080/payments/redirect/154107184321542/postman_merchant_GHAction_174568/154107184321542_1"
        }
    },
    "cancellation_reason": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "26",
            "card_holder_name": "Joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        }
    },
    "shipping": null,
    "billing": {
        "address": {
            "city": "siliguri",
            "country": "IN",
            "line1": "pritilata",
            "line2": null,
            "line3": null,
            "zip": null,
            "state": "westbengal",
            "first_name": null,
            "last_name": null
        },
        "phone": {
            "number": null,
            "country_code": "IN"
        },
        "email": "sahkalplanet@gmail.com"
    },
    "capture_on": null,
    "payment_token": null,
    "email": null,
    "phone": null,
    "statement_descriptor_suffix": null,
    "statement_descriptor_name": null,
    "capture_method": "automatic",
    "name": null,
    "last_payment_error": null,
    "connector_transaction_id": null
}
```

**2. Payment Create (Normal Hyperswitch Flow)**

-Request

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL' \
--data-raw '{
    "amount": 2500,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 2500,
    "customer_id": "abcdef",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5200000000001096",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
        
        
    }
}'
```

-Response

```
{
    "payment_id": "pay_QLFSd62pZGRWHmzJl9V1",
    "merchant_id": "postman_merchant_GHAction_174568",
    "status": "requires_customer_action",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 2500,
    "amount_received": null,
    "connector": "braintree",
    "client_secret": "pay_QLFSd62pZGRWHmzJl9V1_secret_1lRAyjj7PewghQLE5bMm",
    "created": "2025-03-13T01:13:16.662Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_QLFSd62pZGRWHmzJl9V1/postman_merchant_GHAction_174568/pay_QLFSd62pZGRWHmzJl9V1_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "abcdef",
        "created_at": 1741828396,
        "expires": 1741831996,
        "secret": "epk_beff18305e9f49bda8a0b9e2a77b249e"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_1tsuB1vmUFHSgf5OavLc",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_iQuV3uVZfTRA8dJJg53p",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-13T01:28:16.662Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-13T01:13:18.053Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual"
}
```

**2. PSync**

-Request

```
curl --location 'http://localhost:8080/payments/pay_QLFSd62pZGRWHmzJl9V1' \
--header 'Accept: application/json' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL'
```

-Response

```
{
    "payment_id": "pay_QLFSd62pZGRWHmzJl9V1",
    "merchant_id": "postman_merchant_GHAction_174568",
    "status": "succeeded",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2500,
    "connector": "braintree",
    "client_secret": "pay_QLFSd62pZGRWHmzJl9V1_secret_1lRAyjj7PewghQLE5bMm",
    "created": "2025-03-13T01:13:16.662Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "dHJhbnNhY3Rpb25fNGMyNnRlN3I",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_1tsuB1vmUFHSgf5OavLc",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_iQuV3uVZfTRA8dJJg53p",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-13T01:28:16.662Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-13T01:14:51.291Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual"
}
```


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible



**Postman Tests**

**1. Payment Intent Create (Without Braintree MCA Create)**

-Request

```
curl --location 'http://localhost:8080/vs/v1/payment_intents' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'User-Agent: helloMozilla/5.0 (Linux; Android 12; SM-S906N Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.119 Mobile Safari/537.36' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL' \
--data-urlencode 'amount=1200' \
--data-urlencode 'currency=USD' \
--data-urlencode 'confirm=true' \
--data-urlencode 'payment_method_data%5Btype%5D=card' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bnumber%5D=5200000000001096' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bexp_month%5D=10' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bexp_year%5D=26' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bcvc%5D=123' \
--data-urlencode 'connector%5B%5D=braintree' \
--data-urlencode 'capture_method=automatic' \
--data-urlencode 'customer=sahkal' \
--data-urlencode 'statementDescriptorSuffix=merchant_101' \
--data-urlencode 'metadata%5BorderId%5D=1677581650' \
--data-urlencode 'payment_method_options%5Bcard%5D%5Brequest_three_d_secure%5D=any' \
--data-urlencode 'description=Card Payment' \
--data-urlencode 'return_url=https://google.com' \
--data-urlencode 'merchant_connector_details%5Bencoded_data%5D=eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0.2Ef5oJ8MdVY9wdMdVVYHhrjUfY-NzgUc5oN7rKR3IG9jzYWkc9my0bMVQ31H2GjHQGBRuNzR0y-OfzFBHpmpSxA6qt5c-PFs2HaIEV69tXml6u6FcKtPvsMxVTRIiMMN1dJTwxKm9kqBMsXE6rpokDkKOJTU1-33Lz7v0VAT2KsZo7zNc4Tp0SI_tLaBwos4N-Ihws4PGbNy6CkEId0tTArJMg2y7utl759DAnUwwjgNNebMNUa9qAAIX6zCrn0U4n7NGyrpBbKqOu4Cd7sYeysP_jKjE12FexXHcEwHwUZTa453q-DvvvKlbfoACgGjE9ceBMr8kF1d1EnyS2J4DA.Wp1spmaGnWhvvCqY.X5I79LC8PC5AHQy6bT0JCNPrsvqc51iVWu1O5487ihDmCCkwC4eBXgm5STkYtNfttbMHD6-SimAVmtqD0AmhCUoJ7h0qQbcZt4XdB89gH5pdZvaSsmozlYxMG64jvGkXfp22aQZf-SwpcRWslP5CmFGTJDT7OgJTNBOZuoA6tbFIyxoXUh1L6Km4DuJA2dbKPRsw_Cg_5O869Wg5ghQmEtqHToirWLbwtZN32phRLt6L.GooLyxP-9xhU-vvi2vRGdA' \
--data-urlencode 'merchant_connector_details%5Bcreds_identifier%5D=azharamin_noon_1efwedxqwd' \
--data-urlencode 'id=154107184321542' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Bname%5D=Joseph Doe' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Bemail%5D=sahkalplanet@gmail.com' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bcity%5D=siliguri' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bcountry%5D=IN' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bstate%5D=westbengal' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bline1%5D=pritilata' \
--data-urlencode 'payment_method_data%5Bbilling_details%5D%5Baddress%5D%5Bzip%5D=734006' \
--data-urlencode 'metadata%5Bmerchant_id%5D=sahkal' \
--data-urlencode 'metadata%5Beuler_merchant_id%5D=global_installment' \
--data-urlencode 'connector_metadata%5Bnoon%5D%5Border_category%5D=pay' \
--data-urlencode 'payment_method_data%5Bcard%5D%5Bholder_name%5D=Joseph Doe' \
--data-urlencode 'connector_metadata%5Bbraintree%5D%5Bmerchant_account_id%5D=juspay' \
--data-urlencode 'connector_metadata%5Bbraintree%5D%5Bmerchant_config_currency%5D=USD'
```

-Response

```
{
    "id": "154107184321542",
    "object": "payment_intent",
    "amount": 1200,
    "amount_received": null,
    "amount_capturable": 1200,
    "currency": "usd",
    "status": "requires_action",
    "client_secret": "154107184321542_secret_HE2P7xcJNdGJr061tYZh",
    "created": 1741828281,
    "customer": "sahkal",
    "refunds": null,
    "mandate": null,
    "metadata": {
        "orderId": "1677581650",
        "merchant_id": "sahkal",
        "euler_merchant_id": "global_installment"
    },
    "charges": {
        "object": "list",
        "data": [],
        "has_more": false,
        "total_count": 0,
        "url": "http://placeholder"
    },
    "connector": "braintree",
    "description": "Card Payment",
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "authentication_type": "three_ds",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": {
            "return_url": "https://google.com/",
            "url": "http://localhost:8080/payments/redirect/154107184321542/postman_merchant_GHAction_174568/154107184321542_1"
        }
    },
    "cancellation_reason": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "26",
            "card_holder_name": "Joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        }
    },
    "shipping": null,
    "billing": {
        "address": {
            "city": "siliguri",
            "country": "IN",
            "line1": "pritilata",
            "line2": null,
            "line3": null,
            "zip": null,
            "state": "westbengal",
            "first_name": null,
            "last_name": null
        },
        "phone": {
            "number": null,
            "country_code": "IN"
        },
        "email": "sahkalplanet@gmail.com"
    },
    "capture_on": null,
    "payment_token": null,
    "email": null,
    "phone": null,
    "statement_descriptor_suffix": null,
    "statement_descriptor_name": null,
    "capture_method": "automatic",
    "name": null,
    "last_payment_error": null,
    "connector_transaction_id": null
}
```

**2. Payment Create (Normal Hyperswitch Flow)**

-Request

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL' \
--data-raw '{
    "amount": 2500,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 2500,
    "customer_id": "abcdef",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5200000000001096",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
        
        
    }
}'
```

-Response

```
{
    "payment_id": "pay_QLFSd62pZGRWHmzJl9V1",
    "merchant_id": "postman_merchant_GHAction_174568",
    "status": "requires_customer_action",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 2500,
    "amount_received": null,
    "connector": "braintree",
    "client_secret": "pay_QLFSd62pZGRWHmzJl9V1_secret_1lRAyjj7PewghQLE5bMm",
    "created": "2025-03-13T01:13:16.662Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_QLFSd62pZGRWHmzJl9V1/postman_merchant_GHAction_174568/pay_QLFSd62pZGRWHmzJl9V1_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "abcdef",
        "created_at": 1741828396,
        "expires": 1741831996,
        "secret": "epk_beff18305e9f49bda8a0b9e2a77b249e"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_1tsuB1vmUFHSgf5OavLc",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_iQuV3uVZfTRA8dJJg53p",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-13T01:28:16.662Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-13T01:13:18.053Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual"
}
```

**2. PSync**

-Request

```
curl --location 'http://localhost:8080/payments/pay_QLFSd62pZGRWHmzJl9V1' \
--header 'Accept: application/json' \
--header 'api-key: dev_cAhKiY0z6BCPtxdTZKiuoGXNfbk49QwuMRPJudoj4P5gWR24zvL1BniBwqBBP7SL'
```

-Response

```
{
    "payment_id": "pay_QLFSd62pZGRWHmzJl9V1",
    "merchant_id": "postman_merchant_GHAction_174568",
    "status": "succeeded",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2500,
    "connector": "braintree",
    "client_secret": "pay_QLFSd62pZGRWHmzJl9V1_secret_1lRAyjj7PewghQLE5bMm",
    "created": "2025-03-13T01:13:16.662Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "dHJhbnNhY3Rpb25fNGMyNnRlN3I",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_1tsuB1vmUFHSgf5OavLc",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_iQuV3uVZfTRA8dJJg53p",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-13T01:28:16.662Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-13T01:14:51.291Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual"
}
```
