[IMP] payment_adyen: add support HPP notifications from adyen

It is mandatory to switch to a production account
This commit is contained in:
Ludovic Laffineur lla
2015-10-28 16:36:18 +01:00
committed by Damien Bouvy
parent cdc795b200
commit 3dafb19c96
+15 -1
View File
@@ -18,7 +18,7 @@ class AdyenController(http.Controller):
_return_url = '/payment/adyen/return/'
@http.route([
'/payment/adyen/return/',
'/payment/adyen/return',
], type='http', auth='none')
def adyen_return(self, **post):
_logger.info('Beginning Adyen form_feedback with post data %s', pprint.pformat(post)) # debug
@@ -29,3 +29,17 @@ class AdyenController(http.Controller):
custom = json.loads(post.pop('merchantReturnData', '{}'))
return_url = custom.pop('return_url', '/')
return werkzeug.utils.redirect(return_url)
@http.route([
'/payment/adyen/notification',
], type='http', auth='none', methods=['POST'])
def adyen_notification(self, **post):
tx_id = post.get('merchantReference') and request.registry['payment.transaction'].search(request.cr, SUPERUSER_ID, [('reference', 'in', [post.get('merchantReference')])], limit=1, context=request.context)
if post.get('eventCode') in ['AUTHORISATION'] and tx_id:
tx = request.registry['payment.transaction'].browse(request.cr, SUPERUSER_ID, tx_id, context=request.context)
states = (post.get('merchantReference'), post.get('success'), tx.state)
if (post.get('success') == 'true' and tx.state == 'done') or (post.get('success') == 'false' and tx.state in ['cancel', 'error']):
_logger.info('Notification from Adyen for the reference %s: received %s, state is %s', states)
else:
_logger.warning('Notification from Adyen for the reference %s: received %s but state is %s', states)
return '[accepted]'