This PHP client library enables easy interaction with the PayHero API, allowing developers to integrate PayHero's payment processing capabilities into their PHP applications. With this client, you can perform operations like checking wallet balances, topping up service wallets, initiating payments, and querying transaction statuses.
To be able to generate API keys with Pay Hero to use our API services you need to create an account with us. Create an account using below link and verify your account to be able to proceed. Go To: https://app.payhero.co.ke
- Wallet Balance Inquiry: Check the balance of service and payment wallets.
- Wallet Top-Up: Top up service wallets with a specified amount.
- Payment Processing: Send customer M-Pesa STK Push for payment collection.
- Transaction Status: Check the status of a specific transaction.
- Account Transactions: Retrieve a list of transactions for an account.
- SasaPay Payments: Process payments through SasaPay.
- Withdrawals: Withdraw funds to mobile or bank accounts via SasaPay.
To get started run this command in your terminal:
npm i payhero-php
To use this PHP client in your project, simply include the PayHeroAPI
class in your PHP script.
require_once 'node_modules/payhero-php/ph-class.php';
$apiUsername = 'your_api_username';
$apiPassword = 'your_api_password';
$payHeroAPI = new PayHeroAPI($apiUsername, $apiPassword);
$serviceWalletBalance = $payHeroAPI->getServiceWalletBalance();
$paymentWalletBalance = $payHeroAPI->getPaymentWalletBalance();
$topUpResponse = $payHeroAPI->topUpServiceWallet($amount, $phone);
$stkPushResponse = $payHeroAPI->SendCustomerMpesaStkPush($amount, $phone, $channel_id, $external_reference, $callback_url);
$transactionStatus = $payHeroAPI->getTransactionStatus($reference);
$accountTransactions = $payHeroAPI->getAccountTransactions($reference);
$sasapayPaymentResponse = $payHeroAPI-> sasaPayPayment($amount,$phone,$network_code,$external_reference,$callback_url);
$withdrawalResponse = $payHeroAPI->sasaPayWithdrawToMobile($amount,$phone,$network_code,$external_reference,$callback_url);
$withdrawalResponse = $payHeroAPI->sasaPayWithdrawToBank($amount,$account_number,$network_code,$external_reference,$callback_url);
- PHP 5.6 or newer
- cURL support enabled in PHP
Contributions to the PayHeroAPI PHP client are welcome. Please ensure that your code adheres to the existing style and that all tests pass.
This project is licensed under the MIT License - see the LICENSE file for details.