Best practice for network error after Bit transaction?

It appears there are times when a Bit transaction is invoked (twitch.bits.useBits) and confirmed by the viewer but the Extension is never notified. I imagine this could be due to network failure but I have also experienced this myself after having an Extension open for a prolonged period of time (> 24 hours) on a laptop that was sleeping for part of that time. Does the viewer’s auth token expire and need manual refreshing?

Additionally, are there any ways or plans to require ‘consuming’ the transaction (like what Apple and Google do on their mobile platforms)? This way, the Extension can query for unconsumed transactions and consume them upon reception of the complete notification (twitch.bits.onTransactionComplete).

Any insights to further avoid this issue would be much appreciated!

usually the Twitch Extension Handler auto refreshes the JWT, so you shouldn’t get a JWT/auth error

I do a Basket type flow. So user clicks a button, I check the JWT is still good on my EBS, and the user then gets the bits button to ok/click, then the Twitch Bits popuo

Webhooks!! Extensions have a transaction webhook.

So you can compare webhooks, or the API endpoint with your inbound collected data.

I actually proposed a PayPal style approach when bits in extensions first came out, looooooong ago (and before uservoice existed), post to create a transaction then the bits usage would fulfill that payment, and this is roughly what I do currently, jsut with the lack of meta data.

If you want to make your own suggestion(s) you can do so on the uservoice https://twitch.uservoice.com/forums/310213-developers

Edit: there is also RFC0011 that I forgot existed

Edit 2: Wrote up my PayPal-esque flow here

Thanks for the response and valuable feedback. Since I require more data than just the product ID to fulfill the action, webhooks might not provide me with enough information but I like the idea of checking the JWT on my backend before allowing a user to process a Bit transaction.

Those proposals are both good. I would LOVE for there to be a developer payload option instead of only getting the product ID in the transaction receipt. Let’s hope for future improvements!

One common way for extensions that require additional data from the user along with the transaction often have a fallback where if they get a transaction but no data from the user then the extension gives that user a token of some kind so that they can attempt the transaction again but instead of calling useBits the extension instead will skip that step and let the user send the data that’s needed.

Some extensions use that sort of system entirely, where the SKU is for a token of some kind (just make sure not to name them like a currency), that way the user doesn’t need to send additional data with the transaction and the webhook will be sufficient. Your EBS can handle redeeming/fulfilling user requests with those tokens from that point on.

I used to have a unique SKU for each option, but this didn’t allow me to let streamers customize the price. Now I require a user payload. I currently don’t have the case that I have a transaction but not user data. It seems that transactions are placed but onTransactionComplete is never called (presumably network failure).

I could perhaps register the user payload fist and then check for a transaction from the same viewer via a webhook. This would eliminate any issues with network failure on the clients side but I would have to explore this with AWS Lambda and make sure subscribing is robust, etc

Thanks for the suggestions!