Skip to content
Open
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
39 changes: 39 additions & 0 deletions src/Api/Blik/BlikApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Tpay\OpenApi\Api\Blik;

use Tpay\OpenApi\Api\ApiAction;
use Tpay\OpenApi\Model\Objects\RequestBody\CreateAlias;
use Tpay\OpenApi\Model\Objects\RequestBody\DeleteAlias;

class BlikApi extends ApiAction
{
/** @param array $fields */
public function createAlias($fields)
{
return $this->run(static::POST, '/blik/alias', $fields, new CreateAlias());
}

/**
* @param string $aliasValue
* @param string $aliasType
*/
public function getAlias($aliasValue, $aliasType)
{
$requestUrl = $this->addQueryFields(
sprintf('/blik/alias/%s', $aliasValue),
['aliasType' => $aliasType]
);

return $this->run(static::GET, $requestUrl);
}

/**
* @param string $aliasValue
* @param array $fields
*/
public function deleteAlias($aliasValue, $fields)
{
return $this->run(static::DELETE, sprintf('/blik/alias/%s', $aliasValue), $fields, new DeleteAlias());
}
}
20 changes: 20 additions & 0 deletions src/Api/TpayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use RuntimeException;
use Tpay\OpenApi\Api\Accounts\AccountsApi;
use Tpay\OpenApi\Api\Authorization\AuthorizationApi;
use Tpay\OpenApi\Api\Blik\BlikApi;
use Tpay\OpenApi\Api\Collect\CollectApi;
use Tpay\OpenApi\Api\Refunds\RefundsApi;
use Tpay\OpenApi\Api\Reports\ReportsApi;
Expand All @@ -15,6 +16,9 @@

class TpayApi
{
/** @var null|BlikApi */
private $blik;

/** @var null|AccountsApi */
private $accounts;

Expand Down Expand Up @@ -93,6 +97,22 @@ public function getToken()
return $this->token;
}

/** @return BlikApi */
public function blik()
{
$this->authorize();
if (null === $this->blik) {
$this->blik = (new BlikApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

if ($this->clientName) {
$this->blik->setClientName($this->clientName);
}
}

return $this->blik;
}

/** @return AccountsApi */
public function accounts()
{
Expand Down
6 changes: 4 additions & 2 deletions src/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private function setCurlMethod($curl)
case 'POST':
curl_setopt($curl, CURLOPT_POST, 1);
if (!empty($this->postData)) {
$json = json_encode($this->postData);
$json = json_encode($this->postData, JSON_PRESERVE_ZERO_FRACTION);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
}
break;
Expand All @@ -203,7 +203,9 @@ private function setCurlMethod($curl)
case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($this->postData)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->postData);
$json = json_encode($this->postData, JSON_PRESERVE_ZERO_FRACTION);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
}
break;
case 'GET':
Expand Down
1 change: 1 addition & 0 deletions src/Dictionary/HttpCodesDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class HttpCodesDictionary
200 => 'OK - default successful outcome of the request',
201 => 'Created - successfully created a new object',
202 => 'Accepted - successfully created a new object, but requires further action',
204 => 'No Content - successful outcome of the request, but no content to return',
];

const HTTP_ERROR_CODES = [
Expand Down
17 changes: 17 additions & 0 deletions src/Model/Fields/Alias/RecommendedAuthLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Alias;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class RecommendedAuthLevel extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $enum = [
'NOCONFREQ',
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
* @method getValue(): float
*/
class SingleLimitAmount extends Field
{
protected $name = __CLASS__;
protected $type = self::INT;
protected $type = self::NUMBER;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
* @method getValue(): float
*/
class TotalLimitAmount extends Field
{
protected $name = __CLASS__;
protected $type = self::INT;
protected $type = self::NUMBER;
}
16 changes: 16 additions & 0 deletions src/Model/Fields/CreateAlias/Description.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Tpay\OpenApi\Model\Fields\CreateAlias;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Description extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $maxLength = 105;
protected $minLength = 1;
}
24 changes: 24 additions & 0 deletions src/Model/Fields/CreateAlias/Lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Tpay\OpenApi\Model\Fields\CreateAlias;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Lang extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $enum = [
'en',
'pl',
'de',
'fr',
'ru',
'it',
'es',
'uk',
];
}
23 changes: 23 additions & 0 deletions src/Model/Objects/Blik/CreateAliasPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Tpay\OpenApi\Model\Objects\Blik;

use Tpay\OpenApi\Model\Objects\Objects;
use Tpay\OpenApi\Model\Objects\Transactions\BlikPaymentData;

class CreateAliasPay extends Objects
{
const OBJECT_FIELDS = [
'blikPaymentData' => BlikPaymentData::class,
];

/** @var BlikPaymentData */
public $blikPaymentData;

public function getRequiredFields()
{
return [
$this->blikPaymentData,
];
}
}
34 changes: 34 additions & 0 deletions src/Model/Objects/RequestBody/CreateAlias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Tpay\OpenApi\Model\Objects\RequestBody;

use Tpay\OpenApi\Model\Fields\CreateAlias\Description;
use Tpay\OpenApi\Model\Fields\CreateAlias\Lang;
use Tpay\OpenApi\Model\Objects\Blik\CreateAliasPay;
use Tpay\OpenApi\Model\Objects\Objects;

class CreateAlias extends Objects
{
const OBJECT_FIELDS = [
'description' => Description::class,
'lang' => Lang::class,
'pay' => CreateAliasPay::class,
];

/** @var Description */
public $description;

/** @var Lang */
public $lang;

/** @var CreateAliasPay */
public $pay;

public function getRequiredFields()
{
return [
$this->description,
$this->pay,
];
}
}
23 changes: 23 additions & 0 deletions src/Model/Objects/RequestBody/DeleteAlias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Tpay\OpenApi\Model\Objects\RequestBody;

use Tpay\OpenApi\Model\Fields\Alias\Type;
use Tpay\OpenApi\Model\Objects\Objects;

class DeleteAlias extends Objects
{
const OBJECT_FIELDS = [
'aliasType' => Type::class,
];

/** @var Type */
public $aliasType;

public function getRequiredFields()
{
return [
$this->aliasType,
];
}
}
5 changes: 5 additions & 0 deletions src/Model/Objects/Transactions/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Tpay\OpenApi\Model\Fields\Alias\Key;
use Tpay\OpenApi\Model\Fields\Alias\Label;
use Tpay\OpenApi\Model\Fields\Alias\RecommendedAuthLevel;
use Tpay\OpenApi\Model\Fields\Alias\Type;
use Tpay\OpenApi\Model\Fields\Alias\Value;
use Tpay\OpenApi\Model\Fields\Boolean;
Expand All @@ -17,6 +18,7 @@ class Alias extends Objects
'type' => Type::class,
'label' => Label::class,
'key' => Key::class,
'recommendedAuthLevel' => RecommendedAuthLevel::class,
'autopayment' => Autopayment::class,
'noDelay' => Boolean::class,
];
Expand All @@ -33,6 +35,9 @@ class Alias extends Objects
/** @var Key */
public $key;

/** @var RecommendedAuthLevel */
public $recommendedAuthLevel;

/** @var Autopayment */
public $autopayment;

Expand Down
Loading
Loading