Inferring transfer data using webhook events


(Nickforddesign) #1

We are storing references to transfer activity in our own database in order to provide detailed transfer history for users in our application. In order to provide useful data, we need to be able to identify the source and destination, but the webhook data does not distinguish which is which. Currently when a new transfer is initiated, we assume that the first webhook event is regarding the source, and the second is the destination, but because the webhooks fire only 50ms apart, and we have a database write in between, there is a race condition.

What is Dwolla’s best recommendation for responding to transfer_created webhook events to create a complete picture of the transfer? Is there a better approach?

Thanks!


(Spencer Hunter) #2

@nickforddesign, If you are wanting more information on the created transfer then you have a few options on how your application can handle this. You can either call our API to immediately GET the created transfer after it is created, or you can listen for the webhook containing the transfer_created event and then call our API to get more information on the created transfer.

If your application has a valid access token for both user accounts involved in the transaction then you should receive transfer_created webhooks for both accounts. (A single API request can trigger multiple webhooks/events)

Note: We cannot guarantee the order of webhooks fired. In addition, webhook endpoints may occasionally receive the same event more than once. We advise you to build in logic to protect against duplicated events by making your event processing idempotent.


(Spencer Hunter) #3

Also, I forgot to mention that a transfer that is coming from and/or going to a bank account of a fully verified account could also trigger bank_transfer_created events. You’ll want to be sure to account for these events as well and store the associated transfer id alongside the source and/or destination user in your database.


(Chris Antonellis) #4

@spencer, if you could clarify this statement I would appreciate it!

You can … call our API to immediately GET the created transfer after it is created …

When creating a transfer, the response received from Dwolla was a 201 with no body. What do recommend for GETting this transfer without having its ID?


(Spencer Hunter) #5

@chrisantonellis Absolutely. All POSTs returning a 201 should return a link to the created resource in the Location header. You should be able to follow the link in the location header to GET the transfer by Id. :slight_smile: