Detalhes da Assinatura
curl --request GET \
--url https://garu.com.br/api/subscriptions/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscriptions/{id}"
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/subscriptions/{id}', 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/subscriptions/{id}",
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/subscriptions/{id}"
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/subscriptions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscriptions/{id}")
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_body{
"id": 123,
"uuid": "<string>",
"status": "<string>",
"currentPeriodStart": "<string>",
"currentPeriodEnd": "<string>",
"trialEndsAt": {},
"cancelAt": {},
"cancelAtPeriodEnd": true,
"nextPaymentAt": "<string>",
"lastPaymentAt": "<string>",
"failedPaymentCount": 123,
"subscriptionPrice": {},
"customer": {},
"paymentMethod": {}
}Assinaturas
Detalhes da Assinatura
Consulte os detalhes completos de uma assinatura específica
GET
/
api
/
subscriptions
/
{id}
Detalhes da Assinatura
curl --request GET \
--url https://garu.com.br/api/subscriptions/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscriptions/{id}"
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/subscriptions/{id}', 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/subscriptions/{id}",
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/subscriptions/{id}"
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/subscriptions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscriptions/{id}")
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_body{
"id": 123,
"uuid": "<string>",
"status": "<string>",
"currentPeriodStart": "<string>",
"currentPeriodEnd": "<string>",
"trialEndsAt": {},
"cancelAt": {},
"cancelAtPeriodEnd": true,
"nextPaymentAt": "<string>",
"lastPaymentAt": "<string>",
"failedPaymentCount": 123,
"subscriptionPrice": {},
"customer": {},
"paymentMethod": {}
}Visão Geral
Este endpoint retorna os detalhes completos de uma assinatura específica, incluindo informações do cliente, preço, método de pagamento e histórico de eventos.Exemplo de Requisição
curl -X GET https://garu.com.br/api/subscriptions/100 \
-H "Authorization: Bearer sk_test_sua_chave"
const response = await fetch(
'https://garu.com.br/api/subscriptions/100',
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const subscription = await response.json();
console.log(`Cliente: ${subscription.customer.name}`);
console.log(`Status: ${subscription.status}`);
console.log(`Próximo pagamento: ${subscription.nextPaymentAt}`);
import requests
import os
url = "https://garu.com.br/api/subscriptions/100"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}"
}
response = requests.get(url, headers=headers)
subscription = response.json()
print(f"Cliente: {subscription['customer']['name']}")
print(f"Status: {subscription['status']}")
print(f"Próximo pagamento: {subscription['nextPaymentAt']}")
Resposta de Sucesso
number
ID interno da assinatura.
string
Identificador único da assinatura.
string
Status atual:
pending, active, pending_cancellation, canceled, failed.string
Início do período de cobrança atual (ISO 8601).
string
Fim do período de cobrança atual (ISO 8601).
string | null
Data de término do período de teste.
string | null
Data agendada para cancelamento.
boolean
Se o cancelamento ocorrerá ao fim do período.
string
Data da próxima cobrança.
string
Data do último pagamento.
number
Número de tentativas de pagamento falhas.
object
Detalhes do preço/plano da assinatura.
object
Dados do cliente.
object
Método de pagamento associado.
Exemplo de Resposta (200 OK)
{
"id": 100,
"uuid": "sub_xyz789",
"customerId": 50,
"subscriptionPriceId": 456,
"sellerId": 1,
"status": "active",
"currentPeriodStart": "2024-02-15T00:00:00.000Z",
"currentPeriodEnd": "2024-03-15T00:00:00.000Z",
"trialEndsAt": null,
"cancelAt": null,
"cancelledAt": null,
"cancelAtPeriodEnd": false,
"paymentMethodId": 789,
"lastPaymentAt": "2024-02-15T10:00:00.000Z",
"nextPaymentAt": "2024-03-15T10:00:00.000Z",
"failedPaymentCount": 0,
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-02-15T10:00:00.000Z",
"subscriptionPrice": {
"id": 456,
"uuid": "price_def456uvw",
"name": "Plano Mensal",
"unitAmount": 49.90,
"billingInterval": "monthly",
"product": {
"id": 123,
"name": "Premium Membership"
}
},
"customer": {
"id": 50,
"name": "João Silva",
"email": "joao@example.com"
},
"paymentMethod": {
"id": 789,
"cardLast4": "4242",
"cardBrand": "visa"
}
}
Exemplo Completo
async function verificarStatusAssinatura(subscriptionId) {
const response = await fetch(
`https://garu.com.br/api/subscriptions/${subscriptionId}`,
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const subscription = await response.json();
// Verificar se está ativa
const isActive = subscription.status === 'active';
// Verificar se está em período de teste
const inTrial = subscription.trialEndsAt &&
new Date(subscription.trialEndsAt) > new Date();
// Verificar se tem cancelamento agendado
const willCancel = subscription.cancelAtPeriodEnd ||
subscription.status === 'pending_cancellation';
return {
isActive,
inTrial,
willCancel,
nextPayment: subscription.nextPaymentAt,
plan: subscription.subscriptionPrice.name,
customer: subscription.customer
};
}
// Uso
const status = await verificarStatusAssinatura(100);
if (status.isActive) {
console.log(`Assinatura ativa: ${status.plan}`);
console.log(`Próxima cobrança: ${status.nextPayment}`);
}
Próximos Passos
Eventos da Assinatura
Histórico de eventos e pagamentos
Cancelar Assinatura
Cancele uma assinatura
Pausar Assinatura
Pause temporariamente as cobranças
Portal do Cliente
Autoatendimento para assinantes
Was this page helpful?