CI_Merchant is not displaying anything

136 Views Asked by At

For an online payment, I am trying to use ci_merchant. According to http://ci-merchant.org/ , I made a CodeIgniter project. But the function is displaying only blank page.

My function is given below:

 function transaction(){
    $this->load->library('merchant');
    $this->merchant->load('paypal_express');
    $settings = $this->merchant->default_settings();

    $settings = array(
        'username' => 'AAAAAAAAAAA',
        'password' => '111111',
        'signature' => 'AAAAAAAAAAAARCpSSRl31AoJ0SIOUHEnDbhhEgANdZeAmMTkU',
        'test_mode' => true
    );
    $this->merchant->initialize($settings);

        $params = array(
            'amount' => 1.00,
            'currency' => 'USD',
            'return_url' => 'http://localhost/tcm/account/transaction_return',
            'cancel_url' => 'http://localhost/tcm/account/transaction_cancel'
        );
        //'return_url' => 'https://www.example.com/checkout/payment_return/123',
        //'cancel_url' => 'https://www.example.com/checkout');
        $response = $this->merchant->purchase($params);

        if ($response->success()){
            echo "Successfully complete transaction.";
        }
        else{
            $message = $response->message();
            echo('Error processing payment: ' . $message);
            exit;
        } 
}

Where is the problem of my code or procedure ? Awaiting for an affirmative response.

1

There are 1 best solutions below

1
On

I think you missed the $this-> part in below code snippet:

if ($response->success()){
            echo "Successfully complete transaction.";
        }
        else{
            $message = $response->message();
            echo('Error processing payment: ' . $message);
            exit;
        } 

try it with:

if ($response->$this->success()){
            echo "Successfully complete transaction.";
        }
        else{
            $message = $response->$this->message();
            echo('Error processing payment: ' . $message);
            exit;
        }