arrow_back_iosQuestions
help

How to connect my payment service via the API?

check_circle
You can connect any payment service to Bukza via the payment API. The payment API is available on the Business plan. To connect, you need your own server — a mediator between Bukza and your payment service. Programming skills are also required.
This API is currently in beta mode and may have some changes in the future. If our API is not suitable to connect to your payment gateway, please contact us via support@bukza.com, and we will try to improve it.

Integration options

You can implement one of two options:
  1. "With pre-authorization" — option that prevents overbooking. When the order is completed, the amount is first pre-authorized on the card, and then we additionally check that the order is still available and the price has not changed. If the order is no longer available, the pre-authorization is cancellled immediately.

    You can use this integration option to capture funds later manually. You can verify the reservation yourself and either capture funds or cancel the pre-authorization. However, if the funds are still not captured after 3 days, Bukza will send a request to cancel the pre-authorization.

  2. "Simplified mode" — this is an option without pre-authorization. In other words, the funds have already been captured at the moment when the order is completed. However, we still check the availability and amount of the order, and if there is a problem, we will add a warning for the manager in "New order" message.

    This option should be used if your payment service does not support pre-authorization.

How to enable the API?

Send us a request to support@bukza.com for enabling your payment API. We will ask you for the URL of your server to which Bukza will send requests. We will also send your ID and the key to generate a signature hash (for example: 7kd9sl8s0bsm409rdsk3jn20).

How to generate a signing hash?

The following parameters are always present in requests:
  • userId — your ID in the Bukza system, e.g 11223.
  • orderNumber — an order number in Bukza, e.g "574285869".
  • command — a name of the command to run. One of the values: "GetPaymentData", "CaptureCallback", "AuthorizeCallback", "Cancel", "Capture" or "Refund".
  • data — additional command data, such as the transaction number in your payment system: "18493853499".
  • amount — payment amount, e.g 99.75.
  • timestamp — the number of seconds of Unix time, e.g 1596706182. Examples of getting it in different programming languages: https://www.epochconverter.com.
To create or verify the request signature, you need to concatenate all these parameters into a single string (without spaces or plus signes), calculate hmac sha256 with your key, and convert the result to a base64 string:
hash = base64(hmacSha256(userId + orderNumber + command + data + amount + timestamp), key);
You can check the calculation here: http://jsfiddle.net/dwyrk513/1/
Important points:
  • When converting an amount value to a string, use a dot as the separator if there is a fractional part of the number.
  • When receiving your requests, Bukza checks that the timestamp matches the current server time and does not lag by more than 5 minutes.
  • When receiving requests from Bukza, we recommend you to check the hash and the timestamp in the same way.

Option #1 "With pre-authorization"

1.1. When the order is completed Bukza sends a POST request to your server URL with the following body:
{
    userId:11223,
    orderNumber:"574285869",
    command: "GetPaymentData",
    data: "",
    amount: 99.75,
    timestamp: 1596706182,
    hash: "p2t1xcpBiXLPPDdB129vUctRAgGbzQgRcnX4IiZ0bNE="
}
In response to this request, you should send the data:
{
    url: "https://money.yandex.ru/quickpay/shop-widget?writer=seller&default-sum=99.75&button-text=11&payment-type-choice=on&&quickpay=shop&account=410015219149437",
    redirect: false
}
  • url — this is the generated address of the payment page. This page can be located either on your server or on the server of your payment gateway.
  • redirect — a parameter that determines whether the user should be completely redirected to the specified URL. If the value is false, the payment form will appear inside the widget in an iframe. You can change the size of the iframe using css in the widget settings.
1.2 The customer now sees your payment form and makes the payment. Accordingly, you should receive a notification to your server from your payment gateways. After receiving this notification, you should immediately send a POST request to https://public.bukza.com/api/pay. Request body:
{
    userId:11223,
    orderNumber:"574285869",
    command: "AuthorizeCallback",
    data: "18493853499",
    amount: 99.75,
    timestamp: 1596706182,
    hash: "2kkjjx/grcar6B9yknqUMP6eOdMw4yJwa60Uc8fisNA=",
    comment: "Any comment on the payment. It will be visible in the manager interface. It is not used in the request signature calculation."
}
1.3 Then, depending on the availability of the order and the order processing parameters, Bukza can do one of the following: cancel the pre-authorization, immediately capture the funds, or simply place an order, leaving the funds pre-authorized. In the latter case, you can cancel or capture the payment yourself in the Manager's interface. In any case, Bukza will send requests to your server that you should send to your payment gateway.
To cancel the pre-authorization Bukza sends you a request with the body:
{
    userId:11223,
    orderNumber:"574285869",
    command: "Cancel",
    data: "18493853499",
    amount: 99.75,
    timestamp: 1596706182,
    hash: "ejIS+AiPRSH9qXV/bBcAf7OSViCVUtj/hYPsL4aYpNM="
}
To capture pre-authorized funds Bukza sends you a request with the body:
{
    userId:11223,
    orderNumber:"574285869",
    command: "Capture",
    data: "18493853499",
    amount: 99.75,
    timestamp: 1596706182,
    hash: "JE4fRRLObEzCYk7aRFaW81DZw3sTXTOXsEcq3r8zm+Y="
}
You should send any response with the HTTP status 200 (SUCCESS).

Option #2 "Simplified mode"

2.1 When the order is completed, Bukza also sends a POST request to your server URL, the same way as at the step 1.1.
2.2 The customer now sees your payment form and makes the payment. Accordingly, you should receive a notification to your server from your payment gateways. After receiving this notification, you should immediately send a POST request to https://public.bukza.com/api/pay. Request body:
{
    userId:11223,
    orderNumber:"574285869",
    command: "CaptureCallback",
    data: "18493853499",
    amount: 99.75,
    timestamp: 1596706182,
    hash: "eUKOwld1sEK3axhF9ZAy0WugXMJW+9nrs4BRlvnCeb0=",
    comment: "Any comment on the payment. It will be visible in the manager interface. It is not used in the request signature calculation."
}

Refund

You can use the Manager's interface to issue a refund for a specific payment. The refund can be full or partial. When making a refund, Bukza sends a request to your server. You have to send a corresponding request to your payment gateway. Request body from Bukza:
{
    userId:11223,
    orderNumber:"574285869",
    command: "Refund",
    data: "18493853499",
    amount: 50.75,
    timestamp: 1596706182,
    hash: "E62WH04cKUjAvQ0dmirYMc16mCGN96YyQfrft8vLj0A="
}
You should send any response with the HTTP status 200 (SUCCESS).
Didn't find the answer to your question?
Feel free to ask it at
mail_outline support@bukza.com