wip
This commit is contained in:
@@ -56,8 +56,64 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||
|
||||
// OnlinePaymentRepo::syncWithBilling();
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory */
|
||||
$paymentHistory = $data['paymentHistory'];
|
||||
|
||||
/** @var \App\Models\Branch\Branch */
|
||||
$bank = $data['bank_branch'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem */
|
||||
$resource = $data['resource'];
|
||||
|
||||
$response = $data['response'];
|
||||
|
||||
// if ($data['success'] && $paymentHistory) {
|
||||
// $this->runActions($paymentHistory, $bank, $response, $resource);
|
||||
// }
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
|
||||
public function runActions($paymentHistory, $bank, $response, $resource): void
|
||||
{
|
||||
$ecomId = $paymentHistory->orderId;
|
||||
$agentId = $bank->unique_code;
|
||||
$eposId = $response['terminalId'];
|
||||
$account = $resource->parent->sender_datas[0]['deposit_account'];
|
||||
$rrn = $response['authRefNum'];
|
||||
$amount = $resource->tmt_payment_amount;
|
||||
$payPurpose = $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y');
|
||||
|
||||
$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": "%s",
|
||||
"account": "%s",
|
||||
"rrn": "%s",
|
||||
"amount": "%s",
|
||||
"payPurpose": "%s"
|
||||
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
'Content-Type: application/json'
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
info($response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ class OnlinePaymentRepo
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
string $returnURL,
|
||||
$response,
|
||||
): array {
|
||||
return [
|
||||
'success' => true,
|
||||
@@ -206,6 +207,7 @@ class OnlinePaymentRepo
|
||||
'bank_branch' => $bank_branch,
|
||||
'resource' => $resource,
|
||||
'paymentHistory' => $paymentHistory,
|
||||
'response' => $response,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -218,7 +220,8 @@ class OnlinePaymentRepo
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
string $returnURL,
|
||||
$response,
|
||||
): array {
|
||||
return [
|
||||
'success' => false,
|
||||
@@ -229,7 +232,7 @@ class OnlinePaymentRepo
|
||||
'return_url' => $returnURL,
|
||||
'paymentHistory' => $paymentHistory,
|
||||
'bank_branch' => $bank_branch,
|
||||
'resource' => $resource,
|
||||
'response' => $response,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ trait HandlesSberPeyments
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
@@ -64,7 +64,7 @@ trait HandlesSberPeyments
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$resource->update([
|
||||
@@ -80,6 +80,6 @@ trait HandlesSberPeyments
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ trait HandlesVisaMasterPayments
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
@@ -65,7 +65,7 @@ trait HandlesVisaMasterPayments
|
||||
'api_response' => $response->json(),
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$resource->update([
|
||||
@@ -81,6 +81,6 @@ trait HandlesVisaMasterPayments
|
||||
'api_response' => $response->json(),
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user