PHP code example of getkevin / kevin-php

1. Go to this page and download the library: Download getkevin/kevin-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

getkevin / kevin-php example snippets




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);

$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);

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);