hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

fix: incorrect payout_method_id in payouts table

Open sumanmaji4 opened this issue 7 months ago • 1 comments

Type of Change

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

Description

Retrieving payout_method_id across various cases and updating it in the payouts table accordingly

Additional Changes

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

Motivation and Context

How did you test it?

Tested locally by connecting to the local Hyperswitch Card Vault Screenshot 2025-05-26 at 2 11 24 PM

Payout Create Request

curl --location 'http://localhost:8080/payouts/create' \
--header 'Content-Type: application/json' \
--header 'api-key: hidden' \
--data-raw '{
    "amount": 21,
    "currency": "EUR",
    "profile_id": "pro_oG*****inD",
    "customer": {
        "id": "new_id",
        "email": "[email protected]",
        "name": "John Doe",
        "phone": "99*****99",
        "phone_country_code": "+65"
    },
    "connector": [
        "adyen"
    ],
    "description": "Its my first payout request",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_number": "4111 1111 1111 1111",
            "expiry_month": "03",
            "expiry_year": "2030",
            "card_holder_name": "John Doe"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            
            "city": "San Fransico",
            "state": "CA",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "80*****27",
            "country_code": "+91"
        }
    },
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "confirm": true,
    "auto_fulfill": true
}'

Payout Create Response

{
    "payout_id": "3c479b29-*****-ca06536a0f67",
    "merchant_id": "merchant_1748*****8",
    "amount": 21,
    "currency": "EUR",
    "connector": "adyen",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_issuer": null,
            "card_network": null,
            "card_type": null,
            "card_issuing_country": null,
            "bank_code": null,
            "last4": "1111",
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "John Doe"
        }
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": null,
            "zip": "94122",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "805*****27",
            "country_code": "+91"
        },
        "email": null
    },
    "auto_fulfill": true,
    "customer_id": "new_id",
    "customer": {
        "id": "new_id",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "99*****99",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_3c479b29-8a*****f67_secret_Swtw*****BfBb6j",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "merchant_connector_id": "mca_jmmK*****jm",
    "status": "success",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_oG*****inD",
    "created": "2025-05-26T08:46:58.731Z",
    "connector_transaction_id": "ZK*****75",
    "priority": null,
    "payout_link": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "99*****9",
    "phone_country_code": "+65",
    "unified_code": null,
    "unified_message": null,
    "payout_method_id": "pm_qvu*****EN"
}

Payout Sync Request

curl --location 'http://localhost:8080/payouts/3c479b29-*****-ca06536a0f67?force_sync=true' \
--header 'api-key: hidden'

Payout Sync Response

{
    "payout_id": "3c479b29-*****-ca06536a0f67",
    "merchant_id": "merchant_174*****8",
    "amount": 21,
    "currency": "EUR",
    "connector": "adyen",
    "payout_type": "card",
    "payout_method_data": {
        "card": {
            "card_issuer": null,
            "card_network": null,
            "card_type": null,
            "card_issuing_country": null,
            "bank_code": null,
            "last4": "1111",
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "John Doe"
        }
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": null,
            "zip": "94122",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "805*****27",
            "country_code": "+91"
        },
        "email": null
    },
    "auto_fulfill": true,
    "customer_id": "new_id",
    "customer": {
        "id": "new_id",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "99*****99",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_3c479b29-*****-ca06536a0f67_secret_Sw*****b6j",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "merchant_connector_id": "mca_jmmK*****m",
    "status": "success",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_oGi*****nD",
    "created": "2025-05-26T08:46:58.731Z",
    "connector_transaction_id": "ZK*****75",
    "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_qvue0o*****eEN"
}

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

sumanmaji4 avatar May 22 '25 06:05 sumanmaji4

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payouts/helpers.rs  71% smaller

semanticdiff-com[bot] avatar May 22 '25 06:05 semanticdiff-com[bot]