/** * {inheritdoc} */ public function placeRequest(TransferInterface $transferObject) { $log = ['request' => $transferObject->getBody(), 'request_uri' => $transferObject->getUri()]; $result = []; /** @var ZendClient $client */ $client = $this->clientFactory->create(); $client->setConfig($transferObject->getClientConfig()); $client->setMethod($transferObject->getMethod()); switch ($transferObject->getMethod()) { case \Zend_Http_Client::GET: $client->setParameterGet($transferObject->getBody()); break; case \Zend_Http_Client::POST: $client->setParameterPost($transferObject->getBody()); break; default: throw new \LogicException(sprintf('Unsupported HTTP method %s', $transferObject->getMethod())); } $client->setHeaders($transferObject->getHeaders()); $client->setUrlEncodeBody($transferObject->shouldEncode()); $client->setUri($transferObject->getUri()); try { $response = $client->request(); $result = $this->converter ? $this->converter->convert($response->getBody()) : [$response->getBody()]; $log['response'] = $result; } catch (\Zend_Http_Client_Exception $e) { throw new \Magento\Payment\Gateway\Http\ClientException(__($e->getMessage())); } catch (\Magento\Payment\Gateway\Http\ConverterException $e) { throw $e; } finally { $this->logger->debug($log); } return $result; }
/** * Places request to gateway. Returns result as ENV array * * @param TransferInterface $transferObject * @return array * @throws \Magento\Payment\Gateway\Http\ClientException * @throws \Magento\Payment\Gateway\Http\ConverterException * @throws \Exception */ public function placeRequest(TransferInterface $transferObject) { $this->logger->debug(['request' => $transferObject->getBody()]); $client = $this->clientFactory->create($transferObject->getClientConfig()['wsdl'], ['trace' => true]); try { $client->__setSoapHeaders($transferObject->getHeaders()); $response = $client->__soapCall($transferObject->getMethod(), [$transferObject->getBody()]); $result = $this->converter ? $this->converter->convert($response) : [$response]; $this->logger->debug(['response' => $result]); } catch (\Exception $e) { $this->logger->debug(['trace' => $client->__getLastRequest()]); throw $e; } return $result; }
/** * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @return mixed * @throws ClientException */ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) { $request = $transferObject->getBody(); // call lib $service = new \Adyen\Service\Payment($this->_client); try { $response = $service->authorise($request); } catch (\Adyen\AdyenException $e) { $response['error'] = $e->getMessage(); } return $response; }
/** * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @return null */ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) { $request = $transferObject->getBody(); // call lib $service = new \Adyen\Service\Modification($this->_client); try { $response = $service->cancelOrRefund($request); } catch (\Adyen\AdyenException $e) { $response = null; } return $response; }
/** * @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject * @return null */ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) { $requests = $transferObject->getBody(); $responses = []; foreach ($requests as $request) { // call lib $service = new \Adyen\Service\Modification($this->_client); try { $responses[] = $service->refund($request); } catch (\Adyen\AdyenException $e) { $responses[] = null; } } return $responses; }
/** * @inheritdoc */ public function placeRequest(TransferInterface $transferObject) { $data = $transferObject->getBody(); $log = ['request' => $data, 'client' => static::class]; $response['object'] = []; try { $response['object'] = $this->process($data); } catch (\Exception $e) { $message = __($e->getMessage() ?: 'Sorry, but something went wrong'); $this->logger->critical($message); throw new ClientException($message); } finally { $log['response'] = (array) $response['object']; $this->customLogger->debug($log); } return $response; }