开发者

How do I implement "cash out" on my site using PayPal?

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 h开发者_运维百科ow 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!


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, from 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜