/** * {@inheritDoc} */ public function getGateway($name) { /** @var GatewayConfigInterface[] $configs */ if ($configs = $this->gatewayConfigStore->findBy(array('gateway_name' => $name))) { $config = array_shift($configs); $factory = $this->getGatewayFactory($config->getFactoryName()); return $factory->create($config->getParameters()->toArray()); } return $this->staticRegistry->getGateway($name); }
/** * {@inheritDoc} */ public function getPayment($name) { /** @var PaymentConfigInterface $config */ if ($config = $this->paymentConfigStore->findBy(array('paymentName' => $name))) { $factory = $this->getPaymentFactory($config->getFactoryName()); return $factory->create($config->getConfig()); } return $this->staticRegistry->getPayment($name); }
/** * {@inheritDoc} * * @param $request Notify */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $this->gateway->execute($httpRequest = new GetHttpRequest()); if (empty($httpRequest->query['ORDERID'])) { throw new HttpResponse('The notification is invalid. Code 3', 400); } $payment = $this->paymentStorage->findBy([$this->idField => $httpRequest->query['ORDERID']]); if (null === $payment) { throw new HttpResponse('The notification is invalid. Code 4', 400); } $this->gateway->execute(new Notify($payment)); }
/** * @param string $name * * @return GatewayConfigInterface */ protected function findGatewayConfigByName($name) { if (false == $name) { throw new NotFoundHttpException(sprintf('Config name is empty.', $name)); } /** @var GatewayConfigInterface $gatewayConfigs */ $gatewayConfigs = $this->gatewayConfigStorage->findBy(['gatewayName' => $name]); if (empty($gatewayConfigs)) { throw new NotFoundHttpException(sprintf('Config with name %s was not found.', $name)); } return array_shift($gatewayConfigs); }
/** * {@inheritDoc} */ public function getGateways() { // @deprecated It will return empty array here if ($this->backwardCompatibility && $this->gatewayFactoryRegistry instanceof RegistryInterface) { return $this->gatewayFactoryRegistry->getGateways(); } $gateways = []; foreach ($this->gatewayConfigStore->findBy([]) as $gatewayConfig) { /** @var GatewayConfigInterface $gatewayConfig */ $gateways[$gatewayConfig->getGatewayName()] = $this->getGateway($gatewayConfig->getGatewayName()); } return $gateways; }