|
|
|
|
|
|
|
|
// Handle the event |
|
|
// Handle the event |
|
|
switch ($event->type) { |
|
|
switch ($event->type) { |
|
|
case 'charge.succeeded': |
|
|
case 'charge.succeeded': |
|
|
|
|
|
|
|
|
$paymentExist = Payment::searchOne([ |
|
|
$paymentExist = Payment::searchOne([ |
|
|
'id_user' => $idUser, |
|
|
'id_user' => $idUser, |
|
|
'amount' => $amount, |
|
|
'amount' => $amount, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$paymentExist) { |
|
|
if (!$paymentExist) { |
|
|
|
|
|
|
|
|
$paymentManager->creditUser($user, $amount, MeanPayment::CREDIT_CARD, $user); |
|
|
|
|
|
|
|
|
|
|
|
if (isset($order) && $order) { |
|
|
if (isset($order) && $order) { |
|
|
|
|
|
|
|
|
$paymentManager->payOrder($order, MeanPayment::CREDIT_CARD, $user, true); |
|
|
$paymentManager->payOrder($order, MeanPayment::CREDIT_CARD, $user, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// client : envoi d'un email de confirmation de paiement |
|
|
// client : envoi d'un email de confirmation de paiement |
|
|
/*\Yii::$app->mailerService->sendFromProducer( |
|
|
/*\Yii::$app->mailerService->sendFromProducer( |
|
|
'Confirmation de commande', |
|
|
'Confirmation de commande', |
|
|
|
|
|
|
|
|
$contactProducer->email |
|
|
$contactProducer->email |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
$userProducer = $this->getUserProducerModule()->findOneUserProducer($user); |
|
|
|
|
|
|
|
|
$paymentManager->creditUser($user, $amount, MeanPayment::CREDIT_CARD, $user); |
|
|
|
|
|
|
|
|
|
|
|
$userProducer = $this->getUserProducerModule()->findOneUserProducer($user); |
|
|
\Yii::$app->mailerService->sendFromProducer( |
|
|
\Yii::$app->mailerService->sendFromProducer( |
|
|
'Alimentation de votre crédit', |
|
|
'Alimentation de votre crédit', |
|
|
'creditConfirm', |
|
|
'creditConfirm', |