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

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

1. Open the subscriptions Simulator

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

To open the simulator interface, login to your Testing Pays account and click "OPEN" on the "subscriptions" 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 subscription 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 subscriptions 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 subscription, at minimum you need a customer id, plan (encapsulated in an items list) and tax_percent. Using cURL, you need to submit these parameters as you would with a form POST.

Our Tip: Read up on all the possible subscription scenarios

You can add more parameters to your subscriptions: metadata, billing or trial period settings. The latter can be used to handle ‘first 14 days off’ kinda scenarios.

3. Making your first subscriptions request

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

curl -X POST -u API_KEY: \
  -d items[0][plan]=PLAN_10 \
  -d customer=cus_sa9sd9f8asdf98329as9df \
  -d tax_percent=1.00 \
  https://api.testingpays.com/API_KEY/stripe/v1/subscriptions

4. Parse the subscriptions response

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

{
  "id": "sub_D3mOlPUnzEj4Iv2XjtrxrmKN",
  "object": "subscription",
  "application_fee_percent": null,
  "billing": "charge_automatically",
  "billing_cycle_anchor": null,
  "billing_thresholds": "",
  "cancel_at_period_end": null,
  "canceled_at": null,
  "created": 1550495588,
  "current_period_end": 1551359588,
  "current_period_start": 1548767588,
  "customer": "cus_A7gEnmzqIud0yg",
  "discount": null,
  "ended_at": null,
  "livemode": false,
  "metadata": { },
  "items": {
    "object": "list",
    "data": [
        {
        "id": "si_S6upnHBNyZfjc9sZX3bEtUoz",
        "object": "subscription_item",
        "billing_thresholds": "",
        "created": 1550495588,
        "plan": {
          "id": "",
          "object": "plan",
          "active": true,
          "aggregate_usage": null,
          "amount": 1999,
          "billing_scheme": "per_unit",
          "created": 1550495588,
          "currency": "eur",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {},
          "nickname": "Testing Pays Monthly",
          "product": "prod_BUthVRQ7KdFfa7",
          "tiers": null,
          "tiers_mode": null,
          "transform_usage": null,
          "trial_period_days": null,
          "usage_type": "licensed"
        },
        "quantity": 1,
        "subscription": "sub_D3mOlPUnzEj4Iv2XjtrxrmKN"
      }
    ],
    "has_more": false,
    "total_count": 1,
    "url": "/v1/subscription_items?subscription=sub_D3mOlPUnzEj4Iv2XjtrxrmKN"
  },
  "plan": {
    "id": "",
    "object": "plan",
    "active": true,
    "aggregate_usage": null,
    "amount": 1999,
    "billing_scheme": "per_unit",
    "created": 1550495588,
    "currency": "eur",
    "interval": "month",
    "interval_count": 1,
    "livemode": false,
    "metadata": {},
    "nickname": "Testing Pays Monthly",
    "product": "prod_BUthVRQ7KdFfa7",
    "tiers": null,
    "tiers_mode": null,
    "transform_usage": null,
    "trial_period_days": null,
    "usage_type": "licensed"
  },
  "quantity": 1,
  "start": 1550495588,
  "status": "active",
  "tax_percent": 1.00,
  "trial_end": null,
  "trial_start": null
}
Our Tip: Look for the important bits in the response

Save the subscription ID and connect it to your customer ID! This way you can always trace back a transaction, subscription data, etc. Subscription ID can be used to update a subscription: cancel, add more, modify current subscription items, etc.

What's Next

How to give your customers discounts on their subscriptions.

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