CodeIgniter,CI-Merchant和Paypal Sandbox

时间:2012-11-05 00:43:56

标签: codeigniter paypal-sandbox ci-merchant

我正在尝试使用CodeIgniter创建一个小购物车,我发现CI-Merchant使用本指南http://ci-merchant.org/处理支付网关但我真的不明白如何使它与Paypal Sandbox一起使用。

$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一起使用?谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

Ace的评论是现货。您的代码没有任何问题,但您需要检查$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;