From 9b1009cd5a324b41e90a8d9bc5d412e45b43fc57 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 8 Mar 2018 17:11:12 +0100 Subject: [PATCH] [FIX] payment_ogone: fix handling of validation tx The validation transactions introduced in 7d428c871bae3c721acdeacd0f00855846499e34 were not working properly for Ogone, due to several problems: - The refund requests when being sent via the orderdirect.asp API, which does not support refunding previous transactions, according to the Ingenico helpdesk. It only support creating independent refund transactions, which is something that requires special pre-approval from the payment acquirer, and generally not permitted. In order to cancel/refund a previous transaction, the direct maintenance API must be used instead[1]. - Maintenance requests to refund a previous transaction fully should use the RFS code, as explained in the API documentation [1], and should always mention the PAYID of the refunded transaction. - Such maintenance requests must always be SHA-signed, as usual. - The various transaction status codes for refunded transactions need to be taken into account as well (typically those beginning with 8) This commit fixes these various problems. [1] https://payment-services.ingenico.com/int/en/ogone/support/guides/integration%20guides/directlink (5.2 Direct Maintenance) --- addons/payment_ogone/models/payment.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/payment_ogone/models/payment.py b/addons/payment_ogone/models/payment.py index b91acc0eb5d..cb6d5055d0f 100644 --- a/addons/payment_ogone/models/payment.py +++ b/addons/payment_ogone/models/payment.py @@ -213,8 +213,8 @@ class PaymentAcquirerOgone(models.Model): class PaymentTxOgone(models.Model): _inherit = 'payment.transaction' # ogone status - _ogone_valid_tx_status = [5, 9] - _ogone_wait_tx_status = [41, 50, 51, 52, 55, 56, 91, 92, 99] + _ogone_valid_tx_status = [5, 9, 8] + _ogone_wait_tx_status = [41, 50, 51, 52, 55, 56, 91, 92, 99, 81, 82] _ogone_pending_tx_status = [46] # 3DS HTML response _ogone_cancel_tx_status = [1] @@ -410,13 +410,12 @@ class PaymentTxOgone(models.Model): 'ORDERID': reference, 'AMOUNT': int(self.amount * 100), 'CURRENCY': self.currency_id.name, - 'OPERATION': 'RFD', - 'ECI': 2, # Recurring (from MOTO) - 'ALIAS': self.payment_token_id.acquirer_ref, - 'RTIMEOUT': 30, + 'OPERATION': 'RFS', + 'PAYID': self.acquirer_reference, } + data['SHASIGN'] = self.acquirer_id._ogone_generate_shasign('in', data) - direct_order_url = 'https://secure.ogone.com/ncol/%s/orderdirect.asp' % (self.acquirer_id.environment) + direct_order_url = 'https://secure.ogone.com/ncol/%s/maintenancedirect.asp' % (self.acquirer_id.environment) _logger.debug("Ogone data %s", pformat(data)) result = requests.post(direct_order_url, data=data).content