Exemplo n.º 1
0
 public function testTokenize()
 {
     $factory = new Factory();
     $response = $factory->createTokenizeRequest(new ClientStub(), 'EXAMPLE_STORE', 'xyz', new Card('4000000000000002', new \DateTime('2025-5')), new BillingInformation(new Customer('Forenames', 'Surname', 'Mr'), new Address('STREET_ADDRESS_LINE_1', 'STREET_ADDRESS_LINE_2', 'STREET_ADDRESS_LINE_3', 'CITY', 'REGION', 'COUNTRY', '12345'), '*****@*****.**'));
     $xml = new \SimpleXMLElement($response->getBody());
     $this->assertEquals('EXAMPLE_STORE', (string) $xml->store);
     $this->assertEquals('xyz', (string) $xml->key);
     $this->assertEquals('4000000000000002', (string) $xml->card->number);
     $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('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);
 }
Exemplo n.º 2
0
 /**
  * Make a request ro the tokenize api endpoint.
  *
  * @param  TokenizedCard        $card
  * @param  TokenizedBillingInfo $billing
  * @return Guzzle\Http\Message\Response
  */
 public function tokenize(TokenizedCard $card, TokenizedBillingInfo $billing)
 {
     $request = $this->requestFactory->createTokenizeRequest($this->guzzleClient, $this->getStoreId(), $this->getKey(), $card, $billing);
     return $this->guzzleClient->send($request);
 }