2

我正在尝试使用 CodeIgniter 制作一个小购物车,我发现 CI-Merchant 可以通过本指南http://ci-merchant.org/与支付网关一起使用,但我真的不明白如何让它与 Paypal 一起使用沙盒。

$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = array(
    'username' => 'test@test.com',
    'password' => '********',
    'signature' => 'Test Store',
    'test_mode' => true);

$this->merchant->initialize($settings);
$params = array(
    'amount' => 12.00,
    'currency' => 'CAD',
    'return_url' => 'http://payment.test.com',
    'cancel_url' => 'http://payment.test.com/cancel');

$response = $this->merchant->purchase($params);
$this->load->view('welcome_message');

我知道这段代码不能做很多事情,但它什么也没做。只是加载视图,没有任何反应,我不明白。所以,我的问题是,你知道教程或者只是如何让 CI Merchant 与 Paypal Sandbox 一起工作吗?谢谢您的帮助。

4

1 回答 1

2

艾斯的评论很到位。您的代码没有任何问题,但您需要检查$response对象以查看结果(或错误消息)是什么。

$response = $this->merchant->purchase($params);
if ($response->success())
{
    // mark order as complete
    $gateway_reference = $response->reference();
}
else
{
    $message = $response->message();
    echo('Error processing payment: ' . $message);
    exit;
}

您也可以简单地尝试这个来检查对象:

$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
exit;
于 2012-11-05T21:53:22.563 回答