Faturas
Pagar uma fatura
Cobra uma invoice ou registra um pagamento recebido fora da Chargefy.
curl -X POST "https://api.chargefy.io/v1/invoices/inv_2Th8gTm8USwKEyzo/pay" \
-H "Authorization: Bearer {{API_KEY}}"
{
"id": "inv_2Th8gTm8USwKEyzo",
"object": "invoice",
"allow_late_payment": true,
"amount_credit_balance_applied": 0,
"amount_discount": 0,
"amount_due": 12990,
"amount_due_now": 12990,
"amount_paid": 0,
"amount_remaining": 12990,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"attempt_count": 1,
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created_at": "2026-05-19T18:00:00Z",
"currency": "brl",
"customer": "cus_ukMjNUqTsF6VSsch",
"customer_billing_address": {
"city": "São Paulo",
"country": "BR",
"line1": "Av. Paulista, 1000",
"line2": "Conjunto 101",
"postal_code": "01310-100",
"state": "SP"
},
"customer_billing_name": "Cliente Exemplo",
"customer_document": "12345678901",
"customer_document_type": "cpf",
"customer_email": "[email protected]",
"customer_name": "Cliente Exemplo",
"default_payment_method": "pm_1eSxHPuxYX4TEPEF",
"description": "Ajuste mensal",
"due_date": "2026-05-19T12:00:00Z",
"ending_balance": 0,
"hosted_invoice_url": "https://billing.chargefy.io/invoice/ilink_8Pz6wKf3tVn2Qa9LmXr4Bc7D",
"interest": {
"percent_per_month": 1
},
"interest_amount": null,
"invoice_pdf_url": "https://billing.chargefy.io/invoice/inv_2Th8gTm8USwKEyzo.pdf",
"late_fee": {
"type": "fixed",
"value": 200
},
"late_fee_amount": null,
"latest_charge": null,
"line_items": [
{
"id": "ili_jQEZ9UNmQwSwQ7gs",
"object": "invoice_line_item",
"amount_discount": 0,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"currency": "brl",
"description": "Ajuste mensal",
"discountable": true,
"metadata": {},
"period_end": null,
"period_start": null,
"position": 0,
"price": null,
"price_data": {
"currency": "brl",
"unit_amount": 12990
},
"product": null,
"proration": false,
"proration_details": {},
"quantity": 1,
"recurring_interval": null,
"recurring_interval_count": null,
"subscription_item": null,
"unit_amount": 12990
}
],
"livemode": true,
"marked_uncollectible_at": null,
"metadata": {},
"next_payment_attempt": null,
"number": "K7M2-0001",
"paid_at": null,
"paid_out_of_band": false,
"payment_intent": "pi_XJqChDK8b8WLTpZL",
"payment_method_types": [
"credit_card"
],
"payment_settings": {
"payment_method_options": null
},
"starting_balance": 0,
"statement_descriptor": "AJUSTE MENSAL",
"status": "open",
"subscription": "sub_htW6bkMnkPKd3cD6",
"updated_at": "2026-05-19T18:00:05Z",
"voided_at": null
}
{
"error": {
"code": "invalid_request",
"message": "Only invoices linked to a subscription can be charged through this endpoint; use hosted_invoice_url for standalone invoices",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "resource_state_conflict",
"message": "Invoice can only be paid while open",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "transaction_not_permitted",
"message": "The last attempt on this payment method was permanently declined (transaction_not_permitted) and must not be retried with the same card. Use a different payment method.",
"param": "payment_method",
"type": "card_error"
}
}
Cobranças positivas precisam satisfazer o mínimo do plano efetivo e do método.
Um valor insuficiente retorna
amount_too_small antes do processamento e não
autoriza repetição automática. Veja mínimos e tratamento do erro.open vinculada a uma
subscription. A resposta retorna a invoice completa já apontando para o
payment_intent criado. O resultado final da cobrança chega pelos eventos
payment.intent.* e invoice.*.
Use este endpoint para cobrança server-to-server de invoices de assinatura.
Para uma invoice avulsa, compartilhe hosted_invoice_url; a página hospedada
cria a tentativa de pagamento a partir do método escolhido pelo cliente.
Se o cliente já pagou por fora, envie paid_out_of_band: true para registrar
o pagamento sem cobrá-lo. Veja
pagamento recebido fora da Chargefy.
string
obrigatório
ID da invoice (
inv_*).string
Payment method salvo (
pm_*) para esta tentativa. Quando omitido, a Chargefy
resolve o método na ordem: default_payment_method da invoice,
default_payment_method da subscription, e default_payment_method do
customer. Não pode ser combinado com paid_out_of_band.boolean
padrão:"false"
Quando
true, marca a invoice como paga sem cobrar o cliente. Use quando o
valor foi recebido fora da Chargefy. Veja
pagamento recebido fora da Chargefy.Quando uma tentativa desta invoice já levou uma recusa definitiva — um motivo
marcado como “não repita com o mesmo cartão” no catálogo de
recusas — recobrar com o mesmo
cartão é recusado com
402, devolvendo o code da recusa original
(card_declined quando a tentativa bloqueante não registrou um código).
Envie outro payment_method ou cadastre um novo método para o customer; com
um cartão diferente a tentativa segue normalmente.curl -X POST "https://api.chargefy.io/v1/invoices/inv_2Th8gTm8USwKEyzo/pay" \
-H "Authorization: Bearer {{API_KEY}}"
{
"id": "inv_2Th8gTm8USwKEyzo",
"object": "invoice",
"allow_late_payment": true,
"amount_credit_balance_applied": 0,
"amount_discount": 0,
"amount_due": 12990,
"amount_due_now": 12990,
"amount_paid": 0,
"amount_remaining": 12990,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"attempt_count": 1,
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created_at": "2026-05-19T18:00:00Z",
"currency": "brl",
"customer": "cus_ukMjNUqTsF6VSsch",
"customer_billing_address": {
"city": "São Paulo",
"country": "BR",
"line1": "Av. Paulista, 1000",
"line2": "Conjunto 101",
"postal_code": "01310-100",
"state": "SP"
},
"customer_billing_name": "Cliente Exemplo",
"customer_document": "12345678901",
"customer_document_type": "cpf",
"customer_email": "[email protected]",
"customer_name": "Cliente Exemplo",
"default_payment_method": "pm_1eSxHPuxYX4TEPEF",
"description": "Ajuste mensal",
"due_date": "2026-05-19T12:00:00Z",
"ending_balance": 0,
"hosted_invoice_url": "https://billing.chargefy.io/invoice/ilink_8Pz6wKf3tVn2Qa9LmXr4Bc7D",
"interest": {
"percent_per_month": 1
},
"interest_amount": null,
"invoice_pdf_url": "https://billing.chargefy.io/invoice/inv_2Th8gTm8USwKEyzo.pdf",
"late_fee": {
"type": "fixed",
"value": 200
},
"late_fee_amount": null,
"latest_charge": null,
"line_items": [
{
"id": "ili_jQEZ9UNmQwSwQ7gs",
"object": "invoice_line_item",
"amount_discount": 0,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"currency": "brl",
"description": "Ajuste mensal",
"discountable": true,
"metadata": {},
"period_end": null,
"period_start": null,
"position": 0,
"price": null,
"price_data": {
"currency": "brl",
"unit_amount": 12990
},
"product": null,
"proration": false,
"proration_details": {},
"quantity": 1,
"recurring_interval": null,
"recurring_interval_count": null,
"subscription_item": null,
"unit_amount": 12990
}
],
"livemode": true,
"marked_uncollectible_at": null,
"metadata": {},
"next_payment_attempt": null,
"number": "K7M2-0001",
"paid_at": null,
"paid_out_of_band": false,
"payment_intent": "pi_XJqChDK8b8WLTpZL",
"payment_method_types": [
"credit_card"
],
"payment_settings": {
"payment_method_options": null
},
"starting_balance": 0,
"statement_descriptor": "AJUSTE MENSAL",
"status": "open",
"subscription": "sub_htW6bkMnkPKd3cD6",
"updated_at": "2026-05-19T18:00:05Z",
"voided_at": null
}
{
"error": {
"code": "invalid_request",
"message": "Only invoices linked to a subscription can be charged through this endpoint; use hosted_invoice_url for standalone invoices",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "resource_state_conflict",
"message": "Invoice can only be paid while open",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "transaction_not_permitted",
"message": "The last attempt on this payment method was permanently declined (transaction_not_permitted) and must not be retried with the same card. Use a different payment method.",
"param": "payment_method",
"type": "card_error"
}
}
Pagamento recebido fora da Chargefy
Quando o cliente paga por fora, como em dinheiro em espécie ou por transferência direta para a conta da sua organização, enviepaid_out_of_band: true. A invoice passa a paid sem nenhuma cobrança ao
cliente. Isso vale para qualquer invoice open, inclusive avulsa.
O que acontece:
- A invoice fica
paid, compaid_out_of_band: true,amount_paidigual aamount_dueeamount_remainingzerado. Multa e juros por atraso não são calculados: o valor combinado fora da Chargefy é assunto entre você e o cliente. - O
payment_intentda invoice é cancelado comcancellation_reason: "automatic", e as retentativas e lembretes agendados param. - Se a invoice pertence a uma subscription
past_dueouunpaid, a subscription volta aactive, igual a uma invoice paga pela Chargefy. - Os eventos
invoice.paid,payment.intent.cancelede, quando o status muda,subscription.updatedsão entregues normalmente. - Nenhuma transação, taxa ou repasse é gerado. O valor não entra no seu saldo na Chargefy.
Se uma tentativa de pagamento da invoice ainda está em processamento, a
chamada retorna
409: essa tentativa ainda pode ser concluída, e marcar a
invoice por fora cobraria o cliente duas vezes. Aguarde o resultado pelos
eventos payment.intent.* e tente de novo se a tentativa falhar.curl -X POST "https://api.chargefy.io/v1/invoices/inv_2Th8gTm8USwKEyzo/pay" \
-H "Authorization: Bearer {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"paid_out_of_band": true
}'
{
"id": "inv_2Th8gTm8USwKEyzo",
"object": "invoice",
"allow_late_payment": true,
"amount_credit_balance_applied": 0,
"amount_discount": 0,
"amount_due": 12990,
"amount_due_now": 0,
"amount_paid": 12990,
"amount_remaining": 0,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"attempt_count": 0,
"billing_reason": "subscription_cycle",
"collection_method": "send_invoice",
"created_at": "2026-05-19T18:00:00Z",
"currency": "brl",
"customer": "cus_ukMjNUqTsF6VSsch",
"customer_billing_address": {
"city": "São Paulo",
"country": "BR",
"line1": "Av. Paulista, 1000",
"line2": "Conjunto 101",
"postal_code": "01310-100",
"state": "SP"
},
"customer_billing_name": "Cliente Exemplo",
"customer_document": "12345678901",
"customer_document_type": "cpf",
"customer_email": "[email protected]",
"customer_name": "Cliente Exemplo",
"default_payment_method": "pm_1eSxHPuxYX4TEPEF",
"description": "Ajuste mensal",
"due_date": "2026-05-19T12:00:00Z",
"ending_balance": 0,
"hosted_invoice_url": "https://billing.chargefy.io/invoice/ilink_8Pz6wKf3tVn2Qa9LmXr4Bc7D",
"interest": {
"percent_per_month": 1
},
"interest_amount": null,
"invoice_pdf_url": "https://billing.chargefy.io/invoice/inv_2Th8gTm8USwKEyzo.pdf",
"late_fee": {
"type": "fixed",
"value": 200
},
"late_fee_amount": null,
"latest_charge": null,
"line_items": [
{
"id": "ili_jQEZ9UNmQwSwQ7gs",
"object": "invoice_line_item",
"amount_discount": 0,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"currency": "brl",
"description": "Ajuste mensal",
"discountable": true,
"metadata": {},
"period_end": null,
"period_start": null,
"position": 0,
"price": null,
"price_data": {
"currency": "brl",
"unit_amount": 12990
},
"product": null,
"proration": false,
"proration_details": {},
"quantity": 1,
"recurring_interval": null,
"recurring_interval_count": null,
"subscription_item": null,
"unit_amount": 12990
}
],
"livemode": true,
"marked_uncollectible_at": null,
"metadata": {},
"next_payment_attempt": null,
"number": "K7M2-0001",
"paid_at": "2026-05-22T14:30:00Z",
"paid_out_of_band": true,
"payment_intent": "pi_XJqChDK8b8WLTpZL",
"payment_method_types": [
"credit_card"
],
"payment_settings": {
"payment_method_options": null
},
"starting_balance": 0,
"statement_descriptor": "AJUSTE MENSAL",
"status": "paid",
"subscription": "sub_htW6bkMnkPKd3cD6",
"updated_at": "2026-05-22T14:30:00Z",
"voided_at": null
}
{
"error": {
"code": "invalid_request",
"message": "payment_method cannot be combined with paid_out_of_band",
"param": "payment_method",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "resource_state_conflict",
"message": "A payment attempt for this invoice is in progress and may still be collected; wait for its result before marking the invoice paid out of band",
"type": "invalid_request_error"
}
}
⌘I
curl -X POST "https://api.chargefy.io/v1/invoices/inv_2Th8gTm8USwKEyzo/pay" \
-H "Authorization: Bearer {{API_KEY}}"
{
"id": "inv_2Th8gTm8USwKEyzo",
"object": "invoice",
"allow_late_payment": true,
"amount_credit_balance_applied": 0,
"amount_discount": 0,
"amount_due": 12990,
"amount_due_now": 12990,
"amount_paid": 0,
"amount_remaining": 12990,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"attempt_count": 1,
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created_at": "2026-05-19T18:00:00Z",
"currency": "brl",
"customer": "cus_ukMjNUqTsF6VSsch",
"customer_billing_address": {
"city": "São Paulo",
"country": "BR",
"line1": "Av. Paulista, 1000",
"line2": "Conjunto 101",
"postal_code": "01310-100",
"state": "SP"
},
"customer_billing_name": "Cliente Exemplo",
"customer_document": "12345678901",
"customer_document_type": "cpf",
"customer_email": "[email protected]",
"customer_name": "Cliente Exemplo",
"default_payment_method": "pm_1eSxHPuxYX4TEPEF",
"description": "Ajuste mensal",
"due_date": "2026-05-19T12:00:00Z",
"ending_balance": 0,
"hosted_invoice_url": "https://billing.chargefy.io/invoice/ilink_8Pz6wKf3tVn2Qa9LmXr4Bc7D",
"interest": {
"percent_per_month": 1
},
"interest_amount": null,
"invoice_pdf_url": "https://billing.chargefy.io/invoice/inv_2Th8gTm8USwKEyzo.pdf",
"late_fee": {
"type": "fixed",
"value": 200
},
"late_fee_amount": null,
"latest_charge": null,
"line_items": [
{
"id": "ili_jQEZ9UNmQwSwQ7gs",
"object": "invoice_line_item",
"amount_discount": 0,
"amount_subtotal": 12990,
"amount_tax": 0,
"amount_total": 12990,
"currency": "brl",
"description": "Ajuste mensal",
"discountable": true,
"metadata": {},
"period_end": null,
"period_start": null,
"position": 0,
"price": null,
"price_data": {
"currency": "brl",
"unit_amount": 12990
},
"product": null,
"proration": false,
"proration_details": {},
"quantity": 1,
"recurring_interval": null,
"recurring_interval_count": null,
"subscription_item": null,
"unit_amount": 12990
}
],
"livemode": true,
"marked_uncollectible_at": null,
"metadata": {},
"next_payment_attempt": null,
"number": "K7M2-0001",
"paid_at": null,
"paid_out_of_band": false,
"payment_intent": "pi_XJqChDK8b8WLTpZL",
"payment_method_types": [
"credit_card"
],
"payment_settings": {
"payment_method_options": null
},
"starting_balance": 0,
"statement_descriptor": "AJUSTE MENSAL",
"status": "open",
"subscription": "sub_htW6bkMnkPKd3cD6",
"updated_at": "2026-05-19T18:00:05Z",
"voided_at": null
}
{
"error": {
"code": "invalid_request",
"message": "Only invoices linked to a subscription can be charged through this endpoint; use hosted_invoice_url for standalone invoices",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "resource_state_conflict",
"message": "Invoice can only be paid while open",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "transaction_not_permitted",
"message": "The last attempt on this payment method was permanently declined (transaction_not_permitted) and must not be retried with the same card. Use a different payment method.",
"param": "payment_method",
"type": "card_error"
}
}

