+ Add Adyen API cash-in/cash-out

This commit is contained in:
Djery-Tom 2020-08-09 23:13:21 +01:00
parent c8b7185591
commit 029249f3af
3 changed files with 83 additions and 31 deletions

View File

@ -113,11 +113,11 @@ class Handler extends ExceptionHandler
$code = $exception->getCode();
if($error){
if($error->message){
if (isset($error->message)) {
$message = json_decode($error->message);
if(isset($message->errorMessage))
return $this->errorResponse($message->errorMessage,$code);
return $this->errorResponse($error->message,$code);
if (isset($message->errorMessage))
return $this->errorResponse($message->errorMessage, $code);
return $this->errorResponse($error->message, $code);
}
return $this->errorResponse($error,$code);
} else

View File

@ -30,6 +30,10 @@ class iLinkTransactionController extends Controller
use ApiResponser;
use Helper;
private $PAYMENT_URL = "/adyen-api/v1/transaction/payement";
private $PAYOUT_URL = "/adyen-api/v1/transaction/payout";
private $REFUND_URL = "/adyen-api/v1/transaction/refund";
/**
* Create a new controller instance.
*
@ -217,15 +221,25 @@ class iLinkTransactionController extends Controller
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
$body['amount'] = $this->toUSDAmount($montantDepot, $init_country);
// $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('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]);
$response = $client->post('fund-transfer-api/v1/transaction/push', ['json' => $body]);
$code = $response->getStatusCode();
if ($code == 200) {
$response = json_decode($response->getBody()->getContents(), true)["response"];
$transaction->pspReference = $response["pspReference"];
$walletUser->balance -= $transaction->montant;
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
$transaction->commission_banque = $frais * $config->taux_com_banque_envoi_wallet_carte_ilink / 100;
@ -243,7 +257,7 @@ class iLinkTransactionController extends Controller
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'net' => $this->toMoney($montantDepot, $init_country), 'fees' => $this->toMoney($frais, $init_country),
'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message);
// $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail'));
} else {
@ -398,16 +412,26 @@ class iLinkTransactionController extends Controller
$frais = $request->montant * $config->taux_com_user_carte_wallet / 100;
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
$body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
// $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('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['cardholder_name'] = "John Smith";
$body['ref'] = date("Y-m-d H:i:s.u");
// dd($body);
$response = $client->post('fund-transfer-api/v1/transaction/pull', ['json' => $body]);
$response = $client->post($this->PAYMENT_URL, ['json' => $body]);
$code = $response->getStatusCode();
if ($code == 200) {
$response = json_decode($response->getBody()->getContents(), true)["response"];
$transaction->pspReference = $response["pspReference"];
$transaction->commission_banque = $commissionBanque = $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100;
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
@ -451,15 +475,24 @@ class iLinkTransactionController extends Controller
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
$transaction->montant_net_final_country = $transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
$body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
// $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('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('fund-transfer-api/v1/transaction/pull', ['json' => $body]);
$response = $client->post($this->PAYMENT_URL, ['json' => $body]);
$code = $response->getStatusCode();
if ($code == 200) {
$response = json_decode($response->getBody()->getContents(), true)["response"];
$transaction->pspReference = $response["pspReference"];
$transaction->commission_banque = $commissionBanque = $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100;
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
@ -588,15 +621,23 @@ class iLinkTransactionController extends Controller
$frais = floatval($request->montant * $config->taux_com_wallet_ag_carte_cash / 100);
$montantRetrait = $transaction->montant - $frais;
$transaction->montant_net = $montantRetrait;
$body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
// $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('Y-m');
$body['expiry_date'] = $expiration_date->format('m/y');
$body['amount'] = $montantRetrait;
$body['cardholder_name'] = $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('fund-transfer-api/v1/transaction/pull', ['json' => $body]);
$response = $client->post($this->PAYMENT_URL, ['json' => $body]);
$code = $response->getStatusCode();
if ($code == 200) {
$response = json_decode($response->getBody()->getContents(), true)["response"];
$transaction->pspReference = $response["pspReference"];
$banqueCommission = floatval($frais * $config->taux_com_banque_retrait_carte_cash / 100);
$transaction->commission_banque = $banqueCommission;
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
@ -762,15 +803,24 @@ class iLinkTransactionController extends Controller
$frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
$montantDepot = $transaction->montant - $frais;
$transaction->montant_net = $montantDepot;
$body['amount'] = $this->toUSDAmount($montantDepot, $init_country);;
// $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('Y-m');
$body['expiry_date'] = $expiration_date->format('m/y');
$body['amount'] = $montantDepot;
$response = $client->post('fund-transfer-api/v1/transaction/push', ['json' => $body]);
$body['cardholder_name'] = $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->PAYOUT_URL, ['json' => $body]);
$code = $response->getStatusCode();
if ($code == 200) {
$response = json_decode($response->getBody()->getContents(), true)["response"];
$transaction->pspReference = $response["pspReference"];
$banqueCommission = floatval($frais * $config->taux_com_banque_depot_cash_carte / 100);
$transaction->commission_banque = $banqueCommission;
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre

View File

@ -56,6 +56,7 @@ use Illuminate\Database\Eloquent\Model;
* @property int $canceled
* @property int $type
* @property Carbon $date
* @property string pspReference
*
* @property Country $country
* @property Wallet $wallet
@ -147,7 +148,8 @@ class WalletIlinkTransaction extends Model
'id_wallet_hyp_payeur',
'canceled',
'type',
'date'
'date',
'pspReference'
];
public function country()