[IMP] payment_acquirer_paypal: when receiving a pending tx from paypal, update state_message of the tx accordingly + tests
bzr revid: tde@openerp.com-20131122120418-t2nve14q6vjr7m6q
This commit is contained in:
parent
73981072d1
commit
b6836ceb5b
|
@ -156,6 +156,7 @@ class TxPaypal(osv.Model):
|
|||
return self.browse(cr, uid, tx_ids[0], context=context)
|
||||
|
||||
def _paypal_form_get_invalid_parameters(self, cr, uid, tx, data, context=None):
|
||||
# TODO: txn_id: shoudl be false at draft, set afterwards, and verified with txn details
|
||||
invalid_parameters = []
|
||||
if data.get('notify_version')[0] != '2.6':
|
||||
_logger.warning(
|
||||
|
@ -205,6 +206,7 @@ class TxPaypal(osv.Model):
|
|||
_logger.info('Received notification for Paypal payment %s: set as pending' % (tx.reference))
|
||||
tx.write({
|
||||
'state': 'pending',
|
||||
'state_message': data.get('pending_reason', ''),
|
||||
'paypal_txn_id': data['txn_id'],
|
||||
'paypal_txn_type': data.get('express_checkout'),
|
||||
})
|
||||
|
|
|
@ -185,3 +185,24 @@ class PaypalForm(PaypalCommon):
|
|||
)
|
||||
# validate it
|
||||
self.payment_transaction.form_feedback(cr, uid, paypal_post_data, 'paypal', context=context)
|
||||
# check
|
||||
tx = self.payment_transaction.browse(cr, uid, tx_id, context=context)
|
||||
self.assertEqual(tx.state, 'pending', 'paypal: wrong state after receiving a valid pending notification')
|
||||
self.assertEqual(tx.state_message, 'multi_currency', 'paypal: wrong state message after receiving a valid pending notification')
|
||||
self.assertEqual(tx.paypal_txn_id, '08D73520KX778924N', 'paypal: wrong txn_id after receiving a valid pending notification')
|
||||
self.assertFalse(tx.date_validate, 'paypal: validation date should not be updated whenr receiving pending notification')
|
||||
|
||||
# update tx
|
||||
self.payment_transaction.write(cr, uid, [tx_id], {
|
||||
'state': 'draft',
|
||||
'paypal_txn_id': False,
|
||||
}, context=context)
|
||||
# update notification from paypal
|
||||
paypal_post_data['payment_status'] = 'Completed'
|
||||
# validate it
|
||||
self.payment_transaction.form_feedback(cr, uid, paypal_post_data, 'paypal', context=context)
|
||||
# check
|
||||
tx = self.payment_transaction.browse(cr, uid, tx_id, context=context)
|
||||
self.assertEqual(tx.state, 'done', 'paypal: wrong state after receiving a valid pending notification')
|
||||
self.assertEqual(tx.paypal_txn_id, '08D73520KX778924N', 'paypal: wrong txn_id after receiving a valid pending notification')
|
||||
self.assertEqual(tx.date_validate, '2013-11-18 03:21:19', 'paypal: wrong validation date')
|
||||
|
|
Loading…
Reference in New Issue