Unable to use `Twitch.ext.bits.getProducts()`

Hello,

I’m following the instructions to make use of the Bits micro-transactions system, but when I try to get the current products I have I get JS error:

Twitch.ext.bits.getProducts().then(function(products) {
  console.log(products); // [ { sku: 'abc123', cost: { type: 'bits', amount: '10' } } ]
});

Uncaught TypeError: Cannot read property 'getProducts' of undefined

I’ve checked the twitch-ext.js and i cannot find anything related to bits, nor getProducts

Am I missing something?
Thanks :slight_smile:

You are including:

<script src="https://extension-files.twitch.tv/helper/v1/twitch-ext.min.js"></script>

As there is no “twitch-ext.js” file on the TwitchCDN to include

No,

I was including

<script src="https://localhost.rig.twitch.tv:3000/twitch-ext.js"></script>

since that’s what was there in the hello-world example (maybe an old way of doing things?)

When I include the script you mention I get these errors:

Unexpected extension frame event action "undefined"
Unexpected extension frame event action "twitch-ext-loaded"

The Hello World example is pretty old and only useful for the hello world example, which doesn’t include bits within it.

Please see “Extension Helper Library” at

As said, if I include that script then anything works and I get the error I mentioned. Is there any reliable example using that script you mention that works? It’s not like the new script doesn’t work for Bits, it just doesn’t work at all – is it meant to be used in local dev with the Developer Rig?

The developer rig does not currently support testing of bits-enabled extensions (in either local mode or online mode). This is something that we are working on though.

1 Like

Ah, that explains a lot :smiley:

I’ll skip the bits functionality for now and I’ll focus on finishing the extension – or I’ll try to implement that part without testing locally, but I have a bad feeling about it :smiley:

Thanks, that was very helpful!

Hi guys, so there is no way to implement and test Bits in extension at the moment?
Isn’t it the only way to monetize extension at the moment?
@rbartlet

You can ‘simulate’ a transaction by using the setUseLoopback function: https://dev.twitch.tv/docs/extensions/bits/#setuseloopbackboolean

This way when you call useBits(sku) it’ll skip passing control over to Twitch which would normally open a dialog box to confirm/buy bits/cancel, and instead just call onTransactionComplete.

Also there’s nothing at all stopping you testing Bits outside of the rig by whitelisting a test channel, install the extension on that channel and test there, in which case you will have Twitch’s dialog box, and if the sku is set to being in development it wont actually subtract bits from your account (although you still do need sufficient bits in your account to get a confirm button, otherwise you just get options to cancel or buy bits)

I see, that will be definitely good for testing, thanks.
By the way I’m also missing the way to setup and manage bits products (besides the Manage Products tab within the rig).

The Manage Bits Products tab within the rig is, as far as I know, the only way to setup and manage that.

Alright, thanks for confirming me that :slight_smile:
But will those products setup in the rig work during Hosted Test and Release stages of the extension?
Sorry for all the questions, but I’m finding the Bit implementation process a little tricky.

Just like the documentation says, that tab in the rig is how you manage the products for your extension. https://dev.twitch.tv/docs/extensions/bits/#bits-product-catalog

Yup, ok, I’ll give it a try with setUseLoopback for testing, then setting real products throught the rig and testing them in a whitelisted channel.
Thanks for the help!