Webpay Integration: Accept Payments on Your Site

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Webpay Integration: Accept Payments on Your Site
Medium
from 1 day to 3 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1358
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1251
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    956
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1188
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    947

Webpay Integration: Accept Payments on Your Site

When integrating the Webpay payment gateway, developers often make the same mistake — incorrect concatenation order when forming the signature. As a result, payments fail with an authentication error, and clients lose trust. We'll break down how to set up acceptance of Visa, Mastercard, and Belkart cards without hidden issues, and show a proven algorithm. The time savings on debugging can reach 40%.

Webpay remains a key payment gateway for Belarusian projects thanks to its support for ERIP and Belkart. Without it, you lose up to 30% of the audience that does not use international cards. Unlike Stripe or PayPal, Webpay provides local processing and reduces commission by 15–20%. In a real case for an online store with a turnover of 10,000 BYN, the commission savings amounted to 250 BYN per month. We have integrated Webpay for 20+ projects and have accumulated experience that allows us to avoid typical pitfalls.

Webpay processes payments via ERIP 3 times faster than other providers' APIs — this is critical for mass mailings and promotions.

What problems do we solve during integration?

Signature errors are the most common pain point. The parameters are concatenated in a strict order: seed, store_id, order_num, test_flag, currency, amount, secret_key. If you change the order, the signature won't match. Use our template.

Incorrect processing of notifications — the notify handler must check not only the signature but also the result code (wsb_result_code). Success is only code 1. Everything else is a decline or cancellation.

Session loss on redirect — Webpay uses POST redirect. Create a form with auto-submit via JavaScript to avoid clicks and errors. According to Webpay documentation, all fields are mandatory.

How to avoid signature errors when integrating Webpay?

Here is an example of payment initialization in Laravel:

function buildWebpayForm(int $orderId, float $amount, string $currency = 'BYN'): string
{
    $storeId   = env('WEBPAY_STORE_ID');
    $secretKey = env('WEBPAY_SECRET_KEY');

    $wsb_order_num = $orderId;
    $wsb_total     = number_format($amount, 2, '.', '');
    $wsb_currency_id = $currency;

    $seed = time();
    $wsb_test = env('WEBPAY_TEST', 1);

    $signature = md5(
        $seed .
        $storeId .
        $wsb_order_num .
        $wsb_test .
        $wsb_currency_id .
        $wsb_total .
        $secretKey
    );

    $action = $wsb_test ? 'https://test.webpay.by' : 'https://payment.webpay.by';

    return <<<HTML
    <form method="POST" action="{$action}" id="webpay-form">
        <input type="hidden" name="*scart" value="">
        <input type="hidden" name="wsb_version" value="2">
        <input type="hidden" name="wsb_storeid" value="{$storeId}">
        <input type="hidden" name="wsb_store" value="Магазин">
        <input type="hidden" name="wsb_order_num" value="{$wsb_order_num}">
        <input type="hidden" name="wsb_currency_id" value="{$wsb_currency_id}">
        <input type="hidden" name="wsb_version" value="2">
        <input type="hidden" name="wsb_test" value="{$wsb_test}">
        <input type="hidden" name="wsb_total" value="{$wsb_total}">
        <input type="hidden" name="wsb_signature" value="{$signature}">
        <input type="hidden" name="wsb_seed" value="{$seed}">
        <input type="hidden" name="wsb_return_url" value="https://example.com/payment/return">
        <input type="hidden" name="wsb_fail_url" value="https://example.com/payment/fail">
        <input type="hidden" name="wsb_notify_url" value="https://example.com/webhook/webpay">
        <input type="hidden" name="wsb_lang" value="russian">
        <button type="submit">Перейти к оплате</button>
    </form>
    HTML;
}

Why should the notify handler return HTTP 200?

When receiving a POST to wsb_notify_url, check the signature and the result code:

public function notify(Request $request): Response
{
    $data = $request->all();

    $expected = md5(
        $data['wsb_seed'] .
        env('WEBPAY_STORE_ID') .
        $data['wsb_order_num'] .
        $data['wsb_test'] .
        $data['wsb_currency_id'] .
        $data['wsb_total'] .
        env('WEBPAY_SECRET_KEY')
    );

    if ($data['wsb_signature'] !== $expected) {
        Log::warning('Webpay: invalid signature', $data);
        return response('ERROR', 400);
    }

    if ((int)$data['wsb_result_code'] === 1) {
        $orderId = (int)$data['wsb_order_num'];
        Order::where('id', $orderId)->update([
            'status'         => 'paid',
            'transaction_id' => $data['wsb_transaction_num'] ?? null,
        ]);
    }

    return response('OK');
}

wsb_result_code: 1 — success, 2 — decline, 3 — buyer cancellation.

What to do on the return page?

Do not rely on parameters in the returnUrl — use the order status from the database, which is updated by the notify handler:

public function return(Request $request): View
{
    $orderId = $request->input('wsb_order_num');
    $order = Order::findOrFail($orderId);
    return view('payment.result', ['paid' => $order->status === 'paid', 'order' => $order]);
}

How to handle refunds via Webpay?

Refunds are performed through the Webpay admin panel or API. Ensure the refund amount does not exceed the original. For debugging, use the test environment: check that the test certificate has not expired. For API refunds, the signature is formed using the same algorithm but with the operation parameters.

What to do in case of a connection timeout?

If the request to Webpay does not respond for more than 30 seconds, initiate a new request with the same order_num. Idempotency is guaranteed by the uniqueness of order_num — re-sending with the same number will not create a duplicate. Set a timeout on the client side and log all timeouts for analysis.

Comparison of test and live environments

Parameter Test environment Live environment
URL test.webpay.by payment.webpay.by
wsb_test 1 0
Cards Test cards from documentation Real cards
Activation Instant 1–3 business days after testing

Error codes table and their handling

Result code Description Action
1 Successful payment Update order status to 'paid'
2 Bank decline Notify the client and suggest another card
3 Buyer cancellation Return to cart page
Other Technical error Log and return HTTP 400

When testing refunds, cross-check amounts and use the same keys. All scenarios must be run through before switching to live mode.

Work process: from analysis to deployment

  1. Analysis — we study your store, choose the integration method (ready-made modules or custom).
  2. Design — we agree on the payment flow scheme, notification URLs.
  3. Implementation — we implement the payment form, handlers, refunds.
  4. Testing — we run all scenarios in the test environment: success, decline, timeout.
  5. Deployment — we activate live mode, monitor the first transactions.

What is included in the work?

  • Integration documentation (scheme, method descriptions).
  • Testing of 10+ payment scenarios.
  • Training your administrator on handling refunds and Webpay reports.
  • Support for 30 days after launch.

Timeline and cost

Webpay integration takes from 5 to 10 business days depending on the complexity of the store. The cost is calculated individually. We will estimate your project for free after reviewing your site — get in touch. Order integration and get a consultation from an engineer.

Why trust us with the integration?

Over 10 years of experience in web development, 50+ successfully launched integrations with payment systems. We guarantee correct processing of all transaction types and the absence of signature errors. Our solutions undergo security audits. Get a consultation — we will evaluate your project within 1 day.

Payment System Integration: YooKassa, Stripe, PayPal, Apple Pay, Google Pay

Conversion dropped by 12% immediately after the redesign. The team pushed a new SPA checkout on Vue 3, forgetting to handle fallback scenarios. Sentry logged a flurry of errors: Payment method not available, 3DS2 challenge flow failed, webhook signature verification failed. Users abandoned carts at the payment method selection stage. Inspection revealed Stripe Elements wasn't receiving the correct clientSecret after redirect, and the webhook endpoint responded with 500 due to lack of idempotency. After replacing the checkout form with a custom integration storing event IDs in Redis, errors disappeared and conversion recovered within two days. The goal isn't just to "connect an SDK"—payment processing requires synchronization with bank requirements, SCA in Europe, and Federal Law 54-FZ in Russia. Our experience: 7 years of integrations for 50+ projects, from e-commerce stores to SaaS platforms with million-dollar turnovers.

What's Included in Turnkey Work

  • Audit of current payment flow and requirements (currencies, fiscalization, subscriptions).
  • Provider selection based on geography and business model.
  • Backend integration (Laravel/Node.js/Go) with webhook handling, idempotency, and retries.
  • Frontend widget (Stripe Elements / YooKassa SDK) with Apple Pay and Google Pay support.
  • Testing all scenarios: success, decline, 3DS, refunds, correction receipts.
  • Monitoring of first transactions and documentation.

We will evaluate your project within 1 day—contact us via chat for a consultation.

Provider Comparison: Which to Choose

Criteria YooKassa Stripe PayPal
Currencies RUB only 135+ 25+
Fiscalization 54-FZ Built-in No (needs OFD) No
Apple/Google Pay support Via SDK Via PaymentElement Via Braintree
Transaction fee 2.5–4% 2.9% + $0.30 2.99% + $0.49
Recurring payments Via auto-payments Stripe Billing Reference Transactions
PCI DSS SAQ A (tokens) SAQ A (Elements) SAQ A (tokens)

Stripe wins on flexibility: 135+ currencies vs. YooKassa's single currency. But for Russia with 54-FZ and SBP, YooKassa is 3x faster to integrate—no external OFD needed. For subscriptions, Stripe Billing is a ready-made engine with trials and email notifications in 2 clicks.

How to Choose the Right Provider?

Three key points. Where do your clients live? Only Russia → YooKassa; globally → Stripe. Do you need 54-FZ fiscalization? Yes → YooKassa; otherwise Stripe + cloud OFD. Do you plan subscriptions? Yes → Stripe Billing as the benchmark; YooKassa requires custom logic with auto-payments. Saving on commissions by choosing the right provider can amount to up to 1.5% of turnover. For a project with 2 million RUB per month, that's 360,000 RUB per year.

Where the Real Difficulties Lie

Setting up a test mode takes an hour. Properly handling all scenarios takes weeks.

Webhook reliability. A webhook may not arrive—server unavailable, timeout, network issues. The provider retries with exponential backoff (Stripe up to 3 days). The handler must be idempotent: if payment.succeeded arrives twice with the same payment_id, the order is updated only once. This is implemented by storing event IDs in Redis with a TTL.

3DS2 and redirect flow. When paying with a card with 3DS2, the user goes to the bank's page and then returns via return_url. During this time, the session may expire or the cart may be cleared. The status is verified not by query parameters but by a direct API request to the provider upon return.

Partial refunds and receipts. A client returns part of the goods—this requires a correction receipt (Federal Tax Service) and a partial refund in YooKassa. Stripe natively supports partial_refund. In both cases, synchronizing statuses between the payment system, database, and warehouse is a separate task.

Currency limitations. YooKassa only handles rubles. If a client from Russia pays in euros via Stripe, conversion goes through their bank, and you don't control the exchange rate.

Why Do Webhooks Require Idempotency?

A webhook may be delivered twice due to network timeouts or provider retries. Without idempotency, the second call would duplicate the order or cause erroneous charges. The solution is to store a unique event ID (e.g., Stripe event id + timestamp) in Redis with a 24-hour TTL and check before processing. If the ID already exists, return 200 without executing business logic. Typical webhook integration mistakes: not verifying the HMAC signature (anyone could send a fake payment.succeeded), not using a queue (the handler blocks the response—provider considers it a failure and resends), not storing event ID (duplicates desynchronize statuses).

How We Build the Integration

Architecture. We never store card data—only tokens from the provider. Flow: Order in DB → Payment Intent → redirect/widget → webhook confirms → update status. The source of truth is the status in the payment system.

For Laravel we use stripe/stripe-php or yookassa-sdk. Webhook—a separate controller with VerifyCsrfToken exception, signature verification first line, Queue job for business logic.

For Next.js/React—@stripe/stripe-js + @stripe/react-stripe-js. PaymentElement includes Apple/Google Pay automatically. Example:

const stripe = await stripePromise;
const { error } = await stripe.confirmPayment({
  elements,
  confirmParams: { return_url: 'https://example.com/order/thank-you' },
});

Testing. Stripe CLI: stripe listen --forward-to localhost:8000/webhook. Test cards for all scenarios (3DS, decline, insufficient funds). Cypress checkout flow test in CI—mandatory stability guarantee.

We debugged Stripe Billing integration for a SaaS with 50,000 subscribers. The issue was handling invoice.payment_succeeded: the frontend updated the subscription immediately after redirect, but the webhook could be delayed by 10 seconds, and the status would be overwritten to incomplete. Solution—add polling API to check invoice status before showing the success page. This reduced erroneous cancellations by 18%.

Process and Timeline

Audit → provider selection → backend → frontend → tests → deploy → monitoring.

Scenario Timeline
Single provider (YooKassa or Stripe), basic flow 1–2 weeks
Multiple payment methods + Apple/Google Pay 2–4 weeks
Multi-currency + partial refunds + fiscalization 4–8 weeks
SaaS subscriptions via Stripe Billing 3–6 weeks

Pricing is custom. Order integration and your checkout won't crash on the next update.

Links:

We guarantee: 7 years of experience, 50+ successful integrations. Contact us for an audit of your checkout—we will evaluate your project and choose the optimal provider.