2017-02-20 63 views
0

我试图在互联网上到处搜索,无法获得任何工作。将自定义变量添加到Omnipay Paypal Express

我想添加用户ID到我的'Paypal_Express'Omnipay购买。

然而,https://github.com/thephpleague/omnipay-paypal/issues/10中概述的解决方案不适用于我。它说函数sendData不存在。 $请求 - > setTransactionId();和$ request-> setDescription();也抛出一个错误..有没有人能够做到这一点?

$order_paramaters = array(
'amount'  => $grand_total, 
); 

Omnipay::setParameter('custom', $cart->user_id); 
$response = Omnipay::purchase($order_paramaters)->send(); 

我得到:

call_user_func_array() expects parameter 1 to be a valid callback, cannot access protected method Omnipay\PayPal\ExpressGateway::setParameter() 

也试过:

$gateway = Omnipay::create('PayPal_Express'); 
$gateway->setParameter('custom', $cart->user_id); 
$response = $gateway->purchase($order_paramaters)->send(); 

我得到:

Call to protected method Omnipay\Common\AbstractGateway::setParameter() from context 'App\Http\Controllers\CartController' 

任何帮助,不胜感激。

回答

0

我认为不是这样的:

$gateway = Omnipay::create('PayPal_Express'); 
$gateway->setParameter('custom', $cart->user_id); 
$response = $gateway->purchase($order_paramaters)->send(); 

你需要试试这个:

$gateway = Omnipay::create('PayPal_Express'); 
$purchase = $gateway->purchase($order_paramaters); 
$purchase->setParameter('custom', $cart->user_id); 
$response = $purchase->send(); 

custom参数是购买对象的参数,而不是网关对象。