Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
WIKIPEDIA
/
imalipartnersapi
/
app
/
Classes
:
SendSMS.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Classes; //require_once __DIR__ . './../../config/info-bit.php'; use App\Imali\ImaliAccount; use App\Imali\MerchantAccount; use App\Store; use App\User; use Illuminate\Http\Request; use infobip\api\client\SendSingleTextualSms; use infobip\api\configuration\BasicAuthConfiguration; use infobip\api\model\sms\mt\send\textual\SMSTextualRequest; class SendSMS { protected $username; protected $password; protected $from; public function __construct() { $this->username = "Paytek"; $this->password = "Paytek19"; // $this->password = "Paytek2019"; $this->from = "i.Mali"; } public function verifyUser($data) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); // $requestBody->setTo(['+258' . $data['phone']]); $requestBody->setTo([$data['phone']]); $requestBody->setText("Codigo de Validacao: " . $data['codigo'] . "\n" . "i.Mali e o Futuro."); // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function tokenPayment($data) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); // $requestBody->setTo(['+258' . $data['phone']]); $requestBody->setTo([$data['phone']]); $requestBody->setText("Token Pagamento: " . $data['token'] . "\n" . "i.Mali e o Futuro."); // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendMessageToClientePayment($data) { $payerUser = User::query()->where('id', $data['sender_id'])->first(); $comerciante = Store::query()->where('id', $data['store_id'])->first(); $imali = ImaliAccount::query()->where('user_id', $payerUser->id)->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); // $requestBody->setTo(['+258' . $payerUser->phone]); $requestBody->setTo([$payerUser->phone]); // $requestBody->setTo([TO]); $requestBody->setText("Parabens " . strtok($payerUser->name, " ") . "\n" . "Confirmado " . $data['transaction_id'] . "\n" . "Aos " . $data['created_at'] . "\n" . "Pagaste " . $data['amount'] . "MT no comerciante " . $comerciante->account_number . "-" . $comerciante->name . "\n" . "i.Mali e o Futuro."); // 'Confirmado dhjeebjk. // Aos 7/11/2019 as 21h lavantaste 150,00MT no agente 11214 - nome da loja. // O novo saldo m-pesa é de 8,00MT. i.mali e a cena' // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo "Message ID: " . $sentMessageInfo->getMessageId() . "\n"; // echo "Receiver: " . $sentMessageInfo->getTo() . "\n"; // echo "Message status: " . $sentMessageInfo->getStatus()->getName(); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendMessageToCustomerPayment($data, $payment) { // $payerUser = User::query()->where('id', $data['sender_id'])->first(); $payerUser = User::query()->where('id', $payment['sender_id'])->first(); // $comerciante = MerchantAccount::query()->where('id', $data['merchant_account_id'])->first(); $comerciante = Store::query()->where('id', $payment['store_id'])->first(); $imali = ImaliAccount::query()->where('user_id', $payerUser->id)->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $payerUser->phone]); // $requestBody->setTo([TO]); $requestBody->setText("Parabens " . strtok($payerUser->name, " ") . "\n" . "Confirmado " . $payment['transaction_id'] . "\n" . "Aos " . $payment['created_at'] . "\n" . "Recebeste " . $data['amount'] . "MT da loja " . $comerciante->account_number . "-" . $comerciante->name . "\n" . "i.Mali e o Futuro."); // 'Confirmado dhjeebjk. // Aos 7/11/2019 as 21h lavantaste 150,00MT no agente 11214 - nome da loja. // O novo saldo m-pesa é de 8,00MT. i.mali e a cena' // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo "Message ID: " . $sentMessageInfo->getMessageId() . "\n"; // echo "Receiver: " . $sentMessageInfo->getTo() . "\n"; // echo "Message status: " . $sentMessageInfo->getStatus()->getName(); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendMessageToComerciante($data) { $payerUser = User::query()->where('id', $data['sender_id'])->first(); $comerciante = MerchantAccount::query()->where('id', $data['merchant_account_id'])->first(); $imali = ImaliAccount::query()->where('user_id', $payerUser->id)->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $comerciante->telefone_loja]); // $requestBody->setTo([TO]); $requestBody->setText("Parabens " . $comerciante->name . "\n" . "Confirmado " . $data['transaction_id'] . "\n" . "Aos " . $data['created_at'] . "\n" . "Recebeste " . $data['amount'] . "MT do cliente " . $payerUser->name . "-" . $imali->account_number . "\n" . "i.Mali e o Futuro."); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; } catch (Exception $exception) { } } public function sendSMSForUserRecharge($data) { $user = ImaliAccount::query() ->join('users', 'users.id', '=', 'imali_accounts.user_id') ->where('imali_accounts.id', $data->imali_account_id) ->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $user->phone]); // $requestBody->setTo([TO]); $requestBody->setText("Parabens " . $user->name . "." . "\n" . "Confirmado " . $data['transaction_id'] . "." . "\n" . "Aos " . $data['created_at'] . "\n" . "Carregaste com " . $data['amount'] . "MT" . " na sua conta " . $user->account_number . "\n" . "i.Mali, Diferente Como Tu!"); // 'Confirmado dhjeebjk. // Aos 7/11/2019 as 21h lavantaste 150,00MT no agente 11214 - nome da loja. // O novo saldo m-pesa é de 8,00MT. i.mali e a cena' // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo "Message ID: " . $sentMessageInfo->getMessageId() . "\n"; // echo "Receiver: " . $sentMessageInfo->getTo() . "\n"; // echo "Message status: " . $sentMessageInfo->getStatus()->getName(); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendSMSTranferReceiver($data) { $user = ImaliAccount::query()->join('users', 'users.id', '=', 'imali_accounts.user_id') ->where('users.id', $data['reciever_id']) ->first(); $sender = ImaliAccount::query()->join('users', 'users.id', '=', 'imali_accounts.user_id') ->where('users.id', $data['sender_id']) ->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $user->phone]); // $requestBody->setTo([TO]); $requestBody->setText("Parabens " . $user->name . "." . "\n" . "Confirmado " . $data['transaction_id'] . "." . "\n" . "Aos " . $data['created_at'] . "\n" . "Recebeste " . $data['amount'] . "MT" . " do " . $sender->name . "-" . $sender->account_number . "." . "\n" . "i.Mali, Diferente Como Tu!"); // 'Confirmado dhjeebjk. // Aos 7/11/2019 as 21h lavantaste 150,00MT no agente 11214 - nome da loja. // O novo saldo m-pesa é de 8,00MT. i.mali e a cena' // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo "Message ID: " . $sentMessageInfo->getMessageId() . "\n"; // echo "Receiver: " . $sentMessageInfo->getTo() . "\n"; // echo "Message status: " . $sentMessageInfo->getStatus()->getName(); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendSMSTransferSender($data) { $user = ImaliAccount::query()->join('users', 'users.id', '=', 'imali_accounts.user_id') ->where('users.id', $data['sender_id']) ->first(); $userReceiver = ImaliAccount::query()->join('users', 'users.id', '=', 'imali_accounts.user_id') ->where('users.id', $data['reciever_id']) ->first(); // Initializing SendSingleTextualSms client with appropriate configuration $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); // Creating request body $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $user->phone]); $requestBody->setText("Parabens " . $user->name . "." . "\n" . "Confirmado " . $data['transaction_id'] . "." . "\n" . "Aos " . $data['created_at'] . "\n" . "Transferiste " . $data['amount'] . "MT" . " para " . $userReceiver->name . "-" . $userReceiver->account_number . "." . "\n" . "i.Mali, Diferente Como Tu!"); // Executing request try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo "Message ID: " . $sentMessageInfo->getMessageId() . "\n"; // echo "Receiver: " . $sentMessageInfo->getTo() . "\n"; // echo "Message status: " . $sentMessageInfo->getStatus()->getName(); } catch (Exception $exception) { // echo "HTTP status code: " . $exception->getCode() . "\n"; // echo "Error message: " . $exception->getMessage(); } } public function sendSMSPurchaseVoucher($data, $vouchername, $phone) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $phone]); $requestBody->setText("Recarga " . $vouchername . "\n" . "Código: " . $data->pin . "\n" . "Serial: " . $data->serial . "\n" . "i.Mali, Diferente como Tu!"); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { return response()->json($exception); } } public function sendSMSPurchaseCredelec($data, $phone) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $phone]); $requestBody->setText("i.Mali Credelec " . "\n" . $data . "\n" . "i.Mali, Diferente como Tu!"); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { return response()->json($exception); } } public function sendSMSPurchaseZap($data, $phone) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $phone]); $requestBody->setText("i.Mali Tv Recarga " . "\n" . $data . "\n" . "i.Mali, Diferente como Tu!"); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { return response()->json($exception); } } public function sendSMSPurchaseWater($data, $phone) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); $requestBody->setTo(['+258' . $phone]); $requestBody->setText("i.Mali Agua " . "\n" . $data . "\n" . "i.Mali, Diferente como Tu!"); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; return response()->json($sentMessageInfo); } catch (Exception $exception) { return response()->json($exception); } } public function sendMessageTest($phone) { $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->username, $this->password)); $requestBody = new SMSTextualRequest(); $requestBody->setFrom($this->from); // $requestBody->setTo(["+258" . $phone]); $requestBody->setTo(["+258" . $phone]); // $requestBody->setTo(["00258" . $phone]); // $requestBody->setTo(["+258872246236"]); $requestBody->setText("Recarga"); try { $response = $client->execute($requestBody); $sentMessageInfo = $response->getMessages()[0]; // echo $sentMessageInfo; // echo $response; // return response()->json($sentMessageInfo); return response()->json($response); } catch (Exception $exception) { return response()->json($exception); } } }