Skip to main content

Starting a BLIK Level 0 Transaction

To start a transaction, the following parameters should be included in the options parameter:

  • blikCode – 6-digit BLIK code
  • ip – payer IP address
  • companyAddressStreet – company address (street, building number, apartment number), displayed in the banking application (optional)
  • companyAddressCity – company address (city), displayed in the banking application (optional)

The response to the request will contain the standard transaction initiation response object.

In the case of providing an incorrect or already used BLIK code, you will immediately receive a standard error object in response, containing more detailed reasons for the payment rejection.

In this payment method, shop system should wait for an asynchronous notification of the transaction status, rather than redirecting the user using redirectUrl. After successfully initiating the transaction, user must confirm it in their banking app.

info

To start the transaction correctly, you must fill in all required fields, including email, paymentChannel, ip and blikCode.

Example request​

<?php

$shopId = ""; // Payment Point ID
$secretPhrase = ""; // Payment Point Secret
$mainUrl = "https://pay.cashbill.pl/ws/rest";


$transaction = [
"title" => "Example BLIK Level 0 #1",
"amount" => [
"value" => 1.23,
"currencyCode" => "PLN"
],
"personalData" => [
"email" => "example@mail.com"
],
"returnUrl" => "https://cashbill.pl",
"description" => "Transaction description example",
"additionalData" => "#1",
"paymentChannel" => "blik_7517",
"options" => [
["name" => "ip", "value" => "XX.XXX.XX.XX"],
["name" => "blikCode", "value" => "123456"],
["name" => "companyAddressCity", "value" => "Katowice"],
["name" => "companyAddressStreet", "value" => "ul. Sobieskiego 2"]
]
];


$signData = $transaction['title']
. $transaction['amount']['value']
. $transaction['amount']['currencyCode']
. $transaction['returnUrl']
. $transaction['description']
. $transaction['additionalData']
. $transaction['paymentChannel']
. $transaction['personalData']['email'];

foreach ($transaction['options'] as $option) {
$signData .= $option['name'] . $option['value'];
}

$transaction['sign'] = sha1($signData . $secretPhrase);


$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "{$mainUrl}/payment/{$shopId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($transaction)
]);

$response = json_decode(curl_exec($ch));
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode != 200) {
echo "Error: " . $response->errorMessage;
} else {
echo "Transaction ID: " . $response->id;
}