【问题标题】:Paypal sandbox and OmnipayPaypal 沙盒和 Omnipay
【发布时间】:2016-05-23 22:33:55
【问题描述】:

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

数组 ([TOKEN] => EC-55E14916SE342401J [TIMESTAMP] => 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);
        }

有谁知道问题出在哪里?

【问题讨论】:

    标签: php paypal paypal-sandbox omnipay


    【解决方案1】:
    1. 我建议您从 PayPal Express API 切换到 Paypal REST API。 REST API 更新、文档更完善且更完整。
    2. 我建议您为每笔交易提供唯一的退货和取消 URL。这样做的一个例子是在 REST API 的 omnipay-paypal 文档块中。基本上,您需要在调用 purchase() 之前存储交易数据和交易 ID,并将该 ID 用作 returnUrl 的一部分。然后returnUrl中的代码就会知道这是针对哪个交易的。
    3. 在您的 returnUrl 代码中,您需要调用 completePurchase() 并检查其中的响应。在您调用 completePurchase() 之前,您的交易尚未完成,不会有任何资金转手。您也不会在仪表板上看到交易。

    【讨论】:

      猜你喜欢
      • 2014-10-03
      • 2016-11-17
      • 1970-01-01
      • 2011-09-11
      • 2013-02-28
      • 2015-11-25
      • 2020-11-29
      • 2011-12-16
      • 2013-05-09
      相关资源
      最近更新 更多