Stripe'i bir django web sitesine yerleştiriyorum ve her şey bir parça dışında çalışıyor. Sepetimde, kullanıcılar toplamı değiştiren öğeleri güncelleyebilir. Stripe Checkout js komut dosyasında veri miktarını ayarlamak dışında her şey doğru şekilde çalışıyor.Güncelleştirme Şerit veri miktarı
Sayfa yüklendiğinde, her şey harika çalışıyor, ancak müşteri alışveriş sepetini değiştirirse, veri miktarı güncellenmez. Toplamı gösteren başka bir kutu var ve bu miktar güncellemeleri iyi.
<!-- here is the script tag in HTML-->
<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>
Ve güncellemek için çalışır sonra benim javascript
şudur:function updateTotal(amount) {
/* update the total in the cart in both the table cell and
in the stripe button data-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"));
// this returns the correct original amount
script.data("amount", newTotalStripe);
console.log(script.data("amount"));
/* this returns the updated amount, however the HTML data-amount
attribute does not update. */
}
sizin için Şükürler! – sgrutman978