Skip to content
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
6 changes: 5 additions & 1 deletion examples/AccountsApi/AccountsApiExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\AccountsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;

final class AccountsApiExample extends ExamplesConfig
{
Expand All @@ -12,7 +15,8 @@ final class AccountsApiExample extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::PARTNER_CLIENT_ID, self::PARTNER_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::PARTNER_CLIENT_ID, self::PARTNER_CLIENT_SECRET, true, 'read');
}

public function runAllExamples()
Expand Down
7 changes: 6 additions & 1 deletion examples/RefundsApi/RefundsApiExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\RefundsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;

final class RefundsApiExample extends ExamplesConfig
{
Expand All @@ -12,7 +15,9 @@ final class RefundsApiExample extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
// You can inject any of your PSR6 or PSR16 cache implementation
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
}

public function getRefunds()
Expand Down
6 changes: 5 additions & 1 deletion examples/ReportsApi/ReportsApiExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\ReportsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;

final class ReportsApiExample extends ExamplesConfig
{
Expand All @@ -12,7 +15,8 @@ final class ReportsApiExample extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, false, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, false, 'read');
}

public function getReports()
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/BankSelectionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Forms\PaymentForms;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\TpayException;

final class BankSelectionForm extends ExamplesConfig
Expand All @@ -24,7 +27,8 @@ public function getBankForm()

protected function getBanksList($onlineOnly = false)
{
$TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$result = $TpayApi->transactions()->getBankGroups($onlineOnly);
if (!isset($result['result']) || 'success' !== $result['result']) {
throw new TpayException('Unable to get banks list. Response: '.json_encode($result));
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/BlikPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Forms\PaymentForms;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\TpayException;

final class BlikPayment extends ExamplesConfig
Expand All @@ -22,7 +25,8 @@ public function __construct()

protected function processPayment($blikCode)
{
$TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$transaction = $TpayApi->transactions()->createTransaction($this->getRequestBody());
if (isset($transaction['transactionId'])) {
$blikPaymentFields = [
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/CardGate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Forms\PaymentForms;
use Tpay\OpenApi\Model\Fields\FieldTypes;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\TpayException;
use Tpay\OpenApi\Utilities\Util;

Expand All @@ -16,7 +19,8 @@ final class CardGate extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
}

public function init()
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/CardGateExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Forms\PaymentForms;
use Tpay\OpenApi\Model\Fields\FieldTypes;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\Logger;
use Tpay\OpenApi\Utilities\TpayException;
use Tpay\OpenApi\Utilities\Util;
Expand All @@ -17,7 +20,8 @@ final class CardGateExtended extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
}

public function init()
Expand Down
7 changes: 6 additions & 1 deletion examples/TransactionsApi/RecurrentPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\TpayException;

final class RecurrentPayment extends ExamplesConfig
Expand Down Expand Up @@ -33,7 +36,9 @@ public function processPayment(
],
],
];
$TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
// You can inject any of your PSR6 or PSR16 cache implementation
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$transaction = $TpayApi->transactions()->createTransaction($request);
if (
isset($transaction['result'], $transaction['status'])
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/RedirectPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;
use Tpay\OpenApi\Utilities\TpayException;

final class RedirectPayment extends ExamplesConfig
Expand All @@ -13,7 +16,8 @@ public function processTransaction()
if (!isset($_POST['groupId'])) {
throw new TpayException('No payment group Id, unable to create transaction');
}
$TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$result = $TpayApi->transactions()->createTransaction($this->getRequestBody());
if (isset($result['transactionPaymentUrl'])) {
header('Location: '.$result['transactionPaymentUrl']);
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/TransactionQRCodeExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;

final class TransactionQRCodeExample extends ExamplesConfig
{
Expand All @@ -12,7 +15,8 @@ final class TransactionQRCodeExample extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
}

public function runAllExamples()
Expand Down
6 changes: 5 additions & 1 deletion examples/TransactionsApi/TransactionsApiExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Tpay\Example\TransactionsApi;

use Doctrine\Common\Cache\FilesystemCache;
use PSX\Cache\SimpleCache;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Utilities\Cache;

final class TransactionsApiExample extends ExamplesConfig
{
Expand All @@ -12,7 +15,8 @@ final class TransactionsApiExample extends ExamplesConfig
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$cache = new Cache(null, new SimpleCache(new FilesystemCache(__DIR__.'/cache/')));
$this->TpayApi = new TpayApi($cache, self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
}

public function runAllExamples()
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Transactions/TransactionsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function createRefundByTransactionId($fields, $transactionId)
/** @param string $transactionId */
public function cancelTransaction($transactionId)
{
return $this->run(static::POST, sprintf('/transactions/%s/pay', $transactionId));
return $this->run(static::POST, sprintf('/transactions/%s/cancel', $transactionId));
}

/** @param array $fields */
Expand Down