You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
737B

  1. <?php
  2. namespace common\logic\Payment\Event;
  3. use common\logic\Order\Order\Event\OrderDeleteEvent;
  4. use common\logic\Order\Order\Model\Order;
  5. use common\logic\Payment\Module\PaymentModule;
  6. use common\logic\User\User\Module\UserModule;
  7. use justcoded\yii2\eventlistener\observers\Observer;
  8. class OrderObserver extends Observer
  9. {
  10. public function events()
  11. {
  12. return [
  13. Order::EVENT_DELETE => 'onOrderDelete'
  14. ];
  15. }
  16. public function onOrderDelete(OrderDeleteEvent $event)
  17. {
  18. $order = $event->order;
  19. $paymentManager = PaymentModule::getInstance();
  20. $userModule = UserModule::getInstance();
  21. $paymentManager->refundOrderCredit($order, $userModule->getCurrent());
  22. }
  23. }