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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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

脚本宝典总结

以上是脚本宝典为你收集整理的php – 使用Omnipay的PayPal Express Checkout未在沙盒帐户中显示订单全部内容,希望文章能够帮你解决php – 使用Omnipay的PayPal Express Checkout未在沙盒帐户中显示订单所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。