Listar Preços de Assinatura
curl --request GET \
--url https://garu.com.br/api/subscription-prices \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscription-prices"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/subscription-prices', 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://garu.com.br/api/subscription-prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/subscription-prices"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://garu.com.br/api/subscription-prices")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscription-prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyPreços de Assinatura
Listar Preços de Assinatura
Consulte todos os preços de assinatura cadastrados
GET
/
api
/
subscription-prices
Listar Preços de Assinatura
curl --request GET \
--url https://garu.com.br/api/subscription-prices \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscription-prices"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/subscription-prices', 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://garu.com.br/api/subscription-prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/subscription-prices"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://garu.com.br/api/subscription-prices")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscription-prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyVisão Geral
Retorna todos os preços de assinatura do vendedor autenticado.Exemplo de Requisição
curl -X GET https://garu.com.br/api/subscription-prices \
-H "Authorization: Bearer sk_test_sua_chave"
const response = await fetch(
'https://garu.com.br/api/subscription-prices',
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const { data } = await response.json();
data.forEach(preco => {
console.log(`${preco.name}: R$ ${preco.amount.toFixed(2)}/${preco.billingInterval}`);
});
import requests
import os
url = "https://garu.com.br/api/subscription-prices"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}"
}
response = requests.get(url, headers=headers)
result = response.json()
for preco in result['data']:
print(f"{preco['name']}: R$ {preco['amount']:.2f}/{preco['billingInterval']}")
Parâmetros de Query
Filtrar por UUID do produto (ex:
prod_abc123xyz).Filtrar por status ativo/inativo.
Resposta de Sucesso (200 OK)
{
"data": [
{
"id": "price_def456uvw",
"productId": "prod_abc123xyz",
"name": "Plano Mensal",
"amount": 49.90,
"currency": "BRL",
"billingInterval": "monthly",
"trialDays": 7,
"isActive": true,
"createdAt": "2024-01-15T10:35:00.000Z"
},
{
"id": "price_ghi789abc",
"productId": "prod_abc123xyz",
"name": "Plano Anual",
"amount": 479.00,
"currency": "BRL",
"billingInterval": "annually",
"trialDays": 14,
"isActive": true,
"createdAt": "2024-01-15T10:40:00.000Z"
}
]
}
Exemplo: Listar Preços por Produto
async function listarPrecosPorProduto(productId) {
const response = await fetch(
`https://garu.com.br/api/subscription-prices?productId=${productId}`,
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const { data } = await response.json();
return data.map(preco => ({
id: preco.id,
nome: preco.name,
valor: preco.amount,
moeda: preco.currency,
intervalo: preco.billingInterval,
trialDias: preco.trialDays,
checkoutUrl: `https://garu.com.br/pay/${productId}?priceId=${preco.id}`
}));
}
// Uso:
const precos = await listarPrecosPorProduto('prod_abc123xyz');
Próximos Passos
Detalhes do Preço
Consulte os detalhes de um preço específico
Atualizar Preço
Atualize um preço existente
Was this page helpful?
⌘I