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

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

1. Open the webhooks Simulator

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

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

Our Tip: test your webhooks on your local dev machine

If you’d like to get a callback to your local environment (i.e. http://localhost:3000) use a tunnel service like ngrok.com (where you can get a public domain mirroring your local app) or mocky.io where you can have mock endpoints setup easily.

3. Making your first webhooks request

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

curl -X POST -u API_KEY: \
  -d callback_url=http://localhost:3000/webhooks/stripe \
  -d trigger=00 \
  https://api.testingpays.com/API_KEY/stripe/v1/webhooks

4. Parse the webhooks response

The simulator will send back a JSON object that is equivalent of the event data you get back from Stripe on these events. What’s extra in Testing Pays is that you get back the event data in JSON as a response AND the callback to the webhook_url you sent in initially.

You can playback any event now, and set your own up with the custom responses! This was you don’t need to search around the stripe dashboard to find a suitable transaction, invoice, etc. Or wait for the next event to occur in production. Just use the trigger param to get the event data you need for your development or testing!

{
  "id": "evt_1DihQpDPjEFprg5kABYv4x76",
  "object": "event",
  "api_version": "2015-10-16",
  "created": 1545135135,
  "data": {
    "object": {
      "id": "ch_1DihQpDPjEFprg5kRp8CBeNv",
      "object": "charge",
      "amount": 5998,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "balance_transaction": "txn_1DihQpDPjEFprg5kPNefrwSL",
      "captured": true,
      "created": 1545135135,
      "currency": "eur",
      "customer": "cus_9xBh3fQ7zzldaL",
      "description": "Payment for invoice 02EB1D8-0022",
      "destination": null,
      "dispute": null,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": { },
      "invoice": "in_1DigUXDPjEFprg5kYz5MFKXj",
      "livemode": false,
      "metadata": { },
      "on_behalf_of": null,
      "order": null,
      "outcome": {
        "network_status": "approved_by_network",
        "reason": null,
        "risk_level": "normal",
        "risk_score": 55,
        "seller_message": "Payment complete.",
        "type": "authorized"
      },
      "paid": true,
      "payment_intent": null,
      "receipt_email": null,
      "receipt_number": null,
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [ ],
        "has_more": false,
        "total_count": 0,
        "url": "/v1/charges/ch_1DihQpDPjEFprg5kRp8CBeNv/refunds"
      },
      "review": null,
      "shipping": null,
      "source": {
        "id": "card_19dHJaDPjEFprg5k2XoiBF0o",
        "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",
        "customer": "cus_9xBh3fQ7zzldaL",
        "cvc_check": null,
        "dynamic_last4": null,
        "exp_month": 9,
        "exp_year": 2019,
        "fingerprint": "GzMCgcZq3sgjDDwn",
        "funding": "unknown",
        "last4": "1111",
        "metadata": { },
        "name": "sadsdsadsasadasd asdasdsad",
        "tokenization_method": null
      },
      "source_transfer": null,
      "statement_descriptor": null,
      "status": "succeeded",
      "transfer_group": null
    }
  },
  "livemode": false,
  "pending_webhooks": 1,
  "request": null,
  "type": "charge.succeeded"
}
  • Testing Pays is a product of The Payment Works.
  • GDPR
  • Contact