Skip to content

Commit b58d22f

Browse files
committed
apply code standards
1 parent 5320a7f commit b58d22f

File tree

7 files changed

+100
-166
lines changed

7 files changed

+100
-166
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ to your `composer.json` file:
2222
```json
2323
{
2424
"require": {
25-
"PatronBase/omnipay-smartpay": "~3.0"
25+
"PatronBase/omnipay-windcave-hpp": "~1.0"
2626
}
2727
}
2828
```
@@ -36,7 +36,7 @@ And run composer to update your dependencies:
3636

3737
The following gateways are provided by this package:
3838

39-
* SmartPay\Merchant Hosted Integration v1.0
39+
* Windcave REST API Hosted Payment Page (HPP)
4040

4141
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
4242
repository.
@@ -51,5 +51,5 @@ If you want to keep up to date with release anouncements, discuss ideas for the
5151
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
5252
you can subscribe to.
5353

54-
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/PatronBase/omnipay-smartpay/issues),
54+
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/PatronBase/omnipay-windcave-hpp/issues),
5555
or better yet, fork the library and submit a pull request.

src/Gateway.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
/**
1111
* Windcave HPP Payment Gateway
1212
*/
13-
class Gateway extends AbstractGateway
14-
{
13+
class Gateway extends AbstractGateway {
1514
/**
1615
* Get name
1716
*
1817
* @return string
1918
*/
20-
public function getName()
21-
{
19+
public function getName() {
2220
return 'Windcave Hpp';
2321
}
2422

@@ -27,28 +25,23 @@ public function getName()
2725
*
2826
* @return array
2927
*/
30-
public function getDefaultParameters()
31-
{
28+
public function getDefaultParameters() {
3229
return [];
3330
}
3431

35-
public function setApiUsername($value)
36-
{
32+
public function setApiUsername($value) {
3733
return $this->setParameter('apiUsername', $value);
3834
}
3935

40-
public function getApiUsername()
41-
{
36+
public function getApiUsername() {
4237
return $this->getParameter('apiUsername');
4338
}
4439

45-
public function setApiKey($value)
46-
{
40+
public function setApiKey($value) {
4741
return $this->setParameter('apiKey', $value);
4842
}
4943

50-
public function getApiKey()
51-
{
44+
public function getApiKey() {
5245
return $this->getParameter('apiKey');
5346
}
5447

@@ -59,8 +52,7 @@ public function getApiKey()
5952
*
6053
* @return Omnipay\WindcaveHpp\Message\PurchaseRequest
6154
*/
62-
public function purchase(array $parameters = [])
63-
{
55+
public function purchase(array $parameters = []) {
6456
return $this->createRequest(
6557
PurchaseRequest::class,
6658
$parameters
@@ -74,16 +66,14 @@ public function purchase(array $parameters = [])
7466
*
7567
* @return Omnipay\WindcaveHpp\Message\CompletePurchaseRequest
7668
*/
77-
public function completePurchase(array $parameters = [])
78-
{
69+
public function completePurchase(array $parameters = []) {
7970
return $this->createRequest(
8071
CompletePurchaseRequest::class,
8172
$parameters
8273
);
8374
}
8475

85-
public function acceptNotification(array $parameters = [])
86-
{
76+
public function acceptNotification(array $parameters = []) {
8777
return $this->createRequest(
8878
AcceptNotification::class,
8979
$parameters

src/Message/AcceptNotification.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
use Omnipay\Common\Message\NotificationInterface;
99
use Symfony\Component\HttpFoundation\Request as HttpRequest;
1010

11-
class AcceptNotification extends PurchaseRequest implements NotificationInterface{
11+
class AcceptNotification extends PurchaseRequest implements NotificationInterface {
1212
protected $data;
1313

1414
protected $transaction;
1515

16-
public function getData()
17-
{
16+
public function getData() {
1817
return $this->data;
1918
}
20-
public function sendData($data)
21-
{
19+
20+
public function sendData($data) {
2221
$sessionId = $this->httpRequest->query->get('sessionId') ?? $this->httpRequest->request->get('sessionId') ?? '';
2322

24-
if ( empty($sessionId) ) {
23+
if (empty($sessionId)) {
2524
throw new InvalidRequestException('Session id is required');
2625
}
2726

@@ -33,7 +32,8 @@ public function sendData($data)
3332

3433
try {
3534
$httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/' . $sessionId), $headers);
36-
} catch (\Exception $exception) {
35+
}
36+
catch (\Exception $exception) {
3737
throw new InvalidRequestException($exception->getMessage());
3838
}
3939

@@ -45,37 +45,31 @@ public function sendData($data)
4545
return $this;
4646
}
4747

48-
public function getTransaction()
49-
{
48+
public function getTransaction() {
5049
return $this->transaction;
5150
}
5251

53-
public function getTransactionReference()
54-
{
52+
public function getTransactionReference() {
5553
return $this->getTransaction()['id'] ?? '';
5654
}
5755

58-
public function getTransactionStatus()
59-
{
60-
if ( $this->getTransaction() && $this->getAuthorised() && $this->getResponseText() === 'APPROVED' ) {
56+
public function getTransactionStatus() {
57+
if ($this->getTransaction() && $this->getAuthorised() && $this->getResponseText() === 'APPROVED') {
6158
return static::STATUS_COMPLETED;
6259
}
6360

6461
return static::STATUS_FAILED;
6562
}
6663

67-
public function getAuthorised()
68-
{
64+
public function getAuthorised() {
6965
return $this->getTransaction()['authorised'] ?? false;
7066
}
7167

72-
public function getResponseText()
73-
{
68+
public function getResponseText() {
7469
return strtoupper($this->getTransaction()['responseText']) ?? '';
7570
}
7671

77-
public function getMessage()
78-
{
72+
public function getMessage() {
7973
return $this->getResponseText() ?? '';
8074
}
8175
}

src/Message/CompletePurchaseRequest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77
/**
88
* Windcave HPP Complete Purchase Request
99
*/
10-
class CompletePurchaseRequest extends PurchaseRequest
11-
{
12-
public function getData()
13-
{
10+
class CompletePurchaseRequest extends PurchaseRequest {
11+
public function getData() {
1412
return $this->httpRequest->request->all();
1513

1614
}
17-
public function sendData($data)
18-
{
19-
if ( !$data['sessionId'] ) {
15+
16+
public function sendData($data) {
17+
if (!$data['sessionId']) {
2018
throw new InvalidRequestException('Session id is required');
2119
}
2220

@@ -30,7 +28,8 @@ public function sendData($data)
3028

3129
try {
3230
$httpResponse = $this->httpClient->request('GET', $this->getEndpoint('sessions/' . $sessionId), $headers);
33-
} catch (\Exception $exception) {
31+
}
32+
catch (\Exception $exception) {
3433
throw new InvalidRequestException($exception->getMessage());
3534
}
3635

src/Message/CompletePurchaseResponse.php

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
/**
1010
* Windcave HPP Complete Purchase Response
1111
*/
12-
class CompletePurchaseResponse extends AbstractResponse
13-
{
12+
class CompletePurchaseResponse extends AbstractResponse {
1413
/**
1514
* Constructor
1615
*
@@ -19,81 +18,67 @@ class CompletePurchaseResponse extends AbstractResponse
1918
*
2019
* @throws InvalidResponseException If merchant data or order number is missing, or signature does not match
2120
*/
22-
public function __construct(RequestInterface $request, $data)
23-
{
21+
public function __construct(RequestInterface $request, $data) {
2422
parent::__construct($request, $data);
2523
}
2624

27-
public function isSuccessful()
28-
{
25+
public function isSuccessful() {
2926
$transaction = $this->getTransactionResult();
3027

3128
return (
3229
$transaction &&
3330
($transaction['authorised'] ?? false) &&
34-
( strtoupper($transaction['responseText'] ?? '') ) === 'APPROVED'
31+
(strtoupper($transaction['responseText'] ?? '')) === 'APPROVED'
3532
) ?? false;
3633
}
3734

38-
protected function getTransactionResult()
39-
{
35+
protected function getTransactionResult() {
4036
return $this->getData()['transactions'][0] ?? [];
4137
}
4238

43-
public function getTransactionId()
44-
{
39+
public function getTransactionId() {
4540
return $this->getTransactionResult()['merchantReference'] ?? '';
4641
}
4742

48-
public function getTransactionReference()
49-
{
43+
public function getTransactionReference() {
5044
return $this->getTransactionResult()['id'] ?? '';
5145
}
5246

53-
public function getTransactionType()
54-
{
47+
public function getTransactionType() {
5548
return $this->getTransactionResult()['type'] ?? '';
5649
}
5750

58-
public function getMessage()
59-
{
51+
public function getMessage() {
6052
return $this->getResponseText() ?? '';
6153
}
6254

63-
public function getResponseText()
64-
{
55+
public function getResponseText() {
6556
$transaction = $this->getTransactionResult();
6657

6758
return $transaction['responseText'] ?? '';
6859
}
6960

70-
public function getSessionId()
71-
{
61+
public function getSessionId() {
7262
return $this->getTransactionResult()['sessionId'] ?? '';
7363
}
7464

75-
public function getCard()
76-
{
65+
public function getCard() {
7766
return $this->getTransactionResult()['card'] ?? '';
7867
}
7968

80-
public function getCardNumber()
81-
{
69+
public function getCardNumber() {
8270
return $this->getCard()['cardNumber'] ?? '';
8371
}
8472

85-
public function cardHolderName()
86-
{
73+
public function cardHolderName() {
8774
return $this->getCard()['cardHolderName'] ?? '';
8875
}
8976

90-
public function getCardExpiry()
91-
{
77+
public function getCardExpiry() {
9278
return ($this->getCard()['dateExpiryMonth'] ?? '') . '/' . ($this->getCard()['dateExpiryYear'] ?? '');
9379
}
9480

95-
public function getCardType()
96-
{
81+
public function getCardType() {
9782
return $this->getCard()['type'] ?? '';
9883
}
9984
}

0 commit comments

Comments
 (0)