Skip to content

Commit 3684bbb

Browse files
authored
Merge pull request #6 from pixelandtonic/dev-hostedpayments
Addded docblocks to Hosted Payment Gateway
2 parents a53d3ae + 55c92d3 commit 3684bbb

11 files changed

+167
-0
lines changed

src/HostedGateway.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010
*/
1111
class HostedGateway extends AbstractGateway
1212
{
13+
/**
14+
* @return string
15+
*/
1316
public function getName()
1417
{
1518
return 'NetBanx Hosted Payments';
1619
}
1720

21+
/**
22+
* @return array
23+
*/
1824
public function getDefaultParameters()
1925
{
2026
return array(
@@ -24,51 +30,97 @@ public function getDefaultParameters()
2430
);
2531
}
2632

33+
/**
34+
* @param array $parameters
35+
*
36+
* @return \Omnipay\NetBanx\Message\HostedAuthorizeRequest
37+
*/
2738
public function authorize(array $parameters = array())
2839
{
2940
return $this->createRequest('\Omnipay\NetBanx\Message\HostedAuthorizeRequest', $parameters);
3041
}
3142

43+
/**
44+
* @param array $parameters
45+
*
46+
* @return \Omnipay\Common\Message\AbstractRequest
47+
*/
3248
public function purchase(array $parameters = array())
3349
{
3450
return $this->createRequest('\Omnipay\NetBanx\Message\HostedPurchaseRequest', $parameters);
3551
}
3652

53+
/**
54+
* @param array $parameters
55+
*
56+
* @return \Omnipay\NetBanx\Message\HostedCompleteAuthorizeRequest
57+
*/
3758
public function completeAuthorize(array $parameters = array())
3859
{
3960
return $this->createRequest('\Omnipay\NetBanx\Message\HostedCompleteAuthorizeRequest', $parameters);
4061
}
4162

63+
/**
64+
* @param array $parameters
65+
*
66+
* @return \Omnipay\NetBanx\Message\HostedCompletePurchaseRequest
67+
*/
4268
public function completePurchase(array $parameters = array())
4369
{
4470
return $this->createRequest('\Omnipay\NetBanx\Message\HostedCompletePurchaseRequest', $parameters);
4571
}
4672

73+
/**
74+
* @param array $parameters
75+
*
76+
* @return \Omnipay\NetBanx\Message\HostedCaptureRequest
77+
*/
4778
public function capture(array $parameters = array())
4879
{
4980
return $this->createRequest('\Omnipay\NetBanx\Message\HostedCaptureRequest', $parameters);
5081
}
5182

83+
/**
84+
* @param array $parameters
85+
*
86+
* @return \Omnipay\NetBanx\Message\HostedRefundRequest
87+
*/
5288
public function refund(array $parameters = array())
5389
{
5490
return $this->createRequest('\Omnipay\NetBanx\Message\HostedRefundRequest', $parameters);
5591
}
5692

93+
/**
94+
* @param $value
95+
*
96+
* @return $this
97+
*/
5798
public function setKeyId($value)
5899
{
59100
return $this->setParameter('keyId', $value);
60101
}
61102

103+
/**
104+
* @return mixed
105+
*/
62106
public function getKeyId()
63107
{
64108
return $this->getParameter('keyId');
65109
}
66110

111+
/**
112+
* @param $value
113+
*
114+
* @return $this
115+
*/
67116
public function setKeyPassword($value)
68117
{
69118
return $this->setParameter('keyPassword', $value);
70119
}
71120

121+
/**
122+
* @return mixed
123+
*/
72124
public function getKeyPassword()
73125
{
74126
return $this->getParameter('keyPassword');

src/Message/HostedAbstractRequest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,49 @@ abstract class HostedAbstractRequest extends \Omnipay\Common\Message\AbstractReq
99
protected $liveEndpoint = 'https://api.netbanx.com/hosted/v1';
1010
protected $testEndpoint = 'https://api.test.netbanx.com/hosted/v1';
1111

12+
/**
13+
* @param $value
14+
*
15+
* @return \Omnipay\Common\Message\AbstractRequest
16+
*/
1217
public function setKeyId($value)
1318
{
1419
return $this->setParameter('keyId', $value);
1520
}
1621

22+
/**
23+
* @return mixed
24+
*/
1725
public function getKeyId()
1826
{
1927
return $this->getParameter('keyId');
2028
}
2129

30+
/**
31+
* @param $value
32+
*
33+
* @return \Omnipay\Common\Message\AbstractRequest
34+
*/
2235
public function setKeyPassword($value)
2336
{
2437
return $this->setParameter('keyPassword', $value);
2538
}
2639

40+
/**
41+
* @return mixed
42+
*/
2743
public function getKeyPassword()
2844
{
2945
return $this->getParameter('keyPassword');
3046
}
3147

48+
/**
49+
* @param $action
50+
* @param null $data
51+
* @param string $method
52+
*
53+
* @return \Guzzle\Http\Message\Response
54+
*/
3255
public function sendRequest($action, $data = null, $method = RequestInterface::POST)
3356
{
3457
// don't throw exceptions for 4xx errors, need the data for error messages
@@ -60,11 +83,17 @@ function ($event) {
6083
return $this->httpClient->createRequest($method, $url, $headers, $data)->send();
6184
}
6285

86+
/**
87+
* @return string
88+
*/
6389
public function getEndpoint()
6490
{
6591
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
6692
}
6793

94+
/**
95+
* @return array
96+
*/
6897
protected function getBaseData()
6998
{
7099
$data = array();

src/Message/HostedAbstractResponse.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
abstract class HostedAbstractResponse extends \Omnipay\Common\Message\AbstractResponse
66
{
7+
/**
8+
* @return string
9+
*/
710
public function getRedirectMethod()
811
{
912
return 'GET';
1013
}
1114

15+
/**
16+
* @return bool
17+
*/
1218
public function isSuccessful()
1319
{
1420
$successful = (isset($this->data['transaction']['status'])
@@ -17,6 +23,9 @@ public function isSuccessful()
1723
return !$this->isRedirect() && !isset($this->data['error']) && $successful;
1824
}
1925

26+
/**
27+
* @return string|null
28+
*/
2029
public function getMessage()
2130
{
2231
$message = null;
@@ -36,6 +45,9 @@ public function getMessage()
3645
return $message;
3746
}
3847

48+
/**
49+
* @return string|null
50+
*/
3951
public function getCode()
4052
{
4153
$code = null;
@@ -51,6 +63,9 @@ public function getCode()
5163
return $code;
5264
}
5365

66+
/**
67+
* @return string|null
68+
*/
5469
public function getTransactionReference()
5570
{
5671
return isset($this->data['id']) ? $this->data['id'] : null;

src/Message/HostedAuthorizeRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
class HostedAuthorizeRequest extends HostedPurchaseRequest
66
{
77

8+
/**
9+
* @return array|mixed
10+
*/
811
public function getData()
912
{
1013
$data = parent::getData();

src/Message/HostedCaptureRequest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class HostedCaptureRequest extends HostedAbstractRequest
66
{
7+
/**
8+
* @return array
9+
*/
710
public function getData()
811
{
912
$this->validate('amount', 'transactionReference', 'transactionId');
@@ -16,6 +19,11 @@ public function getData()
1619
return $data;
1720
}
1821

22+
/**
23+
* @param mixed $data
24+
*
25+
* @return HostedCaptureResponse
26+
*/
1927
public function sendData($data)
2028
{
2129
$httpResponse = $this->sendRequest($this->getEndpointAction(), null, 'POST');

src/Message/HostedCaptureResponse.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44

55
class HostedCaptureResponse extends HostedAbstractResponse
66
{
7+
/**
8+
* @return bool
9+
*/
710
public function isSuccessful()
811
{
912
$successfulTransaction = (isset($this->data['authType']) && $this->data['authType'] == 'settlement');
1013

1114
return !$this->isRedirect() && !isset($this->data['error']) && $successfulTransaction;
1215
}
1316

17+
/**
18+
* @return bool
19+
*/
1420
public function isRedirect()
1521
{
1622
return false;
1723
}
1824

25+
/**
26+
* @return null
27+
*/
1928
public function getMessage()
2029
{
2130
$message = null;

src/Message/HostedCompletePurchaseRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class HostedCompletePurchaseRequest extends HostedAbstractRequest
66
{
7+
/**
8+
* @return array
9+
*/
710
public function getData()
811
{
912
$this->validate('transactionReference');
@@ -15,6 +18,11 @@ public function getData()
1518
return $data;
1619
}
1720

21+
/**
22+
* @param mixed $data
23+
*
24+
* @return HostedPurchaseResponse
25+
*/
1826
public function sendData($data)
1927
{
2028
$httpResponse = $this->sendRequest($this->getEndpointAction(), null, 'GET');
@@ -23,6 +31,9 @@ public function sendData($data)
2331
return $this->response = new HostedPurchaseResponse($this, $responseData);
2432
}
2533

34+
/**
35+
* @return string
36+
*/
2637
public function getEndpointAction()
2738
{
2839
return "/orders/".$this->getTransactionReference();

src/Message/HostedPurchaseRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class HostedPurchaseRequest extends HostedAbstractRequest
66
{
7+
/**
8+
* @return array
9+
*/
710
public function getData()
811
{
912
$this->validate('amount', 'returnUrl', 'cancelUrl');
@@ -94,6 +97,11 @@ public function getData()
9497
return $data;
9598
}
9699

100+
/**
101+
* @param mixed $data
102+
*
103+
* @return HostedPurchaseResponse
104+
*/
97105
public function sendData($data)
98106
{
99107
$httpResponse = $this->sendRequest($this->getEndpointAction(), $data, 'POST');
@@ -102,6 +110,9 @@ public function sendData($data)
102110
return $this->response = new HostedPurchaseResponse($this, $responseData);
103111
}
104112

113+
/**
114+
* @return string
115+
*/
105116
public function getEndpointAction()
106117
{
107118
return '/orders';

src/Message/HostedPurchaseResponse.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
class HostedPurchaseResponse extends HostedAbstractResponse implements RedirectResponseInterface
88
{
9+
/**
10+
* @return bool
11+
*/
912
public function isRedirect()
1013
{
1114
$hasHostedLink = false;
@@ -23,6 +26,9 @@ public function isRedirect()
2326
return $hasHostedLink && !$hasTransaction;
2427
}
2528

29+
/**
30+
* @return string|null
31+
*/
2632
public function getRedirectUrl()
2733
{
2834
if (isset($this->data['link'])) {
@@ -34,6 +40,9 @@ public function getRedirectUrl()
3440
}
3541
}
3642

43+
/**
44+
* @return null
45+
*/
3746
public function getRedirectData()
3847
{
3948
return null;

0 commit comments

Comments
 (0)