curl --request POST \
--url https://api.example.com/v1/payments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"merchantId": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"customer": {
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"createLink": false,
"rememberSource": false,
"environment": "Digital",
"capture": {
"type": "Automatic"
},
"method": {
"type": "Credit"
},
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"attributes": {
"externalId": "123456"
}
}
'import requests
url = "https://api.example.com/v1/payments"
payload = {
"merchantId": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"customer": {
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"createLink": False,
"rememberSource": False,
"environment": "Digital",
"capture": { "type": "Automatic" },
"method": { "type": "Credit" },
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"attributes": { "externalId": "123456" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
merchantId: '4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2',
orderId: '89f02752-acc9-4a1d-84c7-cdedd61a7a6c',
customer: {
id: '71ddf226-fd85-4256-b91e-c9419777e4b9',
name: 'João Silva',
phoneNumber: '+5511999999999',
email: 'joao.silva@test.com',
document: {type: 'Cpf', number: '22380370044', country: 'BR'},
billingAddress: {
street: 'Avenida Paulista',
number: '1111',
apartment: 'Sala 100',
neighborhood: 'Bela Vista',
city: 'São Paulo',
state: 'SP',
country: 'BR',
postalCode: '01311-200',
longitude: -46.653408,
latitude: -23.56475
}
},
amount: {value: 1000, currency: 'BRL'},
descriptor: 'SUPER',
note: 'Pagamento do pedido 123456',
createLink: false,
rememberSource: false,
environment: 'Digital',
capture: {type: 'Automatic'},
method: {type: 'Credit'},
source: {type: 'customer', customerId: '71ddf226-fd85-4256-b91e-c9419777e4b9'},
items: [
{
name: 'Botijão P13',
description: 'Botijão GLP P13',
quantity: 3,
price: {value: 1000, currency: 'BRL'}
}
],
attributes: {externalId: '123456'}
})
};
fetch('https://api.example.com/v1/payments', 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.example.com/v1/payments",
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([
'merchantId' => '4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2',
'orderId' => '89f02752-acc9-4a1d-84c7-cdedd61a7a6c',
'customer' => [
'id' => '71ddf226-fd85-4256-b91e-c9419777e4b9',
'name' => 'João Silva',
'phoneNumber' => '+5511999999999',
'email' => 'joao.silva@test.com',
'document' => [
'type' => 'Cpf',
'number' => '22380370044',
'country' => 'BR'
],
'billingAddress' => [
'street' => 'Avenida Paulista',
'number' => '1111',
'apartment' => 'Sala 100',
'neighborhood' => 'Bela Vista',
'city' => 'São Paulo',
'state' => 'SP',
'country' => 'BR',
'postalCode' => '01311-200',
'longitude' => -46.653408,
'latitude' => -23.56475
]
],
'amount' => [
'value' => 1000,
'currency' => 'BRL'
],
'descriptor' => 'SUPER',
'note' => 'Pagamento do pedido 123456',
'createLink' => false,
'rememberSource' => false,
'environment' => 'Digital',
'capture' => [
'type' => 'Automatic'
],
'method' => [
'type' => 'Credit'
],
'source' => [
'type' => 'customer',
'customerId' => '71ddf226-fd85-4256-b91e-c9419777e4b9'
],
'items' => [
[
'name' => 'Botijão P13',
'description' => 'Botijão GLP P13',
'quantity' => 3,
'price' => [
'value' => 1000,
'currency' => 'BRL'
]
]
],
'attributes' => [
'externalId' => '123456'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/payments"
payload := strings.NewReader("{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/payments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"merchant": {
"title": "Pedir Gás",
"name": "Pedir Gás",
"categoryCode": "5172",
"url": "https://www.supergasbras.com.br",
"id": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"attributes": {
"externalId": "123456"
}
},
"merchantProvider": {
"provider": {
"id": "e71f2762-e4c4-4ef6-8764-02b97f347ec4",
"name": "Getnet SEP",
"code": "getnetSep",
"type": "Gateway",
"environment": "Digital",
"resolutionKey": "<string>"
},
"name": "Getnet SEP",
"id": "13ef8495-8815-49c8-84fc-382e2cf7a441"
},
"methodResolved": {
"name": "Dinheiro",
"type": "Cash",
"environment": "Physical"
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"capture": {
"type": "Automatic"
},
"state": "Created",
"status": "Pending",
"method": {
"type": "Credit"
},
"operations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "Authorization",
"amount": {
"value": 1000,
"currency": "BRL"
},
"idempotencyKey": "f8347c15-57b7-4213-9c96-00942597b72b",
"status": "Created",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"reason": {
"code": "invalidCredentials",
"message": "Credenciais inválidas"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
],
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
},
"attributes": {
"externalId": "123456"
}
},
"environment": "Digital",
"expiryAt": "2030-06-05T23:59:59-03:00",
"link": {
"url": "https://pagseguro.com.br/v2/checkout/payment.html?code=123456789",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
}
},
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Iniciar pagamento
Inicia um pagamento com os dados informados.
curl --request POST \
--url https://api.example.com/v1/payments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"merchantId": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"customer": {
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"createLink": false,
"rememberSource": false,
"environment": "Digital",
"capture": {
"type": "Automatic"
},
"method": {
"type": "Credit"
},
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"attributes": {
"externalId": "123456"
}
}
'import requests
url = "https://api.example.com/v1/payments"
payload = {
"merchantId": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"customer": {
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"createLink": False,
"rememberSource": False,
"environment": "Digital",
"capture": { "type": "Automatic" },
"method": { "type": "Credit" },
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"attributes": { "externalId": "123456" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
merchantId: '4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2',
orderId: '89f02752-acc9-4a1d-84c7-cdedd61a7a6c',
customer: {
id: '71ddf226-fd85-4256-b91e-c9419777e4b9',
name: 'João Silva',
phoneNumber: '+5511999999999',
email: 'joao.silva@test.com',
document: {type: 'Cpf', number: '22380370044', country: 'BR'},
billingAddress: {
street: 'Avenida Paulista',
number: '1111',
apartment: 'Sala 100',
neighborhood: 'Bela Vista',
city: 'São Paulo',
state: 'SP',
country: 'BR',
postalCode: '01311-200',
longitude: -46.653408,
latitude: -23.56475
}
},
amount: {value: 1000, currency: 'BRL'},
descriptor: 'SUPER',
note: 'Pagamento do pedido 123456',
createLink: false,
rememberSource: false,
environment: 'Digital',
capture: {type: 'Automatic'},
method: {type: 'Credit'},
source: {type: 'customer', customerId: '71ddf226-fd85-4256-b91e-c9419777e4b9'},
items: [
{
name: 'Botijão P13',
description: 'Botijão GLP P13',
quantity: 3,
price: {value: 1000, currency: 'BRL'}
}
],
attributes: {externalId: '123456'}
})
};
fetch('https://api.example.com/v1/payments', 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.example.com/v1/payments",
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([
'merchantId' => '4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2',
'orderId' => '89f02752-acc9-4a1d-84c7-cdedd61a7a6c',
'customer' => [
'id' => '71ddf226-fd85-4256-b91e-c9419777e4b9',
'name' => 'João Silva',
'phoneNumber' => '+5511999999999',
'email' => 'joao.silva@test.com',
'document' => [
'type' => 'Cpf',
'number' => '22380370044',
'country' => 'BR'
],
'billingAddress' => [
'street' => 'Avenida Paulista',
'number' => '1111',
'apartment' => 'Sala 100',
'neighborhood' => 'Bela Vista',
'city' => 'São Paulo',
'state' => 'SP',
'country' => 'BR',
'postalCode' => '01311-200',
'longitude' => -46.653408,
'latitude' => -23.56475
]
],
'amount' => [
'value' => 1000,
'currency' => 'BRL'
],
'descriptor' => 'SUPER',
'note' => 'Pagamento do pedido 123456',
'createLink' => false,
'rememberSource' => false,
'environment' => 'Digital',
'capture' => [
'type' => 'Automatic'
],
'method' => [
'type' => 'Credit'
],
'source' => [
'type' => 'customer',
'customerId' => '71ddf226-fd85-4256-b91e-c9419777e4b9'
],
'items' => [
[
'name' => 'Botijão P13',
'description' => 'Botijão GLP P13',
'quantity' => 3,
'price' => [
'value' => 1000,
'currency' => 'BRL'
]
]
],
'attributes' => [
'externalId' => '123456'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.example.com/v1/payments"
payload := strings.NewReader("{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/payments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"merchantId\": \"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2\",\n \"orderId\": \"89f02752-acc9-4a1d-84c7-cdedd61a7a6c\",\n \"customer\": {\n \"id\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\",\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n },\n \"amount\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n },\n \"descriptor\": \"SUPER\",\n \"note\": \"Pagamento do pedido 123456\",\n \"createLink\": false,\n \"rememberSource\": false,\n \"environment\": \"Digital\",\n \"capture\": {\n \"type\": \"Automatic\"\n },\n \"method\": {\n \"type\": \"Credit\"\n },\n \"source\": {\n \"type\": \"customer\",\n \"customerId\": \"71ddf226-fd85-4256-b91e-c9419777e4b9\"\n },\n \"items\": [\n {\n \"name\": \"Botijão P13\",\n \"description\": \"Botijão GLP P13\",\n \"quantity\": 3,\n \"price\": {\n \"value\": 1000,\n \"currency\": \"BRL\"\n }\n }\n ],\n \"attributes\": {\n \"externalId\": \"123456\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"orderId": "89f02752-acc9-4a1d-84c7-cdedd61a7a6c",
"merchant": {
"title": "Pedir Gás",
"name": "Pedir Gás",
"categoryCode": "5172",
"url": "https://www.supergasbras.com.br",
"id": "4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2",
"attributes": {
"externalId": "123456"
}
},
"merchantProvider": {
"provider": {
"id": "e71f2762-e4c4-4ef6-8764-02b97f347ec4",
"name": "Getnet SEP",
"code": "getnetSep",
"type": "Gateway",
"environment": "Digital",
"resolutionKey": "<string>"
},
"name": "Getnet SEP",
"id": "13ef8495-8815-49c8-84fc-382e2cf7a441"
},
"methodResolved": {
"name": "Dinheiro",
"type": "Cash",
"environment": "Physical"
},
"amount": {
"value": 1000,
"currency": "BRL"
},
"descriptor": "SUPER",
"note": "Pagamento do pedido 123456",
"capture": {
"type": "Automatic"
},
"state": "Created",
"status": "Pending",
"method": {
"type": "Credit"
},
"operations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "Authorization",
"amount": {
"value": 1000,
"currency": "BRL"
},
"idempotencyKey": "f8347c15-57b7-4213-9c96-00942597b72b",
"status": "Created",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"reason": {
"code": "invalidCredentials",
"message": "Credenciais inválidas"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
],
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"id": "71ddf226-fd85-4256-b91e-c9419777e4b9",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
},
"attributes": {
"externalId": "123456"
}
},
"environment": "Digital",
"expiryAt": "2030-06-05T23:59:59-03:00",
"link": {
"url": "https://pagseguro.com.br/v2/checkout/payment.html?code=123456789",
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
}
},
"external": {
"id": "4acebcae92674de18aab02f7a2df2c3c"
},
"items": [
{
"name": "Botijão P13",
"description": "Botijão GLP P13",
"quantity": 3,
"price": {
"value": 1000,
"currency": "BRL"
}
}
],
"source": {
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
},
"attributes": {
"externalId": "123456"
},
"createdAt": "2023-11-07T05:31:56Z",
"modifiedAt": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Corpo
Dados da criação
Identificador do comerciante
"4b3f7d9d-2d1d-48dc-987c-7c74baf16ff2"
Identificador do pedido
"89f02752-acc9-4a1d-84c7-cdedd61a7a6c"
Dados do cliente
Show child attributes
Show child attributes
Valor monetário inteiro com moeda
Show child attributes
Show child attributes
Descrição do pagamento na fatura
"SUPER"
Nota do pagamento
"Pagamento do pedido 123456"
Indica se um link de pagamento deve ser criado
false
Indica se deve persistir a fonte de pagamento
false
Ambiente do pagamento
physical, digital "Digital"
Dados da captura de pagamento
Show child attributes
Show child attributes
Dados do método de pagamento
Show child attributes
Show child attributes
{ "type": "Credit" }
Dados da fonte de pagamento
Show child attributes
Show child attributes
{
"type": "customer",
"customerId": "71ddf226-fd85-4256-b91e-c9419777e4b9"
}
Lista de itens associados ao pagamento
Show child attributes
Show child attributes
Atributos customizados de chave e valor
Show child attributes
Show child attributes
{ "externalId": "123456" }
Resposta
Created
Dados de pagamento
Show child attributes
Show child attributes
Esta página foi útil?