Handling TED reversals

How the system behaves when TEDs are refunded

In the Brazilian Payments System(SPB) all TED transfers are only validated when they get in the destination bank, and in case the destination account is blocked or does not exist, the destination bank sends the TED back to the sender. This operation is pretty common in the real world for users and should be mapped properly to avoid confusions.

Depending on the provider you should expect different outcomes of a refund. In this section we explain how it works in each one.


DOCK Provider Refunds

In the DOCK Provider, TEDs are kept in the authorized state until we receive a confirmation of the destination bank, that can happen from 15 minutes to 48 hours after you make the TED request. If we receive the information that the withdraw was rejected, then we transit the transaction to the failed state, and if the transaction was completed successfully it goes to executed state and later notified after the postback notification is sent to the mediator(for more informations on this flow check out Setup your Domain postbacks.


STR Provider Refunds

When you're using the STR Provider the flow is a little different, so when the user requests for the TED, it is created in the authorized state and when the Central Bank confirms the withdraw we send it to a executed state, later going to notified, and that's the final state of the transaction.
If the transaction gets rejected by the destination bank, it's created another transaction of the type transaction_reversal with the credited amount referencing the original transaction.
In the additionalInfo of the transaction reversal will be a lot more informations about the reason for the rejection, like in the example below:

"additionalData": {
            "originalTransaction": "8eb377ad9ea0d264c7fb6741dbe1ae1c9715a23d7c3cb10081fc5f86e7d2f824",
            "externalTransaction": {
                "id": "STR20200320033505129"
            },
            "description": "Ausência ou Divergência na Indicação do CPF/CNPJ",
            "reasonCode": "3",
            "reversal": true,
            "hash": "f2da94713e35b7da8749ab37b43a61bfe341ccf7f0b45e771114c2660ec72318"
}

All description and reasonCode fields use the same values defined by the Brazilian Central Bank Domains Dictionary related with the CodDevTransf field.