initial commit
This commit is contained in:
10
app/Models/AirtelTransaction.php
Normal file
10
app/Models/AirtelTransaction.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AirtelTransaction extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
38
app/Models/Callback.php
Normal file
38
app/Models/Callback.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Callback extends Model
|
||||
{
|
||||
|
||||
public function updateCallbackMsgStatus($status_code, $code, $airtel_money_id, $message, $id){
|
||||
$current_time = date('Y-m-d H:i:s');
|
||||
$last_updated_by = 'airtel_callback';
|
||||
|
||||
$transaction = Models\AirtelTransaction::where('reference_id', $id)->first();
|
||||
$transaction->status = 'PROCESSED';
|
||||
$transaction->airtel_status_code = $status_code;
|
||||
$transaction->airtel_code = $code;
|
||||
$transaction->airtel_money_id = $airtel_money_id;
|
||||
$transaction->airtel_message = $message;
|
||||
$transaction->last_updated_by = '$last_updated_by';
|
||||
$result = $transaction->save();
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function clickPayUpdateCallbackMsgStatus($status_code, $code, $airtel_money_id, $message, $id){
|
||||
$current_time = date('Y-m-d H:i:s');
|
||||
$last_updated_by = 'airtel_callback';
|
||||
//$sql = "UPDATE transactions SET status = 'PROCESSED', airtel_status_code = '$status_code', airtel_code = '$code', airtel_money_id = '$airtel_money_id', airtel_message = '$message', updated_at = '$current_time', last_updated_by = '$last_updated_by' WHERE reference_id = '{$id}'"
|
||||
$sql = "UPDATE clickpay_900012.transactions_airtel SET status = 'PROCESSED', airtel_status_code = '$status_code', airtel_code = '$code', airtel_money_id = '$airtel_money_id', airtel_message = '$message', updated_at = '$current_time', last_updated_by = '$last_updated_by' WHERE reference_id = '{$id}'";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if (!$result) {
|
||||
die(mysqli_error($conn));
|
||||
}
|
||||
else {
|
||||
return mysqli_affected_rows($conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
app/Models/Product.php
Normal file
10
app/Models/Product.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Models/Tnmtransaction.php
Normal file
10
app/Models/Tnmtransaction.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tnmtransaction extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
73
app/Models/Transaction.php
Normal file
73
app/Models/Transaction.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
private $collect_payment_url = "https://openapiuat.airtel.africa/merchant/v1/payments/";
|
||||
private $access_token_url = "https://openapiuat.airtel.africa/auth/oauth2/token";
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function createAirtel($org_id, $msisdn, $reference_id, $amount, $product_name, $result_code){
|
||||
$bind = [
|
||||
"org_id" => $org_id,
|
||||
"msisdn" => $msisdn,
|
||||
"reference_id" => $reference_id,
|
||||
"amount" => $amount,
|
||||
"product_name" => $product_name,
|
||||
"result_code" => $result_code,
|
||||
"ussd_push_result_code" => $result_code,
|
||||
"last_updated_by" => 'clientRequest'
|
||||
];
|
||||
$result = Models\AirtelTransaction::create($bind);
|
||||
return ($result) ? 1 : 0;
|
||||
}
|
||||
public function createTNM($org_id, $msisdn, $refID, $conversation_id, $amount, $status, $reason, $transaction_id, $product_name){
|
||||
$bind = [
|
||||
"msisdn" => $msisdn,
|
||||
"reference_id" => $refID,
|
||||
"conversation_id" => $conversation_id,
|
||||
"transaction_id" => $transaction_id,
|
||||
"amount" => $amount,
|
||||
"product_name" => $product_name,
|
||||
"org_id" => $org_id,
|
||||
"reason" => $reason,
|
||||
"status" => $status
|
||||
];
|
||||
$result = Models\Tnmtransaction::create($bind);
|
||||
return ($result) ? 1 : 0;
|
||||
}
|
||||
|
||||
public function checkProduct($name){
|
||||
$product = Models\Product::where('name', $name)->first();
|
||||
return $product;
|
||||
}
|
||||
public function checkDuplicateRefID($refid, $org_id){
|
||||
$row_airtel = Models\AirtelTransaction::where('reference_id', $refid, $org_id, $org_id)->first();
|
||||
|
||||
$row_airtel = Models\Tnmtransaction::where('reference_id', $refid, $org_id, $org_id)->first();
|
||||
|
||||
if($row_airtel == true || $row_airtel == true){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function getEnquiry($refid, $org_id){
|
||||
// review this
|
||||
$row_airtel = Models\AirtelTransaction::where('reference_id', $refid, $org_id, $org_id)->first();
|
||||
if(!$row_airtel){
|
||||
$row_airtel = Models\Tnmtransaction::where('reference_id', $refid, $org_id, $org_id)->first();
|
||||
return $row_tnm;
|
||||
}
|
||||
else{
|
||||
return $row_airtel;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
app/Models/User.php
Normal file
39
app/Models/User.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password','api_token'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user