Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Handle DEFAULT_UPDATE and TRANSACTIONS_REMOVED webhooks. #169

Open
1 of 2 tasks
elliotcourant opened this issue May 13, 2021 · 1 comment
Open
1 of 2 tasks

Handle DEFAULT_UPDATE and TRANSACTIONS_REMOVED webhooks. #169

elliotcourant opened this issue May 13, 2021 · 1 comment
Assignees
Labels

Comments

@elliotcourant
Copy link
Member

elliotcourant commented May 13, 2021

Handle Transactions webhooks DEFAULT_UPDATE and TRANSACTIONS_REMOVED if your app needs to keep Transactions data up-to-date. For more details, see Handling Transaction webhooks.

  • DEFAULT_UPDATE is currently handled by retrieving the last 7 days worth of transactions for the specified item ID. If it is guaranteed that the new transactions are always the first ones to be returned, then we could set the limit of our request to the number of new transactions to improve efficiency.
  • TRANSACTIONS_REMOVED is completely implemented however need to be checked for correctness, at the time of writing this it had a bug that prevented it from working. Update as needed.
@elliotcourant elliotcourant added this to the Public Availability milestone May 13, 2021
@elliotcourant elliotcourant self-assigned this May 13, 2021
@elliotcourant
Copy link
Member Author

There is a small issue here with the implementation.

We often receive the TRANSACTIONS_REMOVED webhook before the default update. This means that if a pending transaction has a "spent from" then it is lost when the non-pending transaction is created.

With how closely these webhooks can be dispatched I'm concerned that it might be hard to mitigate this behavior.

My thought is that when the TRANSACTIONS_REMOVED webhook is received we cache the spent from for the removed transaction in redis with a short TTL. Then in the DEFAULT_UPDATE webhook handling we check for the pending_transaction_id in redis and see if it has a spent from. If it does then we allocate that spending automatically.

My worry is that if these webhooks are not handled one after another, or if they are handling in the wrong order or at the same time then this behavior will be inconsistent at best.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant