/
API PIX Datacake

API PIX Datacake

APIs PIX

Ā 

A autenticaĆ§Ć£o para consumo das APIs Ć© feito por meio de JWT. Deve-se entĆ£o enviar o seguinte header em todas as requisiƧƵes:

{ "Authorization": "Bearer {{token}}" }

Sendo o token recuperado pela seguinte requisiĆ§Ć£o.

Exemplo em python:

import requests import json url = "http://localhost:8000/api/token/" payload = json.dumps({ "username_or_email": "{{email}}", "password": "{{password}}" }) headers = { 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload)

Ā 

Resposta:

Status 200

{ "data": { "token": "{{token}}" } }

Ā 

Listar Contratos

GET: {{url}}/api/integrator/contract/?taxvat=01234567899

ParĆ¢metros:

  • taxvat = CPF ou CNPJ do cliente (ObrigatĆ³rio)

Ā 

import requests url = "http://localhost:8000/api/integrator/contract/?taxvat=01234567899" payload={} headers = { 'Authorization': 'Bearer {{token}}' } response = requests.request("GET", url, headers=headers, data=payload)
{ "data": [ { "type": "ContractViewSet", "id": "1", "attributes": { "integration": 9, "remote_id": "1", "contract_name": "contrato 1" } }, { "type": "ContractViewSet", "id": "2", "attributes": { "integration": 9, "remote_id": "2", "contract_name": "contrato 2" } } ] }

Se nĆ£o houver contratos ou nĆ£o for informado pelo ERP, retorna uma lista vazia, mas sem erro:

{ "data": [] }

Listar Boletos

GET: {{url}}/api/integrator/unpaid_bill/?taxvat=01234567899&contract_id=1234

ParĆ¢metros:

  • taxvat = CPF ou CNPJ do cliente (ObrigatĆ³rio)

  • contract_id = Id do contrato (Opcional)

Ā 

Esta requisiĆ§Ć£o irĆ” listar os boletos em aberto no ERP e filtrados pela Regra de CobranƧa, se houver. InformaƧƵes de valor nĆ£o serĆ£o apresentadas neste momento.

Ā 

import requests url = "http://localhost:8000/api/integrator/unpaid_bill/?taxvat=08335564876&contract_id=18945" payload={} headers = { 'Authorization': 'Bearer {{token}}' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text)
{ "data": [ { "type": "UnpaidBillViewSet", "id": "012345678999231", "attributes": { "integration": null, "fatura": "012345678999231", "customer_name": "Ava Zimmerman", "valor": null, "valor_inicial": null, "juros": null, "multa": null, "desconto": null, "emissao": "2022-08-16", "vencimento": "2022-08-30", "historico": "Boleto Datacake", "boleto": "http://localhost:8000/api/integrator/unpaid_bill/083355648769231-08335564876/get_boleto/?integrations=9&internal_pdf=true", "bank_code": null, "barcode": null, "boleto_totem": "http://localhost:8000/api/integrator/unpaid_bill/083355648769231-08335564876/print_boleto/?integrations=9&contract_id=1", "code_fatura": "012345678999231-01234567899", "document_number": "01234567899", "remote_id": "01234", "integration_id": "9", "identifier": null, "pix_code": null, "bill_receipt": null, "bill_pix_receipt": null } }, ] }
{ "errors": "Boletos em aberto nĆ£o encontrados ou cliente nĆ£o existe." }

Pegar Boleto Especifico

GET: {{url}}/api/integrator/unpaid_bill/{{code_fatura}}/get_unpaid_bill/

ParĆ¢metros:

  • code_fatura: Obtido na request anterior

Ā 

import requests url = "http://localhost:8000/api/integrator/unpaid_bill/012345678999231-01234567899/get_unpaid_bill/" payload={} headers = { 'Authorization': 'Bearer {{token}}' } response = requests.request("GET", url, headers=headers, data=payload)
{ "data": { "type": "UnpaidBillViewSet", "id": "012345678999231", "attributes": { "integration": null, "fatura": "012345678999231", "customer_name": "Ava Zimmerman", "valor": 0.1, "valor_inicial": 0.1, "juros": null, "multa": null, "desconto": null, "emissao": "2022-08-16", "vencimento": "2022-08-30", "historico": "Boleto Datacake", "boleto": "http://localhost:8000/api/integrator/unpaid_bill/083355648769231-08335564876/get_boleto/?integrations=9&internal_pdf=true", "bank_code": null, "barcode": "09394985755382544014802844544082887801550238853", "boleto_totem": "http://localhost:8000/api/integrator/unpaid_bill/083355648769231-08335564876/print_boleto/?integrations=9&contract_id=None", "code_fatura": "012345678999231-01234567899", "document_number": "01234567899", "remote_id": "01234", "integration_id": "9", "identifier": "2", "pix_code": null, "bill_receipt": null, "bill_pix_receipt": null } } }
{ "errors": "Boleto nĆ£o encontrado." }

Gerar Pix pelo code_fatura

GET: {{url}}/api/integrator/unpaid_bill/{{code_fatura}}/get_pix/

ParĆ¢metros:

  • code_fatura: Obtido na request anterior

Ā 

import requests url = "http://localhost:8000/api/integrator/unpaid_bill/012345678999231-01234567899/get_pix/" payload={} headers = { 'Authorization': 'Bearer {{token}}' } response = requests.request("GET", url, headers=headers, data=payload)
{ "data": { "type": "UnpaidBillViewSet", "id": "6cbf058e-6b6a-4a64-9680-cafc4a8ab55a", "attributes": { "integration_response": {}, "extra_data": { "descriptition": "Totem Datacake - Boleto: #083355648769231", "pix_key": "30273146000171", "merchant_name": "DATACAKE", "merchant_city": "LENƇƓIS PAULISTA", "customer_code": null, "customer_name": null, "transaction_id": "6cbf058e-6b6a-4a64-9680-cafc4a8ab55a" }, "payment_type": "pix", "origin": "UNKNOWN", "class_type": "charge", "totem_uuid": null, "expiration_date": null, "pix_location": null, "pix_integration_id": "1", "br_code": "00020101021126810014br.gov.bcb.pix0114302731460001710241Totem Datacake - Boleto: 08335564876923152040000530398654040.105802BR5908DATACAKE6015LENCOIS PAULIST610918682-57062290525202208231215DATACAKE1tq3163049E4B", "data_fiscal": null, "txid": "202208231215DATACAKE1tq31", "bill_id": "083355648769231", "card_type": null, "payment_method_name": "Pix 1", "advanced_status": "ATIVA", "nsu_host": null, "ip_origem": null, "cupom_fiscal": null, "total": "0.10", "gateway_response": null, "error": null, "nsu_sitef": null, "pinpad_response": {}, "captured_amount": "0.10", "transaction_id": "202208231215DATACAKE1tq31", "compiled_status": "Status: Success<br />IntegraĆ§Ć£o: Desconhecido<br />AvanƧado: Ativa/NĆ£o Paga<br />", "refund_amount": "0.00", "status": "success", "hora_fiscal": null, "payment_date": null, "hold_mount": "0.00", "integration_status": null, "advanced_id": "6cbf058e-6b6a-4a64-9680-cafc4a8ab55a", "customer_taxvat": "08335564876", "integration_id": "9", "token": "", "created": "2022-08-23T12:15:56.431851-03:00", "updated": "2022-08-23T12:15:56.586389-03:00", "reference": "202208231215DATACAKE1tq31" }, "relationships": { "user": { "links": { "self": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/relationships/user/", "related": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/user/" }, "data": null }, "billing_address": { "links": { "self": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/relationships/billing_address/", "related": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/billing_address/" }, "data": null }, "payment_method": { "links": { "self": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/relationships/payment_method/", "related": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/payment_method/" }, "data": { "type": "PaymentMethod", "id": "1" } }, "credit_card": { "links": { "self": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/relationships/credit_card/", "related": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/credit_card/" }, "data": null }, "order": { "links": { "self": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/relationships/order/", "related": "/api/store/transaction/6cbf058e-6b6a-4a64-9680-cafc4a8ab55a/order/" }, "data": null } } } }
{ "errors": "Erro ao gerar PIX. Por favor tente novamente em instantes." }

Verificar Pix pelo txid

GET: {{url}}/api/pix/integration/{{txid}}/check_transaction_status/

ParĆ¢metros:

  • txid: Obtido na request anterior

Retorna booleano para situaĆ§Ć£o para Pago/NĆ£o Pago

Ā 

import requests url = "http://localhost:8000/api/pix/integration/202208231215DATACAKE1tq31/check_transaction_status/" payload={} headers = { 'Authorization': 'Bearer {{token}}' } response = requests.request("GET", url, headers=headers, data=payload)
{ "data": { "status": true } }
{ "errors": { "status": false } }
{ "errors": { "status": false } }

Ā 

Ā 

Ā 

Ā 

Ā 

Related content