我正在使用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编写的解决方案
处理此问题的最佳方法是设置即时付款通知 (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 上有很多 PHP 类可用于 IPN,如果您碰巧使用它,则可以与 Composer 一起使用。 如果你碰巧正在使用WordPress,我会看看WordPress的PayPal IPN,它会让你非常快速地启动和运行,然后你可以很容易地扩展它来处理你自己的需求。
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);