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 coupons sim

  1. Step 1: Open the coupons simulator
  2. Step 2: Build the payload
  3. Step 3: Send the request to the coupons simulator
  4. Step 4: Parse the coupons response

1. Open the coupons Simulator

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

To open the simulator interface, login to your Testing Pays account and click "OPEN" on the "coupons" 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 coupon 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 coupons 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 coupon, at minimum you need an id, duration and currency. Using cURL, you need to submit these parameters as you would with a form POST.

Our Tip: create coupon that expire

You can add more parameters to your coupons: max_redemptions, redeem_by, etc. this way you can limit how many times one can be redeemed and when your discount expired.

3. Making your first coupons request

Next, your code needs to send the assembled request to the coupons 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.

The example shown below shows how to make a coupons request using cURL.

curl -X POST -u API_KEY: \
  -d id=tp_1000 \
  -d duration=once \
  -d amount_off=25 \
  -d currency=USD \
  https://api.testingpays.com/API_KEY/stripe/v1/coupons

4. Parse the coupons response

The simulator will send back a JSON object that contains information about the coupon - echoing back your call details along with the defaults

{
  "id": "100",
  "object": "coupon",
  "amount_off": 25,
  "created": 1550495718,
  "currency": "usd",
  "duration": "once",
  "duration_in_months": null,
  "livemode": false,
  "max_redemptions": null,
  "metadata": {},
  "name": null,
  "percent_off": null,
  "redeem_by": null,
  "times_redeemed": 0,
  "valid": true
}

What's Next

Dealing with customer complaints and refunds

Refunds API
  • Testing Pays is a product of The Payment Works.
  • GDPR
  • Contact