cURL
curl --request GET \ --url https://garu.com.br/api/subscription-prices \ --header 'Authorization: Bearer <token>'
Consulte todos os preços de assinatura cadastrados
curl -X GET https://garu.com.br/api/subscription-prices \ -H "Authorization: Bearer sk_test_sua_chave"
prod_abc123xyz
{ "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" } ] }
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');
Was this page helpful?