If you try to pay for a boleto right after you get it, it might not work. This is because all boletos need to be registered with the CIP (Câmara Interbancária de Pagamentos) before it’ll work. Sometimes, this can be delayed a couple of hours.
So, if your bank shows you a message that your boleto isn’t registered, all you have to do is wait for a couple of hours and try again. It should work after this.