Skip to content

Commit 0ba8c44

Browse files
committed
Update to Omnypay v3.0.0
1 parent a3f6ea1 commit 0ba8c44

12 files changed

+232
-91
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/vendor
22
composer.lock
33
composer.phar
4-
phpunit.xml
4+
phpunit.xml
5+
/.project
6+
/.buildpath
7+
.idea

composer.json

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
{
2-
"name": "hounddd/omnipay-systempay",
3-
"type": "library",
4-
"description": "SystemPay driver for the Omnipay payment processing library",
5-
"keywords": [
6-
"gateway",
7-
"merchant",
8-
"omnipay",
9-
"pay",
10-
"payment",
11-
"payzen"
12-
],
13-
"homepage": "https://github.com/hounddd/omnipay-systempay",
14-
"license": "MIT",
15-
"authors": [
16-
{
17-
"name": "Hounddd",
18-
"homepage": "https://github.com/hounddd"
19-
}
20-
],
21-
"autoload": {
22-
"psr-4": { "Omnipay\\SystemPay\\" : "src/" }
23-
},
24-
"require": {
25-
"omnipay/common": "~2.0"
26-
},
27-
"require-dev": {
28-
"omnipay/tests": "~2.0"
2+
"name": "hounddd/omnipay-systempay",
3+
"type": "library",
4+
"description": "SystemPay driver for the Omnipay payment processing library",
5+
"keywords": [
6+
"gateway",
7+
"merchant",
8+
"omnipay",
9+
"pay",
10+
"payment",
11+
"payzen"
12+
],
13+
"homepage": "https://github.com/hounddd/omnipay-systempay",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "Hounddd",
18+
"homepage": "https://github.com/hounddd"
2919
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Omnipay\\SystemPay\\": "src/"
24+
}
25+
},
26+
"require": {
27+
"omnipay/common": "~3.0"
28+
},
29+
"require-dev": {
30+
"omnipay/tests": "~3.0",
31+
"squizlabs/php_codesniffer": "^3"
32+
},
33+
"scripts": {
34+
"test": "phpunit",
35+
"check-style": "phpcs -p --standard=PSR2 src/",
36+
"fix-style": "phpcbf -p --standard=PSR2 src/"
37+
}
3038
}

phpunit.xml.dist

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false">
11+
syntaxCheck="false"
12+
beStrictAboutTestsThatDoNotTestAnything="false">
1213
<testsuites>
1314
<testsuite name="Omnipay Test Suite">
1415
<directory>./tests/</directory>
1516
</testsuite>
1617
</testsuites>
17-
<listeners>
18-
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
19-
</listeners>
2018
<filter>
2119
<whitelist>
2220
<directory>./src</directory>

src/Gateway.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace Omnipay\SystemPay;
33

44
use Omnipay\Common\AbstractGateway;
5+
use Omnipay\SystemPay\Message\CompletePurchaseRequest;
6+
use Omnipay\SystemPay\Message\PurchaseRequest;
57

68
/**
79
* SystemPay Gateway
@@ -45,13 +47,18 @@ public function setCertificate($value)
4547
return $this->setParameter('certificate', $value);
4648
}
4749

50+
public function setParameter($key, $value)
51+
{
52+
return parent::setParameter($key, $value);
53+
}
54+
4855
public function purchase(array $parameters = array())
4956
{
50-
return $this->createRequest('\Omnipay\SystemPay\Message\PurchaseRequest', $parameters);
57+
return $this->createRequest(PurchaseRequest::class, $parameters);
5158
}
5259

5360
public function completePurchase(array $parameters = array())
5461
{
55-
return $this->createRequest('\Omnipay\SystemPay\Message\CompletePurchaseRequest', $parameters);
62+
return $this->createRequest(CompletePurchaseRequest::class, $parameters);
5663
}
5764
}

src/Message/AbstractRequest.php

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,122 +2,220 @@
22

33
namespace Omnipay\SystemPay\Message;
44

5+
use Omnipay\Common\Message\AbstractRequest as OmnipayAbstractRequest;
6+
use Omnipay\Common\Message\ResponseInterface;
7+
58
/**
69
* SystemPay Abstract Request
710
*/
8-
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
11+
abstract class AbstractRequest extends OmnipayAbstractRequest
912
{
1013

14+
public function sendData($data)
15+
{
16+
$response = $this->httpClient->request('POST', $this->getEndPoint(), [], http_build_query($data));
17+
$responseData = simplexml_load_string($response->getBody()->getContents());
18+
19+
return $this->createResponse($responseData);
20+
}
21+
22+
abstract public function getEndpoint();
23+
24+
/**
25+
* @return mixed
26+
*/
1127
public function getMerchantId()
1228
{
1329
return $this->getParameter('merchantId');
1430
}
1531

32+
/**
33+
* @param $value
34+
* @return AbstractRequest
35+
*/
1636
public function setMerchantId($value)
1737
{
1838
return $this->setParameter('merchantId', $value);
1939
}
2040

41+
42+
/**
43+
* @return mixed
44+
*/
2145
public function getTransactionDate()
2246
{
2347
return $this->getParameter('transactionDate');
2448
}
2549

50+
/**
51+
* @param $value
52+
* @return AbstractRequest
53+
*/
2654
public function setTransactionDate($value)
2755
{
2856
return $this->setParameter('transactionDate', $value);
2957
}
3058

59+
/**
60+
* @return mixed
61+
*/
3162
public function getCertificate()
3263
{
3364
return $this->getParameter('certificate');
3465
}
3566

67+
/**
68+
* @param $value
69+
* @return AbstractRequest
70+
*/
3671
public function setCertificate($value)
3772
{
3873
return $this->setParameter('certificate', $value);
3974
}
4075

76+
/**
77+
* @param $value
78+
* @return AbstractRequest
79+
*/
4180
public function setSuccessUrl($value)
4281
{
4382
return $this->setParameter('successUrl', $value);
4483
}
4584

85+
/**
86+
* @return mixed
87+
*/
4688
public function getSuccessUrl()
4789
{
4890
return $this->getParameter('successUrl');
4991
}
5092

93+
/**
94+
* @param string $value
95+
* @return AbstractRequest
96+
*/
5197
public function setCancelUrl($value)
5298
{
5399
return $this->setParameter('cancelUrl', $value);
54100
}
55101

102+
/**
103+
* @return mixed|string
104+
*/
56105
public function getCancelUrl()
57106
{
58107
return $this->getParameter('cancelUrl');
59108
}
60109

110+
/**
111+
* @param $value
112+
* @return AbstractRequest
113+
*/
61114
public function setErrorUrl($value)
62115
{
63116
return $this->setParameter('errorUrl', $value);
64117
}
65118

119+
/**
120+
* @return mixed
121+
*/
66122
public function getErrorUrl()
67123
{
68124
return $this->getParameter('errorUrl');
69125
}
70126

127+
/**
128+
* @param $value
129+
* @return AbstractRequest
130+
*/
71131
public function setRefusedUrl($value)
72132
{
73133
return $this->setParameter('refusedUrl', $value);
74134
}
75135

136+
/**
137+
* @return mixed
138+
*/
76139
public function getRefusedUrl()
77140
{
78141
return $this->getParameter('refusedUrl');
79142
}
80143

144+
/**
145+
* @param $value
146+
*/
81147
public function setPaymentCards($value)
82148
{
83149
$this->setParameter('paymentCards', $value);
84150
}
85151

152+
/**
153+
* @return mixed
154+
*/
86155
public function getPaymentCards()
87156
{
88157
return $this->getParameter('paymentCards');
89158
}
90159

160+
/**
161+
* @param $value
162+
* @return AbstractRequest
163+
*/
91164
public function setOrderId($value)
92165
{
93166
return $this->setParameter('orderId', $value);
94167
}
95168

169+
/**
170+
* @return mixed
171+
*/
96172
public function getOrderId()
97173
{
98174
return $this->getParameter('orderId');
99175
}
100176

177+
/**
178+
* @param $value
179+
* @return AbstractRequest
180+
*/
101181
public function setUuid($value)
102182
{
103183
return $this->setParameter('vads_trans_uuid', $value);
104184
}
105185

186+
/**
187+
* @return AbstractRequest
188+
*/
106189
public function getUuid()
107190
{
108191
return $this->setParameter('vads_trans_uuid');
109192
}
110193

194+
/**
195+
* @param string $amount
196+
* @return string
197+
*/
111198
public function formatCurrency($amount)
112199
{
113-
return (string) intval(strval($amount * 100));
200+
return (string)intval(strval($amount * 100));
114201
}
115202

203+
/**
204+
* @param $key
205+
* @param $value
206+
*/
116207
public function addParameter($key, $value)
117208
{
118209
return $this->parameters->set($key, $value);
119210
}
120211

212+
213+
public function getAmount()
214+
{
215+
return $this->getAmountInteger()."";
216+
}
217+
218+
121219
/**
122220
* @see https://payzen.eu/wp-content/uploads/2013/04/Guide_d_implementation_formulaire_paiement_PayZen_v3.4.pdf
123221
*/

src/Message/CompletePurchaseRequest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
class CompletePurchaseRequest extends AbstractRequest
1111
{
12+
13+
public $liveEndpoint = 'https://paiement.systempay.fr/vads-payment/';
14+
15+
1216
public function getData()
1317
{
1418
$signature = $this->generateSignature($this->httpRequest->request->all());
@@ -23,4 +27,9 @@ public function sendData($data)
2327
{
2428
return $this->response = new CompletePurchaseResponse($this, $data);
2529
}
30+
31+
public function getEndpoint()
32+
{
33+
$this->liveEndpoint;
34+
}
2635
}

0 commit comments

Comments
 (0)