Skip to content

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Jun 6, 2024

Type of Change

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

Description

moved payout quote call to payout core from execute_pretasks

Other changes:
Removed unused functions from trait ConnectorIntegration
namely fn execute_pretasks and fn execute_posttasks

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?

Manual

  1. create a merchant
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "merchant_id": "merchant_1717682611",
    "locker_id": "m0010",
    "merchant_name": "NewAge Retailer",
    "merchant_details": {
        "primary_contact_person": "John Test",
        "primary_email": "[email protected]",
        "primary_phone": "sunt laborum",
        "secondary_contact_person": "John Test2",
        "secondary_email": "[email protected]",
        "secondary_phone": "cillum do dolor id",
        "website": "https://www.example.com",
        "about_business": "Online Retail with a wide selection of organic products for North America",
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US"
        }
    },
    "return_url": "https://google.com/success",
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true
    },
    "sub_merchants_enabled": false,
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "primary_business_details": [
        {
            "country": "US",
            "business": "food"
        }
    ]
}'
  1. create wise as payout connector
curl --location 'http://localhost:8080/account/merchant_1717683418/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-feature: integ-custom' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payout_processor",
    "connector_name": "wise",
    "connector_account_details": {
        "auth_type": "BodyKey",
        "api_key": "Bearer 79460cd6-6605-40e6-b72a-3610a62c4894",
        "key1": "16752571"
    },
    "test_mode": false,
    "disabled": false,
    "metadata": {
        "city": "NY",
        "unit": "245"
    }
}'
  1. Create a payout with BACS
curl --location 'http://localhost:8080/payouts/create' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_ZfAFt6ZWvfgxRnWa3SadhIawrVaImUMUCHapTqlbkLFdrqyAYR1BKbYnahJPa0iI' \
--data-raw '{
    "amount": 10,
    "currency": "GBP",
    "customer_id": "cus_fk0raOAfl9oQ7giF1TpF",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payout request",
    "payout_type": "bank",
    "connector": [
        "wise"
    ],
    "payout_method_data": {
        "bank": {
            "bank_sort_code": "231470",
            "bank_account_number": "28821822",
            "bank_name": "Deutsche Bank",
            "bank_country_code": "NL",
            "bank_city": "Amsterdam"
        }
    },
    "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": "Individual",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "confirm": true,
    "auto_fulfill": true
}'

Response:

{
    "payout_id": "eb745d64-296f-4c37-b9c2-dad7e482902f",
    "merchant_id": "merchant_1717683418",
    "amount": 10,
    "currency": "GBP",
    "connector": "wise",
    "payout_type": "bank",
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "customer_id": "cus_fk0raOAfl9oQ7giF1TpF",
    "auto_fulfill": true,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "client_secret": null,
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "status": "success",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_d1YZAurn2YqTwYbgoNSd",
    "created": "2024-06-06T14:17:06.575Z",
    "connector_transaction_id": "53650840",
    "priority": null
}
  1. Create a payout with SEPA
curl --location 'http://localhost:8080/payouts/create' \
--header 'x-feature: integ-custom' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_ZfAFt6ZWvfgxRnWa3SadhIawrVaImUMUCHapTqlbkLFdrqyAYR1BKbYnahJPa0iI' \
--data-raw '{
    "amount": 10,
    "currency": "GBP",
    "customer_id": "cus_fk0raOAfl9oQ7giF1TpF",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payout request",
    "payout_type": "bank",
    "connector": [
        "wise"
    ],
    "payout_method_data": {
        "bank": {
            "iban": "NL46TEST0136169112",
            "bic": "ABNANL2A",
            "bank_name": "Deutsche Bank",
            "bank_country_code": "NL",
            "bank_city": "Amsterdam"
        }
    },
    "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": true,
    "auto_fulfill": true
}'

Response:

{
    "payout_id": "89605ae5-a1ac-425d-b250-52b614b20092",
    "merchant_id": "merchant_1717683418",
    "amount": 10,
    "currency": "GBP",
    "connector": "wise",
    "payout_type": "bank",
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "CA",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "customer_id": "cus_fk0raOAfl9oQ7giF1TpF",
    "auto_fulfill": true,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "client_secret": null,
    "return_url": null,
    "business_country": null,
    "business_label": null,
    "description": "Its my first payout request",
    "entity_type": "NaturalPerson",
    "recurring": true,
    "metadata": {
        "ref": "123"
    },
    "status": "success",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_d1YZAurn2YqTwYbgoNSd",
    "created": "2024-06-06T14:17:13.272Z",
    "connector_transaction_id": "53650842",
    "priority": 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

@hrithikesh026 hrithikesh026 added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Jun 6, 2024
@hrithikesh026 hrithikesh026 added this to the May 2024 Release milestone Jun 6, 2024
@hrithikesh026 hrithikesh026 requested a review from kashif-m June 6, 2024 13:27
@hrithikesh026 hrithikesh026 self-assigned this Jun 6, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners June 6, 2024 13:27
kashif-m
kashif-m previously approved these changes Jun 7, 2024
}
}
}
// async fn execute_pretasks(
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete this altogether, instead of commenting.

.execute_pretasks(&mut router_data, state)
.await
.to_payout_failed_response()?;
// connector_integration
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, delete if not needed

@hrithikesh026 hrithikesh026 requested review from kashif-m and jarnura June 7, 2024 08:15
kashif-m
kashif-m previously approved these changes Jun 7, 2024
@Gnanasundari24 Gnanasundari24 enabled auto-merge June 7, 2024 09:57
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit d0fd709 Jun 7, 2024
@Gnanasundari24 Gnanasundari24 deleted the move-execute_pretasks-to-payout-core-wise branch June 7, 2024 10:59
pixincreate added a commit that referenced this pull request Jun 7, 2024
…out-fix

* 'main' of github.com:juspay/hyperswitch:
  feat(connector): [BOA/CYB] Make state,zip optional for Non US CA Txns (#4915)
  refactor(payout): move payout quote call to payout core from execute_pretasks (#4900)
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants