CodeIgniter Forums
Loading Instamojo Payment gateway SDK giving error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Loading Instamojo Payment gateway SDK giving error (/showthread.php?tid=77646)



Loading Instamojo Payment gateway SDK giving error - tysonchamp - 09-29-2020

here is the SDK url https://github.com/Instamojo/instamojo-php

this page has the example I used in my CI 4 Application

below is my code

PHP Code:
$api = new \Instamojo\Instamojo::init('app', [
            "client_id" =>  'test_ssTbcIWGqmAQYEQUSu8tqyna6msQsQB4dEu',
            "client_secret" => 'test_Y7uuS7kjPgtK4Bi3R0RdWRZ0k9Hq67bhoeYw6Jsd2ZAYXNwUPNQo9vlGgsDAMoz1YjWvjDOcJdDlHIYGMJMFuo8XOsb9QfZH7fzNVvoG1EkGA4uG1GeLxjCcP8v'
        ], true); 


above code giving error :
Code:
"syntax error, unexpected 'init' (T_STRING), expecting variable (T_VARIABLE) or '$'"



RE: Loading Instamojo Payment gateway SDK giving error - InsiteFX - 09-29-2020

PHP Code:
$authType "app/user" /**Depend on app or user based authentication**/ 

It's expecting a string with a $ not 'app'

PHP Code:
$api Instamojo\Instamojo::init($authType,[ 

pass it a string like it is showing in the documentation.


RE: Loading Instamojo Payment gateway SDK giving error - tysonchamp - 09-29-2020

(09-29-2020, 03:50 PM)InsiteFX Wrote:
PHP Code:
$authType "app/user" /**Depend on app or user based authentication**/ 

It's expecting a string with a $ not 'app'

PHP Code:
$api Instamojo\Instamojo::init($authType,[ 

pass it a string like it is showing in the documentation.


Still it's giving same error.. I feel the issue is here: Instamojo::init

Solved the Issue

removing new will solve the issue
wrong code:
Code:
$api = new \Instamojo\Instamojo::init('app', [
            "client_id" =>  'test_ssTbcIWGqmAQYEQUSu8tqyna6msQsQB4dEu',
            "client_secret" => 'test_Y7uuS7kjPgtK4Bi3R0RdWRZ0k9Hq67bhoeYw6Jsd2ZAYXNwUPNQo9vlGgsDAMoz1YjWvjDOcJdDlHIYGMJMFuo8XOsb9QfZH7fzNVvoG1EkGA4uG1GeLxjCcP8v'
        ], true); 

correct code:
Code:
$api = \Instamojo\Instamojo::init('app', [
            "client_id" =>  'test_ssTbcIWGqmAQYEQUSu8tqyna6msQsQB4dEu',
            "client_secret" => 'test_Y7uuS7kjPgtK4Bi3R0RdWRZ0k9Hq67bhoeYw6Jsd2ZAYXNwUPNQo9vlGgsDAMoz1YjWvjDOcJdDlHIYGMJMFuo8XOsb9QfZH7fzNVvoG1EkGA4uG1GeLxjCcP8v'
        ], true);