set synchronous return of saga in session (#17287)
So that it can be read from the template of the payment return page.
This commit is contained in:
parent
421d209312
commit
e433e148e5
|
@ -54,6 +54,9 @@ def saga_transaction(request):
|
|||
num_factures = request.POST.getlist('num_factures')
|
||||
email = request.POST.get('email') or request.user.email
|
||||
error_url = request.POST.get('error_url') or '/'
|
||||
# nettoye la session à chaque transaction
|
||||
if 'saga_retour_synchrone' in request.session:
|
||||
del request.session['saga_retour_synchrone']
|
||||
|
||||
urlretour_asynchrone = request.build_absolute_uri(
|
||||
reverse('nanterre-saga-retour-asynchrone')).rstrip('/')
|
||||
|
@ -124,14 +127,20 @@ def saga_retour_synchrone(request):
|
|||
if (isinstance(saga, dict) and saga.get('err') == 0 and
|
||||
saga.get('data', {}).get('etat')):
|
||||
etat = saga['data']['etat']
|
||||
if etat in MESSAGE_BY_STATE:
|
||||
logger.info('[rsu/saga] retour-synchrone: idop=%s etat=%s',
|
||||
idop, etat)
|
||||
messages.add_message(request, *MESSAGE_BY_STATE[etat])
|
||||
if etat == 'paye':
|
||||
logger.info('[rsu/saga] retour-synchrone: idop=%s etat=%s', idop, etat)
|
||||
request.session['saga_retour_synchrone'] = saga['data']
|
||||
else:
|
||||
logger.error('[rsu/saga] retour-synchrone: idop=%s '
|
||||
'receive unknown etat=%s', idop, etat)
|
||||
messages.error(request, ERROR_MESSAGE)
|
||||
# on nettoye la session
|
||||
if 'saga_retour_synchrone' in request.session:
|
||||
del request.session['saga_retour_synchrone']
|
||||
if etat in MESSAGE_BY_STATE:
|
||||
logger.info('[rsu/saga] retour-synchrone: idop=%s etat=%s', idop, etat)
|
||||
messages.add_message(request, *MESSAGE_BY_STATE[etat])
|
||||
else:
|
||||
logger.error('[rsu/saga] retour-synchrone: idop=%s '
|
||||
'receive unknown etat=%s', idop, etat)
|
||||
messages.error(request, ERROR_MESSAGE)
|
||||
else:
|
||||
logger.error('[rsu/saga] retour-synchrone: idop=%s '
|
||||
'receive bad response=%r', idop, saga)
|
||||
|
|
Loading…
Reference in New Issue