• File: GeneralNotification.php
  • Full Path: /var/www/amparoapi/app/Classes/GeneralNotification.php
  • Date Modified: 11/09/2021 7:47 PM
  • File size: 3.32 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Classes;

use Illuminate\Support\Facades\Http;

class GeneralNotification
{
    protected $username;
    protected $password;
    protected $from;
    protected $key;
    protected $url;

    public function __construct()
    {
        $this->username = "Paytek";
        $this->password = "Paytek19";
        $this->from = "i.Mali";
        $this->key = "Basic MDAwNDp1Yko1eEhNZGhQWEE=";
        $this->url = "https://sislog.me/hubtel/v0/messages/send";

    }

    public function tokenSms($data)
    {
        $token = new GeneralGenerator();
        $transaction = $token->generateMSID();

        $response = Http::withHeaders([
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE='
        ])->post('https://sislog.me/hubtel/v0/messages/send', [
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE=',
            'From' => 'Amparo',
            'To' => '+258'.$data['phone'],
            'RegisteredDelivery' => 'true',
            'Content' => "Codigo de Validacao: " . $data['codigo'],
            'ClientReference' => $transaction,
            'Time' => date('Y-m-d H:i:s')
        ]);

        return response()->json($response->body());
    }

    public function paymentConfirmationClient($data)
    {
        $token = new GeneralGenerator();
        $transaction = $token->generateMSID();

        $response = Http::withHeaders([
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE='
        ])->post('https://sislog.me/hubtel/v0/messages/send', [
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE=',
            'From' => 'Amparo',
            'To' => "+258" . $data['phone'],
            'RegisteredDelivery' => 'true',
            'Content' => "Parabens " . $data['username'] . "\n" . "Confirmado " . $data['transaction'] . "\n" . "Aos " . $data['createdAt'] . "\n" . "Pagaste " . $data['amount'] .
                "MT no comerciante " . $data['loja'] . " pelo cartao " . $data['cardNumber'],
            'ClientReference' => $transaction,
            'Time' => date('Y-m-d H:i:s')
        ]);

        return response()->json($response->body());
    }

    public function paymentConfirmationAccount($data)
    {
        $token = new GeneralGenerator();
        $transaction = $token->generateMSID();

        $response = Http::withHeaders([
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE='
        ])->post('https://sislog.me/hubtel/v0/messages/send', [
            'Authorization' => 'Basic MDAwNDp1Yko1eEhNZGhQWEE=',
            'From' => 'Amparo',
//            'To' => "+258" . $data['phone'],
            'To' => "+258" . $data['phoneAccount'],
            'RegisteredDelivery' => 'true',
            'Content' => "Confirmado " . $data['transaction'] . "\n" . "Aos " . $data['createdAt'] . "\n" . "o cartao " . $data['cardNumber'] . " pagou " . $data['amount'] .
                "MT no comerciante " . $data['loja'] . ". Saldo " . $data['balance'],
            'ClientReference' => $transaction,
            'Time' => date('Y-m-d H:i:s')
        ]);

        return response()->json($response->body());
    }

}