Using Geolocation Utility IPStack in order to hide express payment methods by country

baggubags
New Member
1 0 0

Hi, I'm trying to use an API call to IPstack in order to hide the express payment options for customers coming from Japan (JP). It worked a few times when testing via browser stack, but now my api call is getting the following consolve log error 'because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: cdn.shopify.com cdn.shopifycdn.net cdn.shopifycloud.com app.shopify.com'. Does anyone know any other way to hide elements by geolocation on the shopify checkout.liquid page? 

            <div class ="alt-payments">{{ alternative_payment_methods }}</div>
                <script>
                  jQuery.ajax({
       				url: 'https://api.ipstack.com/check?access_key=API_ACCESS_KEY&fields=country_code',
       				dataType: 'jsonp',
                   	success: function(location) {
                        // If the visitor is browsing from JP.
                        if (location.country_code === 'JP') {
                        // display none express payments.
                        jQuery('.alt-payments').css('display','none');
                        }
                    }
                    } );
                </script>

 

0 Likes