Inconsistent destination link on transfer resource, depending on customer type of recipient

Hello, I’m hoping to find some good pointers towards creating a truly ironclad webhook endpoint that can always tell when funds have moved from point A to B. Apologies for the length of this post…articulating the issue I have is difficult.

In our application, the following types of transfers occur:

verified customer => verified customer
verified customer => unverified customer
unverified customer => verified customer

In all situations, the funds are moving from one bank account (A) to another bank account (B). I understand that several transfer resources are created under the hood to process/track this in Dwolla, and the number of transfers made will either be 3 (verified & verified, both have balances) or 2 (verified and unverified).

I’ve noticed that when point B is a funding source owned by a verified customer, there will be a final “bank transfer” that represents the funds moving from that customer’s Dwolla balance to their bank. On the transfer resource, the destination link will be equivalent to the funding source URL of the point B bank. This is an easy check in the webhook endpoint - if a customer_bank_transfer_completed event occurs & the destination on the transfer resource is equal to the URL of the bank account, then the transfer is fully completed A to B.

However, if the receiving customer is unverified, the final event marking A to B will be a customer_transfer_completed event. Which makes sense, since the funds never touched a dwolla balance owned by that customer. But for transfers going to an unverified customer, the destination on the transfer resource will be the Dwolla customer URL of the receiving customer, not their funding source.

This makes things more complicated. Now the webhook endpoint needs to check whether the transfer resource has a funded-transfer link, i.e. determine whether this is the final transfer in the pipeline.

However, there’s another edge case in which an event that looks exactly like this will occur, when a transfer going from verified => verified fails to complete the final bank transfer due to a negative dwolla balance on the receiving customer. A customer_bank_transfer_creation_failed event will occur simultaneously, but depending on the order they’re processed, sometimes the customer_transfer_completed event, since it doesn’t have a funded-transfer link, causes a transfer to be marked “processed” in our system, when that transfer is actually stuck in a balance. Obviously, this causes issues…

This is where I’m kind of stumped & feel I’m missing something. The amount of logic and API calls already needed just to determine the true “status” of a transfer is getting unwieldy.

I would humbly suggest 2 changes to events be considered:

Change the destination link on the transfer resource to correspond to the funding source it is going to for that transfer. Whether it is a bank account or dwolla balance, I feel this field should always be a funding source instead of a customer. That way, one easy check would be destination_funding_source === destination, i.e. the final destination is equal to the destination for this transfer.

Introduce transfer_pipeline_created and transfer_pipeline_completed
These events would represent the creation and completion of a transfer and all it’s subsequent funded-transfers. There could also be a _failed event that represents the failure of the pipeline to complete.

If you read all of that, thank you :pray:

Please let me know if there’s anything I’m getting wrong, or if there’s a better way to construct the logic on a webhook endpoint.

Hi @dtj

Thanks for the detailed explanation and walkthrough! :raised_hands:

I totally understand the pain and would be happy to create a business case for our Product team to consider your proposal for adding the two events! I wouldn’t be able to provide a turnaround time for that change, but if it is something that gets picked up, we will keep you updated!