【问题标题】:Adding custom variable to Omnipay Paypal Express向 Omnipay Paypal Express 添加自定义变量
【发布时间】:2017-07-09 05:17:47
【问题描述】:

我已尝试在 Internet 上到处搜索,但无法找到任何工作。

我正在尝试将用户 ID 添加到我的“Paypal_Express”Omnipay 购买中。

但是https://github.com/thephpleague/omnipay-paypal/issues/10 中概述的解决方案对我不起作用。它说函数 sendData 不存在。 $request->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'

非常感谢任何帮助。

【问题讨论】:

    标签: laravel laravel-5 paypal laravel-5.2 omnipay


    【解决方案1】:

    我认为不是这个:

    $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参数是购买对象的参数,不是网关对象的参数。

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 2014-02-21
      • 1970-01-01
      • 2014-11-01
      • 2015-01-06
      • 2016-03-05
      • 2017-03-25
      • 2015-02-13
      相关资源
      最近更新 更多