Php 使用Omnipay的PayPal Express结帐在沙箱帐户中不显示订单
我在我的网站上使用了Omnipay PayPal_Express结帐脚本,当我为订单付款时,除了订单没有显示在PayPal沙箱帐户中之外,一切都正常 当我为PayPal_Pro使用相同的脚本时,它确实会显示出来 我的代码如下:Php 使用Omnipay的PayPal Express结帐在沙箱帐户中不显示订单,php,api,omnipay,paypal,Php,Api,Omnipay,Paypal,我在我的网站上使用了Omnipay PayPal_Express结帐脚本,当我为订单付款时,除了订单没有显示在PayPal沙箱帐户中之外,一切都正常 当我为PayPal_Pro使用相同的脚本时,它确实会显示出来 我的代码如下: use Omnipay\Omnipay; // PayPal Express: if(isset($_POST['paypalexpress'])) { $gateway = GatewayFactory::create('PayPal_Express'); $ga
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();
}
我在沙箱中创建了两个测试帐户,一个用于上述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());
}
}
如果您在退货时需要检索订单详细信息的帮助,请告诉我。它可以在重定向之前存储在会话中,也可以存储在数据库中。如果您还没有完成,请查看示例代码:谢谢,我相信“transactionId”是来自PayPal的令牌,但什么是“transactionReference”。虽然我已经向“transactionReference”传递了一个唯一的密钥,并且它工作得很好,但我只需要确定一下。你能澄清一下吗?谢谢。嗨,希娜。这是贝宝返回的参考资料。在发送购买请求之后,但在重定向之前,您调用$response->getTransactionReference()以获取引用。谢谢beech,现在我注意到我的令牌与$response->getTransactionReference()相同。那么什么是transactionId?我的随机密钥?是的,你不应该设置你自己的引用,我认为你的ID和引用方式不对。这个ID可以是任何你喜欢的独一无二的东西。谢谢你的澄清,我从开发者那里得到了同样的回应。