-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:mysiar/omnipay-przelewy24v1
## Added * Blik payment functionality ----
- Loading branch information
Showing
25 changed files
with
979 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ composer.lock | |
tests-api/.env | ||
var/ | ||
.phpunit.result.cache | ||
.docker | ||
index.php | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
class BlikAliasesByEmailCustomRequest extends AbstractRequest | ||
{ | ||
public function getEmail(): string | ||
{ | ||
return $this->getParameter('email'); | ||
} | ||
|
||
public function setEmail(string $email): self | ||
{ | ||
return $this->setParameter('email', $email); | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
$this->validate('email'); | ||
|
||
return [ | ||
'email' => $this->getEmail(), | ||
]; | ||
} | ||
|
||
public function sendData($data): BlikAliasesByEmailCustomResponse | ||
{ | ||
$email = $data['email']; | ||
$httpResponse = $this->sendRequest('GET', sprintf('paymentMethod/blik/getAliasesByEmail/%s/custom', $email), []); | ||
|
||
$responseData = json_decode($httpResponse->getBody()->getContents(), true); | ||
|
||
return $this->response = new BlikAliasesByEmailCustomResponse($this, $responseData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
use Omnipay\Common\Message\RequestInterface; | ||
|
||
class BlikAliasesByEmailCustomResponse extends AbstractResponse | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private $aliases = []; | ||
|
||
public function __construct(RequestInterface $request, $data) | ||
{ | ||
parent::__construct($request, $data); | ||
if (isset($data['data'])) { | ||
$this->aliases = $data['data']; | ||
} | ||
} | ||
|
||
public function getAliases(): array | ||
{ | ||
return $this->aliases; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
class BlikAliasesByEmailRequest extends AbstractRequest | ||
{ | ||
public function getEmail(): string | ||
{ | ||
return $this->getParameter('email'); | ||
} | ||
|
||
public function setEmail(string $email): self | ||
{ | ||
return $this->setParameter('email', $email); | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
$this->validate('email'); | ||
|
||
return [ | ||
'email' => $this->getEmail(), | ||
]; | ||
} | ||
|
||
public function sendData($data): BlikAliasesByEmailResponse | ||
{ | ||
$email = $data['email']; | ||
$httpResponse = $this->sendRequest('GET', sprintf('paymentMethod/blik/getAliasesByEmail/%s', $email), []); | ||
|
||
$responseData = json_decode($httpResponse->getBody()->getContents(), true); | ||
|
||
return $this->response = new BlikAliasesByEmailResponse($this, $responseData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
use Omnipay\Common\Message\RequestInterface; | ||
|
||
class BlikAliasesByEmailResponse extends AbstractResponse | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private $aliases = []; | ||
|
||
public function __construct(RequestInterface $request, $data) | ||
{ | ||
parent::__construct($request, $data); | ||
if (isset($data['data'])) { | ||
$this->aliases = $data['data']; | ||
} | ||
} | ||
|
||
public function getAliases(): array | ||
{ | ||
return $this->aliases; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidRequestException; | ||
|
||
class BlikChargeByAliasRequest extends AbstractRequest | ||
{ | ||
public function getAlternativeKey(): string | ||
{ | ||
return $this->getParameter('alternativeKey'); | ||
} | ||
|
||
public function setAlternativeKey(string $type): self | ||
{ | ||
return $this->setParameter('alternativeKey', $type); | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->getParameter('type'); | ||
} | ||
|
||
public function setType(string $type): self | ||
{ | ||
return $this->setParameter('type', $type); | ||
} | ||
|
||
public function getAliasValue(): string | ||
{ | ||
return $this->getParameter('aliasValue'); | ||
} | ||
|
||
public function setAliasValue(string $aliasValue): self | ||
{ | ||
return $this->setParameter('aliasValue', $aliasValue); | ||
} | ||
|
||
public function getAliasLabel(): string | ||
{ | ||
return $this->getParameter('aliasLabel'); | ||
} | ||
|
||
public function setAliasLabel(string $label): self | ||
{ | ||
return $this->setParameter('aliasLabel', $label); | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
$this->validate('token', 'type'); | ||
|
||
if (! in_array($this->getType(), ['alias', 'alternativeKey'], true)) { | ||
throw new InvalidRequestException( | ||
"The `type` parameter is required, and allows only 'alias', 'alternativeKey' values" | ||
); | ||
} | ||
|
||
if ($this->getType() === 'alternativeKey') { | ||
$this->validate('alternativeKey'); | ||
} | ||
|
||
return [ | ||
'token' => $this->getToken(), | ||
'type' => $this->getType(), | ||
'aliasLabel' => $this->getAliasLabel(), | ||
'aliasValue' => $this->getAliasValue(), | ||
'alternativeKey' => $this->getAlternativeKey(), | ||
]; | ||
} | ||
|
||
public function sendData($data): BlikChargeByAliasResponse | ||
{ | ||
$httpResponse = $this->sendRequest('POST', 'paymentMethod/blik/chargeByAlias', $data); | ||
|
||
$responseData = json_decode($httpResponse->getBody()->getContents(), true); | ||
|
||
return $this->response = new BlikChargeByAliasResponse($this, $responseData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
use Omnipay\Common\Message\RequestInterface; | ||
|
||
class BlikChargeByAliasResponse extends AbstractResponse | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $orderId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $chargeMessage; | ||
|
||
public function __construct(RequestInterface $request, $data) | ||
{ | ||
parent::__construct($request, $data); | ||
if (isset($data['data'])) { | ||
$this->orderId = $data['data']['orderId']; | ||
$this->chargeMessage = $data['data']['message']; | ||
} | ||
} | ||
|
||
public function getOrderId(): string | ||
{ | ||
return $this->orderId; | ||
} | ||
|
||
public function getChargeMessage(): string | ||
{ | ||
return $this->chargeMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omnipay\Przelewy24\Message; | ||
|
||
class BlikChargeByCodeRequest extends AbstractRequest | ||
{ | ||
public function getBlikCode(): string | ||
{ | ||
return $this->getParameter('blikCode'); | ||
} | ||
|
||
public function setBlikCode(string $code): self | ||
{ | ||
return $this->setParameter('blikCode', $code); | ||
} | ||
|
||
public function getAliasValue(): string | ||
{ | ||
return $this->getParameter('aliasValue'); | ||
} | ||
|
||
public function setAliasValue(string $aliasValue): self | ||
{ | ||
return $this->setParameter('aliasValue', $aliasValue); | ||
} | ||
|
||
public function getAliasLabel(): string | ||
{ | ||
return $this->getParameter('aliasLabel'); | ||
} | ||
|
||
public function setAliasLabel(string $label): self | ||
{ | ||
return $this->setParameter('aliasLabel', $label); | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
$this->validate('token', 'blikCode'); | ||
|
||
return [ | ||
'token' => $this->getToken(), | ||
'blikCode' => $this->getBlikCode(), | ||
'aliasLabel' => $this->getAliasLabel(), | ||
'aliasValue' => $this->getAliasValue(), | ||
]; | ||
} | ||
|
||
public function sendData($data): BlikChargeByCodeResponse | ||
{ | ||
$httpResponse = $this->sendRequest('POST', 'paymentMethod/blik/chargeByCode', $data); | ||
|
||
$responseData = json_decode($httpResponse->getBody()->getContents(), true); | ||
|
||
return $this->response = new BlikChargeByCodeResponse($this, $responseData); | ||
} | ||
} |
Oops, something went wrong.