我需要接受来自Laravel-4应用程序的PayPal Express付款,所以我试图确定Omnipay是否是最佳解决方案。症结在于它似乎未实现GetExpressCheckoutDetails,因此无法访问购买者的联系方式。我已经看过有关该问题的这些讨论:

omnipay paypal express not returning address

receive more response data in ci-merchant library codeigniter

但是,都没有给出确定的解决方案。如果我使用Omnipay,是否还必须安装PayPal的Classic API(在这种情况下,为什么要麻烦OmniPay),或者可以在Omnipay中实现GetExpressCheckoutDetails,如果可以,如何实现?

在此先感谢您的任何帮助。

最佳答案

omnipay\paypal\ProGateway.php添加新功能

public function fetchExpressCheckoutDetail(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\FetchExpressCheckoutRequest', $parameters);
}


omnipay\paypal\src\Message添加新文件FetchExpressCheckoutRequest.php

namespace Omnipay\PayPal\Message;
class FetchExpressCheckoutRequest extends AbstractRequest
{
    public function getData()
    {
        $data = $this->getBaseData('GetExpressCheckoutDetails');

        $this->validate('transactionReference');
        $data['TOKEN'] = $this->getTransactionReference();
        $url = $this->getEndpoint()."?USER={$data['USER']}&PWD={$data['PWD']}&SIGNATURE={$data['SIGNATURE']}&METHOD=GetExpressCheckoutDetails&VERSION={$data['VERSION']}&TOKEN={$data['TOKEN']}";
        parse_str (file_get_contents( $url ),$output);
        $data = array_merge($data,$output);
        return $data;
    }
}


用法:

$response = $gateway->completePurchase($params)->send();
$data = $response->getData();
$gateway->fetchExpressCheckoutDetail(array('transactionReference'=>$data['TOKEN']))->getData();


那不是最好的。但这有效。 :)

08-25 16:13