Paypal大规模付款响应

时间:2015-02-03 05:40:02

标签: php paypal

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

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

甚至可以使用Mass Pay API吗?

或者,如果有任何方法可以从这个大规模支付费用计算器获得计算结果我的网站? https://www.paypal.com/np/cgi-bin/webscr?cmd=_batch-payment-overview-outside

我更喜欢用PHP编写的解决方案

2 个答案:

答案 0 :(得分:1)

处理此问题的最佳方法是设置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和/或Packagist上有很多可用于IPN的PHP类,如果您正在使用它,可以与Composer一起使用。如果您正好使用WordPress,我会看一下PayPal IPN for WordPress,它可以让您快速上手,然后您可以轻松扩展它以满足您自己的需求。

答案 1 :(得分:0)

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);