【问题标题】:Palpal Mass Payment ResponcePaypal 批量付款响应
【发布时间】:2015-02-03 05:40:02
【问题描述】:

我正在使用 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 编写的解决方案

【问题讨论】:

    标签: php paypal


    【解决方案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,它可以让您快速启动并运行,然后您可以轻松扩展它以满足您自己的需求。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-06-15
        • 2016-02-07
        • 2017-10-13
        • 2014-05-09
        • 2013-12-26
        • 2011-11-21
        • 1970-01-01
        • 2021-10-11
        相关资源
        最近更新 更多