tpay-com / tpay-openapi-php
Tpay OpenAPI library
Installs: 95 484
Dependents: 4
Suggesters: 0
Security: 0
Stars: 7
Watchers: 6
Forks: 11
Open Issues: 1
Requires
- php: >=5.6.0
- ext-curl: *
- ext-json: *
- phpseclib/phpseclib: ^2 || ^3
- psr/log: ^1 || ^2 || ^3
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3.2
- phpunit/phpunit: ^5.7.27 || ^9.6.10
README
Library for all methods available via OpenAPI Tpay.
Polish version 🇵🇱 wersja polska
Installation
Install via Composer:
composer require tpay-com/tpay-openapi-php
Install via Git over SSH:
git clone git@github.com:tpay-com/tpay-openapi-php.git
Install via Git over HTTPS:
git clone https://github.com/tpay-com/tpay-openapi-php.git
Manual download: https://github.com/tpay-com/tpay-openapi-php/archive/master.zip
Configuration
The only thing you need to do is to set your OAuth credentials like in example config file (see example). You can generate access keys in Tpay's merchant panel.
The src/Loader.php
file handles all required class loading, so you can include this file to any file you are editing.
All methods described in Tpay OpenAPI documentation can be easily executed by running one of the library methods like:
$tpayApi = new TpayApi($clientId, $clientSecret, true, 'read'); $transactions = $tpayApi->Transactions->getTransactions();
All currently available API methods have an example usage in Examples
directory.
Example credentials
for all API calls:
Client id: 1010-e5736adfd4bc5d8c
Client secret: 493e01af815383a687b747675010f65d1eefaeb42f63cfe197e7b30f14a556b7
for notifications validation:
Confirmation code: demo
for credit card encrypting:
Public Key: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JR2ZNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0R05BRENCaVFLQmdRQ2NLRTVZNU1Wemd5a1Z5ODNMS1NTTFlEMEVrU2xadTRVZm1STS8NCmM5L0NtMENuVDM2ekU0L2dMRzBSYzQwODRHNmIzU3l5NVpvZ1kwQXFOVU5vUEptUUZGVyswdXJacU8yNFRCQkxCcU10TTVYSllDaVQNCmVpNkx3RUIyNnpPOFZocW9SK0tiRS92K1l1YlFhNGQ0cWtHU0IzeHBhSUJncllrT2o0aFJDOXk0WXdJREFRQUINCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==
Examples of usage
Frontend forms and payment handlers:
Payment method choice form, BLIK method form, simple credit card form, extended credit card form, recurrent payment example, payment notification webhook.
Merchant accounts registration (for partners only)
Logs
Library has own logging system to save all API calls, responses, webhook notifications, and exceptions.
Make sure that Logs
directory is writable and add rule to Apache .htaccess
or NGINX to deny access to this area from browser.
The log files are created for each day separately.
The logging is enabled by default, but you can disable this feature by command:
Logger::disableLogging();
You can also set your own logging path by this command:
Logger::setLogPath('/my/own/path/Logs/');
The logs file names will be assigned automatically.
You can replace the logging system above by setting up your own implementation of Psr\Log\LoggerInterface
with:
Logger::setLogger($logger);
Custom templates and static files path
You can set your own templates path, so you can copy and modify the phtml
template files from this library.
Util::$customTemplateDirectory = '/my/own/templates/path/';
You can set your own static files path, so you can copy and modify the css
and js
files from this library. By default, the path is based on $_SERVER['REQUEST_URI']
value.
Util::$libraryPath = '/my/own/path/';
Language
The library supports two languages (English and Polish). Default language is English. Change language example:
// Any time you construct the class providing payment forms, you can pass the language in constructor $paymentForms = new PaymentForms('pl'); // After this line all static messages (input labels, buttons titles etc.) will be displayed in Polish // If you want to access translations manually, use: $lang = new Lang(); $lang->setLang('pl'); // for setting language $lang->lang('pay'); // to echo translated key
License
This library is released under the MIT License.