簡體   English   中英

貝寶沙盒和Omnipay

[英]Paypal sandbox and Omnipay

在我的返回URL上購買后,我得到以下成功消息:

數組([TOKEN] => EC-55E14916SE342401J [TIMESTAMP] => 2016-02-12T16:59:00Z [CORRELATIONID] => 5d020c7d4479b [ACK] =>成功[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. 我建議您為每個交易提供唯一的退貨和取消URL。 REST API的omnipay-paypal docblocks就是一個例子。 基本上,您需要先存儲交易數據和交易ID,然后再調用Purchase()並將該ID用作returnUrl的一部分。 然后,returnUrl中的代碼將知道這是針對哪個事務的。
  3. 在您的returnUrl代碼中,您需要調用completePurchase()並檢查響應。 在您調用completePurchase()之前,您的交易尚未完成,並且沒有錢會易手。 您也不會在儀表板上看到交易。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM