コード例 #1
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);
     }
 }
コード例 #2
0
ファイル: OrderService.php プロジェクト: igaponov/shop
 public function createOrder(CreateOrderCommand $command)
 {
     $cart = $this->cartRepository->getCart();
     if ($cart->getLineItems()->count() === 0) {
         throw new \RuntimeException("The cart is empty");
     }
     $address = $command->getAddress();
     $order = new Order(new UuidIdentity(Uuid::uuid4()), $this->tokenStorage->getToken()->getUser(), new Address($address->getCountry(), $address->getCity(), $address->getStreet(), $address->getZipCode()));
     foreach ($cart->getLineItems() as $lineItem) {
         $order->addProduct($lineItem->getProduct(), $lineItem->getQuantity());
     }
     $this->orderRepository->save($order);
     $event = new OrderCreatedEvent($order, $command->getGatewayName());
     $this->eventBus->handle($event);
 }