Overview
TheAkatus.NotificacaoPagamento.Notificacao class handles NIP (Notificação Instantânea de Pagamento) - Instant Payment Notifications sent by Akatus when a transaction’s payment status changes. This allows your application to receive real-time updates about payment status changes.
What is NIP?
NIP (Notificação Instantânea de Pagamento) is Akatus’s webhook system that sends POST requests to your server whenever a transaction’s status changes. This allows you to:- Receive real-time payment status updates
- Update your order system automatically
- Trigger business processes based on payment events
- Avoid polling the status API repeatedly
Notificacao Class
processaRetorno()
Processes and validates a payment notification received from Akatus via webhook.The NIP token used to validate that the notification was actually sent by Akatus. This must match the token configured in your Akatus account settings.
The transaction ID in Akatus (GUID format)
The current payment status as a string. Possible values:
- “Aguardando Pagamento”
- “Em Análise”
- “Aprovado”
- “Cancelado”
- “Processando”
- “Completo”
- “Devolvido”
- “Estornado”
- “Chargeback”
Your store’s transaction ID (optional, only if provided during transaction creation)
Returns
Returns anAkatus.NotificacaoPagamento.Retorno object containing the validated notification data.
Retorno Structure
TheRetorno class contains the following properties from the processed notification:
The transaction ID from Akatus
The current payment status as an enum. Possible values:
aguardandoPagamento- Awaiting PaymentemAnalise- Under Analysisaprovado- Approvedcancelado- Canceledprocessando- Processingcompleto- Completedevolvido- Refundedestornado- Reversedchargeback- Chargeback
Your store’s transaction ID (if one was provided)
Webhook Implementation Example
Create an endpoint in your application to receive POST requests from Akatus:Configuration Requirements
Before processing notifications, ensure you have configured the NIP token in yourWeb.Config:
Security Validation
TheprocessaRetorno() method performs important security validations:
- Token Validation: Verifies that the token sent by Akatus matches your configured NIP token. This ensures the notification came from Akatus and not a malicious third party.
- Required Parameters: Validates that all required parameters (token, transacao_id, status) are present in the POST request.
- Exception Handling: Throws exceptions for invalid tokens or missing parameters.
Error Handling
The method throws exceptions in the following scenarios:- Invalid token: When the posted token doesn’t match your configured NIP token
- Missing parameters: When required parameters (token, transacao_id, or status) are not provided
Best Practices
- Respond Quickly: Process the notification and respond to Akatus within a reasonable time to avoid timeouts.
- Idempotency: Handle the possibility of receiving the same notification multiple times. Check if you’ve already processed the transaction before updating your system.
- Logging: Log all received notifications for debugging and audit purposes.
- Status Updates: Update your order/transaction system based on the status received.
- Security: Always validate the token before processing any notification data.
Status Flow
Typical payment status progression:Aguardando Pagamento→CanceladoAprovado→Devolvido(refund initiated)Completo→Estornado(reversal/chargeback)Completo→Chargeback(dispute filed)