![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/inventory.corals.io/Corals/modules/Payment/Common/Services/ |
<?php namespace Corals\Modules\Payment\Common\Services; use Corals\Foundation\Services\BaseServiceClass; use Corals\Modules\Payment\Common\Http\Requests\TransactionRequest; class TransactionService extends BaseServiceClass { public function preStoreUpdate($request, &$additionalData) { $payment_details = $this->getPaymentDetails($request); $additionalData['extra'] = array_merge($request->get('extra', []) ?? [], $payment_details); $additionalData['amount'] = data_get($payment_details, 'payment_details.paid_amount'); if (data_get($payment_details, 'gateway') == 'Cheque') { if ($request->get('status') == 'completed') { $additionalData['paid_amount'] = data_get($payment_details, 'payment_details.paid_amount'); } else { $additionalData['paid_amount'] = 0; } $additionalData['reference'] = data_get($payment_details, 'payment_details.cheque_number'); } else { $additionalData['reference'] = data_get($payment_details, 'checkoutToken'); $additionalData['paid_amount'] = data_get($payment_details, 'payment_details.paid_amount'); } } public function getPaymentDetails(TransactionRequest $request): array { $gateway = $request->gateway; $checkoutToken = $request->checkoutToken; $payment_details = $request->payment_details; return [ 'gateway' => $gateway, 'checkoutToken' => $checkoutToken, 'payment_details' => $payment_details ]; } }