[FIX] payment_ogone: fix handling of validation tx

The validation transactions introduced in
7d428c871b 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)
This commit is contained in:
Olivier Dony
2018-03-08 17:11:12 +01:00
parent c3769b2290
commit 9b1009cd5a
+6 -7
View File
@@ -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