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

feat(payout): [Payone] add payone connector #4553

Merged
merged 41 commits into from
May 30, 2024
Merged

Conversation

KiranKBR
Copy link
Contributor

@KiranKBR KiranKBR commented May 6, 2024

Type of Change

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

Description

Payone is Payout connector and I have implemented payout fulfill flow

How did you test it?

I tested them through postman and here these are the requests and responses
Merchant Connector:

--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payout_processor",
    "connector_name": "payone",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "",
        "api_secret": "",
        "key1": ""
    },
    "test_mode": false,
    "disabled": false,
    "business_country": "US",
    "business_label": "default",
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        
                
                        "Mastercard",
                        "Visa"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "metadata": {
        "city": "NY",
        "unit": "245"
    }
}'

response:

{
    "connector_type": "payout_processor",
    "connector_name": "payone",
    "connector_label": "payone_US_default",
    "merchant_connector_id": "mca_Rufh4UB4ctrHhOV8JQzG",
    "profile_id": "pro_cp4l2sD7NggkM66Cvrfz",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "",
        "api_secret": "",
        "key1": ""
    },
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "payment_experience": null,
                    "card_networks": [
                        "Mastercard",
                        "Visa"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "payment_experience": null,
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": false,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "test_mode": false,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active"
}

Payout Creation:

{
    "amount": 100,
    "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": "card",
    "payout_method_data": {
        "card": {
            "card_number": "4012000033330026",
            "expiry_month": "05",
            "expiry_year": "30",
            "card_holder_name": "John Smith"
        }
    },
    "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": "Individual",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
        "business_country": "US",
    "business_label": "default",
    // "routing": {
    //     "type": "single",
    //     "data": "adyen"
    // },
    "auto_fulfill": true,
    "confirm": true
}

response:

{
    "payout_id": "5ec9e6ac-1bbc-4236-a217-e0ff890e7f2e",
    "merchant_id": "merchant_1715339934",
    "amount": 100,
    "currency": "EUR",
    "connector": "payone",
    "payout_type": "card",
    "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"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "customer_id": "payout_customer",
    "auto_fulfill": true,
    "email": "payout_customer@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "client_secret": null,
    "return_url": null,
    "business_country": "US",
    "business_label": "default",
    "description": "Its my first payout request",
    "entity_type": "Individual",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
    "status": "success",
    "error_message": null,
    "error_code": null,
    "profile_id": "pro_cp4l2sD7NggkM66Cvrfz",
    "created": "2024-05-10T11:25:54.497Z"
}

Additional Changes

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

Motivation and Context

4902

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

@KiranKBR KiranKBR requested review from a team as code owners May 6, 2024 06:16
@KiranKBR KiranKBR changed the title (feat) : [Payone Payout] added flows feat(payout): [Payone] May 6, 2024
@KiranKBR KiranKBR changed the title feat(payout): [Payone] feat(payout): [Payone] add payone connector May 6, 2024
@Sakilmostak
Copy link
Contributor

Required CI checks are failing, could you address that

@KiranKBR KiranKBR linked an issue May 7, 2024 that may be closed by this pull request
2 tasks
@KiranKBR KiranKBR added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels May 7, 2024
@KiranKBR KiranKBR self-assigned this May 7, 2024
@KiranKBR KiranKBR added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 8, 2024
@KiranKBR KiranKBR changed the base branch from main to payone-template-code May 8, 2024 09:22
@KiranKBR KiranKBR requested review from a team as code owners May 8, 2024 09:22
Sakilmostak
Sakilmostak previously approved these changes May 22, 2024
message: errors
.iter()
.map(|error| format!("{} : {}", error.code, error.message))
.collect::<Vec<_>>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Define the type of the vector

errors
.iter()
.map(|error| format!("{} : {}", error.code, error.message))
.collect::<Vec<_>>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Define the type of the vector

let code = first_error.map(|error| error.code.clone());
Ok(ErrorResponse {
status_code: res.status_code,
code: code.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Discuss with @sai-harsha-vardhan , how retries work, and then decide how the error_code should be populated

Comment on lines 171 to 174
_ => Err(errors::ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("Payone"),
))?,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this default

},
PayoutMethodData::Bank(_) | PayoutMethodData::Wallet(_) => {
Err(errors::ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("Payout"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
get_unimplemented_payment_method_error_message("Payout"),
get_unimplemented_payment_method_error_message("Payone"),

kashif-m
kashif-m previously approved these changes May 24, 2024
SamraatBansal
SamraatBansal previously approved these changes May 26, 2024
crates/router/src/utils.rs Outdated Show resolved Hide resolved
crates/router/src/connector/utils.rs Outdated Show resolved Hide resolved
crates/router/src/connector/payone.rs Show resolved Hide resolved
crates/router/src/connector/payone.rs Show resolved Hide resolved
@KiranKBR KiranKBR dismissed stale reviews from SamraatBansal and kashif-m via 892f9df May 27, 2024 14:10
SamraatBansal
SamraatBansal previously approved these changes May 28, 2024
let format = time::macros::format_description!($date_format);
time::OffsetDateTime::now_utc()
.format(&format)
.change_context(errors::ConnectorError::InvalidDateFormat)
Copy link
Member

Choose a reason for hiding this comment

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

Would have preferred using the fully qualified name for this error usage: router::core::errors::ConnectorError.

@likhinbopanna likhinbopanna added this pull request to the merge queue May 30, 2024
Merged via the queue into main with commit 832968c May 30, 2024
10 checks passed
@likhinbopanna likhinbopanna deleted the payone-payout-flows branch May 30, 2024 09:57
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants