Criar cobrança Pix
curl --request POST \
--url https://api.zynpay.com.br/v1/public/pix/charges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"amountCents": 5000,
"description": "Pedido #8421",
"externalReference": "8421",
"expiresInSeconds": 1800,
"customer": {
"name": "Maria Silva",
"email": "maria@cliente.com",
"externalId": "<string>"
}
}
'import requests
url = "https://api.zynpay.com.br/v1/public/pix/charges"
payload = {
"amountCents": 5000,
"description": "Pedido #8421",
"externalReference": "8421",
"expiresInSeconds": 1800,
"customer": {
"name": "Maria Silva",
"email": "maria@cliente.com",
"externalId": "<string>"
}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amountCents: 5000,
description: 'Pedido #8421',
externalReference: '8421',
expiresInSeconds: 1800,
customer: {name: 'Maria Silva', email: 'maria@cliente.com', externalId: '<string>'}
})
};
fetch('https://api.zynpay.com.br/v1/public/pix/charges', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zynpay.com.br/v1/public/pix/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amountCents' => 5000,
'description' => 'Pedido #8421',
'externalReference' => '8421',
'expiresInSeconds' => 1800,
'customer' => [
'name' => 'Maria Silva',
'email' => 'maria@cliente.com',
'externalId' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zynpay.com.br/v1/public/pix/charges"
payload := strings.NewReader("{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.zynpay.com.br/v1/public/pix/charges")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zynpay.com.br/v1/public/pix/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"charge": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "created",
"amountCents": 123,
"feeCents": 123,
"netAmountCents": 123,
"provider": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"origin": "public_api",
"providerPaymentId": "<string>",
"publicToken": "<string>",
"idempotencyKey": "<string>",
"externalReference": "<string>",
"description": "<string>",
"customer": {
"name": "<string>",
"email": "<string>",
"externalId": "<string>"
},
"pixBrCode": "<string>",
"pixQrCodeImage": "<string>",
"feeSnapshot": {},
"metadata": {},
"expiresAt": "2023-11-07T05:31:56Z",
"paidAt": "2023-11-07T05:31:56Z",
"cancelledAt": "2023-11-07T05:31:56Z",
"nextReconciliationAt": "2023-11-07T05:31:56Z",
"reconciliationAttempts": 123,
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}Cobranças
Criar uma cobrança
Cria uma cobrança Pix e retorna o QR Code e o Pix Copia e Cola. Exige o escopo pix:write.
POST
/
v1
/
public
/
pix
/
charges
Criar cobrança Pix
curl --request POST \
--url https://api.zynpay.com.br/v1/public/pix/charges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"amountCents": 5000,
"description": "Pedido #8421",
"externalReference": "8421",
"expiresInSeconds": 1800,
"customer": {
"name": "Maria Silva",
"email": "maria@cliente.com",
"externalId": "<string>"
}
}
'import requests
url = "https://api.zynpay.com.br/v1/public/pix/charges"
payload = {
"amountCents": 5000,
"description": "Pedido #8421",
"externalReference": "8421",
"expiresInSeconds": 1800,
"customer": {
"name": "Maria Silva",
"email": "maria@cliente.com",
"externalId": "<string>"
}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amountCents: 5000,
description: 'Pedido #8421',
externalReference: '8421',
expiresInSeconds: 1800,
customer: {name: 'Maria Silva', email: 'maria@cliente.com', externalId: '<string>'}
})
};
fetch('https://api.zynpay.com.br/v1/public/pix/charges', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zynpay.com.br/v1/public/pix/charges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amountCents' => 5000,
'description' => 'Pedido #8421',
'externalReference' => '8421',
'expiresInSeconds' => 1800,
'customer' => [
'name' => 'Maria Silva',
'email' => 'maria@cliente.com',
'externalId' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zynpay.com.br/v1/public/pix/charges"
payload := strings.NewReader("{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.zynpay.com.br/v1/public/pix/charges")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zynpay.com.br/v1/public/pix/charges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amountCents\": 5000,\n \"description\": \"Pedido #8421\",\n \"externalReference\": \"8421\",\n \"expiresInSeconds\": 1800,\n \"customer\": {\n \"name\": \"Maria Silva\",\n \"email\": \"maria@cliente.com\",\n \"externalId\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"charge": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "created",
"amountCents": 123,
"feeCents": 123,
"netAmountCents": 123,
"provider": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"origin": "public_api",
"providerPaymentId": "<string>",
"publicToken": "<string>",
"idempotencyKey": "<string>",
"externalReference": "<string>",
"description": "<string>",
"customer": {
"name": "<string>",
"email": "<string>",
"externalId": "<string>"
},
"pixBrCode": "<string>",
"pixQrCodeImage": "<string>",
"feeSnapshot": {},
"metadata": {},
"expiresAt": "2023-11-07T05:31:56Z",
"paidAt": "2023-11-07T05:31:56Z",
"cancelledAt": "2023-11-07T05:31:56Z",
"nextReconciliationAt": "2023-11-07T05:31:56Z",
"reconciliationAttempts": 123,
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}{
"error": {
"code": "ACCOUNT_NOT_VERIFIED",
"message": "<string>",
"requestId": "<string>",
"fields": {}
}
}Exige uma chave de API com o escopo
pix:write. Veja como criar uma em Autenticação.O cabeçalho
Idempotency-Key é obrigatório. Reenviar a mesma chave com o mesmo corpo retorna a cobrança já criada, sem duplicar; reenviar com um corpo diferente retorna 409 IDEMPOTENCY_KEY_REUSED.Em vez de ficar consultando o status manualmente, configure um webhook para ser avisado no instante em que a cobrança for paga.
Authorizations
Chave de API criada em Integrações → Chaves de API no painel.
Headers
Identificador único seu para essa cobrança. Reenviar a mesma chave com o mesmo corpo retorna a cobrança já criada; com um corpo diferente retorna 409.
Required string length:
1 - 255Body
application/json
Valor da cobrança em centavos.
Required range:
80 <= x <= 9000000000000Example:
5000
Texto exibido para o pagador na tela de checkout.
Required string length:
1 - 255Example:
"Pedido #8421"
Identificador do seu próprio sistema.
Required string length:
1 - 255Example:
"8421"
Tempo até a cobrança expirar, em segundos. Se omitido, o provedor Pix define um prazo padrão.
Required range:
60 <= x <= 604800Example:
1800
Show child attributes
Show child attributes
Response
Cobrança criada
Show child attributes
Show child attributes
⌘I
