Fix opening customer payment
This commit is contained in:
parent
9ef8021dc3
commit
30c88f2b17
|
@ -951,25 +951,25 @@ class CustomerAccountOpeningController extends Controller
|
|||
return $this->errorResponse(trans('errors.payment_not_found'), 404);
|
||||
}
|
||||
|
||||
$accountRequest = InfosCustomerAccountOpeningRequest::where('payment_transaction_id', $transaction_id)->first();
|
||||
if ($accountRequest) {
|
||||
if (!CustomerAccountRequest::where('payment_transaction_id', $transaction->id)->exists()) {
|
||||
return $this->errorResponse(trans('errors.payment_invalid'), 400);
|
||||
}
|
||||
}
|
||||
|
||||
$hyperviseur = AgentPlus::where('category', 'hyper')->where('network_id', $accountRequest->network_id)->firstOrFail();
|
||||
$walletHyperviseur = Wallet::where('id_agent', $hyperviseur->id)->firstOrFail();
|
||||
$walletHyperviseur = Wallet::where('id_networkAgent', $hyperviseur->network_agent_id)->firstOrFail();
|
||||
|
||||
$datetime = $this->getCurrentTimeByCountryCode($county->code_country);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$walletHyperviseur->balance_princ += $amountToPaid;
|
||||
$walletHyperviseur->save();
|
||||
|
||||
if (empty($transaction_id)) {
|
||||
if ($payment_method == 'wallet') {
|
||||
|
||||
$walletHyperviseur->balance_princ += $amountToPaid;
|
||||
$walletHyperviseur->save();
|
||||
|
||||
$walletUser->balance -= $amountToPaid;
|
||||
$walletUser->save();
|
||||
} else {
|
||||
|
@ -993,11 +993,11 @@ class CustomerAccountOpeningController extends Controller
|
|||
'customer_surname' => $user->lastname,
|
||||
'customer_phone_number' => $request->input('payment_phone'),
|
||||
'customer_address' => $user->adresse,
|
||||
'customer_country' => $county->name ?? '',
|
||||
'customer_country' => $county->code_country ?? 'CM',
|
||||
'customer_city' => $user->adresse,
|
||||
'customer_state' => $county->code_country ?? '',
|
||||
'customer_state' => $county->code_country ?? 'CM',
|
||||
'customer_zip_code' => '00237',
|
||||
'payment_method' => $request->input('payment_method'),
|
||||
'payment_method' => $payment_method,
|
||||
'reason' => 'N° '.__('messages.customer_account_opening_request').": ".$accountRequest->unique_id,
|
||||
'otp' => $request->input('otp')
|
||||
],
|
||||
|
@ -1017,11 +1017,23 @@ class CustomerAccountOpeningController extends Controller
|
|||
|
||||
CustomerAccountRequest::where('id', $accountRequest->id)->update([
|
||||
'status' => CustomerAccountRequest::ACCEPTED_PAID,
|
||||
'payment_transaction_id' => $transaction_id,
|
||||
'payment_transaction_id' => $transaction?->id,
|
||||
'updated_at' => $datetime
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
$mailParams = ['name' => $accountRequest->lastname, 'request_id' => $accountRequest->unique_id,
|
||||
'gender' => $accountRequest->title, 'account_type' => $accountRequest->customer_account_type_name,
|
||||
'opening_amount' => $this->toMoneyWithCurrencyCode($accountRequest->opening_amount, $accountRequest->currency_code)
|
||||
];
|
||||
|
||||
$mailTitle = trans('messages.customer_account_opening_request_paid_mail_title');
|
||||
$mailMessage = trans('messages.customer_account_opening_request_paid_mail_body', $mailParams);
|
||||
$notification = trans('messages.customer_account_opening_request_paid_notification');
|
||||
|
||||
Event::dispatch(new CustomerAccountRequestEvent($accountRequest, $mailTitle, $mailMessage, $notification));
|
||||
|
||||
} catch (Throwable $e) {
|
||||
DB::rollBack();
|
||||
Log::error($e->getMessage());
|
||||
|
|
|
@ -68,4 +68,15 @@ Your customer account opening request is waiting for more information.
|
|||
Message: :reason",
|
||||
'customer_account_opening_request_awaiting_more_information_notification' => "Your customer account opening request :subscription_id is awaiting more information.",
|
||||
'successful_paid_customer_account_opening_request' => "Customer account opening request paid successfully",
|
||||
'customer_account_opening_request_paid_notification' => "PAYMENT OF YOUR ACCOUNT RECEIVED. YOUR BANK ACCOUNT WILL BE CREDITED",
|
||||
'customer_account_opening_request_paid_mail_title' => "Payment of customer account opening amount",
|
||||
'customer_account_opening_request_paid_mail_body' => ":gender :name,
|
||||
|
||||
Your payment of the customer account opening amount has been received. Your bank account will be credited
|
||||
|
||||
Application information:
|
||||
- ID: :subscription_id
|
||||
- Account type: :account_type
|
||||
- Opening amount: :opening_amount
|
||||
"
|
||||
];
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
return [
|
||||
|
||||
];
|
|
@ -68,4 +68,15 @@ Votre demande d'ouverture de compte client est en attente de plus d'informations
|
|||
Message : :reason",
|
||||
'customer_account_opening_request_awaiting_more_information_notification' => "Votre demande d'ouverture de compte client :subscription_id est en attente de plus d'informations.",
|
||||
'successful_paid_customer_account_opening_request' => "Demande d'ouverture de compte client payée avec succès",
|
||||
'customer_account_opening_request_paid_notification' => "PAIEMENT DU MONTANT OUVERTURE DE VOTRE COMPTE RECU. VOTRE COMPTE BANCAIRE SERA CREDITE",
|
||||
'customer_account_opening_request_paid_mail_title' => "Paiement du montant d'ouverture du compte client",
|
||||
'customer_account_opening_request_paid_mail_body' => ":gender :name ,
|
||||
|
||||
Votre paiement du montant d'ouverture de compte client a été reçu. Votre compte bancaire sera crédité
|
||||
|
||||
Informations de la demande :
|
||||
- ID : :subscription_id
|
||||
- Type de compte : :account_type
|
||||
- Montant d'ouverture: :opening_amount
|
||||
",
|
||||
];
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
return [
|
||||
|
||||
];
|
Loading…
Reference in New Issue