How to Use Midtrans-PHP in CodeIgniter 3

Here is how to use Midtrans-PHP official library in Codeigniter 3 🙂

  1. Install composer in your computer.
  2. Open command prompt / shell, navigate to your project “application” directory.
    cd application
  3. type composer require midtrans/midtrans-php
  4. Composer will download Midtrans library in your CodeIgniter “application” directory. Wait until finished.
  5. Open your “application/config.php”.
  6. Change $config['composer_autoload'] = FALSE; into $config['composer_autoload'] = TRUE;
  7. Now in your controller, you can use Midtrans library. For example if in the example files included use Config::$serverKey, you can use Midtrans\Config::$serverKey.
    Or if in example files use Snap::createTransaction($params), you can use Midtrans\Snap::createTransaction($params)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *