How to Subscribe to Webhooks
Need to Know
- Subscribe to changes in Paytron accounts using the create subscription endpoint.
- You need to create a subscription for each resource type in the account (e.g. payments, and bills).
- Resource types match those available as options for Paytron Links (always lowercase, always plural).
- Any event in the system for that resource will be sent to your specified callback URL.
- All event messages will include the full resource data, matching the API contract for that resource type.
- Delivery will be retried with a linear back-off up to 5 times before it's considered failed.
How to Subscribe
Paytron manages subscription at a resource level, with every type of resource (e.g. bills or payments) requiring its own distinct subscription.
Each subscription specifies a callback URL for delivery of webhook messages, along with its own unique client secret. To create a new webhook subscription, send a PUT
request to the subscriptions/{resourceType}
endpoint.
Subscriptions can share a callback URL, or can have their own unique callback URL.
When successfully creating a new subscription, or replacing an old one, you will receive a unique subscriptionSecret
. Make sure you store this securely in your system as you will need it to verify request signatures later.
Receiving Webhook Events
Webhook events will be sent to you any time a subscribed resource is added, modified or removed from the Paytron system.
Each webhook event will contain an event name, indicating what happened, as well as the full data for that resource if it still exists after the operation.
Paytron will attempt delivery of the message 5 times, with a linear back-off, before marking delivery as failed. If you believe you have missed an event, you can use the list events endpoint to retrieve it.
Webhook Event Format
All Paytron webhooks have the same top level JSON structure, with the affected resource provided in the data
parameter. The format will match the API contract for the specified resource type.
Note: Paytron Links are not available to webhook events.
The event looks as follows:
{
"accountId": "1245-6789",
"resourceType": "payments",
"resourceId": "1234-5678", // i.e. the payment ID or bill ID
"eventName": "payment_updated",
"messageId": "1234-5678",
"sentAt": "2023-04-11T11:52:12.875Z",
"data":{
// API version of your resource
}
}
Available Events
Payment Events
The table below lists all currently supported payment events, available on resource type payments
:
Event Name | Description |
---|---|
payment_created | A new payment has been created in the indicated Paytron account. |
payment_deleted | A payment has been deleted from the indicated Paytron account. |
beneficiary_changed | The beneficiary for this payment has been modified. |
payment_amount_changed | The amount for this payment has been modified. |
payment_currency_changed | The currency of this payment has been modified. |
payment_reference_changed | The reference of this payment has been modified. |
payment_pay_date_changed | The payment's pay date has been modified. |
payment_reason_changed | The payment reason for this payment has been modified. |
payment_purpose_changed | The purpose code for this payment has been modified. |
payment_bill_added | This payment has been associated with a Paytron bill. |
payment_bill_removed | This payment's associated with a Paytron bill has been removed. |
payment_submitted_for_approval | This payment has been sent for approval. |
payment_approved | All required approvers have approved this payment and it is free to proceed. |
payment_rejected | An approver has chosen to reject this payment and it cannot proceed. |
payment_executed | This payment has been sent for execution. |
payment_failed | This payment has failed during execution. |
payment_completed | This payment has been accepted by our banking partners and marked complete. |
payment_returned | This payment was completed, however the beneficiary's bank has returned the funds to Paytron. |
payment_awaiting_funds | Payment execution was attempted, however the funding wallet does not have sufficient funds. |
Bill Events
The table below lists all currently supported bills events, available on the resource type bills
:
Event Name | Description |
---|---|
bill_created | A new bill has been created in the indicated Paytron account. |
bill_deleted | This bill has been deleted from the indicated Paytron account. |
beneficiary_changed | The beneficiary on this bill has been modified. |
bill_date_changed | The bill date for this bill has been modified. |
bill_due_date_changed | The due date for this bill has been modified. |
bill_amount_changed | The total amount on this bill has been modified. |
bill_currency_changed | The currency for this bill has been modified. |
attachment_added | A new attachment has been added to this bill. |
attachment_removed | An attachment has been removed from this bill. |
line_item_added | A new line item has been added to this bill. |
line_item_removed | A line item has been removed from this bill. |
line_item_modified | An existing line item on this bill has been modified. |
bill_submitted_for_approval | This bill has been sent for approval. |
bill_approved | All required approvers have approved this bill. |
bill_rejected | This bill has been rejected by an approver |
bill_paid | This bill has been paid in full. |
bill_archived | This bill has been archived in the Paytron account. |
bill_restored | This bill was previously archived but is now active again. |
bill_moved_to_draft | This bill has been moved from another status back to draft. |
Updated over 1 year ago