贝宝批量付款响应

Palpal Mass Payment Responce

我正在使用 Paypal Masspayment API 并且它工作正常,但我想知道我为交易支付了多少费用,或者交易是国内还是国际,但我只得到这个数组回应

Array
(
     [TIMESTAMP] => 2015%2d02%2d03T05%3a31%3a25Z
     [CORRELATIONID] => 1bccbfad582e7
     [ACK] => Success
     [VERSION] => 51%2e0
     [BUILD] => 15110743
)

批量支付是否可行 API?

或者如果有什么方法可以从这个批量支付费用计算器得到我的网站的计算结果? https://www.paypal.com/np/cgi-bin/webscr?cmd=_batch-payment-overview-outside

我更喜欢用 PHP

编写的解决方案

Paypal 不共享任何机密信息,因此可能无法实现,但您可以使用 curl 计算费用,这是工作代码

    $url = "https://www.paypal.com/np/cgi-bin/webscr";
    $data=array(
      "cmd" => '_calc-masspay-fee',
      "sender_country" => $Country,
      "receiver_country" => 'GB',
      "currency_code" => Mage::app()->getStore()->getCurrentCurrencyCode(),
      "curr_list_reqd" => 1
    );

    $cr = curl_init($url);
    curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);       // Get returned value as string (dont put to screen)
    curl_setopt($cr, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Spoof the user-agent to be the browser that the user is on (and accessing the php $
    curl_setopt($cr, CURLOPT_POST, true);                 // Tell curl that we are posting data
    curl_setopt($cr, CURLOPT_POSTFIELDS, $data);          // Post the data in the array above
    $output = curl_exec($cr); 

    $output = json_decode($output);

处理此问题的最佳方法是设置 Instant Payment Notification (IPN) 解决方案。当您进行 MassPay 交易时,您将获得包含更多详细信息的 IPN。这是一个例子:

Array
(
    [payer_id] => ATSCG2QMC9KAU
    [payment_date] => 09:23:59 Jan 28, 2015 PST
    [payment_gross_1] => 10.00
    [payment_gross_2] => 10.00
    [payment_gross_3] => 10.00
    [payment_status] => Processed
    [receiver_email_1] => andrew_1342623385_per@angelleye.com
    [receiver_email_2] => usb_1329725429_biz@angelleye.com
    [charset] => windows-1252
    [receiver_email_3] => andrew_1277258815_per@angelleye.com
    [mc_currency_1] => USD
    [masspay_txn_id_1] => 1M205262R4107805K
    [mc_currency_2] => USD
    [masspay_txn_id_2] => 95942086WL824160N
    [mc_currency_3] => USD
    [masspay_txn_id_3] => 21W68993Y67646416
    [first_name] => Drew
    [unique_id_1] => 
    [notify_version] => 3.8
    [unique_id_2] => 
    [unique_id_3] => 
    [payer_status] => verified
    [verify_sign] => AJ-yMngskqU0wKMAcE2BE6cQ.uxhA3cw3neNnb2W68Ic2ZwqkxjYIgMg
    [payer_email] => sandbo_1215254764_biz@angelleye.com
    [payer_business_name] => Drew Angell's Test Store
    [last_name] => Angell
    [status_1] => Completed
    [status_2] => Completed
    [status_3] => Completed
    [txn_type] => masspay
    [mc_gross_1] => 10.00
    [mc_gross_2] => 10.00
    [mc_gross_3] => 10.00
    [payment_fee_1] => 0.20
    [residence_country] => US
    [test_ipn] => 1
    [payment_fee_2] => 0.20
    [payment_fee_3] => 0.20
    [mc_fee_1] => 0.20
    [mc_fee_2] => 0.20
    [mc_fee_3] => 0.20
    [ipn_track_id] => 205e7228cfda3
)

那个特定的 MassPay 包含 3 笔付款,因此您可以看到每笔付款的单独数据,您可以循环浏览并相应地处理这些数据。

在 GitHub and/or Packagist 上有大量 PHP 类 可用于 IPN,如果您碰巧正在使用 Composer,则可以将其与 Composer 一起使用。如果您碰巧在使用 WordPress,我会看一下 PayPal IPN for WordPress,这会让您很快上手 运行,然后您可以轻松地扩展它来满足您自己的需求。