Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(payouts): update helper functions for deciding whether or not to consume flows based on current status #5248

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Jul 9, 2024

Type of Change

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

Description

This PR fixes below bugs

  • default status (based on different conditions) does not update in payouts table
  • payout status updation during confirmation happens prior to validating the request
  • helper functions for deciding whether or not to execute different payout flows does not have the updated status list

Additional Changes

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

Motivation and Context

Tested locally using payout's test suite.

How did you test it?

  1. Create a payout using confirm: false, auto_fulfill: false
curl --location 'https://heard-directly-trademarks-diana.trycloudflare.com/payouts/create' \
--header 'x-feature: integ-custom' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_N4b6S09H8f5CHy1vvGEEyvyJcUqcs64R84eVkCtdBr3iTYFOGhCHieJlkoJUSs7w' \
--data-raw '{
    "amount": 1,
    "currency": "EUR",
    "customer_id": "cus_ZcGmeCSo9O0YMHx8S9KT",
    "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": "example@example.com"
            }
        }
    },
    "connector": [
        "adyen"
    ],
    "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"
        }
    },
    "entity_type": "NaturalPerson",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "confirm": false,
    "auto_fulfill": false
}'
  1. Confirm payout
curl --location 'https://heard-directly-trademarks-diana.trycloudflare.com/payouts/46e549bf-8f7c-491f-96c7-f79087074b3d/confirm' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_N4b6S09H8f5CHy1vvGEEyvyJcUqcs64R84eVkCtdBr3iTYFOGhCHieJlkoJUSs7w' \
--data '{
}'
  1. Fulfill payout
curl --location 'https://heard-directly-trademarks-diana.trycloudflare.com/payouts/46e549bf-8f7c-491f-96c7-f79087074b3d/fulfill' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_N4b6S09H8f5CHy1vvGEEyvyJcUqcs64R84eVkCtdBr3iTYFOGhCHieJlkoJUSs7w' \
--data '{
}'

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

…t to consume flows based on current status

refactor(payouts): execute connector steps only when confirm is true in create / update flow
@kashif-m kashif-m self-assigned this Jul 9, 2024
@kashif-m kashif-m requested a review from a team as a code owner July 9, 2024 05:42
@kashif-m kashif-m linked an issue Jul 9, 2024 that may be closed by this pull request
2 tasks
@sahkal sahkal added this to the July 2024 Release milestone Jul 11, 2024
@sahkal sahkal added the Payouts Area: Payouts label Jul 11, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 12, 2024
Merged via the queue into main with commit d65d7b5 Jul 12, 2024
29 checks passed
@likhinbopanna likhinbopanna deleted the payout_refactors branch July 12, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Payouts Area: Payouts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Payout in stages
4 participants