Skip to content

Commit 197299f

Browse files
author
Maksim Rafalko
committed
added supporting of createCard() method
1 parent e4ca2d5 commit 197299f

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

src/Omnipay/NetBanx/Gateway.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class Gateway extends AbstractGateway
2020
{
2121
const DECISION_ACCEPTED = 'ACCEPTED';
22+
const CREATE_CARD_AMOUNT = 100;
2223
const CODE_OK = '0';
2324

2425
/**
@@ -90,6 +91,18 @@ public function void(array $parameters = array())
9091
return $this->createRequest('\Omnipay\NetBanx\Message\VoidRequest', $parameters);
9192
}
9293

94+
/**
95+
* Create card
96+
*
97+
* @param array $parameters
98+
* @return mixed
99+
*/
100+
public function createCard(array $parameters = array())
101+
{
102+
$parameters['amount'] = self::CREATE_CARD_AMOUNT;
103+
return $this->createRequest('\Omnipay\NetBanx\Message\AuthorizeRequest', $parameters);
104+
}
105+
93106
/**
94107
* Setter for Account Number
95108
*

src/Omnipay/NetBanx/Message/Response.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ public function getTransactionReference()
6262
return (string) $this->data->confirmationNumber;
6363
}
6464

65+
/**
66+
* Get card reference
67+
*
68+
* @return string
69+
*/
70+
public function getCardReference()
71+
{
72+
return (string) $this->data->confirmationNumber;
73+
}
74+
6575
/**
6676
* Get message from responce
6777
*

tests/Omnipay/NetBanx/GatewayTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,35 @@ public function testVoidFailure()
301301
$this->assertSame('12345678', $response->getTransactionReference());
302302
$this->assertSame('The confirmation number included in this request could not be found.', $response->getMessage());
303303
}
304+
305+
public function testCreateCard()
306+
{
307+
$this->setMockHttpResponse('CreateCard.txt');
308+
309+
$request = $this->gateway->createCard($this->purchaseOptions);
310+
$requestData = $request->getData();
311+
/** @var $card CreditCard */
312+
$card = $request->getCard();
313+
314+
$response = $request->send();
315+
316+
$sxml = new \SimpleXMLElement($requestData['txnRequest']);
317+
318+
$this->assertSame('ccAuthorize', $requestData['txnMode']);
319+
320+
$this->assertSame('93401', (string) $sxml->billingDetails->zip);
321+
$this->assertSame('VI', (string) $sxml->card->cardType);
322+
323+
$this->assertTrue(isset($sxml->billingDetails));
324+
$this->assertTrue(isset($sxml->shippingDetails));
325+
326+
$this->assertSame('1.00', (string) $sxml->amount);
327+
$this->assertSame('9966441', (string) $sxml->merchantRefNum);
328+
$this->assertSame('93401', $card->getPostcode());
329+
$this->assertSame('[email protected]', $card->getEmail());
330+
331+
$this->assertTrue($response->isSuccessful());
332+
$this->assertSame('244350540', $response->getCardReference());
333+
$this->assertSame('No Error', $response->getMessage());
334+
}
304335
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
HTTP/1.1 200 OK
2+
Connection: close
3+
Date: Sat, 16 Feb 2013 04:22:58 GMT
4+
Server: Microsoft-IIS/6.0
5+
X-Powered-By: ASP.NET
6+
Content-Type: text/html
7+
Content-Length: 638
8+
Cache-Control: private, must-revalidate, max-age=0
9+
Expires: Tue, 01 Jan 1980 00:00:00 GMT
10+
11+
<ccTxnResponseV1 xmlns="http://www.optimalpayments.com/creditcard/xmlschema/v1">
12+
<confirmationNumber>244350540</confirmationNumber>
13+
<decision>ACCEPTED</decision>
14+
<code>0</code>
15+
<description>No Error</description>
16+
<authCode>245904</authCode>
17+
<avsResponse>X</avsResponse>
18+
<detail>
19+
<tag>InternalResponseCode</tag>
20+
<value>0</value>
21+
</detail>
22+
<detail>
23+
<tag>SubErrorCode</tag>
24+
<value>0</value>
25+
</detail>
26+
<detail>
27+
<tag>InternalResponseDescription</tag>
28+
<value>no_error</value>
29+
</detail>
30+
<txnTime>2013-04-17T06:27:04.373-04:00</txnTime>
31+
<duplicateFound>false</duplicateFound>
32+
</ccTxnResponseV1>

0 commit comments

Comments
 (0)