PHP client implementing kevin. API.
- PHP 5.6 or later
- To install latest kevin. PHP Client repository using composer:
composer require getkevin/kevin-php
- Using Composer autoloader, include kevin. PHP Client:
require('vendor/autoload.php');
Detailed information about available versions can be found at packagist repository:
Parameter names and response data match those defined in API documentation.
Detailed API documentation can be found here.
use Kevin\Client;
$clientId = 'my-client-id';
$clientSecret = 'my-client-secret';
$options = ['error' => 'array', 'version' => '0.3', 'lang' => 'en'];
$kevinClient = new Client($clientId, $clientSecret, $options);
$clientId
- Your client id. Your can get it in kevin. platform console.
$clientSecret
- Your client secret. Your can get it in kevin. platform console.
$options
- Optional options array.
error
- Defines return type of error data. Possible values are:array
- returns an array on error,exception
- throws an exception on error, default value isexception
.
version
- Selects API versions to use. Default value is0.3
. Possible values are0.1
,0.2
or0.3
.
lang
- a two-letter lowercase language code defined in ISO 639-1 standart. Sets the language of the frame page.
$response = $kevinClient->auth()->getCountries();
$attr = ['countryCode' => 'LT'];
$response = $kevinClient->auth()->getBanks($attr);
$bankId = 'SEB_LT_SAND';
$response = $kevinClient->auth()->getBank($bankId);
$response = $kevinClient->auth()->getProjectSettings();
$attr = [
'redirectPreferred' => 'false',
'scopes' => 'payments,accounts_basic',
'Request-Id' => 'your-guid',
'Redirect-URL' => 'https://redirect.kevin.eu/authorization.html'
];
$response = $kevinClient->auth()->authenticate($attr);
$attr = ['code' => 'your-auth-code'];
// ...or $attr = 'your-auth-code';
$response = $kevinClient->auth()->receiveToken($attr);
$attr = ['refreshToken' => 'your-refresh-token'];
// ...or $attr = 'your-refresh-token';
$response = $kevinClient->auth()->refreshToken($attr);
$attr = ['Authorization' => 'your-bearer-token'];
// ...or $attr = 'your-bearer-token';
// ...or $attr = 'Bearer your-bearer-token';
$response = $kevinClient->auth()->receiveTokenContent($attr);
$attr = [
'Redirect-URL' => 'https://redirect.kevin.eu/payment.html',
'description' => 'Test',
'currencyCode' => 'EUR',
'amount' => '0.01',
'bankPaymentMethod' => [
'endToEndId' => '1',
'creditorName' => 'John Smith',
'creditorAccount' => [
'iban' => 'LT0000000000000000'
],
],
];
$response = $kevinClient->payment()->initPayment($attr);
$attr = [
'Redirect-URL' => 'https://redirect.kevin.eu/payment.html',
'description' => 'Test',
'currencyCode' => 'EUR',
'amount' => '0.01',
'bankPaymentMethod' => [
'endToEndId' => '1',
'creditorName' => 'John Smith',
'creditorAccount' => [
'iban' => 'LT0000000000000000',
],
],
'cardPaymentMethod' => [],
'paymentMethodPreferred' => 'card',
];
$response = $kevinClient->payment()->initPayment($attr);
$attr = [
'Redirect-URL' => 'https://redirect.kevin.eu/payment.html',
'description' => 'Test',
'currencyCode' => 'EUR',
'amount' => '0.01',
'bankPaymentMethod' => [
'endToEndId' => '1',
'creditorName' => 'John Smith',
'creditorAccount' => [
'iban' => 'LT0000000000000000'
],
],
'cardPaymentMethod' => [],
];
$response = $kevinClient->payment()->initPayment($attr);
$paymentId = 'your-payment-id';
$response = $kevinClient->payment()->getPayment($paymentId);
$paymentId = 'your-payment-id';
$response = $kevinClient->payment()->getPaymentStatus($paymentId);
$paymentId = 'your-payment-id';
$attr = [
'amount' => '1.00',
'Webhook-URL' => 'https://yourapp.com/notify'
];
$response = $kevinClient->payment()->initiatePaymentRefund($paymentId, $attr);
$paymentId = 'your-payment-id';
$response = $kevinClient->payment()->getPaymentRefunds($paymentId);
$accessToken = 'your-bearer-token';
$attr = [
'Authorization' => $accessToken,
'PSU-IP-Address' => 'your-ip-address',
'PSU-User-Agent' => 'your-user-agent',
'PSU-IP-Port' => 'your-ip-port',
'PSU-Http-Method' => 'GET',
'PSU-Device-ID' => 'your-device-id'
];
$response = $kevinClient->account()->getAccountList($attr);
$accountId = 'your-account-id';
$accessToken = 'your-bearer-token';
$attr = [
'Authorization' => $accessToken,
'PSU-IP-Address' => 'your-ip-address',
'PSU-User-Agent' => 'your-user-agent',
'PSU-IP-Port' => 'your-ip-port',
'PSU-Http-Method' => 'GET',
'PSU-Device-ID' => 'your-device-id'
];
$response = $kevinClient->account()->getAccountDetails($accountId, $attr);
$accountId = 'your-account-id';
$accessToken = 'your-bearer-token';
$attr = [
'Authorization' => $accessToken,
'PSU-IP-Address' => 'your-ip-address',
'PSU-User-Agent' => 'your-user-agent',
'PSU-IP-Port' => 'your-ip-port',
'PSU-Http-Method' => 'GET',
'PSU-Device-ID' => 'your-device-id',
'dateFrom' => '2021-09-01',
'dateTo' => '2021-09-15'
];
$response = $kevinClient->account()->getAccountTransactions($accountId, $attr);
$accountId = 'your-account-id';
$accessToken = 'your-bearer-token';
$attr = [
'Authorization' => $accessToken,
'PSU-IP-Address' => 'your-ip-address',
'PSU-User-Agent' => 'your-user-agent',
'PSU-IP-Port' => 'your-ip-port',
'PSU-Http-Method' => 'GET',
'PSU-Device-ID' => 'your-device-id'
];
$response = $kevinClient->account()->getAccountBalance($accountId, $attr);
❗ We recommend ignoring the webhook if the signature is older than 5 minutes.
use Kevin\SecurityManager;
$endpointSecret = 'your-endpoint-secret';
$webhookUrl = 'your-webhook-url';
// Timestamp is provided in milliseconds
$timestampTimeout = 300000;
$requestBody = file_get_contents("php://input");
$headers = getallheaders();
$isValid = SecurityManager::verifySignature($endpointSecret, $requestBody, $headers, $webhookUrl, $timestampTimeout);
Before making any code changes, make sure to run composer install
to install development requirements.
We are using PHP CS Fixer GitHub action to conduct code style checks for each commit and pull request. Make sure to run composer fix-style
before
committing changes to make sure your code matches our style standards. Pull requests with failed style checks will not
be approved.
WARNING: we use risky rules so make sure to check for breaking style fixes.
Style errors and violated rules log can be viewed by running composer check-style
command.
Email: [email protected]
- MIT license
- Copyright© 2020 kevin.