[英]PayPal Express Checkout with Omnipay not showing order in Sandbox account
我在我的網站上使用了Omnipay PayPal_Express結賬腳本,當我支付訂單時一切正常,但訂單沒有顯示在PayPal Sandbox帳戶中。
當我為PayPal_Pro使用相同的腳本時,它會顯示。
我的代碼如下:
use Omnipay\Omnipay;
// PayPal Express:
if(isset($_POST['paypalexpress'])) {
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername('{myusername}');
$gateway->setPassword('{mypassword}');
$gateway->setSignature('{mysignauture}');
$gateway->setTestMode(true);
$response = $gateway->purchase(
array(
'cancelUrl'=>'http://www.mysite.com/?cancelled',
'returnUrl'=>'http://www.mysite.com/?success',
'amount' => "12.99",
'currency' => 'GBP',
'Description' => 'Test Purchase for 12.99'
)
)->send();
$response->redirect();
}
我在Sandbox中創建了兩個測試帳戶,一個用於上面的API,另一個用於支付。 我已嘗試使用測試卡詳細信息和登錄信息付款,但訂單詳細信息未顯示在帳戶中。
有人可以幫忙嗎?
當Paypal返回到returnUrl時,您似乎錯過了completePurchase()部分。 我的代碼假設您在變量$ order中有訂單詳細信息,但它可能看起來像這樣:
if(isset($_GET['success'])) {
$response = $gateway->completePurchase(array(
'transactionId' => $order->transaction,
'transactionReference' => $order->reference,
'amount' => $order->total,
'currency' => $order->currency,
))->send();
if ( ! $response->isSuccessful())
{
throw new Exception($response->getMessage());
}
}
如果您在返回時需要任何幫助來檢索訂單詳細信息,請與我們聯系。 它可以在重定向之前存儲在會話中,也可以存儲在數據庫中。 如果您還沒有,請查看示例代碼: https : //github.com/omnipay/example/blob/master/index.php
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.