Skip to content

Implemented new MultiSafepay REST API #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ And run composer to update your dependencies:

The following gateways are provided by this package:

* MultiSafepay
* MultiSafepay_Rest
* MultiSafepay_Xml (Deprecated)

For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.
Expand Down
108 changes: 8 additions & 100 deletions src/Gateway.php
Original file line number Diff line number Diff line change
@@ -1,111 +1,19 @@
<?php
/**
* MultiSafepay XML Api Gateway.
*/

namespace Omnipay\MultiSafepay;

use Omnipay\Common\AbstractGateway;
use Omnipay\MultiSafepay\Message\FetchIssuersRequest;
use Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest;

/**
* MultiSafepay gateway.
* MultiSafepay XML Api gateway.
*
* @deprecated This API is deprecated and will be removed in
* an upcoming version of this package. Please switch to the Rest API.
*
* @link https://www.multisafepay.com/downloads/handleidingen/Handleiding_connect(ENG).pdf
*/
class Gateway extends AbstractGateway
class Gateway extends XmlGateway
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'MultiSafepay';
}

/**
* {@inheritdoc}
*/
public function getDefaultParameters()
{
return array(
'accountId' => '',
'siteId' => '',
'siteCode' => '',
'testMode' => false,
);
}

public function getAccountId()
{
return $this->getParameter('accountId');
}

public function setAccountId($value)
{
return $this->setParameter('accountId', $value);
}

public function getSiteId()
{
return $this->getParameter('siteId');
}

public function setSiteId($value)
{
return $this->setParameter('siteId', $value);
}

public function getSiteCode()
{
return $this->getParameter('siteCode');
}

public function setSiteCode($value)
{
return $this->setParameter('siteCode', $value);
}

/**
* Retrieve payment methods active on the given MultiSafepay
* account.
*
* @param array $parameters
*
* @return \Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest
*/
public function fetchPaymentMethods(array $parameters = array())
{
return $this->createRequest('\Omnipay\MultiSafepay\Message\FetchPaymentMethodsRequest', $parameters);
}

/**
* Retrieve iDEAL issuers.
*
* @param array $parameters
*
* @return \Omnipay\MultiSafepay\Message\FetchIssuersRequest
*/
public function fetchIssuers(array $parameters = array())
{
return $this->createRequest('\Omnipay\MultiSafepay\Message\FetchIssuersRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\MultiSafepay\Message\PurchaseRequest
*/
public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\MultiSafepay\Message\PurchaseRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\MultiSafepay\Message\CompletePurchaseRequest
*/
public function completePurchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\MultiSafepay\Message\CompletePurchaseRequest', $parameters);
}
}
78 changes: 77 additions & 1 deletion src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,127 @@
<?php
/**
* MultiSafepay Abstract XML Api Request.
*/

namespace Omnipay\MultiSafepay\Message;

use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;

/**
* Multisafepay Abstract XML Api Request.
*
* @deprecated This API is deprecated and will be removed in
* an upcoming version of this package. Please switch to the Rest API.
*/
abstract class AbstractRequest extends BaseAbstractRequest
{
/**
* User Agent.
*
* This user agent will be sent with each API request.
*
* @var string
*/
protected $userAgent = 'Omnipay';

/**
* Live API endpoint.
*
* This endpoint will be used when the test mode is disabled.
*
* @var string
*/
protected $liveEndpoint = 'https://api.multisafepay.com/ewx/';

/**
* Test API endpoint.
*
* This endpoint will be used when the test mode is enabled.
*
* @var string
*/
protected $testEndpoint = 'https://testapi.multisafepay.com/ewx/';

/**
* Get the account identifier.
*
* @return mixed
*/
public function getAccountId()
{
return $this->getParameter('accountId');
}

/**
* Set the account identifier.
*
* @param $value
* @return BaseAbstractRequest
*/
public function setAccountId($value)
{
return $this->setParameter('accountId', $value);
}

/**
* Get the site identifier.
*
* @return mixed
*/
public function getSiteId()
{
return $this->getParameter('siteId');
}

/**
* Set the site identifier.
*
* @param $value
* @return BaseAbstractRequest
*/
public function setSiteId($value)
{
return $this->setParameter('siteId', $value);
}

/**
* Get the site code.
*
* @return mixed
*/
public function getSiteCode()
{
return $this->getParameter('siteCode');
}

/**
* Set the site code.
*
* @param $value
* @return BaseAbstractRequest
*/
public function setSiteCode($value)
{
return $this->setParameter('siteCode', $value);
}

/**
* Get the API endpoint.
*
* @return string
*/
public function getEndpoint()
{
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
if ($this->getTestMode()) {
return $this->testEndpoint;
}

return $this->liveEndpoint;
}

/**
* Get headers.
*
* @return array
*/
protected function getHeaders()
Expand Down
8 changes: 7 additions & 1 deletion src/Message/AbstractResponse.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php
/**
* MultiSafepay Abstract XML Api Response.
*/

namespace Omnipay\MultiSafepay\Message;

use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse;

/**
* @method mixed|\SimpleXMLElement getData()
* MultiSafepay Abstract XML Api Response.
*
* @deprecated This API is deprecated and will be removed in
* an upcoming version of this package. Please switch to the Rest API.
*/
abstract class AbstractResponse extends BaseAbstractResponse
{
Expand Down
15 changes: 13 additions & 2 deletions src/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php
/**
* MultiSafepay XML Api Complete Purchase Request.
*/

namespace Omnipay\MultiSafepay\Message;

use SimpleXMLElement;

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

return $this->response = new CompletePurchaseResponse($this, $httpResponse->xml());
$this->response = new CompletePurchaseResponse(
$this,
$httpResponse->xml()
);

return $this->response;
}
}
Loading