nimiq / hub

The Nimiq Hub provides a unified interface for all Nimiq accounts, addresses, and contracts.
https://nimiq.github.io/hub
31 stars 11 forks source link

I'm trying to use nimliq checkout but keep getting net::ERR_BLOCKED_BY_CLIENT #441

Closed Th0rgal closed 3 years ago

Th0rgal commented 3 years ago

Hi there,

I am trying to play with the checkout api (I would like to offer nimiq as a way to buy my programs). This is my code:

<script type="module" crossorigin="anonymous">
    import HubApi from 'https://cdn.jsdelivr.net/npm/@nimiq/hub-api@latest/dist/standalone/HubApi.standalone.es.js';
    const hubApi = new HubApi('https://hub.nimiq.com');
    document.getElementById('checkoutBtn').addEventListener('click', function (event) {
        const options = {
            appName: 'Hub API Docs',
            recipient: 'NQ08 JYY6 7V0F EL7J CYNX RH78 TGD1 HP64 CSKG',
            value: 3.14 * 1e5, /* 3.14 NIM */
            // See more options in the table below
        };
        hubApi.checkout(options);
    });
</script>

<button id="checkoutBtn">Purchase</button>

I am using brave browser and when I click on the button, it never finish to load: 2021-04-19-093059_1919x1079_escrotum

It might be related to the brave adblocker but it would be a false positive. What should I do?

Sincerely, Thomad

sisou commented 3 years ago

Hi Thomad! Does the popup open and load correctly for you when you try the example on https://nimiq.github.io/hub/api-reference/checkout?

Did you try disabling the Brave shields on your localhost dev site, does it work then?

Th0rgal commented 3 years ago

Hi Thomad! Does the popup open and load correctly for you when you try the example on https://nimiq.github.io/hub/api-reference/checkout?

Did you try disabling the Brave shields on your localhost dev site, does it work then?

This is actually the example I tried to follow in my code. Did I miss something? I tried to disable brave shield (it is in fact disabled on the page) but I don't figure how to disable it on the popup (it seems the logo appears anyway), and this is pretty strange because I do not have these issues when using the nimiq wallet app for example.

sisou commented 3 years ago

There is likely a difference between blocking hub.nimiq.com and hub.nimiq-testnet.com. Please try opening https://hub.nimiq-testnet.com in your page. That should work.

Can you really not access the Brave shields when the popup is open? Can you not click on the Brave icon in the popup?

Th0rgal commented 3 years ago

There is likely a difference between blocking hub.nimiq.com and hub.nimiq-testnet.com. Please try opening https://hub.nimiq-testnet.com in your page. That should work.

Can you really not access the Brave shields when the popup is open? Can you not click on the Brave icon in the popup?

Yes, I have been able to disable it (I restarted brave and it fixed the bug where I could not click on the brave logo). I have the same issue though (and I used https://hub.nimiq-testnet.com this time). image

Th0rgal commented 3 years ago

Is there a small example I could clone to try if I get the same error?

sisou commented 3 years ago

I sucessfully opened the Hub with your exact code from your initial post. But I served my file via http://localhost, not with the file:// protocol. You need to serve the file that calls the Hub from localhost. You can for example use serve from Zeit (https://www.npmjs.com/package/serve). In the folder where your HTML file is, simply run

serve

and you can access your file at http://localhost:5000. Also works with Brave.

Please comment below if this did not fix it for you.

Th0rgal commented 3 years ago

Great thank you very much!