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(); } }
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:'); }
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); }
public function getPaymentType() { return PaymentType::createFromValue($this->paymentType); }