Skip to content

Commit

Permalink
Added support for unRegisterCard comfortpay endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldia authored and tomaj committed Oct 16, 2024
1 parent e167073 commit b790cab
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ComfortPay/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public function checkCard(array $parameters = array())
return $this->createRequest(\Omnipay\ComfortPay\Message\CheckCardRequest::class, $parameters);
}

public function unRegisterCard(array $parameters = array())
{
return $this->createRequest(\Omnipay\ComfortPay\Message\UnRegisterCardRequest::class, $parameters);
}

public function listOfExpirePerId(array $parameters = array())
{
return $this->createRequest(\Omnipay\ComfortPay\Message\ListOfExpirePerIdRequest::class, $parameters);
Expand Down
43 changes: 43 additions & 0 deletions src/ComfortPay/Message/UnRegisterCardRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Omnipay\ComfortPay\Message;

class UnRegisterCardRequest extends AbstractSoapRequest
{
public function getCardId()
{
return $this->getParameter('cardId');
}

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

public function getData()
{
$this->validate('cardId');

$data = parent::getData();
$data['cardId'] = $this->getCardId();
return $data;
}

public function sendData($data)
{
if ($this->getTestmode()) {
if ((int) $data['cardId'] % 2 === 0) {
return $this->response = new UnRegisterCardResponse($this, 0);
}
return $this->response = new UnRegisterCardResponse($this, 5);
}

$request = new \stdClass();
$request->idOfCard = $data['cardId'];

$client = $this->getSoapClient();
$response = $client->unRegisterCard($request);

return $this->response = new UnRegisterCardResponse($this, $response);
}
}
14 changes: 14 additions & 0 deletions src/ComfortPay/Message/UnRegisterCardResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Omnipay\ComfortPay\Message;

use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\ResponseInterface;

class UnRegisterCardResponse extends AbstractResponse implements ResponseInterface
{
public function isSuccessful()
{
return (bool) $this->data;
}
}

0 comments on commit b790cab

Please sign in to comment.