Download the PHP package sparkworldke/kopokopo-laravel-support without Composer
On this page you can find all versions of the php package sparkworldke/kopokopo-laravel-support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sparkworldke/kopokopo-laravel-support
More information about sparkworldke/kopokopo-laravel-support
Files in sparkworldke/kopokopo-laravel-support
Package kopokopo-laravel-support
Short Description A simple package for developers to consume Kopokopo Mpesa API in Laravel 9, 10, 11
License MIT
Homepage https://github.com/sparkworldke/kopokopo-laravel-support
Informations about the package kopokopo-laravel-support
Laravel Kopokopo Package
A simple package for laravel developers to consume Kopokopo API for laravel 8.
Installation
You can easily install this package using composer and an installation command
Configuration
Next, after the package has been installed run this to publish config;
This will help in publishing config/kopokopo.php
file. This kopokopo config file is where you will add all
configurations for Kopokopo APIs. This includes the environment your application is running in(sandbox or production),
callback URLs and required credentials.
For production you need to replace with production credentials and also set 'sandbox' => false
.
For security reasons you may want to define your API credentials in env
file. For example;
Usage
First things first...Authorization
N/B: You can skip the authorization step unless you need to carry out a number of operations in a single execution. Otherwise, the rest of the steps automatically acquire the access_token before calling the API>
Kopo Kopo uses Oauth2 to allow access to the Kopo Kopo API so before anything else, Kopokopo API expects the
application access token
to be used to make calls to the Kopo Kopo API on behalf of the application.
To acquire the token, you need to call the token service like below:
Webhook Subscription
This API enables you to register the callback URLs via which you will receive payment notifications for payments and
transaction that happen in your Kopo kopo app. To register Urls ensure all urls under webhooks are filled with valid
urls in config/kopokopo.php
.
Checkout https://developers.kopokopo.com/guides/webhooks to
understand what each webhook does.
When testing on sandbox you can use ngrok to expose your callbacks to the internet. Then
call registerWebhooks()
on Kopokopo
facade. i.e
Webhook subscription via terminal commands:
Publish any webhook by running the command below in your terminal:
Example:
You may use the --all option to subscribe to all webhook specified in kopokopo webhooks config i.e
Alternatively:
Remember to first import Kopokopo facade with:\
use Kopokopo;
Upon successful creation of the webhook subscription, the api will return true, else you will get the exact error as json HTTP response;
Initiate Mpesa Payment (STK Push)
You can receive payments from M-PESA users via STK Push. You can initiate payment like this;
Upon a successful request a HTTP Status 201 will be returned and the location HTTP Header will contain the URL of the newly created Incoming Payment.
HTTP/1.1 201 Created Location: https://sandbox.kopokopo.com/api/v1/incoming_payments/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c
Query Incoming Payment Status
Coming Soon
Create Payment Recipients
You can add external recipient that will be the destination of your payments in the future, sort of creating contacts. The following are the different types of pay recipients you can create with examples.
(a). Mobile Wallet
Create Pay Recipient for a Mobile Wallet recipient;
A HTTP response code of 201 is returned upon successful creation of the PAY recipient. The URL of the recipient resource is also returned in the HTTP Location Header
HTTP/1.1 201 Created Location: https://sandbox.kopokopo.com/api/v1/pay_recipients/c7f300c0-f1ef-4151-9bbe-005005aa3747
(b). Bank Account
Coming Soon
(c). External Till
Coming Soon
(c). Paybill
Coming Soon
Make Outgoing Payments
Coming Soon
Query Outgoing Payment Status
Coming Soon
Transfer to your settling account(s)
Transfer funds to your pre-approved settlement accounts (bank accounts or mobile wallets).
Coming Soon
Polling
Poll Buygoods Transactions between the specified dates for a particular till or for the whole company.
Coming Soon
Transaction SMS Notifications API Requests
Send sms notifications to your customer after you have received a payment from them.
Coming Soon
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Thank you for considering contributing to laravel-kopokopo
. Pull requests and issues welcome. Be sure to check open
issues and PRs before continuing. Take a look at contributing.md to see a to do list.
Security Vulnerabilities
If you discover a security vulnerability within laravel-kopokopo, please send an e-mail to Michael Gatuma via [email protected]. All security vulnerabilities will be promptly addressed.
License
The laravel-kopokopo package is open-source software licensed under the MIT license
Tags
laravel, mpesa, kopokopo, k2-connect,k2-connect-php, laravel-mpesa, php, stk-push
All versions of kopokopo-laravel-support with dependencies
guzzlehttp/guzzle Version ^7.1
php Version ^8.0|^8.1