Bug: [BUG] Void Reason accepted as string for Nmi



### Bug Description

We were accepting void_reason as string, but since Nmi accepts specific values for void_reason. 

### Expected Behavior

Enum should be created for void_reason.

### Actual Behavior

If cancellation_request is passed as any random string, the request fails.

### Steps To Reproduce

Create a cancellation request for Nmi with cancellation_reason as a random string.

### Context For The Bug

_No response_

### Environment

Integ, Sandbox, Prod

### 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/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs
index 1e8b745107d..d6f1cb1962f 100644
--- a/crates/router/src/connector/nmi/transformers.rs
+++ b/crates/router/src/connector/nmi/transformers.rs
@@ -783,19 +783,43 @@ pub struct NmiCancelRequest {
     pub transaction_type: TransactionType,
     pub security_key: Secret<String>,
     pub transactionid: String,
-    pub void_reason: Option<String>,
+    pub void_reason: NmiVoidReason,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum NmiVoidReason {
+    Fraud,
+    UserCancel,
+    IccRejected,
+    IccCardRemoved,
+    IccNoConfirmation,
+    PosTimeout,
 }
 
 impl TryFrom<&types::PaymentsCancelRouterData> for NmiCancelRequest {
     type Error = Error;
     fn try_from(item: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
         let auth = NmiAuthType::try_from(&item.connector_auth_type)?;
-        Ok(Self {
-            transaction_type: TransactionType::Void,
-            security_key: auth.api_key,
-            transactionid: item.request.connector_transaction_id.clone(),
-            void_reason: item.request.cancellation_reason.clone(),
-        })
+        match &item.request.cancellation_reason {
+            Some(cancellation_reason) => {
+                let void_reason: NmiVoidReason = serde_json::from_str(&format!("\"{}\"", cancellation_reason))
+                    .map_err(|_| errors::ConnectorError::NotSupported {
+                        message: format!("Json deserialise error: unknown variant `{}` expected to be one of `fraud`, `user_cancel`, `icc_rejected`,  `icc_card_removed`, `icc_no_confirmation`, `pos_timeout`. This cancellation_reason", cancellation_reason), 
+                        connector: "nmi" 
+                    })?;
+                Ok(Self {
+                    transaction_type: TransactionType::Void,
+                    security_key: auth.api_key,
+                    transactionid: item.request.connector_transaction_id.clone(),
+                    void_reason,
+                })
+            }
+            None => Err(errors::ConnectorError::MissingRequiredField {
+                field_name: "cancellation_reason",
+            }
+            .into()),
+        }
     }
 }
 

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

Previously, we were accepting void_reason as string, but since Nmi accepts specific values for void_reason, those values have been added to an enum. 


### 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/7222

## 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. Create Payment**

-Request

```
curl --location 'localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data-raw '{
    "amount": 3000,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 3000,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4100000000000100",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "410"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "someone",
            "last_name": "happy"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "someone",
            "last_name": "happy"
        }
    },
    "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_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "processing",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 3000,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": {
        "customer_id": "StripeCustomer",
        "created_at": 1739163116,
        "expires": 1739166716,
        "secret": "epk_515db508176144d8a80582b802c6da31"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:51:59.965Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**2. Psync**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "requires_capture",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 3000,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:54:48.886Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**3. Cancel (Invalid Cancellation Reason)**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data '{
    "cancellation_reason": "abcde"
}'
```

-Response

```
{
    "error": {
        "type": "invalid_request",
        "message": "Payment method type not supported",
        "code": "IR_19",
        "reason": "Json deserialise error: unknown variant `abcde` expected to be one of `fraud`, `user_cancel`, `icc_rejected`,  `icc_card_removed`, `icc_no_confirmation`, `pos_timeout`. This cancellation_reason is not supported by nmi"
    }
}
```

**4. Cancel (Valid Cancellation Reason)**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data '{
    "cancellation_reason": "fraud"
}'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "processing",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": "fraud",
    "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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:58:20.070Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**5. Psync**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "cancelled",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": "fraud",
    "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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:59:47.927Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**Cypress Test Screenshots**

**No3DSAutoCapture**

![image](https://github.com/user-attachments/assets/a2ec398b-3133-4684-b1f9-31065009fc62)

**No3DSManualCapture**

![image](https://github.com/user-attachments/assets/b8367e0c-48f9-447d-bf10-b52da446da9d)

**3DSAutoCapture**

![image](https://github.com/user-attachments/assets/3ddd0e68-59cd-44ba-845a-3f4667fa29d8)

**3DSManualCapture**

![image](https://github.com/user-attachments/assets/db7fa86d-dee4-478e-807c-18437b5d5e31)

**Refund**

![image](https://github.com/user-attachments/assets/25f63eb2-12f1-4a90-8ed3-d8601c95bd79)

**Void**

![image](https://github.com/user-attachments/assets/5d734041-71bf-4f8c-be21-6a4c9445eb6e)

**Headless Tests**

![image](https://github.com/user-attachments/assets/d07647ea-cbd5-4116-ba5d-4b8c80376289)

Note: Please note that subsequent cypress tests for the same flows might fail because NMI has a validation from their end which prevents duplicate transactions from going through, and throws an error similar to "Duplicate transaction REFID:198369517" for the same. 

## 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. Create Payment**

-Request

```
curl --location 'localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data-raw '{
    "amount": 3000,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 3000,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4100000000000100",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "410"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "someone",
            "last_name": "happy"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "someone",
            "last_name": "happy"
        }
    },
    "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_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "processing",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 3000,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": {
        "customer_id": "StripeCustomer",
        "created_at": 1739163116,
        "expires": 1739166716,
        "secret": "epk_515db508176144d8a80582b802c6da31"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:51:59.965Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**2. Psync**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "requires_capture",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 3000,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:54:48.886Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**3. Cancel (Invalid Cancellation Reason)**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data '{
    "cancellation_reason": "abcde"
}'
```

-Response

```
{
    "error": {
        "type": "invalid_request",
        "message": "Payment method type not supported",
        "code": "IR_19",
        "reason": "Json deserialise error: unknown variant `abcde` expected to be one of `fraud`, `user_cancel`, `icc_rejected`,  `icc_card_removed`, `icc_no_confirmation`, `pos_timeout`. This cancellation_reason is not supported by nmi"
    }
}
```

**4. Cancel (Valid Cancellation Reason)**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK' \
--data '{
    "cancellation_reason": "fraud"
}'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "processing",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": "fraud",
    "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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:58:20.070Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**5. Psync**

-Request

```
curl --location 'localhost:8080/payments/pay_uPyEZvr3oVAvYsVvZ0jN?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_XtFublrRhWIHc7iuKjgQtABwUOjTGaEujjdXNQLUs8cI4xaPZiS4YOAO6gMjQ8fK'
```

-Response

```
{
    "payment_id": "pay_uPyEZvr3oVAvYsVvZ0jN",
    "merchant_id": "postman_merchant_GHAction_dd590ad1-bf12-47a6-bde5-586f878b3ba1",
    "status": "cancelled",
    "amount": 3000,
    "net_amount": 3000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_uPyEZvr3oVAvYsVvZ0jN_secret_9j87TpZlvvlMpSC5eFDq",
    "created": "2025-02-10T04:51:56.569Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0100",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "410000",
            "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": "token_hdl9v3A1JuIvmH2tO02R",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "someone",
            "last_name": "happy"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": "fraud",
    "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": "10396960775",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_uPyEZvr3oVAvYsVvZ0jN_1",
    "payment_link": null,
    "profile_id": "pro_qonNkZSegDkXycMtUZsb",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_EtKPhtxukFIa5pSEBtsO",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-02-10T05:06:56.569Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-10T04:59:47.927Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```

**Cypress Test Screenshots**

**No3DSAutoCapture**

![image](https://github.com/user-attachments/assets/a2ec398b-3133-4684-b1f9-31065009fc62)

**No3DSManualCapture**

![image](https://github.com/user-attachments/assets/b8367e0c-48f9-447d-bf10-b52da446da9d)

**3DSAutoCapture**

![image](https://github.com/user-attachments/assets/3ddd0e68-59cd-44ba-845a-3f4667fa29d8)

**3DSManualCapture**

![image](https://github.com/user-attachments/assets/db7fa86d-dee4-478e-807c-18437b5d5e31)

**Refund**

![image](https://github.com/user-attachments/assets/25f63eb2-12f1-4a90-8ed3-d8601c95bd79)

**Void**

![image](https://github.com/user-attachments/assets/5d734041-71bf-4f8c-be21-6a4c9445eb6e)

**Headless Tests**

![image](https://github.com/user-attachments/assets/d07647ea-cbd5-4116-ba5d-4b8c80376289)

Note: Please note that subsequent cypress tests for the same flows might fail because NMI has a validation from their end which prevents duplicate transactions from going through, and throws an error similar to "Duplicate transaction REFID:198369517" for the same. 
