public static function getStrBy($meanPayment) | public static function getStrBy($meanPayment) | ||||
{ | { | ||||
switch($meanPayment) { | switch($meanPayment) { | ||||
case self::CREDIT_CARD : return 'Carte bancaire' ; | |||||
case self::CREDIT_CARD : return 'Paiement en ligne' ; | |||||
case self::MONEY : return 'Espèces' ; | case self::MONEY : return 'Espèces' ; | ||||
case self::CHEQUE : return 'Chèque' ; | case self::CHEQUE : return 'Chèque' ; | ||||
case self::TRANSFER : return 'Virement' ; | case self::TRANSFER : return 'Virement' ; |
[['id_user', 'date', 'status'], 'required', 'message' => ''], | [['id_user', 'date', 'status'], 'required', 'message' => ''], | ||||
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | [['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | ||||
[['auto_payment', 'tiller_synchronization', 'delivery_home'], 'boolean'], | [['auto_payment', 'tiller_synchronization', 'delivery_home'], 'boolean'], | ||||
[['status', 'reference', 'delivery_address'], 'string'], | |||||
[['status', 'reference', 'delivery_address', 'online_payment_url'], 'string'], | |||||
[['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | [['date', 'date_update', 'comment', 'comment_point_sale', 'mean_payment'], 'safe'] | ||||
]; | ]; | ||||
} | } | ||||
'id_delivery_note' => 'Bon de livraison', | 'id_delivery_note' => 'Bon de livraison', | ||||
'reference' => 'Référence', | 'reference' => 'Référence', | ||||
'delivery_home' => 'Livraison à domicile', | 'delivery_home' => 'Livraison à domicile', | ||||
'delivery_address' => 'Adresse de livraison' | |||||
'delivery_address' => 'Adresse de livraison', | |||||
'online_payment_url' => 'URL de paiement' | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m210920_060127_add_field_order_online_payment_url | |||||
*/ | |||||
class m210920_060127_add_field_order_online_payment_url extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('order', 'online_payment_url', Schema::TYPE_STRING); | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'online_payment_url'); | |||||
} | |||||
} |
); | ); | ||||
} | } | ||||
} | } | ||||
// envoi d'un email de confirmation | |||||
$user = User::findOne($paymentIntentMetadata->user_id); | |||||
$userProducer = UserProducer::find() | |||||
->where([ | |||||
'id_user' => $idUser, | |||||
'id_producer' => $idProducer | |||||
]) | |||||
->one(); | |||||
$paramsEmail = [ | |||||
'from_email' => $producer->getEmailOpendistrib(), | |||||
'from_name' => $producer->name, | |||||
'to_email' => $user->email, | |||||
'to_name' => $user->getUsername(), | |||||
'subject' => '['.$producer->name.'] Alimentation de votre crédit', | |||||
'content_view_text' => '@common/mail/creditConfirm-text.php', | |||||
'content_view_html' => '@common/mail/creditConfirm-html.php', | |||||
'content_params' => [ | |||||
'user' => $user, | |||||
'userProducer' => $userProducer, | |||||
'producer' => $producer, | |||||
'amount' => $amount, | |||||
] | |||||
] ; | |||||
Mailjet::sendMail($paramsEmail); | |||||
else { | |||||
// envoi d'un email de confirmation | |||||
$user = User::findOne($paymentIntentMetadata->user_id); | |||||
$userProducer = UserProducer::find() | |||||
->where([ | |||||
'id_user' => $idUser, | |||||
'id_producer' => $idProducer | |||||
]) | |||||
->one(); | |||||
$paramsEmail = [ | |||||
'from_email' => $producer->getEmailOpendistrib(), | |||||
'from_name' => $producer->name, | |||||
'to_email' => $user->email, | |||||
'to_name' => $user->getUsername(), | |||||
'subject' => '['.$producer->name.'] Alimentation de votre crédit', | |||||
'content_view_text' => '@common/mail/creditConfirm-text.php', | |||||
'content_view_html' => '@common/mail/creditConfirm-html.php', | |||||
'content_params' => [ | |||||
'user' => $user, | |||||
'userProducer' => $userProducer, | |||||
'producer' => $producer, | |||||
'amount' => $amount, | |||||
] | |||||
] ; | |||||
Mailjet::sendMail($paramsEmail); | |||||
} | |||||
break; | break; | ||||
), | ), | ||||
]); | ]); | ||||
$redirect = $checkout_session->url; | $redirect = $checkout_session->url; | ||||
$order->online_payment_url = $redirect; | |||||
$order->save(); | |||||
} | } | ||||
} | } | ||||
return $pointsSaleArray; | return $pointsSaleArray; | ||||
} | } | ||||
public function actionConfirm($idOrder) | |||||
public function actionConfirm($idOrder, $returnPayment = '') | |||||
{ | { | ||||
$order = Order::searchOne(['id' => $idOrder]); | $order = Order::searchOne(['id' => $idOrder]); | ||||
$producer = $this->getProducer(); | $producer = $this->getProducer(); | ||||
} | } | ||||
return $this->render('confirm', [ | return $this->render('confirm', [ | ||||
'order' => $order | |||||
'order' => $order, | |||||
'returnPayment' => $returnPayment | |||||
]); | ]); | ||||
} | } | ||||
<div id="order-success"> | <div id="order-success"> | ||||
<?php if($returnPayment != 'success'): ?> | |||||
<div class="alert alert-danger"> | |||||
Le paiement en ligne a échoué.<br /> | |||||
<strong>Attention</strong>, votre commande sera effective à la réception du paiement. | |||||
</div> | |||||
<?php endif; ?> | |||||
<div class="alert alert-success"> | <div class="alert alert-success"> | ||||
<span class="glyphicon glyphicon-ok glyphicon-big"></span> | <span class="glyphicon glyphicon-ok glyphicon-big"></span> | ||||
<div class="content"> | <div class="content"> |