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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"docs": "https://openapi.tpay.com"
},
"require": {
"php": ">=5.6.0",
"php": ">=7.1",
"ext-curl": "*",
"ext-fileinfo": "*",
"ext-json": "*",
Expand Down
15 changes: 15 additions & 0 deletions examples/Notifications/AllNotificationsExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Tpay\OpenApi\Model\Objects\NotificationBody\BlikAliasRegister;
use Tpay\OpenApi\Model\Objects\NotificationBody\BlikAliasUnregister;
use Tpay\OpenApi\Model\Objects\NotificationBody\MarketplaceTransaction;
use Tpay\OpenApi\Model\Objects\NotificationBody\Recurring;
use Tpay\OpenApi\Model\Objects\NotificationBody\Tokenization;
use Tpay\OpenApi\Model\Objects\NotificationBody\TokenUpdate;
use Tpay\OpenApi\Model\Objects\Objects;
Expand Down Expand Up @@ -106,6 +107,20 @@ public function getVerifiedNotification()
exit('TRUE');
}

if ($notification instanceof Recurring) {
// Notification about successful recurring registered

$recurringId = $notification->recurringId->getValue();
// The above example will check the notification and return the value of recurring id

$transactionId = $notification->transactionId->getValue();
// The above example will check the notification and return the value of received transaction id field
// You can access any notification field by $notification->fieldName

// $recurringProcessor->process($notification)
exit('TRUE');
}

// Ignore and silence other notification types if not expected
http_response_code(404);
exit('FALSE');
Expand Down
58 changes: 58 additions & 0 deletions src/Api/Recurring/RecurringApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Tpay\OpenApi\Api\Recurring;

use Tpay\OpenApi\Api\ApiAction;
use Tpay\OpenApi\Model\Objects\RequestBody\Recurring;
use Tpay\OpenApi\Model\Objects\RequestBody\UpdatePaymentInstrument;

class RecurringApi extends ApiAction
{
/** @param array $queryFields */
public function getRecurring($queryFields = [])
{
$requestUrl = $this->addQueryFields('/recurring', $queryFields);

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

/** @param string $recurringId */
public function getRecurringById($recurringId)
{
return $this->run(static::GET, sprintf('/recurring/%s', $recurringId));
}

/**
* @param string $recurringId
* @param array $queryFields
*/
public function getTransactionsByRecurringId($recurringId, $queryFields = [])
{
$requestUrl = $this->addQueryFields(sprintf('/recurring/%s/transactions', $recurringId), $queryFields);

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

/** @param array $fields */
public function createRecurring($fields)
{
return $this->run(static::POST, '/recurring', $fields, new Recurring());
}

/** @param string $recurringId */
public function cancelTransaction($recurringId)
{
return $this->run(static::POST, sprintf('/recurring/%s/cancel', $recurringId));
}

/** @param string $recurringId */
public function updatePaymentInstrument($fields, $recurringId)
{
return $this->run(
static::POST,
sprintf('/recurring/%s/payment_instrument', $recurringId),
$fields,
new UpdatePaymentInstrument()
);
}
}
20 changes: 20 additions & 0 deletions src/Api/TpayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Tpay\OpenApi\Api\Accounts\AccountsApi;
use Tpay\OpenApi\Api\Authorization\AuthorizationApi;
use Tpay\OpenApi\Api\Collect\CollectApi;
use Tpay\OpenApi\Api\Recurring\RecurringApi;
use Tpay\OpenApi\Api\Refunds\RefundsApi;
use Tpay\OpenApi\Api\Reports\ReportsApi;
use Tpay\OpenApi\Api\Transactions\TransactionsApi;
Expand All @@ -24,6 +25,9 @@ class TpayApi
/** @var null|CollectApi */
private $collect;

/** @var null|RecurringApi */
private $recurring;

/** @var null|RefundsApi */
private $refunds;

Expand Down Expand Up @@ -125,6 +129,22 @@ public function authorization()
return $this->authorization;
}

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

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

return $this->recurring;
}

/** @return RefundsApi */
public function refunds()
{
Expand Down
14 changes: 14 additions & 0 deletions src/Model/Fields/Notification/Recurring/IterationCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class NextChargeDate extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Notification/Recurring/Reason.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Reason extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Notification/Recurring/Status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Status extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Notification/Recurring/TransactionId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Notification\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Recurring;

use Tpay\OpenApi\Model\Fields\Field;

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

namespace Tpay\OpenApi\Model\Fields\Recurring\PaymentInstrument;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class PaymentType extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $enum = ['card_token'];
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Recurring/PaymentInstrument/Value.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Recurring\PaymentInstrument;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Value extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
}
15 changes: 15 additions & 0 deletions src/Model/Fields/Recurring/Schedule/Amount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Recurring\Schedule;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): float|int
*/
class Amount extends Field
{
protected $name = __CLASS__;
protected $type = self::NUMBER;
protected $minimum = 0.01;
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Recurring/Schedule/ChargeCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Recurring\Schedule;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): int
*/
class ChargeCount extends Field
{
protected $name = __CLASS__;
protected $type = self::INT;
}
15 changes: 15 additions & 0 deletions src/Model/Fields/Recurring/Schedule/Currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Recurring\Schedule;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class Currency extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $enum = ['PLN'];
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Recurring/Schedule/FirstChargeDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Recurring\Schedule;

use Tpay\OpenApi\Model\Fields\Field;

/**
* @method getValue(): string
*/
class FirstChargeDate extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
}
Loading