Skip to content

Payments testing

Last updated: 14th July 2022

Create a token that represents a card's details that you can later use to request a test payment, without you having to process or store any sensitive information.


Step 1: Request a token

Exchange card details for a reference token that can be used later to request a card payment. Tokens are single use and expire after 15 minutes. To create a token, you'll need to authenticate using your public API key.

The request

Endpoint

    post

    https://api.sandbox.checkout.com/tokens

    Header parameters

    HeaderValue

    Authorization

    required

    Public API key

    This will be prefixed by pktest.

    Content-Type

    required

    application/json

    Body parameters

    You can use any of our test cards' details in the body of your request.

    Field nameDescription

    type

    required
    string

    Set this to card.

    number

    required
    string

    The card number.

    expiry_month

    required
    integer

    The expiry month of the card.

    expiry_year

    required
    integer

    The expiry year of the card.

    name

    optional
    string

    The cardholder's name.

    cvv

    optional
    string

    The card verification value/code. 3 digits, except for Amex (4 digits).

    billing.address

    optional
    object

    The payment source owner's billing address.

    phone

    optional
    object

    The payment source owner's phone number.

    Request example

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      {
      "type": "card",
      "number": "4543474002249996",
      "expiry_month": 6,
      "expiry_year": 2025,
      "name": "Bruce Wayne",
      "cvv": "956",
      "billing_address": {
      "address_line1": "Checkout.com",
      "address_line2": "90 Tottenham Court Road",
      "city": "London",
      "state": "London",
      "zip": "W1T 4TJ",
      "country": "GB"
      },
      "phone": {
      "country_code": "+1",
      "number": "415 555 2671"
      }
      }

      The response

      If your request was successful, you'll receive a 201 response containing a card token prefixed by tok_. You then have 15 minutes to request a payment using this token.

      Response example

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      {
      "type": "card",
      "token": "tok_ubfj2q76miwundwlk72vxt2i7q",
      "expires_on": "2020-08-27T11:37:30Z",
      "expiry_month": 6,
      "expiry_year": 2025,
      "scheme": "VISA",
      "last4": "9996",
      "bin": "454347",
      "card_type": "Credit",
      "card_category": "Consumer",
      "issuer": "GOTHAM STATE BANK",
      "issuer_country": "US",
      "product_id": "F",
      "product_type": "CLASSIC",
      "billing_address": {
      "address_line1": "Checkout.com",
      "address_line2": "90 Tottenham Court Road",
      "city": "London",
      "state": "London",
      "zip": "W1T 4TJ",
      "country": "GB"
      },
      "phone": {
      "country_code": "+1",
      "number": "415 555 2671"
      },
      "name": "Bruce Wayne"
      }

      Step 2: Request a payment using the token

      Create a payment request using the token you just received.