I'm trying to make a little shopping cart with CodeIgniter and I found CI-Merchant to work with payment gateways with this guide http://ci-merchant.org/ but I don't really understand how to make it works with 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');
I know that this code can't do much but it do nothing at all. Just load the view and nothing happens, I don't understand. So, my question is, do you know tutorials or just how to make CI Merchant works with Paypal Sandbox? Thanks for the help.
Ace's comment is spot on. There is nothing wrong with your code, but you need to inspect the $response
object to see what the result (or error message) was.
$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;
}
You can also simply try this to inspect the object:
$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
exit;