[FIX] payment_stripe: integer currencies

The currencies with zero decimal should not be multiplied by 100. See
https://stripe.com/docs/currencies#zero-decimal

opw-760707
This commit is contained in:
Nicolas Martinelli
2017-08-02 11:02:36 +02:00
parent d28e410d36
commit b335ae0348
+26 -6
View File
@@ -1,6 +1,14 @@
odoo.define('payment_stripe.stripe', function(require) {
"use strict";
var ajax = require('web.ajax');
// The following currencies are integer only, see
// https://stripe.com/docs/currencies#zero-decimal
var int_currencies = [
'BIF', 'XAF', 'XPF', 'CLP', 'KMF', 'DJF', 'GNF', 'JPY', 'MGA', 'PYGí',
'RWF', 'KRW', 'VUV', 'VND', 'XOF'
];
var handler = StripeCheckout.configure({
key: $("input[name='stripe_key']").val(),
image: $("input[name='stripe_image']").val(),
@@ -50,19 +58,31 @@ odoo.define('payment_stripe.stripe', function(require) {
e.preventDefault();
if ($('.o_website_payment').length !== 0) {
var currency = $("input[name='currency']").val();
var amount = parseFloat($("input[name='amount']").val() || '0.0');
if (!_.contains(int_currencies, currency)) {
amount = amount*100;
}
ajax.jsonRpc('/website_payment/transaction', 'call', {
reference: $("input[name='invoice_num']").val(),
amount: $("input[name='amount']").val(),
currency_id: $("input[name='currency_id']").val(),
amount: amount,
currency_id: currency,
acquirer_id: acquirer_id
})
handler.open({
name: $("input[name='merchant']").val(),
description: $("input[name='invoice_num']").val(),
currency: $("input[name='currency']").val(),
amount: $("input[name='amount']").val()*100
currency: currency,
amount: amount,
});
} else {
var currency = $("input[name='currency']").val();
var amount = parseFloat($("input[name='amount']").val() || '0.0');
if (!_.contains(int_currencies, currency)) {
amount = amount*100;
}
ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {
so_id: so_id,
so_token: so_token
@@ -71,8 +91,8 @@ odoo.define('payment_stripe.stripe', function(require) {
handler.open({
name: $("input[name='merchant']").val(),
description: $("input[name='invoice_num']").val(),
currency: $("input[name='currency']").val(),
amount: $("input[name='amount']").val()*100
currency: currency,
amount: amount,
});
});
}