parent
cc335879a7
commit
037257b887
|
@ -18,7 +18,7 @@ class AdyenController(http.Controller):
|
||||||
_return_url = '/payment/adyen/return/'
|
_return_url = '/payment/adyen/return/'
|
||||||
|
|
||||||
@http.route([
|
@http.route([
|
||||||
'/payment/adyen/return/',
|
'/payment/adyen/return',
|
||||||
], type='http', auth='none')
|
], type='http', auth='none')
|
||||||
def adyen_return(self, **post):
|
def adyen_return(self, **post):
|
||||||
_logger.info('Beginning Adyen form_feedback with post data %s', pprint.pformat(post)) # debug
|
_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', '{}'))
|
custom = json.loads(post.pop('merchantReturnData', '{}'))
|
||||||
return_url = custom.pop('return_url', '/')
|
return_url = custom.pop('return_url', '/')
|
||||||
return werkzeug.utils.redirect(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]'
|
||||||
|
|
Loading…
Reference in New Issue