【问题标题】:PayPal Express Checkout with Omnipay not showing order in Sandbox account使用 Omnipay 的 PayPal Express Checkout 未在 Sandbox 帐户中显示订单
【发布时间】:2014-03-29 09:20:15
【问题描述】:

我在我的网站上使用了 Omnipay PayPal_Express 结帐脚本,当我为订单付款时一切正常,但订单未显示在 PayPal 沙盒帐户中。

当我对 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,一个用于支付。我已尝试使用测试卡详细信息和登录信息付款,但帐户中未显示订单详细信息。

谁能帮忙?

【问题讨论】:

    标签: php api omnipay paypal


    【解决方案1】:

    当 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

    【讨论】:

    • 谢谢你,我相信“transactionId”是来自 PayPal 的令牌,但什么是“transactionReference”。尽管我已将唯一密钥传递给“transactionReference”并且它工作正常,但我只需要确定。你能澄清一下吗?谢谢。
    • 你好希娜。这是 Paypal 返回的参考。在发送购买请求之后,但在重定向之前,您调用 $response->getTransactionReference() 来获取参考。
    • 感谢 beech,现在我注意到我的令牌与 $response->getTransactionReference() 相同。那么什么是transactionId?我的随机密钥?
    • 是的,您不应该设置自己的参考,我认为您的 ID 和参考方式错误。 ID 可以是任何你喜欢的唯一值。
    • 感谢您的澄清,我得到了开发人员的相同回复。
    猜你喜欢
    • 2015-04-22
    • 2017-11-07
    • 2020-02-21
    • 2014-04-02
    • 2017-03-25
    • 2016-09-17
    • 2016-07-14
    • 2011-10-23
    • 2014-09-28
    相关资源
    最近更新 更多