[FIX] payment_ogone: s2s response should generate payment method

Ogone responses comes from direct s2s calls or form feedback;
not necessarily in that order. The behaviour of the system should
be the same in both cases. This commit add payment_methode creation
when a s2s response contains the necessary information, juste like
the form feedback methods.

Ideally these methods should be merged to share the same code,
this will be done in master (v10).
This commit is contained in:
Damien Bouvy
2016-02-16 11:29:08 +01:00
parent 36e681cbe5
commit a5e8f22701
+10 -2
View File
@@ -264,7 +264,7 @@ class PaymentTxOgone(osv.Model):
'acquirer_id': tx.acquirer_id.id,
'acquirer_ref': alias
})
tx.partner_reference = alias
tx.write({'payment_method_id': ref})
return tx
@@ -294,7 +294,7 @@ class PaymentTxOgone(osv.Model):
'date_validate': datetime.datetime.strptime(data['TRXDATE'], '%m/%d/%y').strftime(DEFAULT_SERVER_DATE_FORMAT),
'acquirer_reference': data['PAYID'],
}
if data.get('ALIAS') and tx.partner_id and tx.type == 'form_save':
if data.get('ALIAS') and tx.partner_id and tx.type == 'form_save' and not tx.payment_method_id:
pm_id = self.pool['payment.method'].create(cr, uid, {
'partner_id': tx.partner_id.id,
'acquirer_id': tx.acquirer_id.id,
@@ -399,6 +399,14 @@ class PaymentTxOgone(osv.Model):
'date_validate': datetime.date.today().strftime(DEFAULT_SERVER_DATE_FORMAT),
'acquirer_reference': tree.get('PAYID'),
})
if tree.get('ALIAS') and tx.partner_id and tx.type == 'form_save' and not tx.payment_method_id:
pm = tx.env['payment.method'].create({
'partner_id': tx.partner_id.id,
'acquirer_id': tx.acquirer_id.id,
'acquirer_ref': tree.get('ALIAS'),
'name': tree.get('CARDNO'),
})
tx.write({'payment_method_id': pm.id})
if tx.callback_eval:
safe_eval(tx.callback_eval, {'self': tx})
return True