I'm trying to find a way to make payments to my users from within the site itself. The payments will occur on a regular basis, but for different amounts each time (like a paycheck). Basically, each user gets paid a formulated amount of money. I've got that part figured out already. It's specifically the part of handling making payments to (as opposed to receiving payments from) my users that I need to know about. I need this to be done as a batch job as well.

I guess my main question is, is there an existing module or combination of modules that I could use to easily accomplish this task? If not, does the PayPal API support this kind of an operation? Would the simple paypal framework module support something like this? If so, How?

I am pretty familiar with the php and sql, as well as Drupal itself. I should be able to formulate a solution, but I'm having difficulty searching for or where to find resources related to this subject. I would like to find some sort of simple paypal framework reference but I have had no such luck.

Comments

wisdom’s picture

A batch and recurring payment is something you are looking for. This sounds interesting. I hear quite often about PayPal recurring payment but not sure about batch payment.

Drupal ecommerce has a recurring payment support. But does not have the batch aspect of it.

Online Business

astersmitem’s picture

I kept looking after I posted and I found that the Paypal API does support outbound payments from a business account with something called masspay. It can apparently pay a whole bunch of people at once (similar to a batch), but from what I understand it would be for sending the same amount to multiple recipients. That's ok though, because I should be able to set this up in a 'batch' using a for each loop, calling each payment individually. This is great, because this is precicely the function I had in mind.

So, my question gets simpler (as I answer myself). Does the Simple Paypal Framework have support for this masspay part of the Paypal API? How would I call masspay from Simple Paypal Framework?

I'm pretty sure I'll have to write my own PHP to pull the paypal email addresses and payment variables from the database, but I need to know how I would hook into Simple Paypal Framework to call this function. Any help is greatly appreciated, and I will post anything I find on my own here.

astersmitem’s picture

I guess I don't need help after all. I did not find anything in drupal that advertised to do what I wanted, and no useful responses here, so I wrote my own proprietary code to accomplish my goals. The idea is to have something occur on a regular basis (weekly) that finds out who the site owes money to, submit payments through paypal (paying the account down to $0), and subtract the amount paid from the user's account so that the database reflects a $0 balance.

I found that while using a premier or business account, PayPal offers something called Mass Pay. Basically it's a way to submit a whole bunch of payments all at once. You can do different amounts for each recipient, which is what I was looking for. What's even better about the Mass Pay service is the fee structure. Fees are 2% with a $1 maximum for the whole transaction, where normal paypal fees are 4%, no max. In other words you could distribute $1000 amongst 50 different recipients for $1, whereas doing individual payments paypal fees would cost you $40 for the same $1000 getting paid out. Cool.

I ended up coding something for Paypal's API that pulls all the values from my database, feeds them into an array, constructs the API readable string, feeds that to paypal API for Mass Pay, then performs all the necessary calculations and database updates. I put that on a weekly cron job and limited IP access to the webserver and viola - automated weekly paychecks on my site via Paypal. Cool.

I'm using Paypal's NVP authentication mechanism, which I found pretty easy to use. It seems to be working wonderfully, but I haven't taken it out of the sandbox yet.

rvarkonyi’s picture

Hi,

I'm so happy I read this post!

I'm trying to achieve quite the same functionality, searched a lot of forums til I found this one. Would you be able to guide me through how you achieved a working solution please? I would be really thankful!

Thanks

cr