Charges

Charging a user

To charge a user, you need to make a POST request to the /charge endpoint with your store API key and the desired parameters. Charges are identified by a unique, random ID.

The API will return a unique URL for each call. You can redirect the user to that URL in order for him to proceed to the payment.

The unique URL looks like this:

https://pay.simplecash.co/charge/4447916040904206b3c26efb695559f4

Users have 10 minutes to pay the required amount. Our system will automatically detect when the payment is done and will redirect the user to a callback URL you specified. You can optionally send an email receipt to the payer, whether the charge failed or succeeded.

If the charge succeeds, you will instantly receive the funds since Bitcoin Cash has 0-conf.

Creating a charge

You can create a charge by sending a POST request to the /charge endpoint with the following arguments:

URL args:

  • api_key (required | string)
    • Your store API key.

JSON parameters:

  • amount (required | float)

    • The full amount you want to charge in USD.
    • Must be greater than 0.25 USD.
  • callback_url (required | string)

    • The URL the payer will be redirected to after paying.
  • name (required | string)

    • A name for the charge operation.
    • MAX: 60 characters.
  • description (optional | string)

    • A description for the charge operation.
    • MAX: 300 characters.
  • customer_email (optional | string)

    • The payer email address for receiving a receipt.

Getting a charge

You can get a charge you charged on a specific store by sending a GET request to the /charge/:uid endpoint with the following arguments:

URL args:

  • api_key (required | string)
    • Your store API key.

This is usefull if you want to verify a charge by yourself.

Getting all charges

You can get all the charges you charged on a specific store by sending a GET request to the /charges endpoint with the following arguments:

URL args:

  • api_key (required | string)

    • Your store API key.
  • start (optional | integer)

    • Counting starter.
    • Default value: 1.
  • limit (optional | integer)

    • Pagination limiter.
    • Default value: 20.

This is usefull if you want to analyze or verify charges by yourself.

Examples

cURL

Creating a charge:

curl -X POST \
  https://api.simplecash.co/v1/charge?api_key=cc8d300559e7421d9d646c0bfb2f798a \
  -H "Content-Type: application/json"
  -d '{
	"amount": 1.50,
	"callback_url": "https://example.com/purchase/thankyou",
	"name": "Example purchase",
	"customer_email": "johndoe@gmail.com"
    }'

Getting a charge:

curl -X GET \
  https://api.simplecash.co/v1/charge/4447916040904206b3c26efb695559f4?api_key=cc8d300559e7421d9d646c0bfb2f798a \

Getting all charges:

curl -X GET \
  https://api.simplecash.co/v1/charges?api_key=cc8d300559e7421d9d646c0bfb2f798a \

Python (Requests)

Creating a charge

import requests

url = "https://api.simplecash.co/v1/charge?api_key=cc8d300559e7421d9d646c0bfb2f798a"

data = {
    "amount": 1.50,
    "callback_url": "https://example.com/purchase/thankyou",
    "name": "Example purchase",
    "description": "This is just a test",
	"customer_email": "johndoe@gmail.com"
}

response = requests.get(url, json=data)

print(response.json())

Getting a charge:

import requests

url = "https://api.simplecash.co/v1/charge/4447916040904206b3c26efb695559f4?api_key=cc8d300559e7421d9d646c0bfb2f798a"

response = requests.get(url)
print(response.json())

Getting all charges:

import requests

url = "https://api.simplecash.co/v1/charges?api_key=cc8d300559e7421d9d646c0bfb2f798a"

response = requests.get(url)

print(response.json())

Note

We will soon release language-specific libraries to easily interact with the API.