PHP code example of jarnovanleeuwen / php-tikkie

1. Go to this page and download the library: Download jarnovanleeuwen/php-tikkie 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/ */

    

jarnovanleeuwen / php-tikkie example snippets


use PHPTikkie\Environment;
use PHPTikkie\PHPTikkie;

$apiKey = "abc123";
$testMode = true;

$environment = new Environment($apiKey, $testMode);
$environment->loadPrivateKey('private_rsa.pem');

$tikkie = new PHPTikkie($environment);

use PHPTikkie\Entities\Platform;

$platform = $tikkie->newPlatform([
    // Mandatory attributes
    'name' => 'YourPlatform',
    'phoneNumber' => '06123456789',
    'platformUsage' => Platform::USAGE_TYPE_MYSELF,

    // Optional attributes
    'email' => '[email protected]',
    'notificationUrl' => ''
])->save();

$platformToken = $platform->platformToken;

$user = $tikkie->newUser($platformToken, [
    'name' => 'ExamplePlatform',
    'phoneNumber' => '06123456789',
    'iban' => 'NL00BANK123456789',
    'bankAccountLabel' => 'YourLabel'
])->save();

$userToken = $user->userToken;
$bankAccountToken = $user->bankAccounts[0]->bankAccountToken;

$paymentRequest = $tikkie->newPaymentRequest($platformToken, $userToken, $bankAccountToken, [
    // Mandatory attributes
    'amountInCents' => '1250',
    'currency' => 'EUR',
    'description' => 'Thank you',
    'externalId' => 'Order 1234'
])->save();

$tikkieUrl = $paymentRequest->paymentRequestUrl;
$paymentRequestToken = $paymentRequest->paymentRequestToken;

function paymentRequest(string $platformToken, string $userToken, string $paymentRequestToken): PaymentRequest

function platforms(): Platform[]

function users(string $platformToken): User[]

function paymentRequests(string $platformToken, string $userToken, int $offset, int $limit, DateTimeInterface $fromDate = null, DateTimeInterface $toDate = null): PaymentRequest[]

$paymentRequest = $tikkie->paymentRequest($platformToken, $userToken, $paymentRequestToken);

foreach ($paymentRequest->payments as $payment) {
    if ($payment->isPaid()) {
        // Payment successful
    }
}