加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 13:16:03 所属栏目:PHP教程 来源:网络整理
导读:我在我的网站上使用了Omnipay PayPal_Express结账脚本,当我支付订单时一切正常,但订单未在PayPal Sandbox帐户中显示. 当我为PayPal_Pro使用相同的脚本时,它会显示. 我的代码如下: use OmnipayOmnipay;// PayPal Express:if(isset($_POST['paypalexpress'])
我在我的网站上使用了Omnipay PayPal_Express结账脚本,当我支付订单时一切正常,但订单未在PayPal Sandbox帐户中显示.

当我为PayPal_Pro使用相同的脚本时,它会显示.

我的代码如下:

use OmnipayOmnipay;

// 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读