+ Update cancelTransaction method

This commit is contained in:
Djery-Tom 2020-06-09 16:27:57 +01:00
parent 100194e441
commit 9c98201781
3 changed files with 33 additions and 7 deletions

View File

@ -79,8 +79,12 @@ class TransactionController extends Controller
// Verification faites au niveau du frontend
// if($walletAgent->balance_princ >= ($transaction->montant + $frais + $config->frais_min_banque_depot)){
$response = $request->facade == 'front' ? $client->post('fund-transfer-api/v1/transaction/push', ['json' => $body]) : $client->get('localhost');
$code = $response->getStatusCode();
$code = 200;
if($request->facade == 'front'){
$response = $client->post('fund-transfer-api/v1/transaction/push', ['json' => $body]);
$code = $response->getStatusCode();
}
if ($code == 200) {
$banqueCommission = floatval(($frais + $config->frais_min_banque_depot) * $config->part_banque_depot / 100);
@ -130,8 +134,12 @@ class TransactionController extends Controller
$body['cvv'] = $request->cvv;
$body['expiry_date'] = $data['expiration_date']->format('Y-m');
$response = $request->facade == 'front' ? $client->post('fund-transfer-api/v1/transaction/pull', ['json' => $body]) : $client->get('localhost');
$code = $response->getStatusCode();
$code = 200;
if($request->facade == 'front'){
$response = $client->post('fund-transfer-api/v1/transaction/pull', ['json' => $body]);
$code = $response->getStatusCode();
}
if($code == 200) {
$banqueCommission = floatval($transaction->montant * $config->part_banque_retrait / 100);
@ -209,6 +217,21 @@ class TransactionController extends Controller
public function cancel($id_transaction)
{
$transaction = WalletTransaction::findOrFail($id_transaction);
$transactionInverse = new WalletTransaction;
$transactionInverse->date = new \DateTime();
$transactionInverse->statut = $transaction->statut;
$transactionInverse->montant = -$transaction->montant;
$transactionInverse->numCarte = $transaction->numCarte;
$transactionInverse->id_wallet = $transaction->id_wallet;
$transactionInverse->id_wallet_sup = $transaction->id_wallet_sup;
$transactionInverse->id_wallet_hyp = $transaction->id_wallet_hyp;
$transactionInverse->commission_ag = -$transaction->commission_ag;
$transactionInverse->commission_sup = -$transaction->commission_sup;
$transactionInverse->commission_hyp = -$transaction->commission_hyp;
$transactionInverse->commission_banque = -$transaction->commission_banque;
$transactionInverse->type = $transaction->type;
$transactionInverse->expiration_date = $transaction->expiration_date;
$walletAgent = $transaction->wallet;
$walletSuperviseur = $transaction->wallet_sup;
$walletHyperviseur = $transaction->wallet_hyp;
@ -230,6 +253,7 @@ class TransactionController extends Controller
$walletSuperviseur->save();
$walletHyperviseur->save();
$transaction->save();
return $this->successResponse($transaction);
$transactionInverse->save();
return $this->successResponse(trans('messages.canceled_credit_request'));
}
}

View File

@ -5,5 +5,6 @@ return [
'canceled_demand' => 'Canceled credit request',
'princ_balance_inf_to_demand_amount' => 'Your main balance is less than the amount of the request, do you want to change the amount ?',
'new_wallet_added' => 'New wallet added',
'success_treated_demand' => 'Request successfully processed'
'success_treated_demand' => 'Request successfully processed',
'canceled_credit_request' => 'Canceled credit request'
];

View File

@ -5,5 +5,6 @@ return [
'canceled_demand' => 'Demande de credit annulée',
'princ_balance_inf_to_demand_amount' => 'Votre solde principal est inférieur au montant de la demande, voulez vous modifier le montant ?',
'new_wallet_added' => 'Nouveau wallet ajouté',
'success_treated_demand' => 'Demande traitée avec succès'
'success_treated_demand' => 'Demande traitée avec succès',
'canceled_credit_request' => 'Demande de crédit annulée'
];