alphaolomi / swahilies-php
Swahilies for PHP
Fund package maintenance!
Patreon
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- laravel/pint: ^1.2
- pestphp/pest: ^1.20
- spatie/pest-plugin-snapshots: ^1.1
This package is auto-updated.
Last update: 2024-11-09 10:37:56 UTC
README
Installation
You can install the package via composer:
composer require alphaolomi/swahilies-php
Usage
use Alphaolomi\Swahilies\Swahilies; $swahilies = new Swahilies([]); // Or $swahilies = Swahilies::create([ 'apiKey' => 'csdheruvhhjdhvjadmvjehrve', 'username' => 'Company name', 'isLive' => false, // ie. sandbox mode ]); $response = $swahilies->payments()->request([ // TZS by default 'amount' => 50000, // 255 is country code for Tanzania, Only Tanzania is supported for now 'orderId' => $order->id, 'phoneNumber' => "255783262616", 'cancelUrl' => "https://yoursite.com/cancel", 'webhookUrl' => "https://yoursite.com/response", 'successUrl' => "https://yoursite.com/success", 'metadata' => [], ]); print_r($response); // Output: // [ // "payment_url" => "https://swahiliespay.invict.site/make-payment-1.html?order=jdhvjadmvjehrve" // ]
// Webhooks // You can use the following code to verify the webhook signature $requestBody = /** get the request body from the webhook request **/; $isValid = $swahilies->webhooks() ->verify($request->getContent()); // true/false
Available APIs
Payments
all()
- Get all payment transactionsdirectRequest($data)
- Make a direct Push USSD from your apprequest($data)
- Make a payment requestfind($id)
- Get payment transaction information
Webhooks
🚧 Work in progress
getDisget($data)
- Generate requery body digestverify($data)
- Verify request body
Testing
Using PestPHP for testing.
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.