74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
}
|