What is the best practice for processing webhooks? What if a webhook fails?
In this article group
- What countries does Lean support for international transfers?
- Many banks in the UAE have a beneficiary cool down period, is there a workaround to avoid this?
- Can a payment intent be cancelled? Also, can a payment intent be usable after the associated payment has failed?
- When a payment initiation has been completed, what does the status “PENDING_WITH_BANK” specify?
- How does Lean confirm that the payment has been successfully made?
- Which types of bank accounts can be used to make a payment?
- How does payment settlement work in the UAE?
- How long will payments take to settle for international payments from the UAE?
- What transfer currencies does Lean support?
- Updating Payment Destination
- How to prevent user pay for multiple times? (Idempotency)
- Is there an expiry period of Customer ID/Destination ID?
- Payment source: "destination for payment source already exists"
- Do you have a sample data format for the webhooks you send?
Webhooks are used to immediately notify your integration of events that take place in the Lean ecosystem. They are especially useful for events that take place on your front end through the Lean SDK or events that take place asynchronously, for example updating you about the status of a payment.
Webhooks can be handled by your integration in 2 ways:
Asynchronously (strongly recommended):
Your backend receives Lean webhook call
Acknowledges it by returning 200 OK to the Lean platform
Then executes code that deals with the webhook content
And finally marks the webhook ID as “executed” so they don’t execute the code twice.
Synchronously:
Your backend receives Lean webhook call
Processes the request on their side
Marks the webhook ID as “executed” so you don’t execute the code twice
And finally returns the response with a 200 OK back to the Lean platform.
To make sure that Lean webhooks are captured successfully by your backend, if the Lean platform doesn’t receive a 200 OK response within 10 seconds, we will try to resend the webhook in increasing intervals. See here for the detailed mechanism.
Therefore, we strongly advise you to implement all webhooks “ASYNCHRONOUSLY”, to avoid processing the same request several times due to delay issues in returning the 200 OK in the right time.