Skip to content

Commit 74c9eba

Browse files
committed
Merge pull request #46 from mrafalko/master
added NetBanx Payment Gateway with unit tests
2 parents d28afd0 + b7abb39 commit 74c9eba

17 files changed

+1131
-1
lines changed

src/Omnipay/AuthorizeNet/Message/AIMVoidRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Omnipay\AuthorizeNet\Message;
1313

1414
/**
15-
* Authorize.Net AIM Authorize Request
15+
* Authorize.Net AIM Void Request
1616
*/
1717
class AIMVoidRequest extends AbstractRequest
1818
{

src/Omnipay/NetBanx/Gateway.php

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Omnipay package.
5+
*
6+
* (c) Adrian Macneil <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Omnipay\NetBanx;
13+
14+
use Omnipay\Common\AbstractGateway;
15+
16+
/**
17+
* NetBanx Class
18+
*/
19+
class Gateway extends AbstractGateway
20+
{
21+
const DECISION_ACCEPTED = 'ACCEPTED';
22+
const CODE_OK = '0';
23+
24+
/**
25+
* Get name of the gateway
26+
*
27+
* @return string
28+
*/
29+
public function getName()
30+
{
31+
return 'NetBanx Gateway';
32+
}
33+
34+
/**
35+
* Get default parameters
36+
*
37+
* @return array
38+
*/
39+
public function getDefaultParameters()
40+
{
41+
return array(
42+
'accountNumber' => '',
43+
'storeId' => '',
44+
'storePassword' => '',
45+
'testMode' => false,
46+
);
47+
}
48+
49+
/**
50+
* Authorize a new amount
51+
*
52+
* @param array $parameters
53+
* @return mixed
54+
*/
55+
public function authorize(array $parameters = array())
56+
{
57+
return $this->createRequest('\Omnipay\NetBanx\Message\AuthorizeRequest', $parameters);
58+
}
59+
60+
/**
61+
* Capture authorized amount
62+
*
63+
* @param array $parameters An array of options
64+
* @return \Omnipay\ResponseInterface
65+
*/
66+
public function capture(array $parameters = array())
67+
{
68+
return $this->createRequest('\Omnipay\NetBanx\Message\CaptureRequest', $parameters);
69+
}
70+
71+
/**
72+
* Create a new charge (combined authorize + capture).
73+
*
74+
* @param array An array of options
75+
* @return \Omnipay\ResponseInterface
76+
*/
77+
public function purchase(array $parameters = array())
78+
{
79+
return $this->createRequest('\Omnipay\NetBanx\Message\PurchaseRequest', $parameters);
80+
}
81+
82+
/**
83+
* Void transaction
84+
*
85+
* @param array $parameters An array of options
86+
* @return \Omnipay\ResponseInterface
87+
*/
88+
public function void(array $parameters = array())
89+
{
90+
return $this->createRequest('\Omnipay\NetBanx\Message\VoidRequest', $parameters);
91+
}
92+
93+
/**
94+
* Setter for Account Number
95+
*
96+
* @param string $value
97+
* @return $this
98+
*/
99+
public function setAccountNumber($value)
100+
{
101+
return $this->setParameter('accountNumber', $value);
102+
}
103+
104+
/**
105+
* Getter for Account Number
106+
*
107+
* @return string
108+
*/
109+
public function getAccountNumber()
110+
{
111+
return $this->getParameter('accountNumber');
112+
}
113+
114+
/**
115+
* Setter for Store ID
116+
*
117+
* @param string $value
118+
* @return $this
119+
*/
120+
public function setStoreId($value)
121+
{
122+
return $this->setParameter('storeId', $value);
123+
}
124+
125+
/**
126+
* Getter for Store ID
127+
*
128+
* @return string
129+
*/
130+
public function getStoreId()
131+
{
132+
return $this->getParameter('storeId');
133+
}
134+
135+
/**
136+
* Setter for Store Password
137+
*
138+
* @param string $value
139+
* @return $this
140+
*/
141+
public function setStorePassword($value)
142+
{
143+
return $this->setParameter('storePassword', $value);
144+
}
145+
146+
/**
147+
* Getter for Store Password
148+
*
149+
* @return string
150+
*/
151+
public function getStorePassword()
152+
{
153+
return $this->getParameter('storePassword');
154+
}
155+
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Omnipay package.
5+
*
6+
* (c) Adrian Macneil <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Omnipay\NetBanx\Message;
13+
14+
/**
15+
* NetBanx Abstract Request
16+
*/
17+
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
18+
{
19+
/**
20+
* Live EndPoint
21+
*
22+
* @var string
23+
*/
24+
protected $liveEndpoint = 'https://webservices.optimalpayments.com/creditcardWS/CreditCardServlet/v1';
25+
26+
/**
27+
* Developer EndPoint
28+
*
29+
* @var string
30+
*/
31+
protected $developerEndpoint = 'https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1';
32+
33+
/**
34+
* Setter for Account Number
35+
*
36+
* @param string $value
37+
* @return $this
38+
*/
39+
public function setAccountNumber($value)
40+
{
41+
return $this->setParameter('accountNumber', $value);
42+
}
43+
44+
/**
45+
* Getter for Account Number
46+
*
47+
* @return string
48+
*/
49+
public function getAccountNumber()
50+
{
51+
return $this->getParameter('accountNumber');
52+
}
53+
54+
/**
55+
* Setter for Store ID
56+
*
57+
* @param string $value
58+
* @return $this
59+
*/
60+
public function setStoreId($value)
61+
{
62+
return $this->setParameter('storeId', $value);
63+
}
64+
65+
/**
66+
* Getter for Store ID
67+
*
68+
* @return string
69+
*/
70+
public function getStoreId()
71+
{
72+
return $this->getParameter('storeId');
73+
}
74+
75+
/**
76+
* Setter for Store Password
77+
*
78+
* @param string $value
79+
* @return $this
80+
*/
81+
public function setStorePassword($value)
82+
{
83+
return $this->setParameter('storePassword', $value);
84+
}
85+
86+
/**
87+
* Getter for Store Password
88+
*
89+
* @return string
90+
*/
91+
public function getStorePassword()
92+
{
93+
return $this->getParameter('storePassword');
94+
}
95+
96+
/**
97+
* Getter for customer ID
98+
*
99+
* @return string
100+
*/
101+
public function getCustomerId()
102+
{
103+
return $this->getParameter('customerId');
104+
}
105+
106+
/**
107+
* Setter for customr ID
108+
*
109+
* @param string $value
110+
* @return $this
111+
*/
112+
public function setCustomerId($value)
113+
{
114+
return $this->setParameter('customerId', $value);
115+
}
116+
117+
/**
118+
* Send request
119+
*
120+
* @return \Omnipay\Common\Message\ResponseInterface|void
121+
*/
122+
public function send()
123+
{
124+
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $this->getData())->send();
125+
126+
return $this->response = new Response($this, $httpResponse->getBody());
127+
}
128+
129+
/**
130+
* Get End Point
131+
*
132+
* Depends on Test or Live environment
133+
*
134+
* @return string
135+
*/
136+
public function getEndpoint()
137+
{
138+
return $this->getTestMode() ? $this->developerEndpoint : $this->liveEndpoint;
139+
}
140+
141+
/**
142+
* Get base data
143+
*
144+
* @return array
145+
*/
146+
protected function getBaseData()
147+
{
148+
$data = array();
149+
$data['txnMode'] = $this->txnMode;
150+
151+
return $data;
152+
}
153+
}

0 commit comments

Comments
 (0)