Skip to content
TestLine Menu
TestLine
API

How to test webhooks and payment integrations (Stripe, PayU, Przelewy24)

The scenarios that most often break payments in production, how to trigger them in a sandbox and what to check on the order side, not just in the gateway.

author
Artur Machowski, Senior QA Engineer
published
reading
7 min

Short answer

You test payments in the provider’s sandbox (Stripe in test mode, PayU and Przelewy24 in their sandbox environments), but most bugs are not in the gateway itself. They are in how the app handles payment notifications, i.e. webhooks. The key scenarios are: a duplicate notification, wrong order, delay, outage and retry, an invalid signature, and a browser closed after payment. In each one you check the order status, the amount, emails, stock levels and that the payment was not booked twice.

How a payment with a webhook works

  1. The app creates a payment with the provider and redirects the user.
  2. The user pays by card, BLIK or bank transfer.
  3. The provider sends a webhook to the app’s server with the payment status.
  4. The user returns to the thank-you page.

Steps 3 and 4 can arrive in any order, and step 4 may never arrive at all. That is why the webhook, not the return page, should change the order status. With some providers, e.g. Przelewy24, after the notification the app must also confirm the transaction with a separate API call. Without it the payment is not booked.

Payment scenarios

scenarioexpected result
successful paymentorder paid, confirmation email, goods reserved
declined payment, e.g. insufficient fundsorder unpaid, a clear message, option to retry
payment with 3D Secure, confirmed and declinedboth results handled, no stuck order
user abandons the payment and comes backorder awaits payment, not cancelled straight away
browser closed after paymentorder paid anyway thanks to the webhook
double click on “pay”one payment
full and partial refundcorrect amount, status, credit note and email
payment after the payment deadlineclear handling, no paid but cancelled order
amounts with cents and large amountsthe same amount in the app, at the provider and on the invoice

Stripe test mode has ready-made cards, e.g. 4242 4242 4242 4242 for a successful payment, 4000 0000 0000 0002 for a declined one and 4000 0027 6000 3184 for a payment with 3D Secure. PayU and Przelewy24 have their own sandbox test data described in their documentation.

Webhook scenarios

scenariohow to triggerexpected result
duplicatethe same event sent a second timeone status change, one email
wrong order“refunded” before “paid”final status correct, does not go backwards
delaywebhook after a few minutesuser sees “awaiting payment”, then “paid”
app server outageendpoint returns 500, provider retriesorder paid after the retry
invalid signaturemodified signature headerrejected, no changes to the order
unknown orderevent with a foreign identifierlogged, no server error
amount different from the ordermodified amount in the eventorder is not marked as paid

With Stripe you can trigger events from the command line:

stripe listen --forward-to localhost:3000/webhooks/stripe
stripe trigger payment_intent.succeeded
stripe events resend evt_123

The last command sends the same event a second time, i.e. it checks the duplicate case. For PayU and Przelewy24, notifications arrive at the address given when the payment is created, so staging must be reachable from the internet.

What to check after every payment

  • the order status in the app and in the provider’s dashboard is the same;
  • the amount and currency match to the cent;
  • the email went out once, not zero or two times;
  • stock or access to the service changed once;
  • the invoice has the right details and VAT;
  • the logs contain the payment ID but no card data.

How I can help

I test payment integrations and webhooks as part of API testing: payment, refund and notification scenarios in the sandbox, with automated tests in CI. A full API test suite usually costs PLN 10,000-15,000 net. Before a shop launch, payments are part of the review described in the guide e-commerce testing before peak season. Describe your integration in the contact form.

Frequently asked questions

How do I test payments without real money?

In the provider's sandbox: Stripe has a test mode with test cards, while PayU and Przelewy24 have separate sandbox environments with their own credentials. The app on staging must be connected to the sandbox, not to production.

What is a webhook in payments?

It is a notification the payment provider sends to the shop's server when a payment status changes, e.g. paid, declined, refunded. The webhook, not the user returning to the site, should change the order status.

Which webhook scenarios matter most?

A duplicate of the same notification, notifications in the wrong order, a delayed notification, a temporary outage of the shop's server and a retry, an invalid signature, and a payment after which the user closed the browser.

How do I test a webhook locally?

With Stripe, use the Stripe CLI: stripe listen forwards events to a local server and stripe trigger fires a chosen event. For other providers you need a public staging address or a tunnel to your local server.

How much does payment testing cost?

Payment and webhook tests are usually part of API testing for PLN 10,000-15,000 net or a pre-launch review for PLN 6,000-10,000 net. The payment scenarios alone usually take 3-5 days of work.

Got a release in a few weeks?

Describe your project in the form. I'll reply with questions about scope or an initial test plan.