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
- The app creates a payment with the provider and redirects the user.
- The user pays by card, BLIK or bank transfer.
- The provider sends a webhook to the app’s server with the payment status.
- 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
| scenario | expected result |
|---|---|
| successful payment | order paid, confirmation email, goods reserved |
| declined payment, e.g. insufficient funds | order unpaid, a clear message, option to retry |
| payment with 3D Secure, confirmed and declined | both results handled, no stuck order |
| user abandons the payment and comes back | order awaits payment, not cancelled straight away |
| browser closed after payment | order paid anyway thanks to the webhook |
| double click on “pay” | one payment |
| full and partial refund | correct amount, status, credit note and email |
| payment after the payment deadline | clear handling, no paid but cancelled order |
| amounts with cents and large amounts | the 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
| scenario | how to trigger | expected result |
|---|---|---|
| duplicate | the same event sent a second time | one status change, one email |
| wrong order | “refunded” before “paid” | final status correct, does not go backwards |
| delay | webhook after a few minutes | user sees “awaiting payment”, then “paid” |
| app server outage | endpoint returns 500, provider retries | order paid after the retry |
| invalid signature | modified signature header | rejected, no changes to the order |
| unknown order | event with a foreign identifier | logged, no server error |
| amount different from the order | modified amount in the event | order 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.