Bug: [BUG] Add reference to Sepa Bank Transfer Next Customer Actions Responses



### Bug Description

Sepa bank transfer payment responses don't contain reference for the payment. 
A reference is very important unique id for the payment reconciliation by the connectors.  e.g. Stripe does create a payment reference but Hyperswitch does not pass it down as part of **next action** in the **create-payment** api call. Check below for the detailed request and response structures. 
 

### Expected Behavior

The next action section of the response should display reference.

```
"next_action": {
        "type": "display_bank_transfer_information",
        "bank_transfer_steps_and_charges_details": {
            "sepa_bank_instructions": {
                "account_holder_name": "LOL GmbH",
                "bic": "SOGEDEFFXXX",
                "country": "DE",
                "iban": "DEXXXXXXXXXXXXXXXX6",
                 "reference" : "HZDK38NZ88MC

            },
            "receiver": {
                "amount_received": 0,
                "amount_charged": null,
                "amount_remaining": 60
            }
        }
    }
 ```
 
 

### Actual Behavior

1. Add a stripe connector to process sepa bank transfer payments ( customers pay to IBAN asynchronously)
2. Create a payment 

```
curl --location 'https://sandbox.hyperswitch.io/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: <apiKey>' \
--data-raw '{
  "amount": 60,
  "authentication_type": "no_three_ds",
  "confirm": true,
  "currency": "EUR",
  "customer_id": "cus_2CMeBeWVAEo4CpobIIOW",
  "payment_method": "bank_transfer",
  "payment_method_type": "sepa",
  "payment_method_data": {
    "bank_transfer": {
        "sepa_bank_transfer" : {
            "billing_details" : {
                "email" : "gmail@rajanikanth.com",
                "name" : "Rajanikanth"
            },
            "country" : "DE"
        }
    }
  }
}'
```

The successful output :

```JSON
{
    "payment_id": "pay_H38rD4DfWwKg6Omoi2j4",
    "merchant_id": "merchant_1713521192",
    "status": "requires_customer_action",
    "amount": 60,
    "net_amount": 60,
    "amount_capturable": 60,
    "amount_received": 0,
    "connector": "stripe",
    "client_secret": "pay_H38rD4DfWwKg6Omoi2j4_secret_hrWAvfkxn8BxCA60muqK",
    "created": "2024-04-22T13:40:07.848Z",
    "currency": "EUR",
    "customer_id": "cus_2CMeBeWVAEo4CpobIIOW",
    "customer": {
        "id": "cus_2CMeBeWVAEo4CpobIIOW",
        "name": "R. Rajanikanth",
        "email": "gmail@rajanikanth.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "bank_transfer",
    "payment_method_data": {
        "bank_transfer": {},
        "billing": null
    },
    "payment_token": "token_e6zWZTicyszgnSJOYfoD",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "gmail@rajanikanth.com",
    "name": "R. Rajanikanth",
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "display_bank_transfer_information",
        "bank_transfer_steps_and_charges_details": {
            "sepa_bank_instructions": {
                "account_holder_name": "LOL GmbH",
                "bic": "SOGEDEFFXXX",
                "country": "DE",
                "iban": "DE7XXXXXXXXX2713356"
            },
            "receiver": {
                "amount_received": 0,
                "amount_charged": null,
                "amount_remaining": 60
            }
        }
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "sepa",
    "connector_label": null,
    "business_country": null,
    "business_label": null,
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cus_2CMeBeWVAEo4CpobIIOW",
        "created_at": 1713793207,
        "expires": 1713796807,
        "secret": "epk_af95122559b54d969745ec25d126fe76"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3P8N6KP6tL3tSvaR0C4oriJt",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3P8N6KP6tL3tSvaR0C4oriJt",
    "payment_link": null,
    "profile_id": "pro_47tvU9WWnp9JNx2Xm6TR",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_8CXOXTBeD2bS07s71M0R",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-04-22T13:55:07.848Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-04-22T13:40:08.953Z"
}
```

3. In above response, the reference  in the next action is missing. 

```
"next_action": {
        "type": "display_bank_transfer_information",
        "bank_transfer_steps_and_charges_details": {
            "sepa_bank_instructions": {
                "account_holder_name": "LOL GmbH",
                "bic": "SOGEDEFFXXX",
                "country": "DE",
                "iban": "DEXXXXXXXXXXX32713356"
            },
            "receiver": {
                "amount_received": 0,
                "amount_charged": null,
                "amount_remaining": 60
            }
        }
    }
   ```
   
   4. Although stripe creates a reference 
   
   ```
      Amount remaining : €0.60 EUR
      BIC : SOGEDEFFXXX
      IBAN : DE73977977789374832713356
      Country: DE
      Account holder name: LOL GmbH
      Reference : HZDK38NZ88MC
   ```
   
   5. `StripeBankTransferDetails` in the code has reference but it is not passed down as the api response. 

### Steps To Reproduce

1. Add a stripe connector to process sepa bank transfer payments ( customers pay to IBAN asynchronously)
2. Create a bank transfer payment.
3. Observe the successful response. 

### Context For The Bug

https://docs.stripe.com/api/payment_intents/object#payment_intent_object-next_action-display_bank_transfer_instructions-reference



### Environment

sandbox hyperswitch


### 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?

None
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index fb679970f3d..c554245b936 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -18325,7 +18325,8 @@
           "account_holder_name",
           "bic",
           "country",
-          "iban"
+          "iban",
+          "reference"
         ],
         "properties": {
           "account_holder_name": {
@@ -18342,6 +18343,10 @@
           "iban": {
             "type": "string",
             "example": "123456789"
+          },
+          "reference": {
+            "type": "string",
+            "example": "U2PVVSEV4V9Y"
           }
         }
       },
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 23c3b219b65..cc6a9af5258 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -3545,6 +3545,8 @@ pub struct SepaBankTransferInstructions {
     pub country: String,
     #[schema(value_type = String, example = "123456789")]
     pub iban: Secret<String>,
+    #[schema(value_type = String, example = "U2PVVSEV4V9Y")]
+    pub reference: Secret<String>,
 }
 
 #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs
index 2129ad327c2..1a25075ce21 100644
--- a/crates/router/src/connector/stripe/transformers.rs
+++ b/crates/router/src/connector/stripe/transformers.rs
@@ -2475,7 +2475,16 @@ pub fn get_connector_metadata(
                 let (sepa_bank_instructions, bacs_bank_instructions) =
                     bank_instructions.map_or((None, None), |financial_address| {
                         (
-                            financial_address.iban.to_owned(),
+                            financial_address
+                                .iban
+                                .to_owned()
+                                .map(|sepa_financial_details| SepaFinancialDetails {
+                                    account_holder_name: sepa_financial_details.account_holder_name,
+                                    bic: sepa_financial_details.bic,
+                                    country: sepa_financial_details.country,
+                                    iban: sepa_financial_details.iban,
+                                    reference: response.reference.to_owned(),
+                                }),
                             financial_address.sort_code.to_owned(),
                         )
                     });
@@ -2880,6 +2889,7 @@ pub struct SepaFinancialDetails {
     pub bic: Secret<String>,
     pub country: Secret<String>,
     pub iban: Secret<String>,
+    pub reference: Option<String>,
 }
 
 #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]

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

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

## Description
<!-- Describe your changes in detail -->
 'reference' added in sepa_bank_instructions, for Stripe Sepa Bank Transfer 

### 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).
-->
https://github.com/juspay/hyperswitch/issues/6014

## 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)?
-->

Request
~~~
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: <apiKey>' \
--data-raw '{
  "amount": 60,
  "authentication_type": "no_three_ds",
  "confirm": true,
  "currency": "EUR",
  "customer_id": "StripeCustomer", 
  "payment_method": "bank_transfer",
  "payment_method_type": "sepa",
  "payment_method_data": {
    "bank_transfer": {
        "sepa_bank_transfer" : {
            "billing_details" : {
                "email" : "gmail@rajanikanth.com",
                "name" : "Rajanikanth"
            },
            "country" : "DE"
        }
    }
  }
}'
~~~

The successful output :

~~~
{
    "payment_id": "pay_bLamnDrh3V3GefetEL3Tm",
    "merchant_id": "merchant_1727948661",
    "status": "requires_customer_action",
    "amount": 60,
    "net_amount": 60,
    "amount_capturable": 60,
    "amount_received": 0,
    "connector": "stripe",
    "client_secret": "pay_bLamnDrh3V3cefctEL3Tm_secret_QsqbBrkZn2pI7cerfer",
    "created": "2024-10-03T13:25:34.962Z",
    "currency": "EUR",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "bank_transfer",
    "payment_method_data": {
        "bank_transfer": {
            "sepa": {}
        },
        "billing": null
    },
    "payment_token": "token_kwd45640isqRNJdwedwB",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "display_bank_transfer_information",
        "bank_transfer_steps_and_charges_details": {
            "sepa_bank_instructions": {
                "account_holder_name": "ABCD France",
                "bic": "SOGEDEFFXXX",
                "country": "DE",
                "iban": "DE4039739XXXXXXXX89727",
                "reference": "8NXKXQARUC9X"
            },
            "receiver": {
                "amount_received": 0,
                "amount_charged": null,
                "amount_remaining": 60
            }
        }
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "sepa",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1727961934,
        "expires": 1727965534,
        "secret": "epk_f8ad2600b91b47bcaa762322eaa6f5f3"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3Q5p2CEOxxxxxx0EG1g4Ou",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3Q5p2CEOxxxxxx0EG1g4Ou",
    "payment_link": null,
    "profile_id": "pro_TSOb6xQbAkCdcsTtYf6C",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_XjEZ8bwoCedxxxdE3u",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-10-03T13:40:34.962Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-10-03T13:25:36.680Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null
}
~~~


## 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`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
