Pausar Assinatura
curl --request POST \
--url https://garu.com.br/api/subscriptions/{id}/pause \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscriptions/{id}/pause"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/subscriptions/{id}/pause', 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}/pause",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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}/pause"
req, _ := http.NewRequest("POST", 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.post("https://garu.com.br/api/subscriptions/{id}/pause")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscriptions/{id}/pause")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyAssinaturas
Pausar Assinatura
Pause temporariamente as cobranças de uma assinatura
POST
/
api
/
subscriptions
/
{id}
/
pause
Pausar Assinatura
curl --request POST \
--url https://garu.com.br/api/subscriptions/{id}/pause \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/subscriptions/{id}/pause"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/subscriptions/{id}/pause', 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}/pause",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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}/pause"
req, _ := http.NewRequest("POST", 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.post("https://garu.com.br/api/subscriptions/{id}/pause")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscriptions/{id}/pause")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyVisão Geral
Pause temporariamente as cobranças de uma assinatura. O cliente pode manter ou perder acesso durante a pausa, dependendo da sua implementação. Use o endpoint de retomar para reativar as cobranças.Exemplo de Requisição
curl -X POST https://garu.com.br/api/subscriptions/100/pause \
-H "Authorization: Bearer sk_test_sua_chave"
const response = await fetch(
'https://garu.com.br/api/subscriptions/100/pause',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const result = await response.json();
console.log(`Status: ${result.status}`); // "paused"
console.log(`Pausada em: ${result.pausedAt}`);
import requests
import os
url = "https://garu.com.br/api/subscriptions/100/pause"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}"
}
response = requests.post(url, headers=headers)
result = response.json()
print(f"Status: {result['status']}") # "paused"
print(f"Pausada em: {result['pausedAt']}")
Resultado
- Status muda para
paused - Cobranças são suspensas
- Nenhum pagamento será tentado enquanto pausada
- Use retomar para reativar
Resposta de Sucesso (200 OK)
{
"id": 100,
"status": "paused",
"pausedAt": "2024-02-20T10:00:00.000Z",
"message": "Assinatura pausada com sucesso"
}
Considerações
Acesso durante a pausa: A decisão de manter ou revogar o acesso do cliente durante a pausa é da sua aplicação. A Garu apenas suspende as cobranças.
Assinaturas pausadas por muito tempo podem precisar de atualização do método de pagamento ao serem retomadas.
Erros Comuns
404 - Assinatura não encontrada
404 - Assinatura não encontrada
{
"statusCode": 404,
"message": "Subscription not found"
}
400 - Assinatura não pode ser pausada
400 - Assinatura não pode ser pausada
{
"statusCode": 400,
"message": "Cannot pause subscription with current status"
}
Próximos Passos
Retomar Assinatura
Reative as cobranças de uma assinatura pausada
Cancelar Assinatura
Cancele definitivamente uma assinatura
Was this page helpful?