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(connector): [Paypal] Add payout flow for wallet(Paypal and Venmo) #4406

Merged
merged 25 commits into from
May 2, 2024

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Apr 21, 2024

Type of Change

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

Description

Paypal and Venmo wallet is added for payout

Additional Changes

  • This PR modifies the API contract
    Paypal
 "payout_method_data": {
        "wallet": {
            "paypal": {
                "email": "sk.sakil@juspay.in",
                "telephone_number": "16608213349",
                "paypal_id": "G83KXTJ5EHCQ2"
            }
        }
    },

Venmo

 "payout_method_data": {
        "wallet": {
            "venmo": {
                "telephone_number": "16608213349"
            }
        }
    },

Motivation and Context

How did you test it?

Tested through Postman:

  • Create an MCA(Paypal Payout):
{
    "connector_type": "payout_processor",
    "connector_name": "paypal",
    "connector_account_details": {
        "auth_type": "BodyKey",
        "api_key": "{{api_key}}",
        "key1": "{{key1}}"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "affirm",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "afterpay_clearpay",
                    "payment_experience": "redirect_to_url",
                    "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": true,
                    "installment_payment_enabled": true
                }
                // {
                //     "payment_method_type": "venmo",
                //     "payment_experience": "redirect_to_url",
                //     "minimum_amount": 1,
                //     "maximum_amount": 68607706,
                //     "recurring_enabled": true,
                //     "installment_payment_enabled": true
                // }
            ]
        },
        {
            "payment_method": "bank_transfer",
            "payment_method_types": [
                {
                    "payment_method_type": "sepa",
                    //"payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "pix",
                    //"payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "bacs",
                    //"payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "merchant_id": "{{merchant_id}}",
        "name": "Mostak"
    },
    "business_country": "US",
    "business_label": "default"
}
  • Create a Payout:
{
    "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"
    },
    "routing": {
        "type": "single",
        "data": "paypal"
    },
    "confirm": true,
    "auto_fulfill": false
}

The status should be requires_fulfillment

  • Fulfill the payout:
{
    "payout_id": "{{payout_id}}"
}

The status should be pending

Venmo cant be tested since it is only available in production

Note: This affects only paypal payout flow

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
  • I added a CHANGELOG entry if applicable

@Sakilmostak Sakilmostak added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels Apr 21, 2024
@Sakilmostak Sakilmostak self-assigned this Apr 21, 2024
@Sakilmostak Sakilmostak requested review from a team as code owners April 21, 2024 15:49
@Sakilmostak Sakilmostak changed the base branch from main to payout_access_token_flow April 21, 2024 15:50
Base automatically changed from payout_access_token_flow to main April 25, 2024 06:47
crates/router/src/connector/paypal.rs Outdated Show resolved Hide resolved
crates/common_enums/src/enums.rs Outdated Show resolved Hide resolved
@Sakilmostak Sakilmostak requested review from a team as code owners April 29, 2024 20:31
@Sakilmostak Sakilmostak removed request for a team April 29, 2024 20:36
kashif-m
kashif-m previously approved these changes Apr 30, 2024

/// mobile number linked to paypal account
#[schema(value_type = String, example = "16608213349")]
pub telephone_number: Option<Secret<String>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it include phone country code as well? eg: +91

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope

@@ -21,6 +23,9 @@ use crate::{
},
};

#[cfg(feature = "payouts")]
const LANGUAGE: &str = "en-US";
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible to move this to consts crate? And name it better? PAYPAL_NOTIFICATION_SCRIPT_LANGUAGE ?

@@ -419,6 +420,9 @@ impl Vaultable for api::CardPayout {
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TokenizedWalletSensitiveValues {
pub email: Option<Email>,
pub telephone_number: Option<masking::Secret<String>>,
pub paypal_id: Option<masking::Secret<String>>,
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
pub paypal_id: Option<masking::Secret<String>>,
pub wallet_id: Option<masking::Secret<String>>,

srujanchikke
srujanchikke previously approved these changes Apr 30, 2024
Copy link
Contributor

@srujanchikke srujanchikke left a comment

Choose a reason for hiding this comment

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

Please resolve ci checks, feature flag needs to be added in const.rs

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit e4ed1e6 May 2, 2024
15 of 18 checks passed
@Gnanasundari24 Gnanasundari24 deleted the paypal_payout branch May 2, 2024 10:29
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.

6 participants