Cobranças
Para mais informações, acessar a open api
Urls dos ambientes
- Sandbox: https://api.sandbox.wepayout.com.br
- Produção: https://api.wepayout.com.br
Atenção
Para esses endpoints é necessário uma API KEY.
Cobrança Simples
endpoint: /v1/payin/payments/{chargeType}
O parâmetro de rota {chargeType} deve ser boleto ou pix.
método: POST
Exemplo de payload e response
{
"clientId": 15,
"customNumber": "123456",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2022-07-25T16:20:00",
"amountInCents": 5000,
"instructions": "any bank"
},
"buyer": {
"name": "Name",
"document": {
"number": "01234567890",
"type": "CPF"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
}
}
{
"key": "string",
"clientId": 0,
"clientName": "string",
"buyerName": "string",
"buyerDocument": "string",
"customNumber": "string",
"ourNumber": "string",
"digitableLine": "string",
"barCodeNumber": "string",
"status": {
"name": "string",
"id": "string"
},
"typePayin": "string",
"amountCents": 0,
"paidAmountCents": null,
"paidAt": null,
"expiresAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z",
"fine": null,
"discount": null,
"splits": [
{
"walletOwner": "string",
"walletUUID": "string",
"percent": 0,
"amountInCents": null
}
],
"statusHistory": [
{
"status": {
"id": 0,
"name": "string"
},
"updatedAt": "string"
}
],
"sender": {
"name": "string",
"document": "string",
"helpdesk": "string"
},
"payinRefunds": [
{
"id": 1,
"payinId": 1,
"statusId": 2,
"user": {
"id": 1,
"name": "Usuário de Teste"
},
"clientId": 1,
"amountCents": 100,
"statuses": [
{
"id": 1,
"statusId": 1,
"name": "Solicitado",
"notification": 1,
"createdAt": "2022-03-11T17:14:47.000000Z"
},
{
"id": 2,
"statusId": 2,
"name": "Pago",
"notification": 1,
"createdAt": "2022-03-11T17:14:49.000000Z"
}
],
"endToEndId": "string",
"reason": "strind",
"callbackUrl": "https://payin-refund.requestcatcher.com/",
"createdAt": "2022-03-11T17:31:03.000000Z",
"updatedAt": "2022-03-11T17:31:05.000000Z"
}
],
"refundAmountCents": 1000
}
Exemplos de código
- NodeJs
- Python
- Java
- PHP
var axios = require('axios');
var data = JSON.stringify({
"clientId": 15,
"customNumber": "258688a0-92ee-42a6-b84d-ea54c6aeaac3",
"callbackUrl": "https://enehias.requestcatcher.com/",
"title": {
"expireDate": "2022-07-25T16:20:00",
"amountInCents": 5000,
"instructions": "any bank"
},
"buyer": {
"name": "Name",
"document": {
"number": "01234567890",
"type": "CPF"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
}
});
var config = {
método: 'post',
url: 'https://api.sandbox.wepayout.co/v1/payin/payments/pix',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_KEY'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "https://api.sandbox.wepayout.com.br/v1/payin/payments/pix"
payload = json.dumps({
"clientId": 15,
"customNumber": "dd30351a-e3ad-436f-8245-052b12a1c77d",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2022-07-25T16:20:00",
"amountInCents": 5000,
"instructions": "any bank"
},
"buyer": {
"name": "Name",
"document": {
"number": "01234567890",
"type": "CPF"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
}
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_KEY'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
class ExempleClass {
public static void main(String args[]) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"clientId\": 15,\n \"customNumber\": \"7c28d442-9562-4fa7-b602-de44690aff2a\",\n \"callbackUrl\": \"https://payin-test.requestcatcher.com/\",\n \"title\": {\n \"expireDate\": \"2022-07-25T16:20:00\",\n \"amountInCents\": 5000,\n \"instructions\": \"any bank\"\n },\n \"buyer\": {\n \"name\": \"Name\",\n \"document\": {\n \"number\": \"01234567890\",\n \"type\": \"CPF\"\n },\n \"address\": {\n \"street\": \"Rua da praça\",\n \"number\": \"123\",\n \"complement\": \"Conjunto comercial\",\n \"zipCode\": \"99999999\",\n \"city\": \"Barueri\",\n \"district\": \"ALPHAVILLE INDUSTRIAL\",\n \"stateCode\": \"SP\"\n }\n }\n}");
Request request = new Request.Builder()
.url("https://api.sandbox.wepayout.co/v1/payin/payments/pix")
.método("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer YOUR_KEY")
.build();
Response response = client.newCall(request).execute();
}
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.sandbox.wepayout.com.br/v1/payin/payments/pix',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"clientId": 15,
"customNumber": "37408675-f488-44f2-b79d-062daf6ebbe6",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2022-07-25T16:20:00",
"amountInCents": 5000,
"instructions": "any bank"
},
"buyer": {
"name": "Name",
"document": {
"number": "01234567890",
"type": "CPF"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer YOUR_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Cobrança com divisão aos destinatários
endpoint: /v1/payin/payments/boleto
método: POST
Exemplo de payload e response
{
"clientId": 104,
"customNumber": "1234",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2021-11-29",
"amountInCents": 15000,
"instructions": "PAGÁVEL DE QUALQUER BANCO COM QR CODE PIX"
},
"buyer": {
"name": "NAME",
"document": {
"type": "CPF",
"number": "1234567890"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
},
"splits" : [
{
"walletUUID":"d953bf82-25a1-4665-807e-4398eb2ebf6b",
"percent": 50
},
{
"walletUUID":"c708f21c-3995-47bd-bbcd-b6c924455e55",
"percent": 50
}
]
}
{
"key": "string",
"clientId": 0,
"clientName": "string",
"buyerName": "string",
"buyerDocument": "string",
"customNumber": "string",
"ourNumber": "string",
"digitableLine": "string",
"barCodeNumber": "string",
"status": {
"name": "string",
"id": "string"
},
"typePayin": "string",
"amountCents": 0,
"paidAmountCents": null,
"paidAt": null,
"expiresAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z",
"fine": null,
"discount": null,
"splits": [
{
"walletOwner": "string",
"walletUUID": "string",
"percent": 0,
"amountInCents": null
}
],
"statusHistory": [
{
"status": {
"id": 0,
"name": "string"
},
"updatedAt": "string"
}
],
"sender": {
"name": "string",
"document": "string",
"helpdesk": "string"
},
"payinRefunds": [
{
"id": 1,
"payinId": 1,
"statusId": 2,
"user": {
"id": 1,
"name": "Usuário de Teste"
},
"clientId": 1,
"amountCents": 100,
"statuses": [
{
"id": 1,
"statusId": 1,
"name": "Solicitado",
"notification": 1,
"createdAt": "2022-03-11T17:14:47.000000Z"
},
{
"id": 2,
"statusId": 2,
"name": "Pago",
"notification": 1,
"createdAt": "2022-03-11T17:14:49.000000Z"
}
],
"endToEndId": "string",
"reason": "strind",
"callbackUrl": "https://payin-refund.requestcatcher.com/",
"createdAt": "2022-03-11T17:31:03.000000Z",
"updatedAt": "2022-03-11T17:31:05.000000Z"
}
],
"refundAmountCents": 1000
}
Exemplos de código
- NodeJs
- Python
- Java
- PHP
var axios = require('axios');
var data = JSON.stringify({
"clientId": 104,
"customNumber": "1234",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2021-11-29",
"amountInCents": 15000,
"instructions": "PAGÁVEL DE QUALQUER BANCO COM QR CODE PIX"
},
"buyer": {
"name": "NAME",
"document": {
"type": "CPF",
"number": "1234567890"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
},
"splits": [
{
"walletUUID": "d953bf82-25a1-4665-807e-4398eb2ebf6b",
"percent": 50
},
{
"walletUUID": "c708f21c-3995-47bd-bbcd-b6c924455e55",
"percent": 50
}
]
});
var config = {
método: 'post',
url: 'https://api.sandbox.wepayout.com.br/v1/payin/payments/boleto',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_KEY'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "https://api.sandbox.wepayout.com.br/v1/payin/payments/boleto"
payload = json.dumps({
"clientId": 104,
"customNumber": "1234",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2021-11-29",
"amountInCents": 15000,
"instructions": "PAGÁVEL DE QUALQUER BANCO COM QR CODE PIX"
},
"buyer": {
"name": "NAME",
"document": {
"type": "CPF",
"number": "1234567890"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
},
"splits": [
{
"walletUUID": "d953bf82-25a1-4665-807e-4398eb2ebf6b",
"percent": 50
},
{
"walletUUID": "c708f21c-3995-47bd-bbcd-b6c924455e55",
"percent": 50
}
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_KEY'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
class ExempleClass {
public static void main(String args[]) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"clientId\": 104,\n\t\"customNumber\": \"1234\",\n \"callbackUrl\": \"https://payin-test.requestcatcher.com/\",\n\t\"title\": {\n\t\t\"expireDate\": \"2021-11-29\",\n\t\t\"amountInCents\": 15000,\n\t\t\"instructions\": \"PAGÁVEL DE QUALQUER BANCO COM QR CODE PIX\"\n\t},\n\t\"buyer\": {\n\t\t\"name\": \"NAME\",\n\t\t\"document\": {\n\t\t\t\"type\": \"CPF\",\n\t\t\t\"number\": \"1234567890\"\n\t\t},\n\t\t\"address\": {\n\t\t\t\"street\": \"Rua da praça\",\n\t\t\t\"number\": \"123\",\n\t\t\t\"complement\": \"Conjunto comercial\",\n\t\t\t\"zipCode\": \"99999999\",\n\t\t\t\"city\": \"Barueri\",\n\t\t\t\"district\": \"ALPHAVILLE INDUSTRIAL\",\n\t\t\t\"stateCode\": \"SP\"\n\t\t}\n\t},\n \"splits\" : [\n \t {\n \t \"walletUUID\":\"d953bf82-25a1-4665-807e-4398eb2ebf6b\",\n \"percent\": 50\n \t },\n \t {\n \t \"walletUUID\":\"c708f21c-3995-47bd-bbcd-b6c924455e55\",\n \"percent\": 50\n \t }\n ]\n}");
Request request = new Request.Builder()
.url("https://api.sandbox.wepayout.com.br/v1/payin/payments/boleto")
.método("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer YOUR_KEY")
.build();
Response response = client.newCall(request).execute();
}
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.sandbox.wepayout.co/v1/payin/payments/boleto',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"clientId": 104,
"customNumber": "1234",
"callbackUrl": "https://payin-test.requestcatcher.com/",
"title": {
"expireDate": "2021-11-29",
"amountInCents": 15000,
"instructions": "PAGÁVEL DE QUALQUER BANCO COM QR CODE PIX"
},
"buyer": {
"name": "NAME",
"document": {
"type": "CPF",
"number": "1234567890"
},
"address": {
"street": "Rua da praça",
"number": "123",
"complement": "conjunto comercial",
"zipCode": "99090900",
"city": "Curitiba",
"district": "Centro",
"stateCode": "PR"
}
},
"splits" : [
{
"walletUUID":"d953bf82-25a1-4665-807e-4398eb2ebf6b",
"percent": 50
},
{
"walletUUID":"c708f21c-3995-47bd-bbcd-b6c924455e55",
"percent": 50
}
]
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer YOUR_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Webhook
Atualização da cobrança
Quando uma cobrança tem os status alterado, é disparado uma requisição post para a url informada no atributo callbackUrl da criação da cobrança.
Todos os webhooks de cobrança são assinados com um hash sha256 fornecido no cabeçalho x-webhook-wpo-signature
.
O hash é enviado como uma Bearer token, ex: Bearer {hash}. Para validar a assinatura você precisa concatenar os campos id, key e amountCents da cobrança com a APIKey
usada para criar as cobranças, e fazer o hash dessa string usando o algoritmo sha256.
Por exemplo: 1KEY120APIKEY
- Se você não tem desconto, não envie a chave discount no data;
- Se você possui discount.percent, então você deve mandar discount.percent e o discount.date;
- Se voce possui discount.amountInCents, então você deve mandar discount.amountInCents e o discount.date;
- Se voce possui discount.dailyAmountInCents, então NÃO precisa enviar os outros campos de percent, date e amount;
{
"id": 0,
"key": "string",
"clientId": 0,
"clientName": "string",
"buyerName": "string",
"buyerDocument": "string",
"customNumber": "string",
"ourNumber": "string",
"digitableLine": "string",
"barCodeNumber": "string",
"status": "string",
"statusCode": 0,
"typePayin": "string",
"amountCents": 0,
"paidAmountCents": null,
"paidAt": null,
"expiresAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z",
"fine": null,
"discount": null,
"splits": [
{
"walletOwner": "string",
"walletUUID": "string",
"percent": 0,
"amountInCents": null
}
],
"statusHistory": [
{
"status": {
"id": 0,
"status": "string",
"statusCode": 0,
"updatedAt": "2022-03-11T17:14:47.000000Z",
"status_detail": "string | apenas para status rejeitado",
"status_detail_description": "string | apenas para status rejeitado"
}
}
],
"sender": {
"name": "string",
"document": "string",
"helpdesk": "string"
},
"payinRefunds": [
{
"id": 1,
"payinId": 1,
"statusId": 2,
"user": {
"id": 1,
"name": "Usuário de Teste"
},
"clientId": 1,
"amountCents": 100,
"statuses": [
{
"id": 1,
"statusId": 1,
"name": "Solicitado",
"notification": 1,
"createdAt": "2022-03-11T17:14:47.000000Z"
},
{
"id": 2,
"statusId": 2,
"name": "Pago",
"notification": 1,
"createdAt": "2022-03-11T17:14:49.000000Z"
}
],
"endToEndId": "EFASA321654987456ASAS123",
"reason": "Devolvendo valores de teste",
"callbackUrl": "https://payin-refund.requestcatcher.com/",
"createdAt": "2022-03-11T17:31:03.000000Z",
"updatedAt": "2022-03-11T17:31:05.000000Z"
}
],
"refundAmountCents": 1000
}