If we perform a mass payment which contains an array of items and if one of the item has some wrong data in it for example the bank account number of the user is not correct,the entire api gets failed that means the payment to the rest of the items is also not carried out.How to handle this case as i want to discard the one which has wrong data but i want rest the mass payment to be done to rest of the items?
@Dikshita_Mahajan , It might be helpful to give a quick overview of how mass payments work.
A Mass payment is made up of a list of items that are individual requests to Dwolla to create transactions. That Mass Payment is essentially a job that is queued on Dwolla’s backend and then picked up by a service to process those items. As that service goes through each item it looks at them individually to attempt to create transactions. That Mass Payment job has a status itself which is separate of the statuses of transactions that items may or may not create. Within that Mass Payment each item has a status itself which is also separate of the statuses of transactions those items may created. Here are those statuses:
Mass Payment Statuses - pending, processing, complete
Mass Payment Item Statuses - pending, failed, success
Transfer Statuses - pending, processed, cancelled, and failed
A complete Mass Payment status doesn’t necessarily mean that the items within that job successfully created transactions, or that the transactions that were created from those items were successfully completed either. It simply means that the service that is tasked with iterating through those items to attempt to create transactions has completed. This is mentioned in this post, The typical process is to create the mass payment, listen for the mass_payment_completed event, and then call the API(List Items for a Mass Payment | Dwolla API Documentation) to reconcile those items within the MassPay to determine if transactions were created. From that list of items, if those statuses on those items were success there should be a link on each item which points to the transfer that was created /transfers/{id} . If the status of the item was failed, e.g. bank account removed, account suspended, etc., the item will not create a transfer and the funds would revert back to the balance/wallet of the source Dwolla account.
Hi @spencer , your answer is very helpful in how to properly handle failed items after an initial successful mass payment creation API call, however, in the example from the original question, the initial API post that creates the mass payment in the first place can also fail for certain reasons such as an invalid destination. When this happens though, in my brief experience, there isn’t much in the response to tell the API user which item caused the entire post to fail. Am I missing something in the response? What is the best way to figure out which of the potentially 5,000 items caused the failure? An item index and reason would be my preferred response.
To add on to that, I would be very curious what other pre-validation steps are run on your side before returning a 201 response code to the create mass payment post request.
Hi @JoeS , You’re right, we’d need to add a pointer to the mass payment item that is failing validation. We don’t have this today unfortunately, but it is something on our longer term roadmap to add. Currently you’d need to iterate through each item’s destination to determine if it’s a valid payment account. The possible validation errors are listed in this table in our docs.
Thanks @spencer . This isn’t an issue that has come up for us yet but just happened to be one of the first things that I tested. We will validate each funding source ourself before adding them to a mass-payment items list.
Thanks for your help!