Charge API

Once you have successfully tokenized a card you are ready to create your first payment. To do this, you make use of our API from your applications backend.

Request

https://online.yoco.com/v1/charges/

Headers

ParameterTypeDescription
secretKey
string
The secret key for your account

Body

ParameterTypeDescription
token
string
token generated on the front end.
eg: tok_DgfdsVFvfbvwjkhdbxv
amountInCents
integer
A positive integer representing the amount in cents
currency
string
An ISO 4217 currency code.

Example

curl https://online.yoco.com/v1/charges/ \
-u sk_test_960bfde0VBrLlpK098e4ffeb53e1: \
-d token=tok_test_DjaqoUgmzwYkwesr3euMxyUV4g \
-d amountInCents=2799 \
-d currency=ZAR
# The colon on the -u argument prevents curl from asking for a password.

Response

Since the card details have already been checked and any 3D Secure steps have already been performed, the vast majority of requests to charge a transaction will be successful.

HTTP: 201 Created
{
"source": {
"id": "card_Aj9RzUkGWYKDaMt0M1s5XbC2zA",
"brand": "visa",
"maskedCard": "**** **** **** 4242",
"expiryMonth": 4,
"expiryYear": 2024,
"fingerprint": "09634a43594b4af0eae0a74be89df8545b29af0d",
"object": "card",
"country": "GB"
},
"object": "charge",
"id": "ch_awLYujNDMwzorIBO1iQkrikLq",
"status": "successful",
"currency": "ZAR",
"amountInCents": 1,
"liveMode": false,
"metadata": {"your metadata object":"that you sent us"}
}