From 5af1937ec1558137660dc4139cb5ffccd587f895 Mon Sep 17 00:00:00 2001 From: nie Date: Wed, 31 Mar 2021 11:39:52 +0000 Subject: [PATCH] [FIX] payment_payulatam: use "Round half to even" method in signature Steps: - Install l10n_ar, website_sale - Go to Website / Configuration / eCommerce / Payment Acquirers - Install PayUlatam - Edit PayUlatam: - Argentinian credentials: http://developers.payulatam.com/en/web_checkout/sandbox.html - Go to Website / Configuration / Settings - Check Multi-Currencies - Save - Click Currencies - Edit all currencies: - Rates: - Edit or create the current rate: - Rate: 1.000000 - Go to Website / Products / Pricelists - Create an ARS pricelist and make it selectable - Go to Website / Products / Products - Create a product (1): - Sales Price: 15.75 - No taxes - Click "Published On Website" - Select your new ARS pricelist - Add (1) to Cart - Process Checkout - Select PayUlatam - Pay Now - Use this info to process the checkout: http://developers.payulatam.com/en/web_checkout/sandbox.html - Pagar (Pay) - Regresar al sitio de la tienda (Back to the store website) Bug: 500: PayUlatam: invalid sign Explanation: From PayU's documentation: > 2. Response page > Signature validation > In order to get the new value new_value you always should approximate > the TX_VALUE to a decimal, using the rounding method "Round half to > even" http://developers.payulatam.com/en/web_checkout/integration.html opw:2457240 closes odoo/odoo#68816 X-original-commit: 5f703cd92293daa1049cbeced9515b251d69bd02 Signed-off-by: backspac --- addons/payment_payulatam/models/payment_acquirer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/payment_payulatam/models/payment_acquirer.py b/addons/payment_payulatam/models/payment_acquirer.py index 3347de49879..6010c8b9be7 100644 --- a/addons/payment_payulatam/models/payment_acquirer.py +++ b/addons/payment_payulatam/models/payment_acquirer.py @@ -50,9 +50,11 @@ class PaymentAcquirer(models.Model): self.payulatam_api_key, self.payulatam_merchant_id, values['referenceCode'], - # Observation from the sandbox: PayU Latam is using a rounded value to generate - # their signature despite saying otherwise in the doc: # http://developers.payulatam.com/en/web_checkout/integration.html + # Section: 2. Response page > Signature validation + # PayU Latam use the "Round half to even" rounding method + # to generate their signature. This happens to be Python 3's + # default rounding method. float_repr(float(values.get('TX_VALUE')), 1), values['currency'], values.get('transactionState'),