I implement Stripe on a django site and everything works, except for one part. In my cart, users can update items that change the total. Everything works correctly, except setting the amount of data on the Stripe Checkout js script.
When the page loads, everything works fine, however, if the client changes his basket, the amount of data is not updated. I have another box that shows the total quantity, and this amount is perfectly updated.
<script id="stripe-script" src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-image="{% static 'img/marketplace.png' %}" data-key="{{ STRIPE_PUBLIC_KEY }}" data-name="Serendipity Artisan Blends" data-description="Purchase Items" data-amount="{{ cart_stripe_total }}"> </script>
And then my javascript, which is trying to update, looks like this:
function updateTotal(amount) { var totalStr = shoppingTotalCell.text().replace('$', ''), originalTotal = parseFloat(totalStr), newTotal = originalTotal + amount, newTotalStripe = newTotal * 100, newTotalStr = newTotal.toFixed(2), script = $('#stripe-script'); shoppingTotalCell.text('$' + newTotalStr); console.log(script.data("amount"));
source share