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']); }
/** * Given a cart id reference will search for transactions for that cart id on innovate * * @param $ref * @return \SimpleXMLElement * @throws InnovateException */ public function searchTransactionsByCartId($cartId) { $request = $this->requestFactory->createSearchByCartIdRequest($this->guzzleClient, $cartId, $this->merchantId, $this->searchKey); $response = $this->guzzleClient->send($request); if (!$response instanceof \Guzzle\Http\Message\Response) { throw new InnovateException('Error while connecting to innovate. Transactions for ' . $cartId . ' could not be fetched.'); } $xml = $response->xml(); if ($xml->trancount <= 0) { throw new InnovateException("No transaction found for {$cartId}"); } return $xml; }