Bug: [INTEGRATION] Worldpay Integration



This issue is a continuation of #6316 for tagging the relevant development work in PRs.
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
index cd028e81ef1..6ae507790dd 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
@@ -26,7 +26,7 @@ use super::{requests::*, response::*};
 use crate::{
     types::ResponseRouterData,
     utils::{
-        self, AddressData, CardData, ForeignTryFrom, PaymentsAuthorizeRequestData,
+        self, AddressData, ApplePay, CardData, ForeignTryFrom, PaymentsAuthorizeRequestData,
         PaymentsSetupMandateRequestData, RouterData as RouterDataTrait,
     },
 };
@@ -150,7 +150,7 @@ fn fetch_payment_instrument(
             })),
             WalletData::ApplePay(data) => Ok(PaymentInstrument::Applepay(WalletPayment {
                 payment_type: PaymentType::Encrypted,
-                wallet_token: Secret::new(data.payment_data),
+                wallet_token: data.get_applepay_decoded_payment_data()?,
                 ..WalletPayment::default()
             })),
             WalletData::AliPayQr(_)

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

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

## Description
This PR fixes the ApplePay integration with WorldPay.

### 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
This PR enables processing ApplePay txns through WorldPay.


## How did you test it?
Tested locally by setting up ApplePay with Worldpay connector

<details>
    <summary>Process an ApplePay txn through WP</summary>

- Create a payment link

cURL

    curl --location --request POST 'http://localhost:8080/payments' \
        --header 'Content-Type: application/json' \
        --header 'Accept: application/json' \
        --header 'api-key: dev_roIAheQpBhdk54rvqzIWVex9ffGGpoTEDrpqhygbxtyZgsuGlPeOb6sHs5gRwP65' \
        --data-raw '{"authentication_type":"three_ds","customer_id":"cus_G6gAIQuPgLJqht6Ny27k","profile_id":"pro_QSzisIfNqLE7FdEU3Wmr","amount":100,"currency":"USD","payment_link":true,"description":"This is my description of why this payment was requested.","capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"john.doe@example.co.in","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#0E103D","logo":"https://hyperswitch.io/favicon.ico","seller_name":"Hyperswitch Inc.","enabled_saved_payment_method":true,"hide_card_nickname_field":true,"show_card_form_by_default":true,"transaction_details":[{"key":"Policy Number","value":"938478327648","ui_configuration":{"is_key_bold":false,"is_value_bold":false,"position":2}},{"key":"Business Country","value":"Germany","ui_configuration":{"is_key_bold":false,"is_value_bold":false,"position":1}},{"key":"Product Name","value":"Life Insurance Elite","ui_configuration":{"is_key_bold":false,"is_value_bold":false,"position":3}}]}}'

Response

    {"payment_id":"pay_i5hWlAfZJt989EoU0Qzn","merchant_id":"merchant_1737359846","status":"requires_payment_method","amount":100,"net_amount":100,"shipping_cost":null,"amount_capturable":100,"amount_received":null,"connector":null,"client_secret":"pay_i5hWlAfZJt989EoU0Qzn_secret_WSq9QS2DQqybQHc2FrIO","created":"2025-01-20T08:43:12.479Z","currency":"USD","customer_id":"cus_G6gAIQuPgLJqht6Ny27k","customer":{"id":"cus_G6gAIQuPgLJqht6Ny27k","name":"John Nether","email":"john.doe@example.co.in","phone":"6168205362","phone_country_code":"+1"},"description":"This is my description of why this payment was requested.","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":null,"payment_method_data":null,"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"CA","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":null},"order_details":null,"email":"john.doe@example.co.in","name":"John Nether","phone":"6168205362","return_url":"https://example.com/","authentication_type":"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":null,"connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_G6gAIQuPgLJqht6Ny27k","created_at":1737362592,"expires":1737366192,"secret":"epk_522026e973534fa0b6e85fc425de48ec"},"manual_retry_allowed":null,"connector_transaction_id":null,"frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":null,"payment_link":{"link":"https://onemore.tame-bird-39.telebit.io/payment_link/merchant_1737359846/pay_i5hWlAfZJt989EoU0Qzn?locale=en","secure_link":null,"payment_link_id":"plink_3VVma7RRENT8hvLlfCko"},"profile_id":"pro_QSzisIfNqLE7FdEU3Wmr","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":null,"incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-01-21T12:29:52.477Z","fingerprint":null,"browser_info":null,"payment_method_id":null,"payment_method_status":null,"updated":"2025-01-20T08:43:12.492Z","split_payments":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null}

- Open payment link and complete txn
- Retrieve payment

cURL

    curl --location --request GET 'http://localhost:8080/payments/pay_i5hWlAfZJt989EoU0Qzn?force_sync=true' \
        --header 'Accept: application/json' \
        --header 'api-key: dev_roIAheQpBhdk54rvqzIWVex9ffGGpoTEDrpqhygbxtyZgsuGlPeOb6sHs5gRwP65'

Response

    {"payment_id":"pay_i5hWlAfZJt989EoU0Qzn","merchant_id":"merchant_1737359846","status":"succeeded","amount":100,"net_amount":100,"shipping_cost":null,"amount_capturable":0,"amount_received":100,"connector":"worldpay","client_secret":"pay_i5hWlAfZJt989EoU0Qzn_secret_WSq9QS2DQqybQHc2FrIO","created":"2025-01-20T08:43:12.479Z","currency":"USD","customer_id":"cus_G6gAIQuPgLJqht6Ny27k","customer":{"id":"cus_G6gAIQuPgLJqht6Ny27k","name":"John Nether","email":"john.doe@example.co.in","phone":"6168205362","phone_country_code":"+1"},"description":"This is my description of why this payment was requested.","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":"wallet","payment_method_data":{"wallet":{"apple_pay":{"last4":"0492","card_network":"Visa","type":"debit"}},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"CA","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":null},"order_details":null,"email":"john.doe@example.co.in","name":"John Nether","phone":"6168205362","return_url":"https://example.com/","authentication_type":"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":"apple_pay","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":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNi4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLg2sGkO:vYpWC37Db6JbhdEll9fIyaH2kwt88eyzXjPICpZY8cZeCeMgt1ol:GABqQG6u+T:u3sfHv3ezSOJxioRTixsThPEhzFW4ZZ6mObj3CK0rnFndcM0swvZMqgQwSEj5tBsydfzM4XKX20O6Nme96ha9twqxTSQIfr1rtl9V3q7fw3w5O9UZT4vQi9BMyCcaHkWSD:RbCWCcmiQqa68XlOgjFizTujqaSOCiqD3rKLoKWRGY+zDciMqs+3KEOGqQBtmdOWzHeNbZ7Y2C6t+hQ9RR:Z491q0vLPK+etGkmyVNB6HsgNKLVR8BWjehM+WuX0NAJU:Z4P8Bpdq0Is5ExjJf8mIzQPCvm4AC2kHDz9uIAwzPK7A7AtWsm1vb","frm_message":null,"metadata":null,"connector_metadata":null,"feature_metadata":null,"reference_id":"1e5bf75c-944c-4446-9cf0-f3720ee9c894","payment_link":null,"profile_id":"pro_QSzisIfNqLE7FdEU3Wmr","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_GHrUdffckdzZorvJydsF","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-01-21T12:29:52.477Z","fingerprint":null,"browser_info":{"os_type":"macOS","language":"en-US","time_zone":-330,"ip_address":"127.0.0.1","os_version":"10.15.7","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15","color_depth":24,"device_model":"Macintosh","java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":null,"payment_method_status":null,"updated":"2025-01-20T08:44:49.142Z","split_payments":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null}

</details>


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