微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 使用Omnipay的PayPal Express Checkout未在沙盒帐户中显示订单

我在我的网站上使用了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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐