Make a Cash In
Cash in Endpoint
Create a cash in operation. The value entered in the 'value' field must be entered in cents. Example: If it is 10 reais, enter 1000 in the 'value' field.
https://sandbox.tickpay.com/api/v1/wallets/in
Request
To access this endpoint, you need to provide a valid access token in the Authorization header.
- cURL
- C#
- JavaScript
- Python
- Java
- PHP
Use the following cURL command to create a cash in operation:
curl -X 'POST' \
'https://sandbox.tickpay.com/api/v1/wallets/in' \
-H 'accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json' \
-d '{
"value": 5000,
"callbackUrl": "https://example.com/callback",
"invoiceDescription": "string",
"metadata": {
"key": "value",
"anotherKey": "anotherValue"
},
"payer": {
"name": "John Doe",
"email": "[email protected]",
"document": "123456789",
"phone": "+5511911111111"
},
"externalReference": "ABC123",
"expireInMinutes": 5
}'
Use the following csharp command to create a cash in operation:
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// URL da API
string apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/in";
// Defina o seu token de acesso aqui
string token = "your_access_token";
// Dados do payload
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
var requestData = new
{
value = 5000,
callbackUrl = "https://example.com/callback",
invoiceDescription = "string",
metadata = new,
{
key = "value",
anotherKey = "anotherValue"
},
payer = new
{
name = "John Doe",
email = "[email protected]",
document = "123456789",
phone = "+5511911111111"
},
externalReference = "ABC123",
expireInMinutes = 5
};
// Serializa o payload para JSON
string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(requestData);
HttpContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(apiUrl, content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
}
}
}
}
Use the following javascript command to create a cash in operation:
const url = 'https://sandbox.tickpay.com/api/v1/wallets/in';
const headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token',
'Content-Type': 'application/json'
};
const requestBody = {
value: 5000,
callbackUrl: 'https://example.com/callback',
invoiceDescription: "string",
metadata: {
key: 'value',
anotherKey: 'anotherValue'
},
payer: {
name: 'John Doe',
email: '[email protected]',
document: '123456789',
phone: '+5511911111111'
},
externalReference: 'ABC123',
expireInMinutes: 5
};
post(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(requestBody)
})
.then(response => response.json())
.then(data => {
console.log('Server Response:', data);
})
.catch(error => {
console.error('Request Error:', error);
});
Use the following python command to create a cash in operation:
import requests
url = 'https://sandbox.tickpay.com/api/v1/wallets/in'
headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token',
'Content-Type': 'application/json'
}
data = {
"value": 5000,
"callbackUrl": "https://example.com/callback",
"invoiceDescription": "string",
"metadata": {
"key": "value",
"anotherKey": "anotherValue"
},
"payer": {
"name": "John Doe",
"email": "[email protected]",
"document": "123456789",
"phone": "+5511911111111"
},
"externalReference": "ABC123",
"expireInMinutes": 5
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Use the following java command to create a cash in operation:
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
public class Example {
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newHttpClient();
String url = "https://sandbox.tickpay.com/api/v1/wallets/in";
Map<String, String> headers = Map.of(
"accept", "application/json",
"Authorization", "Bearer your_access_token",
"Content-Type", "application/json"
);
String requestBody = "{\n" +
" \"value\": 5000,\n" +
" \"callbackUrl\": \"https://example.com/callback\",\n" +
" \"invoiceDescription\": \"string\",\n" +
" \"metadata\": {\n" +
" \"key\": \"value\",\n" +
" \"anotherKey\": \"anotherValue\"\n" +
" },\n" +
" \"payer\": {\n" +
" \"name\": \"John Doe\",\n" +
" \"email\": \"[email protected]\",\n" +
" \"document\": \"123456789\",\n" +
" \"phone\": \"+5511911111111\"\n" +
" },\n" +
" \"externalReference\": \"ABC123\",\n" +
" \"expireInMinutes\": 5\n" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.flatMap(e -> Map.entry(e.getKey(), e.getValue()).stream())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Use the following php command to create a cash in operation:
<?php
$apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/in";
$accessToken = "your_access_token";
$data = array(
'value' => 5000,
'callbackUrl' => 'https://example.com/callback',
'invoiceDescription': 'string',
'metadata' => array(
'key' => 'value',
'anotherKey' => 'anotherValue'
),
'payer' => array(
'name' => 'John Doe',
'email' => '[email protected]',
'document' => '123456789',
'phone' => '+5511911111111'
),
'externalReference' => 'ABC123',
'expireInMinutes' => 5
);
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'accept: application/json',
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json'
));
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $result;
?>
Request body
| Parameter | Description | Required |
|---|---|---|
value | The monetary value associated with the transaction, representing cents. | true |
callbackUrl | The URL to which the transaction status or result will be sent asynchronously. | true |
invoiceDescription | Add a comment on the transaction. | false |
metadata | Additional key-value pairs providing metadata information related to the transaction. | false |
payer | Information about the payer initiating the transaction. | true |
payer.name | The name of the payer. | true |
payer.email | The email address of the payer. | true |
payer.document | The document or identification number of the payer. | true |
payer.phone | The phone number of the payer. | false |
externalReference | An external reference or identifier associated with the transaction, provided by the user or system. | false |
expireInMinutes | The time duration, in minutes, within which the transaction should be completed or expire. | false |
Response
The response will contain a data object, along with additional information:
{
"messageError": null,
"success": true,
"data": {
"id": "857ce245-92f8-4580-8be8-979ade39ce49",
"value": 5000,
"tax": 20,
"callbackUrl": "https://google.com",
"description": "Cash-in created successfully!",
"operation": "CASH_IN",
"status": "PENDING",
"codeCopyPaste": "chave:01234567890;valor:50.00;descricao:Pagamento de exemplo",
"qrcodeImage": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADIAQMA...",
"metadata": {
"foo": "bar"
},
"payer": {
"name": "John Doe",
"email": "[email protected]",
"phone": "+5511999999999",
"document": "01234567890"
},
"externalReference": "your_internal_id",
"createdAt": "2024-04-12T03:44:52.218Z"
}
}
Response Properties
| Parameter | Description | Default Value |
|---|---|---|
messageError | Error message. | null |
success | Indicates whether the request was successful. | false |
data Properties | ||
id | Unique identifier for the transaction. | |
value | Specific value in the response, representing cents. | |
tax | Tax value. | |
callbackUrl | URL for callback. | |
description | Description of the operation. | |
operation | Type of operation. | |
status | Current status of the transaction. Possible properties | |
codeCopyPaste | URL for copying and pasting the code. | |
qrcodeImage | Data URI for the QR code image. | |
metadata | Additional metadata. | |
payer | Information about the payer initiating the transaction. | |
payer.name | The name of the payer. | |
payer.email | The email address of the payer. | |
payer.document | The document or identification number of the payer. | |
payer.phone | The phone number of the payer. | |
externalReference | External reference identifier. | |
createdAt | Date and time of creation. |
Possible Properties
| Parameter | Description |
|---|---|
status | PENDING, CANCELED, SUCCEED, FAILED |