Testing Pays
  • Features
  • Benefits
  • Guides
  • Pricing
  • Getting Started
  • About
  • Contact
  • Login
  • Signup

Stripe Basics

Welcome Sim Features What can I do?

API reference

What's Stripe? Tokens - Getting started Charges Customers Subscriptions Coupons Refunds Webhooks FAQ

Getting Started with the tokens sim

Here's how to make your first request - creating a card token - with Testing Pays sims.

  1. Create your Testing Pays account
  2. Step 1: Open the tokens simulator
  3. Step 2: Build the payload
  4. Step 3: Send the request to the tokens simulator
  5. Step 4: Parse the tokens response

Create Your Testing Pays Account

First, you’ll need an account on Testing Pays. It takes seconds.

Create your Testing Pays account

1. Open the tokens Simulator

For the purposes of making test token call, you'll be using the tokens simulator in your Testing Pays account.

To open the simulator interface, login to your Testing Pays account and click "OPEN" on the "tokens" bookmark on your dashboard. You'll see the following sections in your simulator:

  • Integrate: coding instructions in various languages to help you connect your code to the simulator.
  • Debug: use the Live Log to watch transactions being processed in real-time. Or download the file-based logs.
  • Test: a map of real token response codes that you can trigger with values in your test requests. Or custom your own.
  • Reports: real-time test reports showing the frequency and coverage of your tokens testing.
  • Settings: real-world settings you can activate for your testing like latency delays, trigger parameters, etc.

2. Build the payload

The simplest option is using cURL. To create a Stripe token, at minimum you need a card[number], card[exp_month], card[exp_year] and card[cvc]. Using cURL, you need to submit these parameters as you would with a form POST.

Add address details to your request. This can be used in billing and customer details later.

Our Tip: use the Simulator to try out these real life payment scenarios

Remember: you can trigger different responses from the simulator by the values you use in the requests. By default, the simulator will use cvc value as the trigger value.

3. Making your first charges request

Next, your code needs to send the assembled request to the tokens simulator. The URL to POST to can be found under the "Integration" tab of the simulator - make sure to copy&paste this URL from your simulator as it contains your unique API_KEY.

curl -X POST -u API_KEY: \
  -d card[number]=4111111111111111 \
  -d card[exp_month]=12 \
  -d card[exp_year]=25 \
  -d card[cvc]=100 \
  https://api.testingpays.com/API_KEY/stripe/v1/tokens

4. Parse the tokens response

The simulator will send back a JSON object that contains information about the card or bank account. These details can be saved safely in your own systems (i.e. the last 4 digits and the card type). You can show these to your customer(s), helping them to identify their preferred payment option - this is especially important when a customer has multiple cards saved.

Take a look at an example response:

{
  "id": "tok_VA1AHiaFbceQKOur3QZ87Y11",
  "object": "token",
  "card": {
    "id": "card_aLUvGXRXygx8cuwSIWXvmsm6",
    "object": "card",
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": null,
    "address_zip_check": null,
    "brand": "Visa",
    "country": "US",
    "cvc_check": "unchecked",
    "dynamic_last4": null,
    "exp_month": 12,
    "exp_year": 25,
    "fingerprint": "cpDLiFvOzL0OEy6o",
    "funding": "credit",
    "last4": "4242",
    "metadata": {},
    "name": null,
    "tokenization_method": null
  },
  "client_ip": null,
  "created": 1550495473,
  "livemode": false,
  "type": "card",
  "used": false
}
Our Tip: Remember the token ID

Tokens are the single reference you need to create charges, so it’s essential to remember them. You need to use it when creating customers, subscribing to plans, etc.

What's Next

Explore how you can use Tokens: for charges, customers, subscriptions, etc.

Charging for goods and services
  • Testing Pays is a product of The Payment Works.
  • GDPR
  • Contact