2017-02-20 61 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參數是購買對象的參數,而不是網關對象。