wip
This commit is contained in:
@@ -25,6 +25,8 @@ class OnlinePaymentController extends Controller
|
|||||||
{
|
{
|
||||||
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
||||||
|
|
||||||
|
// OnlinePaymentRepo::syncWithBilling();
|
||||||
|
|
||||||
return view(OnlinePaymentRepo::statusView(), $data);
|
return view(OnlinePaymentRepo::statusView(), $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +37,8 @@ class OnlinePaymentController extends Controller
|
|||||||
{
|
{
|
||||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||||
|
|
||||||
|
// OnlinePaymentRepo::syncWithBilling();
|
||||||
|
|
||||||
return view(OnlinePaymentRepo::statusView(), $data);
|
return view(OnlinePaymentRepo::statusView(), $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property string $username
|
* @property string $username
|
||||||
* @property int $online_paymantable_id
|
* @property int $online_paymantable_id
|
||||||
* @property string $online_paymantable_type
|
* @property string $online_paymantable_type
|
||||||
|
* @property ?array $api_response
|
||||||
* @property \Illuminate\Support\Carbon $created_at
|
* @property \Illuminate\Support\Carbon $created_at
|
||||||
* @property \Illuminate\Support\Carbon $updated_at
|
* @property \Illuminate\Support\Carbon $updated_at
|
||||||
*/
|
*/
|
||||||
@@ -40,4 +41,16 @@ class OnlinePaymentHistory extends Model
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $table = 'online_payment_histories';
|
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
|
* Sync with billing
|
||||||
*/
|
*/
|
||||||
// public static function syncWithBilling(): bool|string
|
public static function syncWithBilling(
|
||||||
// {
|
string $uuid,
|
||||||
// $curl = curl_init();
|
string $bank_code,
|
||||||
|
string $terminal_id,
|
||||||
|
string $account_number,
|
||||||
|
string $rrn,
|
||||||
|
string $amount,
|
||||||
|
string $pay_purpose,
|
||||||
|
) {
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
// curl_setopt_array($curl, [
|
curl_setopt_array($curl, [
|
||||||
// CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||||
// CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
// CURLOPT_ENCODING => '',
|
CURLOPT_ENCODING => '',
|
||||||
// CURLOPT_MAXREDIRS => 10,
|
CURLOPT_MAXREDIRS => 10,
|
||||||
// CURLOPT_TIMEOUT => 0,
|
CURLOPT_TIMEOUT => 0,
|
||||||
// CURLOPT_FOLLOWLOCATION => true,
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
// CURLOPT_CUSTOMREQUEST => 'POST',
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
// CURLOPT_POSTFIELDS => sprintf(
|
CURLOPT_POSTFIELDS => sprintf(
|
||||||
// '{
|
'{
|
||||||
// "ecomId" : "%s",
|
"ecomId" : "%s",
|
||||||
// "agentId" : "%s",
|
"agentId" : "%s",
|
||||||
// "eposId" : "30401238",
|
"eposId" : "%s",
|
||||||
// "account" : "130420912769753",
|
"account" : "%s",
|
||||||
// "rnn" : "110784016238",
|
"rnn" : "%s",
|
||||||
// "amount" : 895.46,
|
"amount" : %s,
|
||||||
// "payPurpose" : "Mart 2025"
|
"payPurpose" : "%s"
|
||||||
// }',
|
}',
|
||||||
// // $uuid,
|
$uuid,
|
||||||
// // $bankCode,
|
$bank_code,
|
||||||
|
$terminal_id,
|
||||||
|
$account_number,
|
||||||
|
$rrn,
|
||||||
|
$amount,
|
||||||
|
$pay_purpose,
|
||||||
|
),
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||||
|
'Content-Type: application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
// ),
|
$response = curl_exec($curl);
|
||||||
// CURLOPT_HTTPHEADER => [
|
|
||||||
// 'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
|
||||||
// 'Content-Type: application/json',
|
|
||||||
// ],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// $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
|
* 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(
|
public static function successfulPaymentResponse(
|
||||||
OnlinePaymentHistory $paymentHistory,
|
OnlinePaymentHistory $paymentHistory,
|
||||||
@@ -208,7 +208,7 @@ class OnlinePaymentRepo
|
|||||||
/**
|
/**
|
||||||
* Failed payment response
|
* 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(
|
public static function failedPaymentResponse(
|
||||||
OnlinePaymentHistory $paymentHistory,
|
OnlinePaymentHistory $paymentHistory,
|
||||||
@@ -229,7 +229,7 @@ class OnlinePaymentRepo
|
|||||||
/**
|
/**
|
||||||
* Resource not found
|
* 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
|
protected static function resourceNotFound(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ trait HandlesVisaMasterPayments
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @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
|
public static function checkPaymentVisaMaster(Request $request): array
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ trait HandlesVisaMasterPayments
|
|||||||
|
|
||||||
$bank_branch = $resource->parent->branch;
|
$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',
|
'language' => 'ru',
|
||||||
'orderId' => $request->orderId,
|
'orderId' => $request->orderId,
|
||||||
'userName' => $bank_branch->billing_visa_master_username,
|
'userName' => $bank_branch->billing_visa_master_username,
|
||||||
@@ -42,29 +42,38 @@ trait HandlesVisaMasterPayments
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$payment_status = $response['ErrorCode'] == '0';
|
$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);
|
$returnURL = url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id);
|
||||||
|
|
||||||
if ($payment_status) {
|
if ($payment_status) {
|
||||||
$resource->update([
|
$resource->update([
|
||||||
'payer_name' => $response['cardholderName'],
|
'payer_name' => $cardholderName,
|
||||||
'payer_card' => $response['Pan'],
|
'payer_card' => $cardPan,
|
||||||
'paid' => true,
|
'paid' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$paymentHistory->update([
|
$paymentHistory->update([
|
||||||
'paymentStatus' => OnlinePaymentRepo::PAID,
|
'paymentStatus' => OnlinePaymentRepo::PAID,
|
||||||
|
'cardholderName' => $cardholderName,
|
||||||
|
'pan' => $cardPan,
|
||||||
|
'api_response' => $response->body(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource->update([
|
$resource->update([
|
||||||
'payer_name' => $response['cardholderName'] ?? '-',
|
'payer_name' => $cardholderName,
|
||||||
'payer_card' => $response['Pan'] ?? '-',
|
'payer_card' => $cardPan,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$paymentHistory->update([
|
$paymentHistory->update([
|
||||||
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
||||||
|
'cardholderName' => $cardholderName,
|
||||||
|
'pan' => $cardPan,
|
||||||
|
'api_response' => $response->body(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
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