kevinpurwito / laravel-zenziva
Zenziva integration for Laravel
Fund package maintenance!
kevinpurwito
www.paypal.me/kevinpurwito
Installs: 2 303
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^6.19.0
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.3
README
Laravel Zenziva is a package that integrates Zenziva for Laravel.
Installation
You can install the package via composer:
composer require kevinpurwito/laravel-zenziva
Configuration
The vendor:publish
command will publish a file named kp_zenziva.php
within your laravel project config
folder config/kp_zenziva.php
.
Published Config File Contents
[ 'type' => strtolower(env('KP_ZENZIVA_TYPE', 'console')), // gsm or console 'userkey' => env('KP_ZENZIVA_USERKEY'), 'passkey' => env('KP_ZENZIVA_PASSKEY'), ];
Alternatively you can ignore the above publish command and add this following variables to your .env
file.
KP_ZENZIVA_TYPE=console
KP_ZENZIVA_USERKEY=user
KP_ZENZIVA_PASSKEY=secret
Auto Discovery
If you're using Laravel 5.5+ you don't need to manually add the service provider or facade. This will be
Auto-Discovered. For all versions of Laravel below 5.5, you must manually add the ServiceProvider & Facade to the
appropriate arrays within your Laravel project config/app.php
Provider
[ Kevinpurwito\LaravelZenziva\ZenzivaServiceProvider::class, ];
Alias / Facade
[ 'Zenziva' => Kevinpurwito\LaravelZenziva\ZenzivaFacade::class, ];
Usage
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva; // returns the balance/credit that you have Zenziva::getBalance(); // returns the balance/credit that you have, including the expiry date of the balance Zenziva::balance(); // send SMS Zenziva::sendSms('+62xxx', 'message'); // send Whatsapp message Zenziva::sendWa('+62xxx', 'message'); // send Whatsapp file from URL, including a caption/message Zenziva::sendWaFile('+62xxx', 'message', 'https://image.com/image.png'); // GSM only feature to send SMS OTP Zenziva::sendOtp('+62xxx', '123xxx'); // Console only feature to send voice message Zenziva::sendWa('+62xxx', 'message');
Accepted file types for
sendWaFile()
are: .doc .pdf .xls .xlsx .csv .gif .jpg .mp4 .mp3
Handling the response
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva; // returns the balance/credit that you have $response = Zenziva::sendWa('+62xxx', 'message'); if ($response->getStatusCode() == 201) { // if you want to check the response body, such as `messageId` you can do this: $content = json_decode($response->getBody()->getContents()); dump($content); // { // "messageId":"157365", // "to":"+62xxx", // "status":"1", // "text":"Success" // } }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email kevin.purwito@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the PHP Package Boilerplate by Beyond Code with some modifications inspired from PHP Package Skeleton by spatie.