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

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

1. Open the charges Simulator

For the purposes of making test charge transaction, you'll be using the charges simulator in your Testing Pays account.

To open the simulator interface, login to your Testing Pays account and click "OPEN" on the "charges" 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 charge 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 charge 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 charge, at minimum you need an amount, currency and source, where source is the card token you have received using Stripe.js. Using cURL, you need to submit these parameters as you would with a form POST.

Add metadata to your request. In that object you can store references, information about the charge or customer or some data you need back when handling the response from Stripe.

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 charges 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 charges transaction using cURL.

curl -X POST -u API_KEY: \
  -d amount=100 \
  -d currency=EUR \
  -d description='My Test Request' \
  -d source=testingPays \
  https://api.testingpays.com/API_KEY/stripe/v1/charges

4. Parse the charges response

The simulator will send back a JSON object that contains information about the transaction: the result from the gateway, the bank authorisation result, source (i.e. card, bank account, etc.), shipping information.

The important parameter to look for in the response is the `status` and the `outcome` object. Status will tell you the overall result of the transaction: succeeded, failed, etc. and in outcome you can check the results from the issuer, acquirer and stripe’s internal fraud checks.

{
  "id": "ch_kbAlCiPSKRhSLMpfDnmhKPOe",
  "object": "charge",
  "amount": 100,
  "amount_refunded": 0,
  "application": null,
  "application_fee": null,
  "application_fee_amount": null,
  "balance_transaction": "txn_BJ0qm7cVtX6tSNIStlXtM7qT",
  "captured": true,
  "created": 1550495753,
  "currency": "eur",
  "customer": null,
  "description": LiveCurlExample,
  "destination": null,
  "dispute": null,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": "in_IBmgbQkUcC5uEX77Ikvz1Qwf",
  "livemode": false,
  "metadata": {},
  "on_behalf_of": null,
  "order": null,
  "outcome": {
    "network_status": "approved_by_network",
    "reason": null,
    "risk_level": "normal",
    "risk_score": 48,
    "seller_message": "Payment complete.",
    "type": "authorized"
  },
  "paid": true,
  "payment_intent": null,
  "receipt_email": null,
  "receipt_number": null,
  "receipt_url": "https://pay.stripe.com/receipts/acct_z7QIpJpNYZO6B3ASI4rxl175/ch_kbAlCiPSKRhSLMpfDnmhKPOe/rcpt_RRiyOUaIwnvrLyL2VgkqJ5Pl",
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/charges/ch_kbAlCiPSKRhSLMpfDnmhKPOe/refunds"
  },
  "review": null,
  "shipping": null,
  "source": {
    "id": "sk_test_source",
    "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": null,
    "cvc_check": null,
    "dynamic_last4": null,
    "exp_month": 6,
    "exp_year": 2020,
    "fingerprint": "uTVvJ6IdZam2OiEi",
    "funding": "credit",
    "last4": "4242",
    "metadata": {},
    "name": null,
    "tokenization_method": null
  },
  "source_transfer": null,
  "statement_descriptor": null,
  "status": "succeeded",
  "transfer_data": null,
  "transfer_group": null
}

What's Next

Dealing with your customers.

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