Theme switcher

Criar Cobraça

Esse endpoint cria uma cobrança no cartão de crédito.

Feito os passos em Configuração de Cobrança é necessario armazenar os dados da resposta do iframe do 3ds para utilizar no body dessa requisição.

Caso a resposta desse endpoint retorne authData.response, deve iniciar o desafio 3ds, passando authData.response.stepUrl e authData.response.token , seguindo os passos abaixo:

JavaScript
<form id="stepForm" method="POST" target="stepUpIframe"> <input id="stepInputJwt" type="hidden" name="JWT" value="" /> </form> <iframe id="stepIframe" name="stepUpIframe" style="border: none; width: 100%; height: 500px;"></iframe> function startChallenge3DS(stepUrl, stepToken) { const formStep = document.getElementById("stepForm"); const inputJwt = document.getElementById("stepInputJwt"); // Define o endpoint e o token JWT formStep.action = stepUrl; inputJwt.value = stepToken; // Envia o formulário para o iframe formStep.submit(); }

Sempre que o desafio 3DS for acionado, será aberto o iframe do 3DS. O usuário deverá inserir o código enviado pelo banco dentro do iframe para confirmar a transação.

Você deve criar uma página específica para verificar o resultado do pagamento, utilizando o endpoint Obter Transação. Essa página deve consultar o status da transação a cada 5 segundos, verificando se o status retornado é succeeded (sucesso) ou failed (falha).

Após o usuário enviar o código do banco mencionado anteriormente, o sistema chamará automaticamente o redirectURL, abrindo dentro do iframe a página que você criou.

Assim que o endpoint dessa página retornar event.data?.status === "succeeded", significa que a transação foi concluída com sucesso.

Segue abaixo um exemplo de código para criar a página de verificação da transação:

JavaScript
<div id="loading" style="display: none;">Verificando transação...</div> <div id="message" style="display: none; font-weight: bold; margin-top: 10px;"></div> async function verifyTransaction(id) { const loadingElement = document.getElementById("loading"); const messageElement = document.getElementById("message"); loadingElement.style.display = "block"; messageElement.style.display = "none"; let interval = null; try { interval = setInterval(async () => { try { const response = await fetch( `/transactions/credit/get-transaction?transactionId=${id}` ); const res = await response.json(); const status = res.transaction?.status; if (status === "succeeded") { clearInterval(interval); loadingElement.style.display = "none"; messageElement.textContent = "✅ Pagamento concluído com sucesso!"; messageElement.style.color = "green"; messageElement.style.display = "block"; window.parent.postMessage({ status: "succeeded" }, window.location.origin); } if (status === "failed") { clearInterval(interval); loadingElement.style.display = "none"; messageElement.textContent = "❌ Falha ao realizar pagamento."; messageElement.style.color = "red"; messageElement.style.display = "block"; window.parent.postMessage({ status: "failed" }, window.location.origin); } } catch (err) { clearInterval(interval); loadingElement.style.display = "none"; messageElement.textContent = "Erro ao verificar a transação."; messageElement.style.color = "red"; messageElement.style.display = "block"; window.parent.postMessage({ status: "error" }, window.location.origin); } }, 5000); } catch (e) { loadingElement.style.display = "none"; messageElement.textContent = "Erro inesperado."; messageElement.style.color = "red"; messageElement.style.display = "block"; window.parent.postMessage({ status: "error" }, "*"); } } }

Exemplo de Resposta - Endpoint

{ "transaction": { "id": "A0292...", "status": "pending" | "created" | "paid" | "canceled", "amount": "500", "original_amount": "500", "description": "Pagamento CARD", "external_id": "0b2...", "payment_type": "credit_card", "refunded": "0", "voided": "0", "captured": "0", "account_id": "9F41...", "deleted_at": null, "created_at": "2025-10-20T19:10:58.920000Z", "updated_at": "2025-10-20T20:01:10.812000Z", "webhook_url": "https://example.com/webhook", "transactions_pix_cash_in_id": null, "end_to_end_id": null, "payer_name": null, "payer_national_registration": null, "payer_type": null, "gateway": "5", "transactions_bank_slip_id": null, "transaction_type": "5", "payment_link_id": null, "payer_email": null, "in_infraction": false, "token_used": null, "refund_id": null, "bank_ispb": null, "end_to_end_refund_id": null, "is_threeds": true, "iid": "80..." }, "authData": { "action": "REDIRECT", "providerType": "CYBERSOURCE", "responseType": "AUTHENTICATION", "response": { "pareq": "eyJtZ...", "token": "eyJhb..." }, "networkTransactionId": "7609..." } }

Header Parameters

Authorizationstring Required

Colocar no formato Bearer TOKEN

Acceptstring Required

application/json

Content-Typestring Required

application/json

Body Parameters

paymentLinkIdstring Required

ID da transação

amountnumber Required

Valor em centavos de reais

paymentMethodobject Required

Show child attributes

paymentSourceobject Required

Show child attributes

threeDSecure2object Required

Show child attributes

webhook_urlstring

Webhook caso houver

Response

200
Object
{ "transaction": { "id": "A0292...", "status": "pending" | "created" | "paid" | "canceled", "amount": "500", "original_amount": "500", "description": "Pagamento CARD", "external_id": "0b2...", "payment_type": "credit_card", "refunded": "0", "voided": "0", "captured": "0", "account_id": "9F41...", "deleted_at": null, "created_at": "2025-10-20T19:10:58.920000Z", "updated_at": "2025-10-20T20:01:10.812000Z", "webhook_url": "https://example.com/webhook", "transactions_pix_cash_in_id": null, "end_to_end_id": null, "payer_name": null, "payer_national_registration": null, "payer_type": null, "gateway": "5", "transactions_bank_slip_id": null, "transaction_type": "5", "payment_link_id": null, "payer_email": null, "in_infraction": false, "token_used": null, "refund_id": null, "bank_ispb": null, "end_to_end_refund_id": null, "is_threeds": true, "iid": "80..." }, "authData": { "action": "REDIRECT", "providerType": "CYBERSOURCE", "responseType": "AUTHENTICATION", "response": { "pareq": "eyJtZ...", "token": "eyJhb..." }, "networkTransactionId": "7609..." } }
400
Object
Bad Request -- Composição do request inválido
401
Object
Unauthorized -- Chave TOKEN inválida
403
Object
Forbidden -- Apenas administradores
404
Object
Not Found -- Pedido não existe
405
Object
Method Not Allowed -- Método não permitido
406
Object
Not Acceptable -- Formato JSON inválido
410
Object
Gone -- Essa requisição não existe mais
418
Object
I'm a teapot.
429
Object
Too Many Requests -- Muitas requisições em um curto espaço de tempo
500
Object
Internal Server Error -- Favor tente mais tarde
503
Object
Service Unavailable -- Estamos temporariamente inativos, favor aguardar.
Was this section helpful?

What made this section unhelpful for you?

Base URL

Production:

Sandbox:

Language Box

POST

/

Select
1

Response

Was this section helpful?

What made this section unhelpful for you?