Install via composer
composer require kiplingkelvin/chpter-laravel-sdk
Run vendor:publish command inside your laravel project
php artisan vendor:publish --provider="KiplingKelvin\ChpterLaravelSdk\ChpterServiceProvider"
After publishing you will find config/chpter.php config file. You can now adjust the configurations appropriately. Additionally, add the configurations to your env for security purposes.
Add the following files to your .env
CLIENT_DOMAIN=
CHPTER_TOKEN=
eg.
CLIENT_DOMAIN=chpter.co
CHPTER_TOKEN=chpter_pk_2b4037c1c8
$chpter= new \KiplingKelvin\ChpterLaravelSdk\Chpter();
$customer = array(
"payment_method"=> "MPesa",
"full_name"=> "John Doe",
"location"=> "Nairobi",
"phone_number"=> "254700123123",
"email"=> "[email protected]" );
$products = array( array(
"product_id"=> "08",
"product_name"=> "HoodEez",
"quantity"=> "1",
"unit_price"=> "1" ));
$amount = array(
"delivery_fee"=> "0",
"discount_fee"=> "0",
"total"=> "1",
"currency"=> "kes");
$callback_details = array(
"transaction_reference"=> "123456789123",
"callback_url"=> "https://df02-197-232-140-206.in.ngrok.io/api/chpter_mpesa_payment_callback_url" );
$response = $chpter->mpesaPayment($customer, $products, $amount, $callback_details);
//Response Is in json
return $response;
$chpter= new \KiplingKelvin\ChpterLaravelSdk\Chpter();
$customer = array(
"full_name"=> "John Doe",
"location"=> "Nairobi",
"phone_number"=> "254706347307",
"email"=> "[email protected]" );
$products = array( array(
"product_name"=> "HoodEez",
"quantity"=> "1",
"unit_price"=> "1" ));
$amount = array(
"order_id"=> "859",
"delivery_fee"=> 0,
"discount_fee"=> 0,
"total"=> 500,
"currency"=> "kes");
$callback_details = array(
"success_url" => "https://www.url.com",
"failed_url" => "https://www.url.com",
"callback_url" => "https://yourcallback.com/url"
)
Log::info('********Starting Redirect Api Request**********');
$response = $chpter->hostedRedirectPayment($customer, $amount, $callback_details);
//The response is in json
Log::alert('Chpter Redirect API Response');
return $response;
$chpter= new \KiplingKelvin\ChpterLaravelSdk\Chpter();
$type = "Mpesa";
$phoneNumber = "254700000000";
Log::info('********Starting Api Request**********');
$response = $chpter->createMobilePayoutDestination($type, $phoneNumber);
//The response is in json
Log::alert('Chpter API Response');
return $response;
$chpter= new \KiplingKelvin\ChpterLaravelSdk\Chpter();
$bankName = "KCB";
$bankAccountName = "ALBERT CHELA";
$bankAccountNumber = "123451267";
Log::info('********Starting Api Request**********');
$response = $chpter->createBankPayoutDestination($bankName, $bankAccountName, $bankAccountNumber);
//The response is in json
Log::alert('Chpter API Response');
return $response;