如何实现“提现”功能在我的网站上使用 PayPal?

发布于 2024-08-24 12:22:01 字数 408 浏览 3 评论 0 原文

我在我的网站上设置了一个信用系统,用户 A 可以从用户 B 购买文档(假设为 1 个信用),并且用户 B 的帐户会记入贷方(假设为 1 美元)。然后,用户 B 可以“兑现”并将他们从我(网站的)PayPal 帐户赚取的钱存入他们的 PayPal 帐户(假设他们的电子邮件地址目前有效)。当用户 A 购买信用时,他们会被带到 PayPal,在那里他们可以登录并完成购买,为此,我在我的网站上设置了一个 IPN 侦听器,用于将信用信息存储到我网站的数据库中。但是,我找不到一种机制将“兑现”信息(即用户的电子邮件和要支付的金额)发送到PayPal。详细说明:我知道当有人从我这里购买时 PayPal 会发送 IPN,但是当用户单击“兑现”按钮时,如何从我的网站发布到 PayPal?我见过提到 Mass Pay,但似乎找不到任何代码示例。我是否遗漏了什么,或者是否有不同的(更好的)方法来做到这一点?谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两人的回忆 2024-08-31 12:22:02

您是正确的,您必须使用 mass pay,并且有 NVPSOAP。 Paypal 的代码示例页面还包含 PHP NVPSOAP 示例。

至于有更好的办法吗?我认为 PayPal 没有。除了您为接受资金所支付的费用外,您还需要为每次付款支付另外 2% 的费用(最多 1 美元)。

从 NVP 示例代码中,我们可以大致了解一个简单的 URL 编码帖子:

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";
}

由于您已经在使用 IPN,因此来自 MassPay API 文档

如果您的帐户启用了即时付款通知 (IPN),PayPal 将为批量付款交易处理期间的每笔付款发送两个 IPN。 IPN 将发布到您的帐户个人资料中指定的通知 URL。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文