/** * @Given the store allows paying :paymentMethodName * @Given the store allows paying with :paymentMethodName */ public function storeAllowsPaying($paymentMethodName) { $paymentMethod = $this->paymentMethodFactory->createNew(); $paymentMethod->setCode('PM_' . $paymentMethodName); $paymentMethod->setName(ucfirst($paymentMethodName)); $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($paymentMethodName)); $paymentMethod->setDescription('Payment method'); $channel = $this->sharedStorage->get('channel'); $channel->addPaymentMethod($paymentMethod); $this->paymentMethodRepository->add($paymentMethod); }
/** * @param string $name * @param string $code * @param bool $addForCurrentChannel * @param string $description */ private function createPaymentMethodFromNameAndCode($name, $code, $description = '', $addForCurrentChannel = true) { /** @var PaymentMethodInterface $paymentMethod */ $paymentMethod = $this->paymentMethodFactory->createNew(); $paymentMethod->setName(ucfirst($name)); $paymentMethod->setCode($code); $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($name)); $paymentMethod->setDescription($description); if ($addForCurrentChannel && $this->sharedStorage->has('channel')) { $channel = $this->sharedStorage->get('channel'); $channel->addPaymentMethod($paymentMethod); } $this->sharedStorage->set('payment_method', $paymentMethod); $this->paymentMethodRepository->add($paymentMethod); }
/** * @Given the store has a payment method :paymentMethodName with a code :paymentMethodCode */ public function theStoreHasAPaymentMethodWithACode($paymentMethodName, $paymentMethodCode) { $paymentMethod = $this->createPaymentMethodFromNameAndCode($paymentMethodName, $paymentMethodCode); $this->sharedStorage->set('payment_method', $paymentMethod); $this->paymentMethodRepository->add($paymentMethod); }