7. Receiving the webhook

PagBrasil will send a webhook to your server whenever a subscription is changed.

You need to login to the PagBrasil Dashboard and specify the URL you want PagBrasil to send the webhook. By default we only allow outgoing connections to HTTPS URLs at standard port 443. If you plan to use a different port number in the webhook's URL please contact us requesting an exception.

Webhook content has the following structure:

Field

Description

Length

Field

Description

Length

secret

Secret phrase as defined in the PagBrasil Dashboard

128

subscription

Subscription identification

9

status

0 = Waiting for first payment
1 = Active
2 = Pending payment
3 = Inactive/Cancelled
4 = Expired
5 = Paused

1

amount_brl

Amount in Brazilian Real of the recurring charge

7.2

next_billing_date

Start date for the first recurring charge.
Format: YYYY-MM-DD

10

signature

HMAC-MD5 hash that authenticates the webhook.

See note "c"   

32

Notes:

a) Response format is defined at the PagBrasil Dashboard. API's response format may be defined as XML or JSON, and the webhook may be sent as an XML, a JSON or a POST.


b) After processing our webhook, your server needs to acknowledge that it has successfully received it by writing "Received successfully [timestamp]". If the webhook fails our system will e-mail your technical contact a warning notification (subject "Urgent: Error posting webhook"). If you activate the auto resend, our system will then try to resend failed webhook as follows:

  • The next 7 attempts will take place every 7 minutes.

  • The next 23 attempts will take place every 60 minutes. If the last attempt of sending the webhook fails, our system will e-mail another warning notification (subject "Urgent: Error posting webhook").

Please note that any webhook can be resent manually at any time at the PagBrasil Dashboard.


c) To authenticate the legitimacy of the webhook, you may check the parameter secret and/or the parameter signature, which is a HMAC-MD5 hash based on the values of all elements (except the secret) and a key defined at the PagBrasil Dashboard, menu Account > Settings. The HMAC-MD5 source string is the concatenation of all the elements that are present in the structure and its total length.

CONFIDENTIAL