wearesho-team / platon
Platon integration
Requires
- php: ^8.4
- ext-json: *
- guzzlehttp/guzzle: ^7.4.5
- horat1us/environment-config: ^1.6
- horat1us/luhn-algorithm: ^6.0
- nesbot/carbon: ^3.8.4
- wearesho-team/bobra-payments: ^3.1
Requires (Dev)
- phpunit/phpunit: ^13.4
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.0
- 2.0.1
- 2.0.0
- 1.13.7
- 1.13.6
- 1.13.5
- 1.13.4
- 1.13.3
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.2.0-BETA
- 1.1.0
- 1.0.0
- 1.0.0-RC6
- 1.0.0-RC5
- 1.0.0-RC4
- 1.0.0-RC3
- 1.0.0-RC2
- 1.0.0-RC1
- dev-fix/uppercase-http-method
- dev-php-8.4
- dev-feature/direct-debit
- dev-hotfix/credit-response-optimize
- dev-feature/cghooks
- dev-feature/unique-transfer
This package is auto-updated.
Last update: 2026-10-26 20:22:32 UTC
README
Platon SDK for PHP.
Changelog |
Usage Examples
Compatibility: tested on PHP 8.4, PHP 8.5
API
Installation
Using composer:
composer require wearesho-team/platon
Usage
Configuration
For configuration you have to use ConfigInterface. Available implementations:
- Config - simple entity. Example:
<?php use Wearesho\Bobra\Platon; $config = new Platon\Config("Key", "Pass", "PaymentType");
- EnvironmentConfig - configuration using getenv. Example:
<?php use Wearesho\Bobra\Platon; $config = new Platon\EnvironmentConfig();
Environment configuration:
| Variable | Required | Default | Description |
|---|---|---|---|
| PLATON_KEY | yes | public key | |
| PLATON_PASS | yes | secret key | |
| PLATON_URL | no | https://secure.platononline.com/ | base url to make C2C requests |
| PLATON_PAYMENT | no | CC | default payment type |
| PLATON_LANGUAGE | no | ua | language: ru or ua |
Generating payment configuration
Use Client to fetch payment config
<?php use Wearesho\Bobra\Platon; use Wearesho\Bobra\Payments; $config = new Platon\EnvironmentConfig(); $client = new Platon\Client($config); $payment = $client->createPayment( new Payments\UrlPair( 'http://redirect-url-on-success', 'http://redirect-url-on-fail' ), new Platon\Transaction( $serviceId = 1, $amount = 500, $paymentType = 'paymentType', $description = 'description for payment', $ext = [ 0 => 'some-info' ], // optional, will be returned in notification $currency = 'UAH', // optional $formId = 'Form id for front-end' // optional ) );
Rendering form
<?php $config = $payment->jsonSerialize(); // ['action' => 'URL', 'data' => 'url']
*You should send data to action url.
Notification
Use Notification\Server to create payment instance from platon`s request:
<?php use Wearesho\Bobra\Platon; class PlatonController { public function actionHandle() { // You can use several platon configs in different cases. // Handler will get that one that matches `key` param from platon`s request. // All platon configs should be passed into ConfigProvider. $configProvider = new Platon\Notification\ConfigProvider([ new Platon\Config('First key', 'first pass', 'CC'), new Platon\Config('Second key', 'second pass', 'CC'), ]); $server = new Platon\Notification\Server($configProvider); try { $payment = $server->handle($_POST); } catch (Platon\Notification\InvalidSignException $exception) { // handle invalid sign } catch (\InvalidArgumentException $exception) { // When received data is incorrect or some required fields are empty } // You can use returned Payment instance to save transaction data. } }
Direct Debit
Recurring charge of previously saved card token (no 3DS, customer is not present). Use DirectDebit\Client:
<?php use Wearesho\Bobra\Platon; $client = new Platon\DirectDebit\Client(new Platon\EnvironmentConfig(), new GuzzleHttp\Client()); try { $response = $client->charge(new Platon\DirectDebit\Request( orderId: 'order-1', amount: 100.50, description: 'Recurring charge', cardToken: $cardToken, // from previous payment notification termUrl: 'https://example.com/', phone: '380930000000', email: 'payer@example.com', // the same email as in original payment, if any ext: ['ext1 value', 'ext2 value'], // optional, ext3 is reserved )); // $response['result']: SUCCESS or DECLINED (see $response['decline_reason']) } catch (Platon\DirectDebit\InvalidCardException $exception) { // card token can not be used anymore } catch (Platon\DirectDebit\Exception $exception) { // request failed }
Info
Fetching information about account balance. Use Info\ConfigInterface for configuration. EnvironmentConfig available:
| Variable | Required | Description |
|---|---|---|
| PLATON_INFO_PUBLIC_KEY | yes | Public Key for Info API |
| PLATON_INFO_PRIVATE_KEY | yes | Private Key for Info API |
<?php use Wearesho\Bobra\Platon; $publicKey = readline("Public Key: "); $privateKey = readline("Private Key: "); $config = new Platon\Info\Config($publicKey, $privateKey); $client = new GuzzleHttp\Client(); $repository = new Platon\Info\Repository($config, $client); // All items can be converted to string and JSON formats $responses = $repository->get();
See Info\Response for details.