2016-04-25 84 views
0

我們在結帳時遇到小問題,客戶有時會顯示錯誤的價格。條紋結帳錯誤錯誤值

例如,如果總應該是150.00£其表現爲£15,000

它真的很難讓我們調試,因爲我們不能複製的問題,我們和它似乎沒有要依賴於瀏覽器。

我們正在採取在GBP£

這裏的量是我們使用的代碼:

<form action="/user/dashboard/releases/card/{$release->releaseFrontID}/" method="POST" class="stripe-container"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="REMOVED" data-amount="{math equation='x * 100' x=$release->releaseGrandTotal}" 
+0

我相信你看到的是15,000便士,這是150英鎊轉換成該貨幣的最小單位。更多信息:http://stackoverflow.com/a/35326901/1459653 –

回答

0

所以,我認爲你應該做兩件事情。首先,確保您正確設置貨幣,而不是簡單地覆蓋標籤。由於您的代碼示例實際上並不完整,因此我很難說出錯的原因。我的猜測是,你的小數學腳本雖然會走俏。

我建議分開數學計算並將其放入一個單獨的部分進行計算,並使用Custom Checkout Integration [1]而不是基本檢出集成。

[1] https://stripe.com/docs/checkout#integration-custom

原文:

<form action="/user/dashboard/releases/card/{$release->releaseFrontID}/" method="POST" class="stripe-container"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="REMOVED" data-amount="{math equation='x * 100' x=$release->releaseGrandTotal}" 

推薦:

<script src="https://checkout.stripe.com/checkout.js"></script> 

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

<script> 

    var amount = 100 * {$release->releaseGrandTotal}; 
    console.log('Amount >> ' + amount); 

    var handler = StripeCheckout.configure({ 
    key: 'pk_test_xxx', 
    locale: 'auto', 
    currency: 'gbp', 
    amount: amount, 
    token: function(token) { 
     $.post(
     "/user/dashboard/releases/card/{$release->releaseFrontID}/", 
     { 
      stripeToken: token.id, 
      stripeAmount: amount, 
      stripeEmail: token.email 
     }, function (data, status) { 
      // request succeeded, do something 
     } 
    ); 
    } 
    }); 

    $('#customButton').on('click', function(e) { 

    // Open Checkout with further options: 
    handler.open({ 
     name: 'Company Name', 
     description: 'Charge Description' 
    }); 
    e.preventDefault(); 
    }); 

    // Close Checkout on page navigation: 
    $(window).on('popstate', function() { 
    handler.close(); 
    }); 
</script> 

一旦你做到了這一點,它應該是顯而易見的問題出在哪裏發生。這是一個Smarty模板嗎?你是否考慮過把這個量作爲上下文的一部分,而不是在模板語言中做一些數學方程式?