hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

refactor(connector): [WorldpayWPG] Refactored payout flow

Open Vani-1107 opened this issue 1 month ago • 2 comments

Type of Change

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

Description

  • Refactored the code
  • saving the card_network if we receive it in request for cards and apple pay to later populate it back during conversion back to payout_method_data (No test cases)
  • Fixed cargo ci-hack check failing in main

Additional Changes

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

How did you test it?

Screenshot 2025-11-12 at 3 00 51 PM
Payout - applepay decrypt

Request:


{
    "amount": 100,
    "currency": "GBP",
    "customer_id": "payout_customer1",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payout request",
    "payout_type": "wallet",
    "payout_method_data": {
        "wallet": {
            "apple_pay_decrypt": {
                "dpan": "4444333322221111",
                "expiry_month": "05",
                "expiry_year": "2035",
                "card_holder_name": "John Appleseed"
            }
        }
    },
    "billing": {
        "address": {
            "city": "Los Angeles",
            "country": "US",
            "line1": "123 Main St",
            "line2": "Apt 4B",
            "zip": "90001",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "entity_type": "Individual",
    "recurring": false,
    "auto_fulfill": true,
    "confirm": true
}

Response :


{
    "payout_id": "payout_MW3Vow0WrKvmBaXXsUCf",
    "merchant_id": "merchant_1763126458",
    "merchant_order_reference_id": null,
    "amount": 100,
    "currency": "GBP",
    "connector": "worldpayxml",
    "payout_type": "wallet",
    "payout_method_data": {
        "wallet": {
            "email": null,
            "telephone_number": null,
            "paypal_id": null
        }
    },
    "billing": {
        "address": {
            "city": "Los Angeles",
            "country": "US",
            "line1": "123 Main St",
            "line2": "Apt 4B",
            "line3": null,
            "zip": "90001",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "auto_fulfill": true,
    "customer_id": "payout_customer1",
    "customer": {
        "id": "payout_customer1",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_payout_MW3Vow0WrKvmBaXXsUCf_secret_TO2Mxieec70EFVO5w4E0",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": false,
    "metadata": {},
    "merchant_connector_id": "mca_B9MGFAetWWIb3h98lTZ2",
    "status": "initiated",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_VaadBUi3MkKMNdvFUSCO",
    "created": "2025-11-14T13:22:05.188Z",
    "connector_transaction_id": "payout_MW3Vow0WrKvmBaXXsUCf_1",
    "priority": null,
    "payout_link": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "unified_code": null,
    "unified_message": null,
    "payout_method_id": null
}

Payout - card

Request:


{
    "amount": 100,
    "currency": "GBP",
    "customer_id": "payout_customer11",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payout request",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_number": "5454545454545454",
            "expiry_month": "12",
            "expiry_year": "2025",
            "card_holder_name": "CL-BRW1",
            "card_network": "Mastercard"
        }
    },
    "entity_type": "Individual",
    "recurring": true,
    "auto_fulfill": true,
    "confirm": true
}

Response:


{
    "payout_id": "payout_gjz1yv2dFkgAJYKPFXUY",
    "merchant_id": "merchant_1763126458",
    "merchant_order_reference_id": null,
    "amount": 100,
    "currency": "GBP",
    "connector": "worldpayxml",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_issuer": null,
            "card_network": "Mastercard",
            "card_type": null,
            "card_issuing_country": null,
            "bank_code": null,
            "last4": "5454",
            "card_isin": "545454",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2025",
            "card_holder_name": "CL-BRW1"
        }
    },
    "billing": null,
    "auto_fulfill": true,
    "customer_id": "payout_customer11",
    "customer": {
        "id": "payout_customer11",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_payout_gjz1yv2dFkgAJYKPFXUY_secret_rnfaI8xcUqiLxXl6znMq",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {},
    "merchant_connector_id": "mca_B9MGFAetWWIb3h98lTZ2",
    "status": "initiated",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_VaadBUi3MkKMNdvFUSCO",
    "created": "2025-11-14T13:22:47.177Z",
    "connector_transaction_id": "payout_gjz1yv2dFkgAJYKPFXUY_1",
    "priority": null,
    "payout_link": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "unified_code": null,
    "unified_message": null,
    "payout_method_id": "pm_v0Slf5GGpNu4HNCwj6hE"
}

Payout - cancel

Request:


curl --location 'http://localhost:8080/payouts/payout_gjz1yv2dFkgAJYKPFXUY/cancel' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_PPaGv7lb9xKYmaj2IdVWgaoU' \
--data '{
    "payout_id": "payout_gjz1yv2dFkgAJYKPFXUY"
}'

Response:


{
    "payout_id": "payout_gjz1yv2dFkgAJYKPFXUY",
    "merchant_id": "merchant_1763126458",
    "merchant_order_reference_id": null,
    "amount": 100,
    "currency": "GBP",
    "connector": "worldpayxml",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_issuer": null,
            "card_network": "Mastercard",
            "card_type": null,
            "card_issuing_country": null,
            "bank_code": null,
            "last4": "5454",
            "card_isin": "545454",
            "card_extended_bin": null,
            "card_exp_month": "12",
            "card_exp_year": "2025",
            "card_holder_name": "CL-BRW1"
        }
    },
    "billing": null,
    "auto_fulfill": true,
    "customer_id": "payout_customer11",
    "customer": {
        "id": "payout_customer11",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_payout_gjz1yv2dFkgAJYKPFXUY_secret_rnfaI8xcUqiLxXl6znMq",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {},
    "merchant_connector_id": "mca_B9MGFAetWWIb3h98lTZ2",
    "status": "cancelled",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_VaadBUi3MkKMNdvFUSCO",
    "created": "2025-11-14T13:22:47.177Z",
    "connector_transaction_id": "payout_gjz1yv2dFkgAJYKPFXUY_1",
    "priority": null,
    "payout_link": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "unified_code": null,
    "unified_message": null,
    "payout_method_id": "pm_v0Slf5GGpNu4HNCwj6hE"
}

Checklist

  • [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

Vani-1107 avatar Nov 12 '25 09:11 Vani-1107

Codecov Report

:x: Patch coverage is 0% with 56 lines in your changes missing coverage. Please review. :warning: Please upload report for BASE (main@bc9c8fa). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...nectors/src/connectors/worldpayxml/transformers.rs 0.00% 38 Missing :warning:
crates/router/src/core/payment_methods/vault.rs 0.00% 16 Missing :warning:
...es/router/src/core/payment_methods/transformers.rs 0.00% 2 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10226   +/-   ##
=======================================
  Coverage        ?    6.49%           
=======================================
  Files           ?     1233           
  Lines           ?   308739           
  Branches        ?        0           
=======================================
  Hits            ?    20068           
  Misses          ?   288671           
  Partials        ?        0           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 12 '25 09:11 codecov[bot]