Skip to content

Commit

Permalink
[FIX] stripe: Fix float representation error
Browse files Browse the repository at this point in the history
- Stripe needs to have the amount in integer, so we have to multiply by 100 the amount.
  Which sometimes create float representation errors and remove/add ~1 cent on some transactions (i.e 72.60€)
  • Loading branch information
tbe-odoo committed Apr 23, 2018
1 parent 29c6c06 commit 76c17ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/payment_stripe/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from odoo.addons.payment.models.payment_acquirer import ValidationError
from odoo.exceptions import UserError
from odoo.tools.safe_eval import safe_eval
from odoo.tools.float_utils import float_round

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -90,7 +91,7 @@ class PaymentTransactionStripe(models.Model):
def _create_stripe_charge(self, acquirer_ref=None, tokenid=None, email=None):
api_url_charge = 'https://%s/charges' % (self.acquirer_id._get_stripe_api_url())
charge_params = {
'amount': int(self.amount if self.currency_id.name in INT_CURRENCIES else self.amount*100),
'amount': int(self.amount if self.currency_id.name in INT_CURRENCIES else float_round(self.amount * 100, 2)),
'currency': self.currency_id.name,
'metadata[reference]': self.reference
}
Expand Down

0 comments on commit 76c17ab

Please sign in to comment.