Download the PHP package samuelmwangiw/africastalking-laravel without Composer
On this page you can find all versions of the php package samuelmwangiw/africastalking-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download samuelmwangiw/africastalking-laravel
More information about samuelmwangiw/africastalking-laravel
Files in samuelmwangiw/africastalking-laravel
Package africastalking-laravel
Short Description This is my package africastalking-laravel
License MIT
Homepage https://github.com/samuelmwangiw/africastalking-laravel
Informations about the package africastalking-laravel
africastalking-laravel
This is an unofficial Laravel SDK for interacting with Africa's Talking APIs that takes advantage of native Laravel components such as
- HTTP Client in place of Guzzle client
- Service Container for a great dev experience
- Notifications to allow you route notifications via Africastalking
- Config
- Collections
- Among many others
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
You should configure the package by setting the env
variables in your .env
file.
Usage
Application Balance
Bulk Messages
The most basic example to send out a message is
Other valid examples are
The response is Collection of \SamuelMwangiW\Africastalking\ValueObjects\RecipientsApiResponse
objects
Premium Messages
The response is Collection of \SamuelMwangiW\Africastalking\ValueObjects\RecipientsApiResponse
objects
Airtime
The most basic example to disburse airtime is
You may also pass an instance of AirtimeTransaction
The Airtime class provides an add()
that's basically an alias to the to()
and since either of these methods can be
fluently chained, it unlocks capabilities such as adding the recipients in a loop and sending once at the end
USSD Response
This package allows to easily create USSD
response by exposing a \SamuelMwangiW\Africastalking\Response\UssdResponse
class that implements Laravel's Responsable contract.
To send a ussd response, simply return africastalking()->ussd()
in your controller.
The ussd
optionally takes 2 parameters and returns an instance of UssdResponse
:
response
- The response message to be displayed to the clientexpectsInput
- A boolean whether or not to prompt for user input. The default value istrue
The UssdResponse
class has the following methods that can be chained fluently
response
- Receives the response message to be displayed to the client as an argumentexpectsInput
- Receives the expectsInput boolean to be displayed to the client as an argument. The default value is trueend
- Is an aliasexpectsInput()
but sets the boolean valuefalse
always
See below an example controller that makes of the UssdResponse
and Ussd's HttpRequest
:
Payments (wip)
Mobile Checkout
Wallet Balance
Stash top up
Voice Responses
This package provides an easy and intuitive voice response builder that allows any combination of the following:
Note that all params marked as optional in the documentation are also optional
See example in a controller below:
Synthesized Speech Attributes.
The action supports the use of Speech Synthesis Markup Language(SSML).
To respond with Synthesized Speech, pass a callback say()
above as the first parameter that receives an instance of object
Note You can only have a single within an XML response
Making Calls
WebRTC
HTTP Requests
The package ships with the following Laravel Requests that you can inject into your application controllers:
In addition to exposing the post params in a nice FormRequest object, these classes also include nice helper methods where applicable e.g.
id()
to retrieve the unique ATPid associated with every requestphone()
to retrieve the client's phone numberuserInput()
to retrieve ussd user inputstatus()
to get transaction / request final statusdeliveryFailed()
returns a booleantrue
if sms or airtime delivery failed andfalse
otherwise- among many others
Example for a Message Delivery callback action Controller
Notification
The package ships with a Channel to allow for easily routing of notifications via Africastalking SMS.
To route a notification via Africastalking, return SamuelMwangiW\Africastalking\Notifications\AfricastalkingChannel
in
your notifications via
method and the text message to be sent in the toAfricastalking
method
Also ensure that the notifiable model implements SamuelMwangiW\Africastalking\Contracts\ReceivesSmsMessages
and that
the model's routeNotificationForAfricastalking()
returns the phone number to receive the message
Testing
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
- Samuel Mwangi
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of africastalking-laravel with dependencies
illuminate/contracts Version ^10.0|^11.0
saloonphp/laravel-plugin Version ^3.5
spatie/laravel-package-tools Version ^1.14