【问题标题】:How do I get PayPal_Express response using OmniPay?如何使用 OmniPay 获得 PayPal_Express 响应?
【发布时间】:2014-08-13 18:29:45
【问题描述】:

我已经到处搜索并在 OmniPays github 上转了一圈,试图找到有关如何在 OmniPay 中实施 PayPal Express 的文档。

        $response = Omnipay::purchase([
            'amount' => $total,
            'encodedTestIDs' => serialize($payForTestID),
            'returnUrl' => 'http://php.bhiceu.com/payment/return',
            'cancelUrl' => 'http://php.bhiceu.com/payment/cancel' 
        ])->send();
        //dd($response);
        //die;
        if ($response->isRedirect()) {
            // redirect to offsite payment gateway
            $response->redirect();
        } else {
            // payment failed: display message to customer
            echo $response->getMessage();
        }

上面的代码成功地将我发送到适当金额的 PayPal,当我取消或检查时,我返回到相应的 URL,但是我得到的只是 paypal 令牌,我找不到任何关于如何处理的文档.

【问题讨论】:

  • 是的... Omnipay 似乎很方便,但文档根本不存在。你找到答案了吗?

标签: laravel-4 omnipay paypal


【解决方案1】:

答案很简单,但我不得不去挖掘它的源代码,因为该库的文档不存在。

$response = Omnipay::completePurchase([
    'amount' => $price,
    'currency' => $currency
])->send();

您只需使用与初始 Omnipay::purchase 相同的 amountcurrency 调用 Omnipay::completePurchase

在此之后,您将使用Omnipay::fetchCheckout()->send() 获取诸如送货地址等信息。

【讨论】:

    【解决方案2】:

    您需要使用 completePurchase() 方法完成购买。

    https://github.com/thephpleague/omnipay-example/blob/master/index.php#L203-L218查看omnipay/示例代码

    【讨论】:

      猜你喜欢
      • 2021-09-09
      • 2018-03-17
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多