Skip to main content

Test your integration

Use GOV.UK Pay testing features to check your integration before you go live, and to test changes after your service is live.

The way you test depends on:

  • whether your service is live
  • which payment service provider (PSP) you use
  • whether you are testing the GOV.UK Pay API, the full user journey, or both

Choose a testing mode

Each GOV.UK Pay service has one test point.

You can use it in 2 modes:

  • ‘not live yet’ for a new service
  • sandbox for a live service

Use ‘not live yet’ for a new service

When you first create a GOV.UK Pay service, it is labelled ‘not live yet’ in the GOV.UK Pay admin tool.

Use this mode to:

  • explore how the GOV.UK Pay API works
  • test payments
  • test service settings
  • check your integration before you go live

Use sandbox for a live service

After your service goes live, use sandbox mode to test changes.

To enter sandbox mode:

  1. From the admin tool dashboard, select Enter sandbox mode.
  2. On the Enter sandbox mode page, select Enter sandbox mode.

You can use sandbox mode to:

  • make test payments
  • view test transactions
  • try different settings and functionality
  • run automated smoke tests

Changes in sandbox mode do not affect your live service. Users can still make payments to the live version.

You can leave sandbox mode at any time.

 Important limitations when testing GOV.UK Pay

Do not use both testing modes for automated integration tests that run when you change your code.

If you need automated integration tests, build a stub to simulate the GOV.UK Pay API instead. For example, you can use WireMock.

In sandbox mode, use the same test API keys created in ‘not live yet’ mode. Create new live API keys only when you go live to take payments.

 What you can test by payment service provider

If your PSP is Stripe

If your service uses Stripe, you can use ‘not live yet’ and sandbox modes to test:

  • transaction fees
  • payments to your bank account
  • 3D Secure (3DS) with specific test card numbers

If your PSP is Worldpay

If your service uses Worldpay, you can use ‘not live yet’ and sandbox modes for:

  • reporting on payments
  • smoke testing
  • viewing transactions
  • refunding transactions

Worldpay does not support 3DS testing in sandbox mode.

 Worldpay test accounts

You can link a Worldpay test account to GOV.UK Pay.

Some services use a Worldpay test account to connect GOV.UK Pay to Worldpay reporting products.

Most organisations do not need a Worldpay test account. We do not recommend using one unless you have a clear reason.

If you use a Worldpay test account:

  • GOV.UK Pay cannot support problems with the account
  • you should not use it for long-term automated testing

To ask for a Worldpay test account, email govuk-pay-support@digital.cabinet-office.gov.uk.

If we approve your request, we will add the test account as a separate GOV.UK Pay service.

 Test the whole user journey

Test the full user journey as well as the API.

You can create a reusable link in the GOV.UK Pay admin tool. It behaves like a payment link created through the API.

You can use the link to:

  • open a GOV.UK Pay payment page from your prototype
  • complete a test payment
  • send the user back to your service with a return_url
  • test the full payment journey

To create a reusable payment link:

  1. Sign in to the the GOV.UK Pay admin tool.
  2. Select the service you want to test in My services.
  3. Select Test with your users to create the link.

You can also:

  • use mock card numbers to test successful and unsuccessful payments
  • use HTTP instead of HTTPS for the return_url while your service is in sandbox or ‘not live yet’ mode
  • test any payment links you have already set up

You do not need to set up a secure URL for testing.

Performance testing

You must contact us to get written approval before you do any performance testing.

 Use mock card numbers

Use mock card numbers when you test payments. Do not use real card numbers.

You can use any valid value for the other payment fields. For example, the card expiry date can be any future date.

Mock card numbers work for all test payments in sandbox and ‘not live yet’ modes.

There are separate sets of mock card numbers for:

Mock card numbers for Stripe

The PSP transaction fee depends on the card country.

Testing action Card number Card brand Card type Country
Successful payment 4000008260000000 Visa Credit UK
Successful payment 4000058260000005 Visa Debit UK
Successful payment 4000002500000003 Visa Credit France
Successful payment 4242424242424242 Visa Credit US
Successful payment 4000056655665556 Visa Debit US
Successful payment 5105105105105100 Mastercard Debit US
Successful payment 5200828282828210 Mastercard Debit US
Successful payment 371449635398431 American Express Credit US
Requires 3DS check 4000002500003155 Visa Credit France
Card declined 4000000000000002 Visa Credit or debit US
Card expired 4000000000000069 Visa Credit or debit US
Invalid CVC code 4000000000000127 Visa Credit or debit US
Payment disputed and lost 4000000000000259 Visa Credit US
Payment disputed and won 4000000000002685 Visa Credit US
General error 4000000000000119 Visa Credit or debit US

Test recurring payments for a Stripe service

There are additional mock card numbers to test recurring payments with Stripe.

Use these mock card numbers to test recurring payments with Stripe.

Recurring payments have 2 steps:

  1. Take an initial payment to set up an agreement.
  2. Take later recurring payments automatically.

Each test card gives a result for both steps.

Testing actions Card number Card brand Card type Country
Successful set up payment without 3DS

Successful recurring payments
4242424242424242 Visa Credit US
Successful set up payment with 3DS

Successful recurring payments
4000002500003155 Visa Credit France
Successful set up payment with 3DS

Unsuccessful recurring payments
4000002760003184 Visa Credit Germany
Unsuccessful set up payment 4000000000009995 Visa Credit US

Mock card numbers for Worldpay

Testing action Card number Card brand Card type
Successful payment 4444333322221111 Visa Credit
Successful payment 4242424242424242 Visa Credit
Successful payment 4000056655665556 Visa Debit
Successful payment 4988080000000000 Visa Debit - corporate
Successful payment 4000160000000004 Visa Debit - prepaid
Successful payment 4131840000000003 Visa Debit - corporate prepaid
Successful payment 4111111111111111 Visa Credit - corporate
Successful payment 4000000000000010 Visa Credit or debit
Successful payment 222100000000000 Mastercard Credit
Successful payment 5105105105105100 Mastercard Debit
Successful payment 5200828282828210 Mastercard Debit
Successful payment 371449635398431 American Express Credit
Successful payment 3566002020360505 JCB Credit
Successful payment 6011000990139424 Discover Credit
Card type not accepted 6759649826438453 Maestro Debit
Card declined 4000000000000002 Visa Credit or debit
Card expired 4000000000000069 Visa Credit or debit
Invalid CVC code 4000000000000127 Visa Credit or debit
General error 4000000000000119 Visa Credit or debit

Test recurring payments for a Worldpay service

Use these mock card numbers to test recurring payments with Worldpay.

Recurring payments have 2 steps:

  1. Take an initial payment to set up an agreement.
  2. Take later recurring payments automatically.

Each test card gives a result for both steps.

Testing actions Card number Card brand Card type
1. Successful set up payment

2. Successful recurring payment
4000056655665556 Visa Debit
1. Successful set up payment

2. Unsuccessful recurring payment
5105105105105100 Mastercard Debit

 Use mock email addresses

If you are testing manually, you can use real email addresses.

If you are doing automated tests, you must use one of these mock email addresses.

  • simulate-delivered@notifications.service.gov.uk
  • simulate-delivered-2@notifications.service.gov.uk
  • simulate-delivered-3@notifications.service.gov.uk