Пример #1
0
 public function isPaymentTypeAvailable(PaymentType $paymentType)
 {
     switch ($paymentType->getValue()) {
         case PaymentType::CASH:
             return $this->cashPaymentAvailable;
         case PaymentType::BANK:
             return $this->bankPaymentAvailable;
         case PaymentType::CARD:
             return $this->cardPaymentAvailable;
         default:
             throw new \LogicException();
     }
 }
Пример #2
0
 private function createOrder(PaymentForm $form)
 {
     $values = $form->getValues();
     $this->orderService->createFromCart($this->currentCartService->getCurrentCart(), PaymentType::createFromValue($values->paymentType));
     $this->currentCartService->resetCurrentCart();
     $this->redirect(':Front:Order:Order:');
 }
Пример #3
0
 private function addTypeControl()
 {
     $paymentItems = [];
     foreach (PaymentType::getValues() as $paymentType) {
         $paymentType = PaymentType::createFromValue($paymentType);
         if ($this->orderService->isPaymentTypeAvailable($paymentType)) {
             $paymentItems[$paymentType->getValue()] = $paymentType->getLabel();
         }
     }
     if (count($paymentItems) === 0) {
         throw new \Exception('No payment type available');
     }
     $this->addRadioList('paymentType', 'Payment', $paymentItems)->setRequired('Please choose payment type.')->setDefaultValue(PaymentType::CASH);
 }
Пример #4
0
 public function getPaymentType()
 {
     return PaymentType::createFromValue($this->paymentType);
 }