예제 #1
0
 public function testCreateMpiRequest()
 {
     $factory = new Factory();
     $request = $factory->createMpiRequest(new ClientStub(), 'POST', Client::INNOVATE_MPI_URL, null, 'EXAMPLE_STORE', 'xyz', new PaymentTransaction('sale', 'ecom', true, 'ORDER_NUMBER', 'DESCRIPTION', 'USD', 40), new PaymentCard('4000000000000002', '123', new \DateTime('2025-5')), new PaymentBillingInformation(new Customer('Forenames', 'Surname', 'Mr'), new Address('STREET_ADDRESS_LINE_1', 'STREET_ADDRESS_LINE_2', 'STREET_ADDRESS_LINE_3', 'CITY', 'REGION', 'COUNTRY', '12345'), '*****@*****.**', '192.168.0.1'));
     $xml = new \SimpleXMLElement($request->getBody());
     $this->assertEquals('xyz', (string) $xml->key);
     $this->assertEquals('sale', (string) $xml->tran->type);
     $this->assertEquals('USD', (string) $xml->tran->currency);
     $this->assertEquals('4000000000000002', (string) $xml->card->number);
     $this->assertEquals('123', (string) $xml->card->cvv);
     $this->assertEquals('05', (string) $xml->card->expiry->month);
     $this->assertEquals('2025', (string) $xml->card->expiry->year);
     $this->assertEquals('Forenames', (string) $xml->billing->name->first);
     $this->assertEquals('Surname', (string) $xml->billing->name->last);
     $this->assertEquals('Mr', (string) $xml->billing->name->title);
     $this->assertEquals('STREET_ADDRESS_LINE_1', (string) $xml->billing->address->line1);
     $this->assertEquals('STREET_ADDRESS_LINE_2', (string) $xml->billing->address->line2);
     $this->assertEquals('STREET_ADDRESS_LINE_3', (string) $xml->billing->address->line3);
     $this->assertEquals('CITY', (string) $xml->billing->address->city);
     $this->assertEquals('REGION', (string) $xml->billing->address->region);
     $this->assertEquals('COUNTRY', (string) $xml->billing->address->country);
     $this->assertEquals('12345', (string) $xml->billing->address->zip);
     $this->assertEquals('*****@*****.**', (string) $xml->billing->email);
     $this->assertEquals('192.168.0.1', (string) $xml->billing->ip);
 }
예제 #2
0
파일: Client.php 프로젝트: namshi/innovate
 /**
  * Authorize mpi request by sending request to innovate api to do mpi authentication.
  *
  * @return array|\Guzzle\Http\Message\Response|null
  * @throws Exception\AuthFailed
  */
 protected function authorizeMpiRequest()
 {
     $request = $this->requestFactory->createMpiRequest($this->guzzleClient, 'POST', self::INNOVATE_MPI_URL, null, $this->getStoreId(), $this->getKey(), $this->getTransaction(), $this->getCard(), $this->getBillingInformation());
     $response = $this->guzzleClient->send($request);
     if (empty($response)) {
         throw new AuthFailed("Innovate authorization request timeout");
     }
     if (!$response->xml() instanceof \SimpleXMLElement) {
         throw new AuthFailed("Invalid Innovate authorization request");
     }
     if (!empty((string) $response->xml()->error)) {
         throw new AuthFailed((string) $response->getBody());
     }
     return $response;
 }