wip
This commit is contained in:
@@ -25,6 +25,8 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
||||
|
||||
// OnlinePaymentRepo::syncWithBilling();
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
|
||||
@@ -35,6 +37,8 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||
|
||||
// OnlinePaymentRepo::syncWithBilling();
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $username
|
||||
* @property int $online_paymantable_id
|
||||
* @property string $online_paymantable_type
|
||||
* @property ?array $api_response
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
@@ -40,4 +41,16 @@ class OnlinePaymentHistory extends Model
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'online_payment_histories';
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'api_response' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,43 +7,56 @@ trait HandlesBillingSyncing
|
||||
/**
|
||||
* Sync with billing
|
||||
*/
|
||||
// public static function syncWithBilling(): bool|string
|
||||
// {
|
||||
// $curl = curl_init();
|
||||
public static function syncWithBilling(
|
||||
string $uuid,
|
||||
string $bank_code,
|
||||
string $terminal_id,
|
||||
string $account_number,
|
||||
string $rrn,
|
||||
string $amount,
|
||||
string $pay_purpose,
|
||||
) {
|
||||
$curl = curl_init();
|
||||
|
||||
// curl_setopt_array($curl, [
|
||||
// CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
// CURLOPT_RETURNTRANSFER => true,
|
||||
// CURLOPT_ENCODING => '',
|
||||
// CURLOPT_MAXREDIRS => 10,
|
||||
// CURLOPT_TIMEOUT => 0,
|
||||
// CURLOPT_FOLLOWLOCATION => true,
|
||||
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
// CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
// CURLOPT_POSTFIELDS => sprintf(
|
||||
// '{
|
||||
// "ecomId" : "%s",
|
||||
// "agentId" : "%s",
|
||||
// "eposId" : "30401238",
|
||||
// "account" : "130420912769753",
|
||||
// "rnn" : "110784016238",
|
||||
// "amount" : 895.46,
|
||||
// "payPurpose" : "Mart 2025"
|
||||
// }',
|
||||
// // $uuid,
|
||||
// // $bankCode,
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf(
|
||||
'{
|
||||
"ecomId" : "%s",
|
||||
"agentId" : "%s",
|
||||
"eposId" : "%s",
|
||||
"account" : "%s",
|
||||
"rnn" : "%s",
|
||||
"amount" : %s,
|
||||
"payPurpose" : "%s"
|
||||
}',
|
||||
$uuid,
|
||||
$bank_code,
|
||||
$terminal_id,
|
||||
$account_number,
|
||||
$rrn,
|
||||
$amount,
|
||||
$pay_purpose,
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
// ),
|
||||
// CURLOPT_HTTPHEADER => [
|
||||
// 'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
// 'Content-Type: application/json',
|
||||
// ],
|
||||
// ]);
|
||||
$response = curl_exec($curl);
|
||||
|
||||
// $response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
// curl_close($curl);
|
||||
info($response);
|
||||
|
||||
// return $response;
|
||||
// }
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class OnlinePaymentRepo
|
||||
/**
|
||||
* Successfully payment response
|
||||
*
|
||||
* @return array<string, bool|string>
|
||||
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
|
||||
*/
|
||||
public static function successfulPaymentResponse(
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
@@ -208,7 +208,7 @@ class OnlinePaymentRepo
|
||||
/**
|
||||
* Failed payment response
|
||||
*
|
||||
* @return array<string, bool|string>
|
||||
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
|
||||
*/
|
||||
public static function failedPaymentResponse(
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
@@ -229,7 +229,7 @@ class OnlinePaymentRepo
|
||||
/**
|
||||
* Resource not found
|
||||
*
|
||||
* @return array<string, string|bool>
|
||||
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
|
||||
*/
|
||||
protected static function resourceNotFound(): array
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ trait HandlesVisaMasterPayments
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return array<string, bool|string>
|
||||
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
|
||||
*/
|
||||
public static function checkPaymentVisaMaster(Request $request): array
|
||||
{
|
||||
@@ -34,7 +34,7 @@ trait HandlesVisaMasterPayments
|
||||
|
||||
$bank_branch = $resource->parent->branch;
|
||||
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $request->orderId,
|
||||
'userName' => $bank_branch->billing_visa_master_username,
|
||||
@@ -42,29 +42,38 @@ trait HandlesVisaMasterPayments
|
||||
]);
|
||||
|
||||
$payment_status = $response['ErrorCode'] == '0';
|
||||
$cardholderName = $response['cardAuthInfo']['cardholderName'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['Pan'] ?? '-';
|
||||
|
||||
$returnURL = url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id);
|
||||
|
||||
if ($payment_status) {
|
||||
$resource->update([
|
||||
'payer_name' => $response['cardholderName'],
|
||||
'payer_card' => $response['Pan'],
|
||||
'payer_name' => $cardholderName,
|
||||
'payer_card' => $cardPan,
|
||||
'paid' => true,
|
||||
]);
|
||||
|
||||
$paymentHistory->update([
|
||||
'paymentStatus' => OnlinePaymentRepo::PAID,
|
||||
'cardholderName' => $cardholderName,
|
||||
'pan' => $cardPan,
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
}
|
||||
|
||||
$resource->update([
|
||||
'payer_name' => $response['cardholderName'] ?? '-',
|
||||
'payer_card' => $response['Pan'] ?? '-',
|
||||
'payer_name' => $cardholderName,
|
||||
'payer_card' => $cardPan,
|
||||
]);
|
||||
|
||||
$paymentHistory->update([
|
||||
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
||||
'cardholderName' => $cardholderName,
|
||||
'pan' => $cardPan,
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('online_payment_histories', function (Blueprint $table) {
|
||||
$table->json('api_response')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('online_payment_histories', function (Blueprint $table) {
|
||||
$table->dropColumn('api_response');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user