From eb8beffbe959390c6cf9d2cca9902c231786249f Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 10 Nov 2020 09:30:39 +0000 Subject: [PATCH] [FIX] payment_paypal: Paypal Acquirer fees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable fee (Var) and fixed fee (Fix) indicated by paypal must be subtracted from the transaction amount (Am). So let's consider that Am = 100€, Var = 2.9% and Fix = 0.3€ Total fee = 100€ * (2.9/100) + 0.3€ = 3.20€ So in this case, the merchant will get 96.80€ and Paypal will get 3.20€ This computation can be verified with the simulator here: https://salecalc.com/paypal?p=100&l=us&r=0&e=0&f=0&m=2&c=0. So the idea here is to compute Am such that the merchant will get 100€ if he set his price to 100€ fees = amount_fees_included * percentage / 100 + fixed fees = (amount + fees) * percentage / 100 + fixed fees = (amount * percentage / 100 + fixed) / (1 - percentage / 100) if the merchant needs to keep 100€, Am will be equal to 103.30€. That way, paypal takes 103.30 * 2.9% + 0.30 = 3.30 and the merchant takes 103.30 - 3.30 = 100 opw:2369557 X-original-commit: 6850e638dfa652ab3fe8065ea09e23cb07648d7a Co-authored-by: AdrienHorgnies --- addons/payment_paypal/models/payment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/payment_paypal/models/payment.py b/addons/payment_paypal/models/payment.py index b0834681707..cf0d0df23f8 100644 --- a/addons/payment_paypal/models/payment.py +++ b/addons/payment_paypal/models/payment.py @@ -81,7 +81,7 @@ class AcquirerPaypal(models.Model): else: percentage = self.fees_int_var fixed = self.fees_int_fixed - fees = (percentage / 100.0 * amount) + fixed / (1 - percentage / 100.0) + fees = (percentage / 100.0 * amount + fixed) / (1 - percentage / 100.0) return fees def paypal_form_generate_values(self, values):