簡體   English   中英

如何從Omnipay / PayPal調用GetExpressCheckoutDetails?

[英]How to call GetExpressCheckoutDetails from Omnipay/PayPal?

我需要接受來自Laravel-4應用程序的PayPal Express付款,所以我試圖確定Omnipay是否是最佳解決方案。 症結在於它似乎未實現GetExpressCheckoutDetails,因此無法訪問購買者的聯系方式。 我已經看過有關該問題的這些討論:

omn​​ipay貝寶快遞未返回地址

在ci-merchant庫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();

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

Omnipay還不支持GetExpressCheckoutDetails。 當前為此打開了一個拉取請求

但是,它確實實現了GetTransactionDetails ,您可能會發現它很有用,因為它可以返回有關現有事務的大多數信息。

基於kei。 我建議對應用程序進行以下補充:

  1. 創建新路徑app/omnipay/paypal/Message/
  2. 創建新文件app/omnipay/paypal/ExtendedExpressGateway.php

     namespace App\\Omnipay\\PayPal; use Omnipay\\PayPal\\ExpressGateway; /** * PayPal Express extended Class */ class ExtendedExpressGateway extends ExpressGateway { public function getName() { return 'PayPal Express extended'; } public function fetchExpressCheckoutDetail(array $parameters = array()) { return $this->createRequest('\\\\App\\\\Omnipay\\\\PayPal\\\\Message\\\\FetchExpressCheckoutRequest', $parameters); } } 
  3. 創建新文件app/omnipay/paypal/Message/FetchExpressCheckoutRequest.php

     namespace App\\Omnipay\\PayPal\\Message; use Omnipay\\PayPal\\Message\\AbstractRequest; 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; } } 
  4. 在composer.json中添加到psr-4 autoload

     "autoload": { "classmap": [ ... ], "psr-4": { "App\\\\Omnipay\\\\PayPal\\\\": "app/omnipay/paypal/" } }, 
  5. 跑:

     php artisan dump-autoload 
  6. 現在在app/config/packages/ignited/laravel-omnipay/config.php您可以編寫:

     'driver' => '\\\\App\\\\Omnipay\\\\PayPal\\\\ExtendedExpressGateway', 

現在,當您更新時將沒有問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM