Bug: [BUG] [XENDIT] CVV needs to be optional



### Bug Description

CVV should be made an optional field for the connector Xendit.

### Expected Behavior

If we do not pass CVV payment is getting failed for Xendit PSP

### Actual Behavior

If we do not pass CVV payment should still get succeeded for Xendit PSP

### Steps To Reproduce

Provide an unambiguous set of steps to reproduce this bug. Include code or configuration to reproduce, if relevant.
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'


### Context For The Bug

_No response_

### Environment

Are you using hyperswitch hosted version? Yes/No
If yes, please provide the value of the `x-request-id` response header to help us debug your issue.

If not (or if building/running locally), please provide the following details:
1. Operating System or Linux distribution:
2. Rust version (output of `rustc --version`): ``
3. App version (output of `cargo r --features vergen -- --version`): ``


### 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/hyperswitch_connectors/src/connectors/xendit.rs b/crates/hyperswitch_connectors/src/connectors/xendit.rs
index ff84224a658..57c5978bdf3 100644
--- a/crates/hyperswitch_connectors/src/connectors/xendit.rs
+++ b/crates/hyperswitch_connectors/src/connectors/xendit.rs
@@ -626,31 +626,18 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
         event_builder: Option<&mut ConnectorEvent>,
         res: Response,
     ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
-        let response: xendit::XenditPaymentResponse = res
+        let response: xendit::XenditCaptureResponse = res
             .response
             .parse_struct("Xendit PaymentsResponse")
             .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
-
-        let response_integrity_object = connector_utils::get_capture_integrity_object(
-            self.amount_converter,
-            Some(response.amount),
-            response.currency.to_string().clone(),
-        )?;
-
         event_builder.map(|i| i.set_response_body(&response));
         router_env::logger::info!(connector_response=?response);
-
-        let new_router_data = RouterData::try_from(ResponseRouterData {
+        RouterData::try_from(ResponseRouterData {
             response,
             data: data.clone(),
             http_code: res.status_code,
         })
-        .change_context(errors::ConnectorError::ResponseHandlingFailed);
-
-        new_router_data.map(|mut router_data| {
-            router_data.request.integrity_object = Some(response_integrity_object);
-            router_data
-        })
+        .change_context(errors::ConnectorError::ResponseHandlingFailed)
     }
 
     fn get_error_response(
diff --git a/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs b/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
index 7b649289ea0..ea10e96dcbf 100644
--- a/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
@@ -133,7 +133,8 @@ pub struct CardInformation {
     pub card_number: CardNumber,
     pub expiry_month: Secret<String>,
     pub expiry_year: Secret<String>,
-    pub cvv: Secret<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub cvv: Option<Secret<String>>,
     pub cardholder_name: Secret<String>,
     pub cardholder_email: pii::Email,
     pub cardholder_phone_number: Secret<String>,
@@ -201,6 +202,16 @@ fn map_payment_response_to_attempt_status(
     }
 }
 
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct XenditCaptureResponse {
+    pub id: String,
+    pub status: PaymentStatus,
+    pub actions: Option<Vec<Action>>,
+    pub payment_method: PaymentMethodInfo,
+    pub failure_code: Option<String>,
+    pub reference_id: Secret<String>,
+}
+
 #[derive(Debug, Clone, Serialize, Deserialize)]
 #[serde(rename_all = "UPPERCASE")]
 pub enum MethodType {
@@ -242,7 +253,11 @@ impl TryFrom<XenditRouterData<&PaymentsAuthorizeRouterData>> for XenditPaymentsR
                             card_number: card_data.card_number.clone(),
                             expiry_month: card_data.card_exp_month.clone(),
                             expiry_year: card_data.get_expiry_year_4_digit(),
-                            cvv: card_data.card_cvc.clone(),
+                            cvv: if card_data.card_cvc.clone().expose().is_empty() {
+                                None
+                            } else {
+                                Some(card_data.card_cvc.clone())
+                            },
                             cardholder_name: card_data
                                 .get_cardholder_name()
                                 .or(item.router_data.get_billing_full_name())?,
@@ -410,7 +425,7 @@ impl<F>
 }
 
 impl<F>
-    TryFrom<ResponseRouterData<F, XenditPaymentResponse, PaymentsCaptureData, PaymentsResponseData>>
+    TryFrom<ResponseRouterData<F, XenditCaptureResponse, PaymentsCaptureData, PaymentsResponseData>>
     for RouterData<F, PaymentsCaptureData, PaymentsResponseData>
 {
     type Error = error_stack::Report<errors::ConnectorError>;
@@ -418,12 +433,18 @@ impl<F>
     fn try_from(
         item: ResponseRouterData<
             F,
-            XenditPaymentResponse,
+            XenditCaptureResponse,
             PaymentsCaptureData,
             PaymentsResponseData,
         >,
     ) -> Result<Self, Self::Error> {
-        let status = map_payment_response_to_attempt_status(item.response.clone(), true);
+        let status = match item.response.status {
+            PaymentStatus::Failed => enums::AttemptStatus::Failure,
+            PaymentStatus::Succeeded | PaymentStatus::Verified => enums::AttemptStatus::Charged,
+            PaymentStatus::Pending => enums::AttemptStatus::Pending,
+            PaymentStatus::RequiresAction => enums::AttemptStatus::AuthenticationPending,
+            PaymentStatus::AwaitingCapture => enums::AttemptStatus::Authorized,
+        };
         let response = if status == enums::AttemptStatus::Failure {
             Err(ErrorResponse {
                 code: item

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

1. CVV should be made an optional field for the connector Xendit.
2. Fix Capture Flow for Xendit

### 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`
3. `crates/router/src/configs`
4. `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/8920

## 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)?
-->
Testing CURL's:
Payments Create:
Request:
```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_43StkeAliDdRysVQ1Bk58TfaGfqvDrRcQDIWNdnr9rx3WGPr7qnKR9ZQzdmf7P07' \
--data-raw '{
    "amount": 6540000,
    "currency": "IDR",
    "confirm": true,
    "capture_method": "manual",
    "email": "abc@def.com",
    "amount_to_capture": 6540000,
    "billing": {
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_exp_month": "11",
            "card_exp_year": "29",
            "card_holder_name": "John Doe",
            "card_number": "4000000000001091",
            "card_cvc": "100"
        }
    },
    "payment_method_type": "credit",
    "retry_action": "manual_retry"
}'
```
Response:
```
{
    "payment_id": "pay_iapkM8sQja6Xvfdn9Tje",
    "merchant_id": "merchant_1754983663",
    "status": "processing",
    "amount": 6540000,
    "net_amount": 6540000,
    "shipping_cost": null,
    "amount_capturable": 6540000,
    "amount_received": null,
    "connector": "xendit",
    "client_secret": "pay_iapkM8sQja6Xvfdn9Tje_secret_83zsZQ4asN8r6n39cRgb",
    "created": "2025-08-12T09:59:40.385Z",
    "currency": "IDR",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": null,
        "email": "abc@def.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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1091",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "11",
            "card_exp_year": "29",
            "card_holder_name": "John Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": null,
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": 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": 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": "pr-d7afb058-5ecb-424b-af1a-60c6ce3f8df0",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "2aa664ab-6a91-417d-a9bb-db3f6fd1fc21",
    "payment_link": null,
    "profile_id": "pro_pRZDis5aB5cSfftyA4Dq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mJa8AsZOXYdYmggROjBG",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-12T10:14:40.385Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-12T09:59:41.228Z",
    "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",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```

Payments Retrieve:
Request:
```
curl --location 'http://localhost:8080/payments/pay_iapkM8sQja6Xvfdn9Tje?force_sync=true&expand_captures=true&expand_attempts=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_43StkeAliDdRysVQ1Bk58TfaGfqvDrRcQDIWNdnr9rx3WGPr7qnKR9ZQzdmf7P07'
```
Response:
```
{
    "payment_id": "pay_iapkM8sQja6Xvfdn9Tje",
    "merchant_id": "merchant_1754983663",
    "status": "requires_capture",
    "amount": 6540000,
    "net_amount": 6540000,
    "shipping_cost": null,
    "amount_capturable": 6540000,
    "amount_received": null,
    "connector": "xendit",
    "client_secret": "pay_iapkM8sQja6Xvfdn9Tje_secret_83zsZQ4asN8r6n39cRgb",
    "created": "2025-08-12T09:59:40.385Z",
    "currency": "IDR",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": null,
        "email": "abc@def.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "attempts": [
        {
            "attempt_id": "pay_iapkM8sQja6Xvfdn9Tje_1",
            "status": "pending",
            "amount": 6540000,
            "order_tax_amount": null,
            "currency": "IDR",
            "connector": "xendit",
            "error_message": null,
            "payment_method": "card",
            "connector_transaction_id": "pr-d7afb058-5ecb-424b-af1a-60c6ce3f8df0",
            "capture_method": "manual",
            "authentication_type": "no_three_ds",
            "created_at": "2025-08-12T09:59:40.385Z",
            "modified_at": "2025-08-12T09:59:41.229Z",
            "cancellation_reason": null,
            "mandate_id": null,
            "error_code": null,
            "payment_token": null,
            "connector_metadata": null,
            "payment_experience": null,
            "payment_method_type": "credit",
            "reference_id": "2aa664ab-6a91-417d-a9bb-db3f6fd1fc21",
            "unified_code": null,
            "unified_message": null,
            "client_source": null,
            "client_version": 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": "1091",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "11",
            "card_exp_year": "29",
            "card_holder_name": "John Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": null,
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": 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": 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": "pr-d7afb058-5ecb-424b-af1a-60c6ce3f8df0",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "2aa664ab-6a91-417d-a9bb-db3f6fd1fc21",
    "payment_link": null,
    "profile_id": "pro_pRZDis5aB5cSfftyA4Dq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mJa8AsZOXYdYmggROjBG",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-12T10:14:40.385Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-12T09:59:48.778Z",
    "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",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```

Payments Capture:
Request:
```
curl --location 'http://localhost:8080/payments/pay_iapkM8sQja6Xvfdn9Tje/capture' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_43StkeAliDdRysVQ1Bk58TfaGfqvDrRcQDIWNdnr9rx3WGPr7qnKR9ZQzdmf7P07' \
--data '{
  "statement_descriptor_name": "Joseph",
  "statement_descriptor_prefix" :"joseph",
  "statement_descriptor_suffix": "JS"
}'
```
Response:
```
{
    "payment_id": "pay_iapkM8sQja6Xvfdn9Tje",
    "merchant_id": "merchant_1754983663",
    "status": "succeeded",
    "amount": 6540000,
    "net_amount": 6540000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540000,
    "connector": "xendit",
    "client_secret": "pay_iapkM8sQja6Xvfdn9Tje_secret_83zsZQ4asN8r6n39cRgb",
    "created": "2025-08-12T09:59:40.385Z",
    "currency": "IDR",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": null,
        "email": "abc@def.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": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1091",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "11",
            "card_exp_year": "29",
            "card_holder_name": "John Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": null,
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": 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": 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": "pr-d7afb058-5ecb-424b-af1a-60c6ce3f8df0",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "1746e4f7-36a7-4058-9301-aac9772f97b7",
    "payment_link": null,
    "profile_id": "pro_pRZDis5aB5cSfftyA4Dq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_mJa8AsZOXYdYmggROjBG",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-12T10:14:40.385Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-12T09:59:57.719Z",
    "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",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```

Note: Existing CYPRESS not working on main branch for PSP Xendit and hence skipping Cypress tests for this PR

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