Skip to content

Commit 342d0a3

Browse files
committed
Merge pull request #5 from nielstholenaar/master
Implemented new MultiSafepay REST API
2 parents e8d6494 + b878cd3 commit 342d0a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2648
-145
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ And run composer to update your dependencies:
3131

3232
The following gateways are provided by this package:
3333

34-
* MultiSafepay
34+
* MultiSafepay_Rest
35+
* MultiSafepay_Xml (Deprecated)
3536

3637
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
3738
repository.

src/Gateway.php

Lines changed: 8 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,19 @@
11
<?php
2+
/**
3+
* MultiSafepay XML Api Gateway.
4+
*/
25

36
namespace Omnipay\MultiSafepay;
47

5-
use Omnipay\Common\AbstractGateway;
6-
use Omnipay\MultiSafepay\Message\FetchIssuersRequest;
7-
use Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest;
8-
98
/**
10-
* MultiSafepay gateway.
9+
* MultiSafepay XML Api gateway.
10+
*
11+
* @deprecated This API is deprecated and will be removed in
12+
* an upcoming version of this package. Please switch to the Rest API.
1113
*
1214
* @link https://www.multisafepay.com/downloads/handleidingen/Handleiding_connect(ENG).pdf
1315
*/
14-
class Gateway extends AbstractGateway
16+
class Gateway extends XmlGateway
1517
{
16-
/**
17-
* {@inheritdoc}
18-
*/
19-
public function getName()
20-
{
21-
return 'MultiSafepay';
22-
}
23-
24-
/**
25-
* {@inheritdoc}
26-
*/
27-
public function getDefaultParameters()
28-
{
29-
return array(
30-
'accountId' => '',
31-
'siteId' => '',
32-
'siteCode' => '',
33-
'testMode' => false,
34-
);
35-
}
36-
37-
public function getAccountId()
38-
{
39-
return $this->getParameter('accountId');
40-
}
41-
42-
public function setAccountId($value)
43-
{
44-
return $this->setParameter('accountId', $value);
45-
}
46-
47-
public function getSiteId()
48-
{
49-
return $this->getParameter('siteId');
50-
}
51-
52-
public function setSiteId($value)
53-
{
54-
return $this->setParameter('siteId', $value);
55-
}
56-
57-
public function getSiteCode()
58-
{
59-
return $this->getParameter('siteCode');
60-
}
61-
62-
public function setSiteCode($value)
63-
{
64-
return $this->setParameter('siteCode', $value);
65-
}
66-
67-
/**
68-
* Retrieve payment methods active on the given MultiSafepay
69-
* account.
70-
*
71-
* @param array $parameters
72-
*
73-
* @return \Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest
74-
*/
75-
public function fetchPaymentMethods(array $parameters = array())
76-
{
77-
return $this->createRequest('\Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest', $parameters);
78-
}
79-
80-
/**
81-
* Retrieve iDEAL issuers.
82-
*
83-
* @param array $parameters
84-
*
85-
* @return \Omnipay\MultiSafepay\Message\FetchIssuersRequest
86-
*/
87-
public function fetchIssuers(array $parameters = array())
88-
{
89-
return $this->createRequest('\Omnipay\MultiSafepay\Message\FetchIssuersRequest', $parameters);
90-
}
91-
92-
/**
93-
* @param array $parameters
94-
*
95-
* @return \Omnipay\MultiSafepay\Message\PurchaseRequest
96-
*/
97-
public function purchase(array $parameters = array())
98-
{
99-
return $this->createRequest('\Omnipay\MultiSafepay\Message\PurchaseRequest', $parameters);
100-
}
10118

102-
/**
103-
* @param array $parameters
104-
*
105-
* @return \Omnipay\MultiSafepay\Message\CompletePurchaseRequest
106-
*/
107-
public function completePurchase(array $parameters = array())
108-
{
109-
return $this->createRequest('\Omnipay\MultiSafepay\Message\CompletePurchaseRequest', $parameters);
110-
}
11119
}

src/Message/AbstractRequest.php

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,127 @@
11
<?php
2+
/**
3+
* MultiSafepay Abstract XML Api Request.
4+
*/
25

36
namespace Omnipay\MultiSafepay\Message;
47

58
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
69

10+
/**
11+
* Multisafepay Abstract XML Api Request.
12+
*
13+
* @deprecated This API is deprecated and will be removed in
14+
* an upcoming version of this package. Please switch to the Rest API.
15+
*/
716
abstract class AbstractRequest extends BaseAbstractRequest
817
{
18+
/**
19+
* User Agent.
20+
*
21+
* This user agent will be sent with each API request.
22+
*
23+
* @var string
24+
*/
925
protected $userAgent = 'Omnipay';
26+
27+
/**
28+
* Live API endpoint.
29+
*
30+
* This endpoint will be used when the test mode is disabled.
31+
*
32+
* @var string
33+
*/
1034
protected $liveEndpoint = 'https://api.multisafepay.com/ewx/';
35+
36+
/**
37+
* Test API endpoint.
38+
*
39+
* This endpoint will be used when the test mode is enabled.
40+
*
41+
* @var string
42+
*/
1143
protected $testEndpoint = 'https://testapi.multisafepay.com/ewx/';
1244

45+
/**
46+
* Get the account identifier.
47+
*
48+
* @return mixed
49+
*/
1350
public function getAccountId()
1451
{
1552
return $this->getParameter('accountId');
1653
}
1754

55+
/**
56+
* Set the account identifier.
57+
*
58+
* @param $value
59+
* @return BaseAbstractRequest
60+
*/
1861
public function setAccountId($value)
1962
{
2063
return $this->setParameter('accountId', $value);
2164
}
2265

66+
/**
67+
* Get the site identifier.
68+
*
69+
* @return mixed
70+
*/
2371
public function getSiteId()
2472
{
2573
return $this->getParameter('siteId');
2674
}
2775

76+
/**
77+
* Set the site identifier.
78+
*
79+
* @param $value
80+
* @return BaseAbstractRequest
81+
*/
2882
public function setSiteId($value)
2983
{
3084
return $this->setParameter('siteId', $value);
3185
}
3286

87+
/**
88+
* Get the site code.
89+
*
90+
* @return mixed
91+
*/
3392
public function getSiteCode()
3493
{
3594
return $this->getParameter('siteCode');
3695
}
3796

97+
/**
98+
* Set the site code.
99+
*
100+
* @param $value
101+
* @return BaseAbstractRequest
102+
*/
38103
public function setSiteCode($value)
39104
{
40105
return $this->setParameter('siteCode', $value);
41106
}
42107

108+
/**
109+
* Get the API endpoint.
110+
*
111+
* @return string
112+
*/
43113
public function getEndpoint()
44114
{
45-
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
115+
if ($this->getTestMode()) {
116+
return $this->testEndpoint;
117+
}
118+
119+
return $this->liveEndpoint;
46120
}
47121

48122
/**
123+
* Get headers.
124+
*
49125
* @return array
50126
*/
51127
protected function getHeaders()

src/Message/AbstractResponse.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
2+
/**
3+
* MultiSafepay Abstract XML Api Response.
4+
*/
25

36
namespace Omnipay\MultiSafepay\Message;
47

58
use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse;
69

710
/**
8-
* @method mixed|\SimpleXMLElement getData()
11+
* MultiSafepay Abstract XML Api Response.
12+
*
13+
* @deprecated This API is deprecated and will be removed in
14+
* an upcoming version of this package. Please switch to the Rest API.
915
*/
1016
abstract class AbstractResponse extends BaseAbstractResponse
1117
{

src/Message/CompletePurchaseRequest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
2+
/**
3+
* MultiSafepay XML Api Complete Purchase Request.
4+
*/
25

36
namespace Omnipay\MultiSafepay\Message;
47

58
use SimpleXMLElement;
69

710
/**
8-
* @method \Omnipay\MultiSafepay\Message\CompletePurchaseResponse send()
11+
* MultiSafepay XML Api Complete Purchase Request.
12+
*
13+
* @deprecated This API is deprecated and will be removed in
14+
* an upcoming version of this package. Please switch to the Rest API.
915
*/
1016
class CompletePurchaseRequest extends PurchaseRequest
1117
{
@@ -41,6 +47,11 @@ public function sendData($data)
4147
$data->asXML()
4248
)->send();
4349

44-
return $this->response = new CompletePurchaseResponse($this, $httpResponse->xml());
50+
$this->response = new CompletePurchaseResponse(
51+
$this,
52+
$httpResponse->xml()
53+
);
54+
55+
return $this->response;
4556
}
4657
}

0 commit comments

Comments
 (0)