0

I am working with Web services/Api in codeigniter,I want to integrate "Razorpay" Account so for this i am trying to integrate "Razorpay" source code But i am getting error "syntax error, unexpected 'use' (T_USE)" Here is my code

function razorpayApi_post()
{
    include 'razorpay/Razorpay.php';
    use Razorpay\Api\Api;
    $api_key="xxxxxxxxxxxxxxxx";
    $api_secret="xxxxxxxxxxxxxxx";
    $api = new Api($api_key, $api_secret);
}    
amit
  • 1
  • 1
  • 18
  • 28
  • which version are you using? – PHP Ninja Dec 16 '19 at 09:52
  • instead of `use Razorpay\Api\Api;` try `$className = new Razorpay(); $function Name = $className->api();` – PHP Ninja Dec 16 '19 at 09:54
  • Here is your answer https://stackoverflow.com/questions/3700626/namespace-in-php-codeigniter-framework – PHP Ninja Dec 16 '19 at 09:59
  • @Gulshan: i am using codeignter version 3 – amit Dec 16 '19 at 10:01
  • Namespace are supported by php and not by the framework (Codeigniter in your case). If you use namespaces php version must be >= 5.3.0 Codeigniter doesn't use namespaces because it is written to support php 4. – PHP Ninja Dec 16 '19 at 10:02
  • @Gulshan:Sir, What should i do then ? please correct/write code so i can check and implment in my side – amit Dec 16 '19 at 10:11
  • try it with `class` instead of `namespace` – PHP Ninja Dec 16 '19 at 10:16
  • @Gulshan: Can you explain please – amit Dec 16 '19 at 10:17
  • Here is a github repo https://github.com/MazahirHaroon/Razorpay-Subscription-Codeigniter- – PHP Ninja Dec 16 '19 at 10:22
  • I have attached js url. You can include this url and make object for it. https://checkout.razorpay.com/v1/checkout.js $className = new Razorpay(); – Ruchi Patel Dec 16 '19 at 10:25
  • @Gulshan: i tried same as their controller , means i added following two lines ( upload razopray in assets folder) require_once ('assets\razorpay\Razorpay.php'); use Razorpay\Api\Api as RazorpayApi; But i am getting following error " require_once(assets\razorpay\Razorpay.php): failed to open stream: No such file or directory" – amit Dec 16 '19 at 10:28
  • @RuchiPatel: should i use "include" or "require" method also ? and can i use this file for "create account" and for "transfer" api ? – amit Dec 16 '19 at 10:36

0 Answers0