- Integrate Stripe payment to Card operation
This commit is contained in:
parent
c1fce57743
commit
80efef9576
|
@ -38,6 +38,11 @@ VISA_API_PASSWORD=PasswordHere!
|
||||||
NOTIFICATION_SERVICE_URL=localhost:8083
|
NOTIFICATION_SERVICE_URL=localhost:8083
|
||||||
NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg
|
NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg
|
||||||
|
|
||||||
|
|
||||||
|
PAYMENT_SERVICE_URL=localhost:8087
|
||||||
|
PAYMENT_SERVICE_KEY=U14YhuyFhweMeYpIYj8Ft2jm4cVgbMzD
|
||||||
|
|
||||||
|
|
||||||
SWAGGER_GENERATE_ALWAYS=true
|
SWAGGER_GENERATE_ALWAYS=true
|
||||||
SWAGGER_DOCS_TOKEN=ZfMqCAdHHrSH8ADdXreIejgjJtOwsH4K
|
SWAGGER_DOCS_TOKEN=ZfMqCAdHHrSH8ADdXreIejgjJtOwsH4K
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use App\Models\WalletsUser;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
@ -32,9 +33,11 @@ use Throwable;
|
||||||
class iLinkTransactionController extends Controller
|
class iLinkTransactionController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
private $PAYMENT_URL = "/adyen-api/v1/transaction/payement";
|
private $PAYMENT_URL = "/stripe/payIn";
|
||||||
private $PAYOUT_URL = "/adyen-api/v1/transaction/payout";
|
private $PAYOUT_URL = "/stripe/payOut";
|
||||||
private $REFUND_URL = "/adyen-api/v1/transaction/refund";
|
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';
|
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');
|
return $this->errorResponse('errors.invalid_cvv');
|
||||||
|
|
||||||
$transaction->fill($data);
|
$transaction->fill($data);
|
||||||
// Client API
|
// Pay through payment service
|
||||||
$client = new \GuzzleHttp\Client([
|
$client = new Client([
|
||||||
'base_uri' => env('VISA_API_URL'),
|
'base_uri' => config('services.payment_service.base_uri'),
|
||||||
'auth' => [env('VISA_API_USERNAME'), env('VISA_API_PASSWORD')]
|
'headers' => [
|
||||||
|
'Authorization' => config('services.payment_service.key'),
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -265,9 +270,9 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
||||||
$transaction->id_transaction = $this->getTransactionID();
|
$transaction->id_transaction = $this->getTransactionID();
|
||||||
|
$transaction->type_id_destinataire = $request->input('type_id_destinataire');
|
||||||
if ($configPayeur->type == 'ilink') {
|
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) { // Si c'est un wallet ilink
|
||||||
if ($destinataire->network->country->id == $request->final_country) {
|
if ($destinataire->network->country->id == $request->final_country) {
|
||||||
$walletDestinataire = WalletsUser::where('idUser', $destinataire->id)->firstOrFail();
|
$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);
|
$frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant);
|
||||||
|
|
||||||
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
|
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
|
||||||
// $body['amount'] = $this->toUSDAmount($montantDepot, $init_country);
|
$identification = Identification::with(['country'])->where('id_user', $user->id)->first();
|
||||||
$body['card_number'] = $user->numero_carte;
|
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
|
||||||
$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");
|
|
||||||
|
|
||||||
$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();
|
$code = $response->getStatusCode();
|
||||||
|
$content = json_decode($response->getBody()->getContents(), true);
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
$response = $content["response"];
|
||||||
$transaction->pspReference = $response["pspReference"];
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
||||||
|
|
||||||
$walletUser->balance -= $transaction->montant;
|
$walletUser->balance -= $transaction->montant;
|
||||||
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
//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');
|
$response_message = $message . trans('messages.sent_by_mail');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(trans('errors.visa_api_failed'), 500);
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -651,24 +666,48 @@ class iLinkTransactionController extends Controller
|
||||||
$frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant);
|
$frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant);
|
||||||
|
|
||||||
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais;
|
$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();
|
$identification = Identification::where('id_user', $user->id)->first();
|
||||||
$body['cardholder_name'] = $identification ? $identification->lastname . ' ' . $identification->firstname : $user->lastname . ' ' . $user->firstname; //"John Smith" ;
|
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
|
||||||
$body['currency'] = $this->getCurrency($init_country);
|
|
||||||
$body['ref'] = date("Y-m-d H:i:s.u");
|
$payment_transaction_id = $request->input('payment_transaction_id');
|
||||||
// dd($body);
|
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();
|
$code = $response->getStatusCode();
|
||||||
|
$content = json_decode($response->getBody()->getContents(), true);
|
||||||
|
if ($code == 301) {
|
||||||
|
return $this->successResponse($content["response"], $content['status']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
$response = $content["response"];
|
||||||
$transaction->pspReference = $response["pspReference"];
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
||||||
|
|
||||||
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
$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
|
//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'));
|
$response_message = ($message . trans('messages.sent_by_mail'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(trans('errors.visa_api_failed'));
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 11: // User - Retrait de carte vers cash
|
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 = $montantRetrait = $transaction->montant + $frais;
|
||||||
$transaction->montant_net_final_country = $transaction->montant;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
$content = json_decode($response->getBody()->getContents(), true);
|
||||||
|
if ($code == 301) {
|
||||||
|
return $this->successResponse($content["response"], $content['status']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
$response = $content["response"];
|
||||||
$transaction->pspReference = $response["pspReference"];
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
||||||
|
|
||||||
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
$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
|
//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'));
|
return $this->successResponse($message . trans('messages.sent_by_mail'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(trans('errors.visa_api_failed'));
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12: // Agent - Retrait en cash
|
case 12: // Agent - Retrait en cash
|
||||||
|
@ -886,22 +950,45 @@ class iLinkTransactionController extends Controller
|
||||||
$frais = $this->calculateFees($plr_customer_cart_cash_national, $request->montant);
|
$frais = $this->calculateFees($plr_customer_cart_cash_national, $request->montant);
|
||||||
$montantRetrait = $transaction->montant + $frais;
|
$montantRetrait = $transaction->montant + $frais;
|
||||||
$transaction->montant_net = $montantRetrait;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
$content = json_decode($response->getBody()->getContents(), true);
|
||||||
|
if ($code == 301) {
|
||||||
|
return $this->successResponse($content["response"], $content['status']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
$response = $content["response"];
|
||||||
$transaction->pspReference = $response["pspReference"];
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
||||||
|
|
||||||
$banqueCommission = $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais);
|
$banqueCommission = $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais);
|
||||||
$transaction->commission_banque = $banqueCommission;
|
$transaction->commission_banque = $banqueCommission;
|
||||||
|
@ -936,7 +1023,7 @@ class iLinkTransactionController extends Controller
|
||||||
$response_message = (trans('messages.successful_transaction'));
|
$response_message = (trans('messages.successful_transaction'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(trans('errors.visa_api_failed'));
|
throw new Exception($content['error'] ?? __('errors.visa_api_failed'), $content['status'] ?? 500);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 14: // Agent - Envoi de cash vers wallet iLink
|
case 14: // Agent - Envoi de cash vers wallet iLink
|
||||||
|
@ -1097,23 +1184,33 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
$montantDepot = $transaction->montant - $frais;
|
$montantDepot = $transaction->montant - $frais;
|
||||||
$transaction->montant_net = $montantDepot;
|
$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";
|
// PayOut through payment service
|
||||||
$body['currency'] = $this->getCurrency($init_country);
|
$response = $client->post($this->PAYOUT_URL, ['json' => [
|
||||||
$body['ref'] = date("Y-m-d H:i:s.u");
|
'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();
|
$code = $response->getStatusCode();
|
||||||
|
$content = json_decode($response->getBody()->getContents(), true);
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
$response = $content["response"];
|
||||||
$transaction->pspReference = $response["pspReference"];
|
$transaction->payment_transaction_id = $response["transaction_id"];
|
||||||
|
|
||||||
$banqueCommission = $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais);
|
$banqueCommission = $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais);
|
||||||
$transaction->commission_banque = $banqueCommission;
|
$transaction->commission_banque = $banqueCommission;
|
||||||
|
@ -1148,7 +1245,7 @@ class iLinkTransactionController extends Controller
|
||||||
$response_message = (trans('messages.successful_transaction'));
|
$response_message = (trans('messages.successful_transaction'));
|
||||||
|
|
||||||
} else {
|
} 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;
|
break;
|
||||||
case 17: // Agent - Envoi de cash vers cash
|
case 17: // Agent - Envoi de cash vers cash
|
||||||
|
@ -1666,7 +1763,7 @@ class iLinkTransactionController extends Controller
|
||||||
$date = $data->date;
|
$date = $data->date;
|
||||||
unset($data->date);
|
unset($data->date);
|
||||||
$wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null;
|
$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;
|
$emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
|
||||||
if (!$wallet_user && !$data->nom_emetteur)
|
if (!$wallet_user && !$data->nom_emetteur)
|
||||||
$emetteur = $data->numero_carte;
|
$emetteur = $data->numero_carte;
|
||||||
|
@ -1754,7 +1851,7 @@ class iLinkTransactionController extends Controller
|
||||||
if ($configNetworkDestinataire->type != 'ilink') {
|
if ($configNetworkDestinataire->type != 'ilink') {
|
||||||
$data['destinataire'] = $request->id_destinataire;
|
$data['destinataire'] = $request->id_destinataire;
|
||||||
} else {
|
} 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['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire;
|
||||||
}
|
}
|
||||||
$data['frais'] = round($frais + $taxe, 2);
|
$data['frais'] = round($frais + $taxe, 2);
|
||||||
|
|
|
@ -205,6 +205,7 @@ class WalletIlinkTransaction extends Model
|
||||||
'numero_carte' => 'required',
|
'numero_carte' => 'required',
|
||||||
'cvv' => 'required|size:3',
|
'cvv' => 'required|size:3',
|
||||||
'expiration_date' => 'required|date_format:m/y|after_or_equal:today',
|
'expiration_date' => 'required|date_format:m/y|after_or_equal:today',
|
||||||
|
'payment_transaction_id' => 'nullable|string' // Required if payment was redirected
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,7 @@ class WalletIlinkTransaction extends Model
|
||||||
return [
|
return [
|
||||||
// 'final_country' => 'required|integer|exists:countries,id',
|
// 'final_country' => 'required|integer|exists:countries,id',
|
||||||
'cvv' => 'required|size:3',
|
'cvv' => 'required|size:3',
|
||||||
|
'payment_transaction_id' => 'nullable|string' // Required if payment was redirected
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +248,7 @@ class WalletIlinkTransaction extends Model
|
||||||
'type_document_destinataire' => 'required',
|
'type_document_destinataire' => 'required',
|
||||||
// 'id_document_destinataire'=>'required',
|
// 'id_document_destinataire'=>'required',
|
||||||
'id_destinataire' => 'required_without:phone_destinataire',
|
'id_destinataire' => 'required_without:phone_destinataire',
|
||||||
|
'type_id_destinataire' => 'required|string|in:user_code,phone',
|
||||||
'network_destinataire' => 'required|integer|exists:networks,id',
|
'network_destinataire' => 'required|integer|exists:networks,id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^8.0",
|
"php": "^8.0",
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/laravel-dompdf": "^0.9.0",
|
"barryvdh/laravel-dompdf": "^0.9.0",
|
||||||
"brick/money": "^0.5.2",
|
"brick/money": "^0.5.2",
|
||||||
"darkaonline/swagger-lume": "^8.0",
|
"darkaonline/swagger-lume": "^8.0",
|
||||||
|
"doctrine/dbal": "^3.6",
|
||||||
"flipbox/lumen-generator": "8.2.2",
|
"flipbox/lumen-generator": "8.2.2",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"illuminate/mail": "^8.62",
|
"illuminate/mail": "^8.62",
|
||||||
|
@ -44,7 +45,10 @@
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"optimize-autoloader": true
|
"optimize-autoloader": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"php-http/discovery": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,10 @@ return [
|
||||||
'base_uri' => env('NOTIFICATION_SERVICE_URL'),
|
'base_uri' => env('NOTIFICATION_SERVICE_URL'),
|
||||||
'key' => env('NOTIFICATION_SERVICE_KEY')
|
'key' => env('NOTIFICATION_SERVICE_KEY')
|
||||||
],
|
],
|
||||||
|
'payment_service' => [
|
||||||
|
'base_uri' => env('PAYMENT_SERVICE_URL'),
|
||||||
|
'key' => env('PAYMENT_SERVICE_KEY')
|
||||||
|
],
|
||||||
'app_url' => env('APP_URL'),
|
'app_url' => env('APP_URL'),
|
||||||
'app_debug' => env('APP_DEBUG', false)
|
'app_debug' => env('APP_DEBUG', false)
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class RenamePspReferenceInWalletIlinkTransaction extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('wallet_ilink_transaction', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('pspReference', 'payment_transaction_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('wallet_ilink_transaction', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('payment_transaction_id', 'pspReference');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,5 +85,6 @@ Paying network : :network :country',
|
||||||
"update_banking_information" => "Update your banking information",
|
"update_banking_information" => "Update your banking information",
|
||||||
"wallet_already_linked_to_bank_account" => "Your wallet is already linked to your bank account",
|
"wallet_already_linked_to_bank_account" => "Your wallet is already linked to your bank account",
|
||||||
"users_group_not_found" => "This group code does not exist",
|
"users_group_not_found" => "This group code does not exist",
|
||||||
"amount_not_allowed" => "This amount is not allowed. It must be between :min and :max"
|
"amount_not_allowed" => "This amount is not allowed. It must be between :min and :max",
|
||||||
|
"transaction_already_completed" => "This transaction has already been completed"
|
||||||
];
|
];
|
||||||
|
|
|
@ -85,5 +85,6 @@ Réseau payeur : :network :country',
|
||||||
"update_banking_information" => "Mettez à jour vos informations bancaires",
|
"update_banking_information" => "Mettez à jour vos informations bancaires",
|
||||||
"wallet_already_linked_to_bank_account" => "Votre wallet est déjà rattaché à votre compte bancaire",
|
"wallet_already_linked_to_bank_account" => "Votre wallet est déjà rattaché à votre compte bancaire",
|
||||||
"users_group_not_found" => "Ce code de groupe n'existe pas",
|
"users_group_not_found" => "Ce code de groupe n'existe pas",
|
||||||
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max"
|
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max",
|
||||||
|
"transaction_already_completed" => "Cette transaction a déjà été éffectuée"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue