php - Paypal 沙盒和 Omnipay

标签 php paypal paypal-sandbox omnipay

在我的返回网址上购买后,我收到了这条成功消息:

Array ( [TOKEN] => EC-55E14916SE342401J [TIMESTAMP] => 2016-02-12T16:59:00Z [CORRELATIONID] => 5d020c7d4479b [ACK] => Success [VERSION] => 119.0 [BUILD] => 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. 我建议您为每笔交易提供唯一的返回和取消网址。这样做的一个例子是 REST API 的 omnipay-paypal 文档 block 。基本上,您需要在调用 purchase() 并将该 ID 作为 returnUrl 的一部分之前存储交易数据和交易 ID。然后 returnUrl 中的代码将知道这是针对哪个交易。
  3. 在您的 returnUrl 代码中,您需要调用 completePurchase() 并检查它的响应。在您调用 completePurchase() 之前,您的交易还没有完成,也没有钱易手。您也不会在仪表板上看到交易。

关于php - Paypal 沙盒和 Omnipay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368319/

相关文章:

Paypal 沙箱不起作用

laravel - 如何在 laravel 中集成 Paypal 支付网关?

python - PayPal 错误 10002 使用权限 API 和 TransactionSearch

php - file_get_contents,HTTP 请求失败

php - PHP GET 方法中的多个请求

Paypal 付款高级设置错误

paypal - 是否可以使用 UpdateRecurringPaymentsProfile PayPal 仅更改 AMT?

PHP mysql查询按两列分组并计数

javascript - JS 重定向后 session 丢失

paypal - 自适应 Paypal 支付错误代码: 579017