Skip to main content

Prefill payment fields

If you collect your users’ details in your service before you redirect them to GOV.UK Pay, you can prefill some of the fields on the Enter payment details page. If you prefill fields, your users should not need to enter their details twice.

Your users can still edit these details before they complete their payment.

To prefill fields, include the following optional parameters in the API request when you create a new payment:

  • email
  • prefilled_cardholder_details - with optional cardholder_name and billing_address parameters

This example request creates a £100 fine and prefills the user’s email address, billing address, and the cardholder name:

{
  "amount": 10000,
  "reference" : "54321",
  "description": "Pay a fine you've been issued.",
  "return_url": "https://your.service.gov.uk/completed",
  "email": "sherlock.holmes@example.com",
  "prefilled_cardholder_details": {
    "cardholder_name": "Sherlock Holmes",
    "billing_address": {
      "line1": "221 Baker Street",
      "line2": "Flat b",
      "postcode": "NW1 6XE",
      "city": "London",
      "country": "GB"
    }
  }
}

All the parameters in billing_address are optional and must have values no longer than:

  • 254 characters for email
  • 255 characters for cardholder_name
  • 255 characters each for line1, line2 and city in billing_address
  • 25 characters for postcode in billing_address

The country parameter must be an ISO 3166-1 alpha-2 code. If you do not include country or send an invalid value, the Country or territory field on the payment page will default to ‘United Kingdom’.

Data collected by your GOV.UK Pay admin account

After your user completes their payment, your GOV.UK Pay account will collect your user’s:

If your user does not complete their payment, your GOV.UK Pay account will still collect the billing_address value. This will happen even if you’ve chosen not to collect your users’ billing addresses.