About the extension Bits

Hello.

I have two questions about Bits development for extensions.

First.
I’m currently using Rig for development, but I’m not sure if
useBits always returns 401 error.
If it works correctly, a confirmation dialog seems to be displayed, but
How can I check if it works?

Secondly
Is the compensation for the Bits given before useBits? Or is it after onTransactionComplete?
If it’s after onTransactionComplete, it seems that when the process fails, it just consumes the Bits, how should I handle it?

The Extension rig does NOT fully support useBits, as extension monetization requires the Twitch page to create a dialog box where the process is handled, and this all takes place outside of the extension. If you use setUseLoopBack and set that to true, then useBits can be used in the rig but it’ll be entirely simulated and there wont be a dialog box. For full testing of bits you should test on Twitch on your test channel.

I’m not sure what you mean “is the compensation for Bits given before useBits”. When your extension runs the useBits function, it’ll ask the user if they accept or deny it. If the user accepts then bits will be deducted from their balance, onTransactionComplete will fire (as well as the API/EventSub topic for extension transactions), and it’ll be up to your extension logic (either in the client-side or server side) to handle whatever it is that is supposed to happen.

If your extension fails to do what the user exchanged their bits for, then that’s entirely your responsibility to handle. if they’ve spent their bits there will be a record of this on the Get Extension Transactions endpoint so you can be sure of exactly who has used their bits, on which channel with which SKU, and you can internally keep a record of which transactions have/haven’t been fulfilled by your extension.

You may also be interested in, this information in testing bits in extensions