Package Data | |
---|---|
Maintainer Username: | saleemepoch |
Maintainer Contact: | saleem@web-epoch.com (Saleem Beg) |
Package Create Date: | 2016-05-28 |
Package Last Update: | 2016-05-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:05:11 |
Package Statistics | |
---|---|
Total Downloads: | 146 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 2 |
Total Open Issues: | 0 |
The txtNation Gateway PHP Library works with Laravel 5+. It is an extension of Marc O'Leary's txtnation/txtnation-gateway-php.
This README assumes you are using the following PHP extensions:
composer require saleemepoch/txtnation
'saleemepoch\txtNation\Providers\txtNationServiceProvider' // Laravel 5
saleemepoch\txtNation\Providers\txtNationServiceProvider::class // Laravel 5.1 or greater
php artisan vendor:publish
return [
/* REQUIRED */
'username' => '',
'ekey' => '',
// also known as sender id.
'title' => '',
/* OPTIONAL */
// if set, requests to txtNation will also consists of the supplied shortcode
'shortcode' => '',
// required only if sending MT to Bill based on texted keywords
'keywords' => [
/*
* keywords and their corresponding amounts.
*
* This will set the value when billing the customer based on the keyword texted by the user
*
*
'BILL10' => 10.00,
'BILL5' => 5.00,
*/
'BILL1' => 1.00
]
];
$message = new SMSMessage;
$result = $message->msisdn('447459831491')->body('Please reply to this message with keyword PENNY!')->senderId('784645')->send();
if ($result->success()){
dd('Message sent!');
} else {
dd('Error sending message! Code: ' . $result->getErrorCode() . ' (' . $result->getErrorMessage() . ')');
}
'keywords' => [
'BILL10' => 10.00,
'BILL5' => 5.00,
'BILL1' => 1.00
]
Login to your txtNation account -> APIs -> Gateway and set your responder URL, e.g. http://example.com/txtNationResponse
Setup a route in your routes.php:
Route::post('txtNationResponse', 'txtNationController@response');
protected $except = [
'txtNationResponse',
];
public function response(Request $request) {
if ($request->action == 'mpush_ir_message' &&
(isset($request->billing) && $request->billing == 'MT')) {
$keywords = config('txtNation.keywords');
$message = new SMSMessage;
$result = $message->msisdn($request->number)
->reply(1)
->body('Thank you for your business')
->id($request->id)
->network($request->network)
->currency('GBP')
->value($keywords[$request->message])
->send();
}
}
The above controller method will accept the response from txtNation and if billing is set to MT it will reply back charging the user.