Paypal Payout API Integration

Hello,

I want to create a payout functionality in my website using PayPal. PayPal has a payout API to integrate into your website but I have no experiences with API’s (and the API connector plugin) and I do not know where to start.
Is there a plugin I can use to integrate this into my website or did some of you already integrate this functionality and want to provide some information? That would really help me.

Thanks.

2 Likes

Hello @Thimo,

Here’s how I have been using it for the user to sign up for a subscription plan (recurring payment):

STEP 1 - Login with PayPal


Login Dialog Redirect: Sorry about that
Access Token Endpoint: https://api.sandbox.paypal.com/v1/oauth2/token
User Profile Endpoint: https://api.sandbox.paypal.com/v1/identity/openidconnect/userinfo?schema=openid

STEP 2 - Create Billing Plan


Here’s the link to the Official PayPal API documentation where you get the template JSON Body: https://developer.paypal.com/docs/api/payments.billing-plans/v1/#billing-plans_create

Step 3 - Create Billing Agreement

Step 4 - Redirect the user to the agreement approval after creating the agreement:

Step 5 - Execute the agreement:

That’s it, @Thimo.
If you want to make a simple payment (not recurring), I suggest you use “Payments” or “Orders” from https://developer.paypal.com/docs/api/overview/.

Now, the thing is, I’m not too happy about this UX:

  1. First, the user has to click a button to Login to PayPal, so we can get his OAuth token.
  2. When the user is back in our app, he clicks another button so we can make an API request to create his billing agreement (assuming you already have a billing plan), and then redirect him (again!) to PayPal to approve this agreement.
  3. And then, when the user is once more back in our app, he clicks a button (or we perform an action any other way) to Execute the billing agreement.

Could anyone shed a light? Is this the best way to setup this payment flow?
Is there any way we could make the initial OAuth call and perform an API request in the same login, so the user doesn’t get redirected twice?

Thank you very much, and I hope I’ve helped, @Thimo.

4 Likes

Thank you so much for this great explanation! You helped a lot! I will try to integrate this API into my site and maybe I’ll find a solution for your problem.

Thanks again!

1 Like

Hi,
Did you manage to implement it with only one redirect?
Thanks,
Yon

Hello @yon1,

Yes, I did it with 2 steps :grin:

The main thing is that I learned how to connect with PayPal without having to login, just with a basic auth:

So, here’s how it goes:

Step 1 (Admin) - Create Billing Plans
Create every single billing plan you might use. My SaaS, for example, has 10 billing plans, each one with a different name, description and value. Here’s how you create a billing plan:


The Body JSON is:

{
  "name": "<Plan Name>",
  "description": "<Plan Description>",
  "type": "INFINITE",
  "payment_definitions": [
    {
      "name": "<Nome Def. Pgto>",
      "type": "REGULAR",
      "frequency": "MONTH",
      "frequency_interval": "1",
      "amount": {
        "value": "<Plan Amount>",
        "currency": "USD"
      },
      "cycles": "0"
    }
  ],
  "merchant_preferences": {
    "setup_fee": {
      "value": "<Setup Fee Amount>",
      "currency": "USD"
    },
    "return_url": "https://yourapp.com/api/1.1/oauth_redirect",
    "cancel_url": "https://yourapp.com/api/1.1/oauth_redirect",
    "auto_bill_amount": "YES",
    "initial_fail_amount_action": "CANCEL",
    "max_fail_attempts": "0"
  }
}

(That’s the way I setup the JSON. You can do it differently, just check out PayPal API Documentation with the full code, and change it however you like. I recommend using Postman to analyze if the code is correct)

Step 2 (Admin) - Activate Billing Plan
Change state to ACTIVE:

Ok, everything is set up for the user to subscribe to a plan now:

Step 1 (User) - Choose Plan and Approve
When the user clicks the button below, the app will “Create a Billing Agreement” and redirect the user to the Approval URL (I already showed how in the previous post).


This will redirect him to PayPal to choose how he’s going to pay.

Step 2 (User) - Confirm
When he gets back from the PayPal Approval Page, he will have a “token” parameter automatically set up by PayPal. Just “Execute Agreement” with this token, and show a Success Screen to the user.

So, basically, the user just has to click once to go to PayPal and choose payment method, and then click again to confirm when he gets back to the page.
It was possible by learning how to request APIs using BASIC (not Oauth), and by redesigning UX.

FYI, It’s already live and working in my app.

Hope I could help.

Cheers!

Renato

5 Likes

What did you use as username and password. Client_ID and Secret?

Hey @koechamos51,

(1) Access https://developer.paypal.com, click on your username at the top right, “Dashboard”.

(2) You will land at My Apps & Credentials, you probably have already created a REST API APP, if not, click “Create App”:

(3) Use the ‘Client ID’ as Username, and ‘Secret’ as Password (Beware of ‘Live’ and ‘Sandbox’ buttons up there, there should be different client ID’s and Secret’s for each):

Cheers,

Renato

thank you a lots!!

Greetings, someone who has updated information on how to make payments with paypal subscriptions since all this has changed and the APIs are now different, I have been trying to integrate PayPal for subscriptions for 2 days and nothing works … I would appreciate it very much …

@Thimo Did you ever manage to get PAYOUT functionality working? I found this forum post and all the solutions had nothing to do with Payouts specifically, but payments and plans. Would love to know if and how you got it working in the end!

Hey @renatoasse ,
i think you have mastered in it.
Thank you very much for this. I also needed this so badly.
I will try these all and then let you know.