I have a credit system set up on my site where user A can purchase a document from user B, let's say for 1 credit and user B's account gets credited, let's say for $1. User B can then "cash out" and recieve the money they earned from my (the site's) PayPal account into their PayPal account (let's assume that their email address is valid for now). When user A purchases a credit, they are taken to PayPal where they can login and complete the purchase, for this purpose I have an IPN listener set up on my site that stores credit information to my site's database. However, I can't find a mechanism to send the "cash out" information (i.e. user's email and amount to be paid) to PayPal. To elaborate: I understand that PayPal sends the IPN when someone purchases from me, but how do I post from my site to PayPal when the user clicks the "cash out" button? I have seen mention of Mass Pay, but can't seem to locate any code samples to go from. Am I missing something, or is there perhaps a different (and better) way to do this? Thanks!
+1
A:
You are correct that you have to use mass pay, and there is documentation for NVP and SOAP. Paypal's code sample page also has PHP NVP and SOAP examples.
As to a better way? I don't think there is with PayPal. You'll be paying another 2% fee per payment (limited to a maximum of $1) on top of whatever you paid to accept the funds.
From the NVP sample code, a rough idea of a simple URL encoded post:
foreach($receiversArray as $i => $receiverData) {
$receiverEmail = urlencode($receiverData['receiverEmail']);
$amount = urlencode($receiverData['amount']);
$uniqueID = urlencode($receiverData['uniqueID']);
$note = urlencode($receiverData['note']);
$nvpStr .= "&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note";
}
Since you're using IPN already, form the MassPay API Doc:
If you have Instant Payment Notification (IPN) enabled for your account, PayPal will send two IPNs for each payment made during Mass Payment transaction processing. The IPNs are posted to the Notify URL specified in your account profile.
Tim Lytle
2010-03-11 05:04:47
Oh my, no clue why I didn't come across those pages with samples earlier... So there is no way to simply post a querystring to PayPal? On that note, does the NVP/SOAP method also do a post back to my IPN?
Alex
2010-03-11 05:32:40
Actually, I believe NVP (name value pair) is pretty much just a query string, the example code shows them using cURL to do the request. And there is also a MultiPay IPN.
Tim Lytle
2010-03-11 14:38:19
Thank you! The awesomeness of this site is pretty epic! :)
Alex
2010-03-11 14:55:43