1. Go to this page and download the library: Download astrasoftwares/astrapay 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/ */
astrasoftwares / astrapay example snippets
use Astrapay\AstraMpesa;
$config = [
'consumerKey' => 'YOUR_CONSUMER_KEY',
'consumerSecret' => 'YOUR_CONSUMER_SECRET',
'shortcode' => '174379', // Paybill or Till Number
'passkey' => 'YOUR_PASSKEY', // Required for STK Push
'callbackUrl' => 'https://yourdomain.com/callback', // Global callback for STK
'env' => 'sandbox', // 'sandbox' or 'live'
// Required only for B2C
'initiatorName' => 'YOUR_INITIATOR_NAME',
'securityCredential' => 'YOUR_ENCRYPTED_CREDENTIAL'
];
$client = new AstraMpesa($config);