コード例 #1
0
 public function notify(RequestVerifiedEvent $event)
 {
     $payment = $event->getPayment();
     $status = $event->getStatus()->getValue();
     switch ($status) {
         case GetHumanStatus::STATUS_AUTHORIZED:
         case GetHumanStatus::STATUS_CAPTURED:
         case GetHumanStatus::STATUS_REFUNDED:
             $this->repository->clearCart();
             $type = 'success';
             break;
         case GetHumanStatus::STATUS_CANCELED:
         case GetHumanStatus::STATUS_EXPIRED:
         case GetHumanStatus::STATUS_FAILED:
             $type = 'danger';
             break;
         case GetHumanStatus::STATUS_PENDING:
         case GetHumanStatus::STATUS_SUSPENDED:
             $this->repository->clearCart();
             $type = 'warning';
             break;
         case GetHumanStatus::STATUS_NEW:
         case GetHumanStatus::STATUS_UNKNOWN:
             $this->repository->clearCart();
             $type = 'info';
             break;
         default:
             throw new \RuntimeException('Unknown status ' . $status);
     }
     $formatter = new \NumberFormatter($this->translator->getLocale(), \NumberFormatter::CURRENCY);
     $this->session->getFlashBag()->add($type, $this->translator->trans('flash.payment.' . $type, ['%status%' => $this->translator->trans('meta.status.' . $status), '%amount%' => $formatter->formatCurrency($payment->getTotalAmount() / 100, $payment->getCurrencyCode())]));
 }
コード例 #2
0
 public function notify(RequestVerifiedEvent $event)
 {
     $payment = $event->getPayment();
     $status = $event->getStatus()->getValue();
     if (in_array($status, [GetHumanStatus::STATUS_AUTHORIZED, GetHumanStatus::STATUS_CAPTURED, GetHumanStatus::STATUS_REFUNDED])) {
         $order = $this->orderRepository->findByIdentity(new UuidIdentity($payment->getNumber()));
         $order->markAsPaid();
         $this->orderRepository->save($order);
     }
 }
コード例 #3
0
 public function notify(RequestVerifiedEvent $event)
 {
     $order = $this->repository->getById($event->getPayment()->getNumber());
     $message = \Swift_Message::newInstance($this->translator->trans('message.email_subject'), $this->engine->render(':order:email.html.twig', ['order' => $order]), 'html/text', 'utf-8');
     $this->mailer->send($message);
 }