+ Add Adyen API cash-in/cash-out
This commit is contained in:
parent
c8b7185591
commit
029249f3af
|
@ -113,11 +113,11 @@ class Handler extends ExceptionHandler
|
||||||
$code = $exception->getCode();
|
$code = $exception->getCode();
|
||||||
|
|
||||||
if($error){
|
if($error){
|
||||||
if($error->message){
|
if (isset($error->message)) {
|
||||||
$message = json_decode($error->message);
|
$message = json_decode($error->message);
|
||||||
if(isset($message->errorMessage))
|
if (isset($message->errorMessage))
|
||||||
return $this->errorResponse($message->errorMessage,$code);
|
return $this->errorResponse($message->errorMessage, $code);
|
||||||
return $this->errorResponse($error->message,$code);
|
return $this->errorResponse($error->message, $code);
|
||||||
}
|
}
|
||||||
return $this->errorResponse($error,$code);
|
return $this->errorResponse($error,$code);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -30,6 +30,10 @@ class iLinkTransactionController extends Controller
|
||||||
use ApiResponser;
|
use ApiResponser;
|
||||||
use Helper;
|
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.
|
* Create a new controller instance.
|
||||||
*
|
*
|
||||||
|
@ -217,15 +221,25 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
|
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
|
||||||
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
|
$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['card_number'] = $user->numero_carte;
|
||||||
$body['cvv'] = $request->cvv;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
|
||||||
if ($code == 200) {
|
if ($code == 200) {
|
||||||
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
||||||
|
$transaction->pspReference = $response["pspReference"];
|
||||||
|
|
||||||
$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
|
||||||
$transaction->commission_banque = $frais * $config->taux_com_banque_envoi_wallet_carte_ilink / 100;
|
$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),
|
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
|
||||||
'net' => $this->toMoney($montantDepot, $init_country), 'fees' => $this->toMoney($frais, $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)]);
|
'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'));
|
return $this->successResponse($message . trans('messages.sent_by_mail'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -398,16 +412,26 @@ class iLinkTransactionController extends Controller
|
||||||
$frais = $request->montant * $config->taux_com_user_carte_wallet / 100;
|
$frais = $request->montant * $config->taux_com_user_carte_wallet / 100;
|
||||||
|
|
||||||
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
|
$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['card_number'] = $user->numero_carte;
|
||||||
$body['cvv'] = $request->cvv;
|
$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);
|
// dd($body);
|
||||||
|
|
||||||
$response = $client->post('fund-transfer-api/v1/transaction/pull', ['json' => $body]);
|
$response = $client->post($this->PAYMENT_URL, ['json' => $body]);
|
||||||
$code = $response->getStatusCode();
|
$code = $response->getStatusCode();
|
||||||
|
|
||||||
if ($code == 200) {
|
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;
|
$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
|
//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;
|
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
|
||||||
$transaction->montant_net_final_country = $transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
|
$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['card_number'] = $user->numero_carte;
|
||||||
$body['cvv'] = $request->cvv;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
|
||||||
if ($code == 200) {
|
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;
|
$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
|
//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);
|
$frais = floatval($request->montant * $config->taux_com_wallet_ag_carte_cash / 100);
|
||||||
$montantRetrait = $transaction->montant - $frais;
|
$montantRetrait = $transaction->montant - $frais;
|
||||||
$transaction->montant_net = $montantRetrait;
|
$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['card_number'] = $request->numero_carte;
|
||||||
$body['cvv'] = $request->cvv;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
|
||||||
if ($code == 200) {
|
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);
|
$banqueCommission = floatval($frais * $config->taux_com_banque_retrait_carte_cash / 100);
|
||||||
$transaction->commission_banque = $banqueCommission;
|
$transaction->commission_banque = $banqueCommission;
|
||||||
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
|
// 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;
|
$frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
|
||||||
$montantDepot = $transaction->montant - $frais;
|
$montantDepot = $transaction->montant - $frais;
|
||||||
$transaction->montant_net = $montantDepot;
|
$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['card_number'] = $request->numero_carte;
|
||||||
$body['cvv'] = $request->cvv;
|
$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();
|
$code = $response->getStatusCode();
|
||||||
|
|
||||||
if ($code == 200) {
|
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);
|
$banqueCommission = floatval($frais * $config->taux_com_banque_depot_cash_carte / 100);
|
||||||
$transaction->commission_banque = $banqueCommission;
|
$transaction->commission_banque = $banqueCommission;
|
||||||
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
|
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
|
||||||
|
|
|
@ -56,6 +56,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property int $canceled
|
* @property int $canceled
|
||||||
* @property int $type
|
* @property int $type
|
||||||
* @property Carbon $date
|
* @property Carbon $date
|
||||||
|
* @property string pspReference
|
||||||
*
|
*
|
||||||
* @property Country $country
|
* @property Country $country
|
||||||
* @property Wallet $wallet
|
* @property Wallet $wallet
|
||||||
|
@ -137,18 +138,19 @@ class WalletIlinkTransaction extends Model
|
||||||
'final_country',
|
'final_country',
|
||||||
'commission_banque',
|
'commission_banque',
|
||||||
'commission_ag',
|
'commission_ag',
|
||||||
'commission_sup',
|
'commission_sup',
|
||||||
'commission_hyp',
|
'commission_hyp',
|
||||||
'commission_hyp_final_country',
|
'commission_hyp_final_country',
|
||||||
'id_wallet_user',
|
'id_wallet_user',
|
||||||
'id_wallet_ag',
|
'id_wallet_ag',
|
||||||
'id_wallet_sup',
|
'id_wallet_sup',
|
||||||
'id_wallet_hyp',
|
'id_wallet_hyp',
|
||||||
'id_wallet_hyp_payeur',
|
'id_wallet_hyp_payeur',
|
||||||
'canceled',
|
'canceled',
|
||||||
'type',
|
'type',
|
||||||
'date'
|
'date',
|
||||||
];
|
'pspReference'
|
||||||
|
];
|
||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue