|
|
|
@ -22,6 +22,7 @@ use App\Models\WalletsUser;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use DateTime;
|
|
|
|
|
use Exception;
|
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
@ -32,9 +33,11 @@ use Throwable;
|
|
|
|
|
class iLinkTransactionController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private $PAYMENT_URL = "/adyen-api/v1/transaction/payement";
|
|
|
|
|
private $PAYOUT_URL = "/adyen-api/v1/transaction/payout";
|
|
|
|
|
private $PAYMENT_URL = "/stripe/payIn";
|
|
|
|
|
private $PAYOUT_URL = "/stripe/payOut";
|
|
|
|
|
private $REFUND_URL = "/adyen-api/v1/transaction/refund";
|
|
|
|
|
|
|
|
|
|
private $PAYMENT_CHECK_STATUS = "/check";
|
|
|
|
|
private $PAYING_NETWORK_SIMULATOR_SEND_FRAME_URL = 'http://localhost:8084/receive_payment';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -222,10 +225,12 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
return $this->errorResponse('errors.invalid_cvv');
|
|
|
|
|
|
|
|
|
|
$transaction->fill($data);
|
|
|
|
|
// Client API
|
|
|
|
|
$client = new \GuzzleHttp\Client([
|
|
|
|
|
'base_uri' => env('VISA_API_URL'),
|
|
|
|
|
'auth' => [env('VISA_API_USERNAME'), env('VISA_API_PASSWORD')]
|
|
|
|
|
// Pay through payment service
|
|
|
|
|
$client = new Client([
|
|
|
|
|
'base_uri' => config('services.payment_service.base_uri'),
|
|
|
|
|
'headers' => [
|
|
|
|
|
'Authorization' => config('services.payment_service.key'),
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -265,9 +270,9 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
|
|
|
|
$transaction->id_transaction = $this->getTransactionID();
|
|
|
|
|
|
|
|
|
|
$transaction->type_id_destinataire = $request->input('type_id_destinataire');
|
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
|
$destinataire = User::where('user_code', $request->id_destinataire)->first();
|
|
|
|
|
$destinataire = User::where($transaction->type_id_destinataire, $request->id_destinataire)->first();
|
|
|
|
|
if ($destinataire) { // Si c'est un wallet ilink
|
|
|
|
|
if ($destinataire->network->country->id == $request->final_country) {
|
|
|
|
|
$walletDestinataire = WalletsUser::where('idUser', $destinataire->id)->firstOrFail();
|
|
|
|
@ -351,24 +356,34 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantDepot, $init_country);
|
|
|
|
|
$body['card_number'] = $user->numero_carte;
|
|
|
|
|
$body['cvv'] = $request->cvv;
|
|
|
|
|
// $body['expiry_date'] = $user->expiration_date->format('Y-m');
|
|
|
|
|
$body['expiry_date'] = $user->expiration_date->format('m/y');
|
|
|
|
|
$body['amount'] = $montantDepot;
|
|
|
|
|
$identification = Identification::where('id_user', $user->id)->first();
|
|
|
|
|
$body['cardholder_name'] = $identification ? $identification->lastname . ' ' . $identification->firstname : $user->lastname . ' ' . $user->firstname; //"John Smith" ;
|
|
|
|
|
$body['currency'] = $this->getCurrency($init_country);
|
|
|
|
|
$body['ref'] = date("Y-m-d H:i:s.u");
|
|
|
|
|
$identification = Identification::with(['country'])->where('id_user', $user->id)->first();
|
|
|
|
|
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
|
|
|
|
|
|
|
|
|
|
$response = $client->post($this->PAYOUT_URL, ['json' => $body, 'http_errors' => false]);
|
|
|
|
|
// PayOut through payment service
|
|
|
|
|
$response = $client->post($this->PAYOUT_URL, ['json' => [
|
|
|
|
|
'card_no' => $user->numero_carte,
|
|
|
|
|
'exp_month' => date("m", strtotime($user->expiration_date)),
|
|
|
|
|
'exp_year' => date("Y", strtotime($user->expiration_date)),
|
|
|
|
|
'cvc' => $request->input('cvv'),
|
|
|
|
|
'amount' => $montantDepot,
|
|
|
|
|
'currency' => $this->getCurrency($init_country),
|
|
|
|
|
'payment_method' => 'CARD',
|
|
|
|
|
'customer_id' => $user->id,
|
|
|
|
|
'customer_email' => $user->email,
|
|
|
|
|
'customer_name' => $identification ? $identification->firstname : $user->firstname,
|
|
|
|
|
'customer_surname' => $identification ? $identification->lastname : $user->lastname,
|
|
|
|
|
'customer_phone_number' => $user->phone,
|
|
|
|
|
'customer_address' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_city' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_country' => $customer_country_code,
|
|
|
|
|
'reason' => "User - Envoi de wallet à carte"
|
|
|
|
|
], 'http_errors' => false]);
|
|
|
|
|
|
|
|
|
|
$code = $response->getStatusCode();
|
|
|
|
|
|
|
|
|
|
$content = json_decode($response->getBody()->getContents(), true);
|
|
|
|
|
if ($code == 200) {
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
$response = $content["response"];
|
|
|
|
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
|
|
|
|
|
|
|
|
|
$walletUser->balance -= $transaction->montant;
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
@ -391,7 +406,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response_message = $message . trans('messages.sent_by_mail');
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception(trans('errors.visa_api_failed'), 500);
|
|
|
|
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -651,24 +666,48 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
|
$body['card_number'] = $user->numero_carte;
|
|
|
|
|
$body['cvv'] = $request->cvv;
|
|
|
|
|
// $body['expiry_date'] = $user->expiration_date->format('Y-m');
|
|
|
|
|
$body['expiry_date'] = $user->expiration_date->format('m/y');
|
|
|
|
|
$body['amount'] = $montantRetrait;
|
|
|
|
|
$identification = Identification::where('id_user', $user->id)->first();
|
|
|
|
|
$body['cardholder_name'] = $identification ? $identification->lastname . ' ' . $identification->firstname : $user->lastname . ' ' . $user->firstname; //"John Smith" ;
|
|
|
|
|
$body['currency'] = $this->getCurrency($init_country);
|
|
|
|
|
$body['ref'] = date("Y-m-d H:i:s.u");
|
|
|
|
|
// dd($body);
|
|
|
|
|
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
|
|
|
|
|
|
|
|
|
|
$payment_transaction_id = $request->input('payment_transaction_id');
|
|
|
|
|
if (empty($payment_transaction_id)) {
|
|
|
|
|
// PayIn through payment service
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => [
|
|
|
|
|
'card_no' => $user->numero_carte,
|
|
|
|
|
'exp_month' => date("m", strtotime($user->expiration_date)),
|
|
|
|
|
'exp_year' => date("Y", strtotime($user->expiration_date)),
|
|
|
|
|
'cvc' => $request->input('cvv'),
|
|
|
|
|
'amount' => $montantRetrait,
|
|
|
|
|
'currency' => $this->getCurrency($init_country),
|
|
|
|
|
'payment_method' => 'CARD',
|
|
|
|
|
'customer_id' => $user->id,
|
|
|
|
|
'customer_email' => $user->email,
|
|
|
|
|
'customer_name' => $identification ? $identification->firstname : $user->firstname,
|
|
|
|
|
'customer_surname' => $identification ? $identification->lastname : $user->lastname,
|
|
|
|
|
'customer_address' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_city' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_country' => $customer_country_code,
|
|
|
|
|
'reason' => "User - Retrait de carte vers wallet"
|
|
|
|
|
], 'http_errors' => false]);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Check payment status through payment service
|
|
|
|
|
if (WalletIlinkTransaction::where('payment_transaction_id', $payment_transaction_id)->exists()) {
|
|
|
|
|
throw new Exception(__('errors.transaction_already_completed'), 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $client->get($this->PAYMENT_CHECK_STATUS . '/' . $payment_transaction_id, ['http_errors' => false]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => $body, 'http_errors' => false]);
|
|
|
|
|
$code = $response->getStatusCode();
|
|
|
|
|
$content = json_decode($response->getBody()->getContents(), true);
|
|
|
|
|
if ($code == 301) {
|
|
|
|
|
return $this->successResponse($content["response"], $content['status']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($code == 200) {
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
$response = $content["response"];
|
|
|
|
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
|
|
|
|
|
|
|
|
|
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
@ -691,7 +730,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response_message = ($message . trans('messages.sent_by_mail'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception(trans('errors.visa_api_failed'));
|
|
|
|
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 11: // User - Retrait de carte vers cash
|
|
|
|
@ -719,23 +758,48 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
$transaction->montant_net_final_country = $transaction->montant;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
|
$body['card_number'] = $user->numero_carte;
|
|
|
|
|
$body['cvv'] = $request->cvv;
|
|
|
|
|
// $body['expiry_date'] = $user->expiration_date->format('Y-m');
|
|
|
|
|
$body['expiry_date'] = $user->expiration_date->format('m/y');
|
|
|
|
|
$body['amount'] = $montantRetrait;
|
|
|
|
|
$identification = Identification::where('id_user', $user->id)->first();
|
|
|
|
|
$body['cardholder_name'] = $identification ? $identification->lastname . ' ' . $identification->firstname : $user->lastname . ' ' . $user->firstname; //"John Smith" ;
|
|
|
|
|
$body['currency'] = $this->getCurrency($init_country);
|
|
|
|
|
$body['ref'] = date("Y-m-d H:i:s.u");
|
|
|
|
|
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => $body, 'http_errors' => false]);
|
|
|
|
|
$identification = Identification::where('id_user', $user->id)->first();
|
|
|
|
|
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
|
|
|
|
|
|
|
|
|
|
$payment_transaction_id = $request->input('payment_transaction_id');
|
|
|
|
|
if (empty($payment_transaction_id)) {
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => [
|
|
|
|
|
'card_no' => $user->numero_carte,
|
|
|
|
|
'exp_month' => date("m", strtotime($user->expiration_date)),
|
|
|
|
|
'exp_year' => date("Y", strtotime($user->expiration_date)),
|
|
|
|
|
'cvc' => $request->input('cvv'),
|
|
|
|
|
'amount' => $montantRetrait,
|
|
|
|
|
'currency' => $this->getCurrency($init_country),
|
|
|
|
|
'payment_method' => 'CARD',
|
|
|
|
|
'customer_id' => $user->id,
|
|
|
|
|
'customer_email' => $user->email,
|
|
|
|
|
'customer_name' => $identification ? $identification->firstname : $user->firstname,
|
|
|
|
|
'customer_surname' => $identification ? $identification->lastname : $user->lastname,
|
|
|
|
|
'customer_address' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_city' => $identification ? $identification->town : $user->adresse,
|
|
|
|
|
'customer_country' => $customer_country_code,
|
|
|
|
|
'reason' => "User - Retrait de carte vers cash"
|
|
|
|
|
], 'http_errors' => false]);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Check payment status through payment service
|
|
|
|
|
if (WalletIlinkTransaction::where('payment_transaction_id', $payment_transaction_id)->exists()) {
|
|
|
|
|
throw new Exception(__('errors.transaction_already_completed'), 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $client->get($this->PAYMENT_CHECK_STATUS . '/' . $payment_transaction_id, ['http_errors' => false]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$code = $response->getStatusCode();
|
|
|
|
|
$content = json_decode($response->getBody()->getContents(), true);
|
|
|
|
|
if ($code == 301) {
|
|
|
|
|
return $this->successResponse($content["response"], $content['status']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($code == 200) {
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
$response = $content["response"];
|
|
|
|
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
|
|
|
|
|
|
|
|
|
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
@ -763,7 +827,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
return $this->successResponse($message . trans('messages.sent_by_mail'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception(trans('errors.visa_api_failed'));
|
|
|
|
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 12: // Agent - Retrait en cash
|
|
|
|
@ -886,22 +950,45 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$frais = $this->calculateFees($plr_customer_cart_cash_national, $request->montant);
|
|
|
|
|
$montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
$transaction->montant_net = $montantRetrait;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
|
$body['card_number'] = $request->numero_carte;
|
|
|
|
|
$body['cvv'] = $request->cvv;
|
|
|
|
|
// $body['expiry_date'] = $expiration_date->format('Y-m');
|
|
|
|
|
$body['expiry_date'] = $expiration_date->format('m/y');
|
|
|
|
|
$body['amount'] = $montantRetrait;
|
|
|
|
|
$body['cardholder_name'] = $request->lastname ? $request->lastname . ' ' . $request->firstname : "John Smith";
|
|
|
|
|
$body['currency'] = $this->getCurrency($init_country);
|
|
|
|
|
$body['ref'] = date("Y-m-d H:i:s.u");
|
|
|
|
|
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => $body, 'http_errors' => false]);
|
|
|
|
|
$payment_transaction_id = $request->input('payment_transaction_id');
|
|
|
|
|
if (empty($payment_transaction_id)) {
|
|
|
|
|
$response = $client->post($this->PAYMENT_URL, ['json' => [
|
|
|
|
|
'card_no' => $request->input('numero_carte'),
|
|
|
|
|
'exp_month' => $expiration_date->format('m'),
|
|
|
|
|
'exp_year' => $expiration_date->format('Y'),
|
|
|
|
|
'cvc' => $request->input('cvv'),
|
|
|
|
|
'amount' => $montantRetrait,
|
|
|
|
|
'currency' => $this->getCurrency($init_country),
|
|
|
|
|
'payment_method' => 'CARD',
|
|
|
|
|
'customer_email' => $request->input('customer_email'),
|
|
|
|
|
'customer_name' => $request->input('firstname'),
|
|
|
|
|
'customer_surname' => $request->input('lastname'),
|
|
|
|
|
'customer_address' => $request->input('customer_address'),
|
|
|
|
|
'customer_city' => $request->input('customer_city'),
|
|
|
|
|
'customer_country' => $request->input('customer_country'),
|
|
|
|
|
'customer_state' => $request->input('customer_state'),
|
|
|
|
|
'customer_zip_code' => $request->input('customer_zip_code'),
|
|
|
|
|
'reason' => " Agent - Retrait de la carte vers cash"
|
|
|
|
|
], 'http_errors' => false]);
|
|
|
|
|
} else {
|
|
|
|
|
// Check payment status through payment service
|
|
|
|
|
if (WalletIlinkTransaction::where('payment_transaction_id', $payment_transaction_id)->exists()) {
|
|
|
|
|
throw new Exception(__('errors.transaction_already_completed'), 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $client->get($this->PAYMENT_CHECK_STATUS . '/' . $payment_transaction_id, ['http_errors' => false]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$code = $response->getStatusCode();
|
|
|
|
|
$content = json_decode($response->getBody()->getContents(), true);
|
|
|
|
|
if ($code == 301) {
|
|
|
|
|
return $this->successResponse($content["response"], $content['status']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($code == 200) {
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
$response = $content["response"];
|
|
|
|
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
|
|
|
|
|
|
|
|
|
$banqueCommission = $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
$transaction->commission_banque = $banqueCommission;
|
|
|
|
@ -936,7 +1023,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response_message = (trans('messages.successful_transaction'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception(trans('errors.visa_api_failed'));
|
|
|
|
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 14: // Agent - Envoi de cash vers wallet iLink
|
|
|
|
@ -1097,23 +1184,33 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$montantDepot = $transaction->montant - $frais;
|
|
|
|
|
$transaction->montant_net = $montantDepot;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantDepot, $init_country);;
|
|
|
|
|
$body['card_number'] = $request->numero_carte;
|
|
|
|
|
$body['cvv'] = $request->cvv;
|
|
|
|
|
// $body['expiry_date'] = $expiration_date->format('Y-m');
|
|
|
|
|
$body['expiry_date'] = $expiration_date->format('m/y');
|
|
|
|
|
$body['amount'] = $montantDepot;
|
|
|
|
|
|
|
|
|
|
$body['cardholder_name'] = $request->lastname ? $request->lastname . ' ' . $request->firstname : "John Smith";
|
|
|
|
|
$body['currency'] = $this->getCurrency($init_country);
|
|
|
|
|
$body['ref'] = date("Y-m-d H:i:s.u");
|
|
|
|
|
// PayOut through payment service
|
|
|
|
|
$response = $client->post($this->PAYOUT_URL, ['json' => [
|
|
|
|
|
'card_no' => $request->input('numero_carte'),
|
|
|
|
|
'exp_month' => $expiration_date->format('m'),
|
|
|
|
|
'exp_year' => $expiration_date->format('Y'),
|
|
|
|
|
'cvc' => $request->input('cvv'),
|
|
|
|
|
'amount' => $montantDepot,
|
|
|
|
|
'currency' => $this->getCurrency($init_country),
|
|
|
|
|
'payment_method' => 'CARD',
|
|
|
|
|
'customer_email' => $request->input('customer_email'),
|
|
|
|
|
'customer_name' => $request->input('firstname'),
|
|
|
|
|
'customer_surname' => $request->input('lastname'),
|
|
|
|
|
'customer_address' => $request->input('customer_address'),
|
|
|
|
|
'customer_city' => $request->input('customer_city'),
|
|
|
|
|
'customer_country' => $request->input('customer_country'),
|
|
|
|
|
'customer_state' => $request->input('customer_state'),
|
|
|
|
|
'customer_zip_code' => $request->input('customer_zip_code'),
|
|
|
|
|
'reason' => "Agent - Envoi de cash vers une carte visa"
|
|
|
|
|
], 'http_errors' => false]);
|
|
|
|
|
|
|
|
|
|
$response = $client->post($this->PAYOUT_URL, ['json' => $body, 'http_errors' => false]);
|
|
|
|
|
$code = $response->getStatusCode();
|
|
|
|
|
$content = json_decode($response->getBody()->getContents(), true);
|
|
|
|
|
|
|
|
|
|
if ($code == 200) {
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
$response = $content["response"];
|
|
|
|
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
|
|
|
|
|
|
|
|
|
$banqueCommission = $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais);
|
|
|
|
|
$transaction->commission_banque = $banqueCommission;
|
|
|
|
@ -1148,7 +1245,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response_message = (trans('messages.successful_transaction'));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
|
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 17: // Agent - Envoi de cash vers cash
|
|
|
|
@ -1666,7 +1763,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$date = $data->date;
|
|
|
|
|
unset($data->date);
|
|
|
|
|
$wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null;
|
|
|
|
|
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->first() : null;
|
|
|
|
|
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->orWhere('phone', $data->id_destinataire)->first() : null;
|
|
|
|
|
$emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
|
|
|
|
|
if (!$wallet_user && !$data->nom_emetteur)
|
|
|
|
|
$emetteur = $data->numero_carte;
|
|
|
|
@ -1754,7 +1851,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
if ($configNetworkDestinataire->type != 'ilink') {
|
|
|
|
|
$data['destinataire'] = $request->id_destinataire;
|
|
|
|
|
} else {
|
|
|
|
|
$destinataire = User::where('user_code', $request->id_destinataire)->first();
|
|
|
|
|
$destinataire = User::where('user_code', $request->id_destinataire)->orWhere('phone', $request->id_destinataire)->first();
|
|
|
|
|
$data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire;
|
|
|
|
|
}
|
|
|
|
|
$data['frais'] = round($frais + $taxe, 2);
|
|
|
|
|