ShellRox
ShellRox

Reputation: 2602

Utilize Paypal API to send a single payment to email

Say i've had a cash out page on my website that included Paypal cash out system where user would specify his/her email. What is the new updated way to send single payment to the specified email? Which API would i need to use?

I've been researching it approximately for an hour and i can't seem to find a proper method, I've seen this:

curl -v https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token" \
  -d '{
  "sender_batch_header":{
    "sender_batch_id":"2014021801",
    "email_subject":"You have a payout!",
    "recipient_type":"EMAIL"
  },
  "items":[
    {
      "recipient_type":"EMAIL",
      "amount":{
        "value":"1.0",
        "currency":"USD"
      },
      "note":"Thanks for your patronage!",
      "sender_item_id":"201403140001",
      "receiver":"[email protected]"
    }
  ]
}' - [from here][1]

But i can't seem to understand how to obtain sender_batch_header. I think this method is used for different purposes.


So what's the newest working method to send payments by paypal?

Thanks!

Upvotes: 2

Views: 495

Answers (1)

Javier García
Javier García

Reputation: 1114

As far as I understand, the Payouts API is the API that's substituting the previous Mass Payments API, used to send many payouts synchronously or asynchronously to different beneficiaries.

Basically imagine a company that uses Paypal to pay his employees and has an internal application which every month sends everyone their salaries.

As you can read in the docs:

Note: Payouts are available everywhere that Mass Payments are available. Any payouts that you send through the Payouts API appear as Mass Payments in your PayPal account and in Mass Payment reports.

Now, regarding the sender_batch_header, it basically allows you to track payments by batches so you don't accidentally send the same batch twice.

Let's say every Christmas, the same company I mentioned above, likes to send a small gift to their employees, something like an extra 500$. If by some chance the client application which the company has developed to send the payments has a bug and doesn't log extraordinary payments in the calendar, the CEO might get confused and try to send it twice. In that case, Paypal refuses to accept another payout with the same sender_batch_Id.

Furthermore, you can retrieve the information of a certain batch through its sender_batch_Id through the following endpoint:

/v1/payments/payouts/payout_batch_id

That way you can know if the batch has already been processed and your employees have it in their Paypal accounts, if it has been denied, or whatever you need.

If you need more information, I found the API to be fairly well documented: link.

Upvotes: 1

Related Questions