Atualizar Preço de Assinatura
curl --request PATCH \
--url https://garu.com.br/api/subscription-prices/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"amount": 123,
"billingInterval": "<string>",
"trialDays": 123,
"isActive": true
}
'import requests
url = "https://garu.com.br/api/subscription-prices/{id}"
payload = {
"name": "<string>",
"amount": 123,
"billingInterval": "<string>",
"trialDays": 123,
"isActive": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
amount: 123,
billingInterval: '<string>',
trialDays: 123,
isActive: true
})
};
fetch('https://garu.com.br/api/subscription-prices/{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/subscription-prices/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'amount' => 123,
'billingInterval' => '<string>',
'trialDays' => 123,
'isActive' => true
]),
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://garu.com.br/api/subscription-prices/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://garu.com.br/api/subscription-prices/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscription-prices/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_bodyPreços de Assinatura
Atualizar Preço de Assinatura
Atualize um preço de assinatura existente
PATCH
/
api
/
subscription-prices
/
{id}
Atualizar Preço de Assinatura
curl --request PATCH \
--url https://garu.com.br/api/subscription-prices/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"amount": 123,
"billingInterval": "<string>",
"trialDays": 123,
"isActive": true
}
'import requests
url = "https://garu.com.br/api/subscription-prices/{id}"
payload = {
"name": "<string>",
"amount": 123,
"billingInterval": "<string>",
"trialDays": 123,
"isActive": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
amount: 123,
billingInterval: '<string>',
trialDays: 123,
isActive: true
})
};
fetch('https://garu.com.br/api/subscription-prices/{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/subscription-prices/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'amount' => 123,
'billingInterval' => '<string>',
'trialDays' => 123,
'isActive' => true
]),
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://garu.com.br/api/subscription-prices/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://garu.com.br/api/subscription-prices/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/subscription-prices/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"amount\": 123,\n \"billingInterval\": \"<string>\",\n \"trialDays\": 123,\n \"isActive\": true\n}"
response = http.request(request)
puts response.read_bodyVisão Geral
Atualize um preço de assinatura existente. Alterações de valor e período de teste afetam apenas novas assinaturas. Assinaturas existentes mantêm os valores originais.Exemplo de Requisição
curl -X PATCH https://garu.com.br/api/subscription-prices/456 \
-H "Authorization: Bearer sk_test_sua_chave" \
-H "Content-Type: application/json" \
-d '{
"name": "Plano Mensal Premium",
"amount": 59.90,
"isActive": true
}'
const response = await fetch(
'https://garu.com.br/api/subscription-prices/456',
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Plano Mensal Premium',
amount: 59.90,
isActive: true
})
}
);
const preco = await response.json();
console.log(`Preço atualizado: ${preco.name}`);
import requests
import os
url = "https://garu.com.br/api/subscription-prices/456"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}",
"Content-Type": "application/json"
}
payload = {
"name": "Plano Mensal Premium",
"amount": 59.90,
"isActive": True
}
response = requests.patch(url, json=payload, headers=headers)
preco = response.json()
print(f"Preço atualizado: {preco['name']}")
Parâmetros
string
Nome do plano.
number
Valor em Reais (afeta apenas novas assinaturas).
string
Intervalo de cobrança:
daily, weekly, monthly, annually (afeta apenas novas assinaturas).integer
Dias de teste gratuito (afeta apenas novas assinaturas).
boolean
Se o plano está disponível para novos assinantes.
Campos Atualizáveis
| Campo | Descrição | Afeta assinaturas existentes? |
|---|---|---|
name | Nome do plano | Não |
amount | Valor em Reais | Não - apenas novas |
billingInterval | Intervalo de cobrança | Não - apenas novas |
trialDays | Dias de teste | Não - apenas novas |
isActive | Disponibilidade | Não |
Alterações de
amount e trialDays afetam apenas novas assinaturas. Assinaturas existentes mantêm os valores originais contratados.Resposta de Sucesso (200 OK)
{
"id": "price_def456uvw",
"productId": "prod_abc123xyz",
"sellerId": 1,
"name": "Plano Mensal Premium",
"amount": 59.90,
"currency": "BRL",
"billingInterval": "monthly",
"trialDays": 7,
"isActive": true,
"createdAt": "2024-01-15T10:35:00.000Z",
"updatedAt": "2024-01-20T15:00:00.000Z"
}
Desativar um Plano
Para impedir novas assinaturas em um plano sem excluí-lo:curl -X PATCH https://garu.com.br/api/subscription-prices/456 \
-H "Authorization: Bearer sk_test_sua_chave" \
-H "Content-Type: application/json" \
-d '{"isActive": false}'
Desativar um plano não afeta assinaturas existentes. Elas continuam sendo cobradas normalmente.
Erros Comuns
404 - Preço não encontrado
404 - Preço não encontrado
{
"statusCode": 404,
"message": "Subscription price not found"
}
400 - Valor inválido
400 - Valor inválido
{
"statusCode": 400,
"message": ["amount must be a positive number"]
}
Próximos Passos
Excluir Preço
Remova um preço
Listar Assinaturas
Consulte assinaturas ativas
Was this page helpful?