Here is how to use Midtrans-PHP official library in Codeigniter 3 🙂
- Install composer in your computer.
- Open command prompt / shell, navigate to your project “application” directory.
cd application
- type
composer require midtrans/midtrans-php
- Composer will download Midtrans library in your CodeIgniter “application” directory. Wait until finished.
- Open your “application/config.php”.
- Change
$config['composer_autoload'] = FALSE;
into$config['composer_autoload'] = TRUE;
- Now in your controller, you can use Midtrans library. For example if in the example files included use
Config::$serverKey
, you can useMidtrans\Config::$serverKey
.
Or if in example files useSnap::createTransaction($params)
, you can useMidtrans\Snap::createTransaction($params)
Leave a Reply