public function testCreateSearchByCartIdRequest() { $factory = new Factory(); $request = $factory->createSearchByCartIdRequest(new ClientStub(), 'cardid', 'merchantId', 'searchKey'); $authString = base64_encode('merchantId:searchKey'); $this->assertEquals('GET', $request->getMethod()); $this->assertEquals('https://secure.innovatepayments.com/tools/api/xml/transaction/cardid/cart', $request->getUrl()); $this->assertEquals('Basic ' . $authString, (string) $request->getHeaders()->getAll()['authorization']); }
/** * Constructor * * @param string $storeId * @param string $key * @param \Namshi\Innovate\Payment\Transaction $transaction * @param string $baseUrl * @param array $config */ public function __construct($storeId, $merchantId, $key, $searchKey, $baseUrl = '', $config = null) { parent::__construct($baseUrl, $config); $this->setStoreId($storeId); $this->setMerchantId($merchantId); $this->setSearchKey($searchKey); $this->setKey($key); $this->setRequestFactory(RequestFactory::getInstance()); }
/** * Authorize innovate remote request. * * @param \SimpleXMLElement $mpiData * @return array|\Guzzle\Http\Message\Response|null * @throws Exception\AuthFailed */ protected function authorizeRemoteRequest($mpiData) { $request = $this->requestFactory->createRemoteRequest($this->guzzleClient, 'POST', self::INNOVATE_URL, null, $this->getStoreId(), $this->getKey(), $this->getTransaction(), $this->getCard(), $this->getBillingInformation(), $this->getBrowser(), $mpiData); $response = $this->guzzleClient->send($request); if (!$response || !isset($response) || !$response->xml() instanceof \SimpleXMLElement) { return new Response('Authentication Failed', self::RESPONSE_ERROR_STATUS); } if (!in_array($response->xml()->auth->status, $this->successfulPaymentStatusCodes)) { return new Response($response->getBody(), self::RESPONSE_ERROR_STATUS, $response->getHeaders()->toArray()); } return new Response($response->getBody(), $response->getStatusCode(), $response->getHeaders()->toArray()); }