Skip to content

fix(payouts): add should_continue flag for propagating error for each call#9531

Merged
likhinbopanna merged 1 commit intomainfrom
skip_call_based_on_payout_response
Oct 10, 2025
Merged

fix(payouts): add should_continue flag for propagating error for each call#9531
likhinbopanna merged 1 commit intomainfrom
skip_call_based_on_payout_response

Conversation

@Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Sep 24, 2025

Type of Change

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

Description

Paypal requires creation of access token before payment/payouts in its flow.
In Access token flow, we do get error response

PaypalAccessTokenErrorResponse { error: \"invalid_client\", error_description: \"Client Authentication failed\" }

The error response gets updated on router data but we don’t do a early return based on this condition thus this gets overwritten by payout’s response.
In this case, even if access token is not generated (null), it still goes to payout create flow and fails at connector service with missing value (5xx) (edited)

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 through Postman:

  • Create an MCA (Paypal payout) with incorrect credentials
  • Create a Paypal Payout
curl --location '{{baseUrl}}/payouts/create' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:{{api_key}}' \
--data-raw '{
    "amount": 1,
    "currency": "EUR",
    "customer_id": "payout_customer",
    "email": "payout_customer@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payout request",
    "payout_type": "wallet",
    "payout_method_data": {
        "wallet": {
            "paypal": {
                "email": "sk.sakil@juspay.in"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "NY",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "entity_type": "NaturalPerson",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
    "confirm": true,
    "auto_fulfill": true
}'

It should give out an 2xx with failed response:

{
    "payout_id": "payout_OCfkeZ0BRP1TvVBCbqJS",
    "merchant_id": "merchant_1758740236",
    "merchant_order_reference_id": null,
    "amount": 1,
    "currency": "EUR",
    "connector": "paypal",
    "payout_type": "wallet",
    "payout_method_data": {
        "wallet": {
            "email": "sk******@juspay.in",
            "telephone_number": null,
            "paypal_id": null
        }
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "NY",
            "first_name": "John",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "auto_fulfill": true,
    "customer_id": "payout_customer",
    "customer": {
        "id": "payout_customer",
        "name": "John Doe",
        "email": "payout_customer@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "client_secret": "payout_payout_OCfkeZ0BRP1TvVBCbqJS_secret_odzX4yMLCWleZmuNb9sh",
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "NaturalPerson",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
    "merchant_connector_id": "mca_jWza4o9JclyqVqh3maid",
    "status": "failed",
    "error_message": "invalid_client",
    "error_code": "invalid_client",
    "profile_id": "pro_yOBs0ZV2FcCS8k3ZEbCM",
    "created": "2025-09-24T18:58:12.868Z",
    "connector_transaction_id": null,
    "priority": null,
    "payout_link": null,
    "email": "payout_customer@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "unified_code": "UE_9000",
    "unified_message": "Something went wrong",
    "payout_method_id": null
}

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

@Sakilmostak Sakilmostak self-assigned this Sep 24, 2025
@Sakilmostak Sakilmostak added the C-bug Category: Bug label Sep 24, 2025
@Sakilmostak Sakilmostak requested a review from a team as a code owner September 24, 2025 04:52
@Sakilmostak Sakilmostak added the Payouts Area: Payouts label Sep 24, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 24, 2025

Review changes with  SemanticDiff

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

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Sep 29, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 10, 2025
Merged via the queue into main with commit f95c976 Oct 10, 2025
28 of 33 checks passed
@likhinbopanna likhinbopanna deleted the skip_call_based_on_payout_response branch October 10, 2025 07:57
drdholu pushed a commit to drdholu/hyperswitch that referenced this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Category: Bug Payouts Area: Payouts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX]: [PAYOUTS] add should_continue flag for propagating error for each call

4 participants