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.

OrderObserver.php 745B

12345678910111213141516171819202122232425262728
  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\Wrapper\PaymentManager;
  6. use common\logic\User\User\Wrapper\UserManager;
  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 = PaymentManager::getInstance();
  20. $userManager = UserManager::getInstance();
  21. $paymentManager->refundOrderCredit($order, $userManager->getCurrent());
  22. }
  23. }