Paypal sandbox and Omnipay



在退货网址上购买后,我收到以下成功消息:

数组 ( [令牌] => EC-55E14916SE342401J [时间戳] => 2016-02-12T16:59:00Z [相关ID] => 5d020c7d4479b [ACK] => 成功 [版本] => 119.0 [内部版本] => 18308778 )

但是在沙盒帐户上仍然没有任何变化...

这是我的代码:

$gateway = Omnipay::create('PayPal_Express');
        // Initialise the gateway
        $gateway->initialize(array(
            'username' => 'user',
            'password' => 'pass',
            'signature' => 'sig',
            'testMode' => true, // Or false when you are ready for live transactions
        ));
        // Do an authorisation transaction on the gateway
        $transaction = $gateway->purchase(array(
            'returnUrl' => 'http://client.com/api/return',
            'cancelUrl' => 'http://localhost:8000/cancel',
            'amount' => '10.00',
            'currency' => 'USD',
            'description' => 'This is a test authorize transaction.',
                // 'card'          => $card,
        ));
        $this->response = $transaction->send();
        if ($this->response->isRedirect()) {
            // Yes it's a redirect.  Redirect the customer to this URL:
            $redirectUrl = $this->response->getRedirectUrl();
            return redirect($redirectUrl);
        }

有人知道问题是什么吗?

  1. 我建议你从PayPal Express API切换到PayPal REST API。REST API 更新、文档更完善、更完整。
  2. 我建议您为每笔交易提供唯一的退货和取消 URL。执行此操作的一个例子是在 REST API 的 omnipay-PayPal docblock 中。基本上,在调用 purchase() 之前,您需要存储交易数据和交易 ID,并将该 ID 用作 returnURL 的一部分。然后 returnUrl 中的代码将知道这是针对哪个事务的。
  3. 在你的 returnUrl 代码中,你需要调用 completePurchase() 并检查它的响应。在你调用completePurchase()之前,你的交易还没有完成,没有钱会转手。您也不会在仪表板上看到交易。

最新更新