PHP code example of kiplingkelvin / chpter-laravel-sdk

1. Go to this page and download the library: Download kiplingkelvin/chpter-laravel-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kiplingkelvin / chpter-laravel-sdk example snippets


        $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;

bash
php artisan vendor:publish --provider="KiplingKelvin\ChpterLaravelSdk\ChpterServiceProvider"