Skip to content

feat(connector): [Adyenplatform] process payouts using PSP tokens#9040

Merged
likhinbopanna merged 5 commits intomainfrom
9010-feature-extend-psp-token-provisioning-through-adyen-platform
Aug 25, 2025
Merged

feat(connector): [Adyenplatform] process payouts using PSP tokens#9040
likhinbopanna merged 5 commits intomainfrom
9010-feature-extend-psp-token-provisioning-through-adyen-platform

Conversation

@kashif-m
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR adds support for Adyen tokenized card payouts in the AdyenPlatform connector. This enables processing payouts using stored PSP tokens

  • Restructured AdyenCardIdentification as an enum supporting both raw card data and stored payment method IDs
  • Added StoredPaymentCounterparty and RawPaymentCounterparty for handling different payment method types
  • Implemented fallback logic: stored payment method ID → raw card details
  • Added fetch_payout_method_data helper function to centralize payout method data retrieval
  • Enhanced validator to check for stored transfer method IDs before fetching raw card details

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Enables merchants to process Adyen payouts using previously stored PSP tokens without requiring raw card data. This is helpful for migrated PSP tokens (created outside of HS).

How did you test it?

1. Create a payment CIT

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_ACto5kMwzvZvAZCM5LMfFoDaBxAKHNeQkYVRuitCrf2Q30DrqxbPr6YFOe8c2f3l' \
    --data-raw '{"amount":4500,"currency":"EUR","confirm":true,"profile_id":"pro_S5yvh1TfnZi2Gjv7uSUQ","capture_method":"automatic","authentication_type":"three_ds","setup_future_usage":"off_session","customer_id":"cus_payment_cit_1","email":"abc@example.com","return_url":"https://google.com","payment_method":"card","payment_method_type":"debit","payment_method_data":{"card":{"card_number":"4111111111111111","card_exp_month":"03","card_exp_year":"2030","card_cvc":"737"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","zip":"94122","country":"SG","first_name":"joseph","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true,"ip_address":"127.0.0.1"},"customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"session_expiry":2890}'

Response

{"payment_id":"pay_funVtY7kQ3avj2SN3Lzm","merchant_id":"merchant_1755863240","status":"succeeded","amount":4500,"net_amount":4500,"shipping_cost":null,"amount_capturable":0,"amount_received":4500,"connector":"adyen","client_secret":"pay_funVtY7kQ3avj2SN3Lzm_secret_cR7UTM6j2h1jabVHAFHq","created":"2025-08-22T12:57:49.884Z","currency":"EUR","customer_id":"cus_uRtCHhDU0C2hafZMVHx1","customer":{"id":"cus_uRtCHhDU0C2hafZMVHx1","name":"Albert Klaassen","email":"abc@example.com","phone":"6168205362","phone_country_code":"+1"},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"1111","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"411111","card_extended_bin":null,"card_exp_month":"03","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"SG","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":null,"first_name":"joseph","last_name":"Doe","origin_zip":null},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"order_details":null,"email":"abc@example.com","name":"Albert Klaassen","phone":"6168205362","return_url":"https://google.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":"debit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_uRtCHhDU0C2hafZMVHx1","created_at":1755867469,"expires":1755871069,"secret":"epk_fdc03a4797ef451a98b2929bcfc398ca"},"manual_retry_allowed":false,"connector_transaction_id":"VCV7F35F2L3C37V5","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":{"redirect_response":null,"search_tags":null,"apple_pay_recurring_details":null,"gateway_system":"direct"},"reference_id":"pay_funVtY7kQ3avj2SN3Lzm_1","payment_link":null,"profile_id":"pro_sHtakSPxfG6JnK0wpCKG","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_A3zlBnD9y8WvakW0ratr","incremental_authorization_allowed":false,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-08-22T13:45:59.884Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"127.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"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_channel":null,"payment_method_id":"pm_L6rQCpfqi5f1OAG4DHIG","network_transaction_id":"056847192959811","payment_method_status":"active","updated":"2025-08-22T12:57:50.457Z","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":"X99D3DNTHP447NV5","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}

Manually update connector_mandate_detail to include payout MCA as well

{
    "mca_A3zlBnD9y8WvakW0ratr": {
        "mandate_metadata": null,
        "payment_method_type": "debit",
        "connector_mandate_id": "X99D3DNTHP447NV5",
        "connector_mandate_status": "active",
        "original_payment_authorized_amount": 4500,
        "original_payment_authorized_currency": "EUR",
        "connector_mandate_request_reference_id": "GOSHRSEHXi2emhKCLC"
    }
}

Updated to

{
    "mca_A3zlBnD9y8WvakW0ratr": {
        "mandate_metadata": null,
        "payment_method_type": "debit",
        "connector_mandate_id": "X99D3DNTHP447NV5",
        "connector_mandate_status": "active",
        "original_payment_authorized_amount": 4500,
        "original_payment_authorized_currency": "EUR",
        "connector_mandate_request_reference_id": "GOSHRSEHXi2emhKCLC"
    },
    "payouts": {
        "mca_NsHlFe2GsWvK9CdftrLt": {
            "transfer_method_id": "X99D3DNTHP447NV5"
        }
    }
}
2. Create a payout using payout_method_id

cURL

curl --location --request POST 'http://localhost:8080/payouts/create' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_XKQaI34jBT7ZKVNZtpbrc1feIuijxd7MgPf8GMFvqLxniEGUdbNoKPcm0r8aHZhg' \
    --data '{"payout_method_id":"pm_L6rQCpfqi5f1OAG4DHIG","amount":100,"currency":"EUR","customer_id":"cus_CzI1yN5av9n1nICj0ofl","connector":["adyenplatform"],"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"DE","first_name":"Albert","last_name":"Klassen"},"phone":{"number":"8056594427","country_code":"+91"}},"entity_type":"Individual","recurring":true,"metadata":{"ref":"123"},"confirm":true,"auto_fulfill":true}'

Response

{"payout_id":"payout_wJvyBtv3lJXXYe2f2Zlo","merchant_id":"merchant_1755867774","merchant_order_reference_id":null,"amount":100,"currency":"EUR","connector":"adyenplatform","payout_type":"card","payout_method_data":null,"billing":{"address":{"city":"San Fransico","country":"DE","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"CA","first_name":"Albert","last_name":"Klassen","origin_zip":null},"phone":{"number":"8056594427","country_code":"+91"},"email":null},"auto_fulfill":true,"customer_id":"cus_CzI1yN5av9n1nICj0ofl","customer":{"id":"cus_CzI1yN5av9n1nICj0ofl","name":"Albert Klaassen","email":"abc@example.com","phone":"6168205362","phone_country_code":"+1"},"client_secret":"payout_payout_wJvyBtv3lJXXYe2f2Zlo_secret_jgJ0TCCA8exlXEeh5KsK","return_url":null,"business_country":null,"business_label":null,"description":null,"entity_type":"Individual","recurring":true,"metadata":{"ref":"123"},"merchant_connector_id":"mca_8gi7OlijF22Wv9ImMR4w","status":"initiated","error_message":null,"error_code":null,"profile_id":"pro_8lrTNA9EX88OGfPXiElF","created":"2025-08-22T14:57:13.628Z","connector_transaction_id":"38EBH7682DK7VMVK","priority":null,"payout_link":null,"email":"abc@example.com","name":"Albert Klaassen","phone":"6168205362","phone_country_code":"+1","unified_code":null,"unified_message":null,"payout_method_id":"pm_L6rQCpfqi5f1OAG4DHIG"}

Checklist

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

@kashif-m kashif-m self-assigned this Aug 22, 2025
@kashif-m kashif-m requested review from a team as code owners August 22, 2025 15:11
@kashif-m kashif-m linked an issue Aug 22, 2025 that may be closed by this pull request
2 tasks
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 22, 2025

Comment on lines +38 to +39
export OPENSSL_DIR="${pkgs.openssl.dev}"
export OPENSSL_LIB_DIR="${pkgs.openssl.out}/lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change needed?

Copy link
Contributor Author

@kashif-m kashif-m Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Needed for cases when there's openssl installed in the system, to differentiate between nix and system env.

@likhinbopanna likhinbopanna added this pull request to the merge queue Aug 25, 2025
Merged via the queue into main with commit b8c5bf3 Aug 25, 2025
21 of 25 checks passed
@likhinbopanna likhinbopanna deleted the 9010-feature-extend-psp-token-provisioning-through-adyen-platform branch August 25, 2025 13:10
Pradesh-S pushed a commit that referenced this pull request Aug 26, 2025
)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] extend PSP token provisioning through Adyen Platform

7 participants