簡體   English   中英

將自定義變量添加到Omnipay Paypal Express

[英]Adding custom variable to 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'

任何幫助深表感謝。

我認為與其相反:

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

暫無
暫無

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

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