在我的返回网址上购买后,我收到了这条成功消息:
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);
}
谁知道有什么问题?
最佳答案
- 我建议您从 PayPal Express API 切换到 Paypal REST API。 REST API 更新、文档更好、更完整。
- 我建议您为每笔交易提供唯一的返回和取消网址。这样做的一个例子是 REST API 的 omnipay-paypal 文档 block 。基本上,您需要在调用 purchase() 并将该 ID 作为 returnUrl 的一部分之前存储交易数据和交易 ID。然后 returnUrl 中的代码将知道这是针对哪个交易。
- 在您的 returnUrl 代码中,您需要调用 completePurchase() 并检查它的响应。在您调用 completePurchase() 之前,您的交易还没有完成,也没有钱易手。您也不会在仪表板上看到交易。
关于php - Paypal 沙盒和 Omnipay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368319/