Skip to Content
Menu
This question has been flagged

Hello,

I have modified the shop/payment/get_status controller but when the session gets modified in the code. The logged in user gets logged out. How can I make the user logged in when inside the shop/payment/get_status.

Code:

@http.route('/shop/payment/get_status/<int:sale_order_id>', type='json', auth="public", website=True)
def payment_get_status(self, sale_order_id, **post):
print("payment_get_status")
order = request.env['sale.order'].sudo().browse(sale_order_id).exists()
print("order");print(order)
assert order.id == request.session.get('sale_last_order_id')
#----------------------------------------------------------------------------------
_logger.info("request.session")
_logger.info(request.session)
tx = request.session.get('__website_sale_last_tx_id')
print(tx)
if tx:
if type(tx) == int:
tx = request.env['payment.transaction'].sudo().search([('id','=',tx)])
if tx and tx.sale_order_id.id == int(sale_order_id):
print(tx.acquirer_id.provider)
print(tx.moneris_session)
if tx.acquirer_id.provider == 'moneris' and tx.moneris_session:
try:
if type(tx.moneris_session) == str:
tx_session = literal_eval(tx.moneris_session)
except Exception as e:
_logger.warning("Exception: " + str(e.args))
_logger.info("tx_session: " + str(tx_session))
if tx_session:

_logger.info("website_sale_current_pl" + str(request.session.get('website_sale_current_pl')))
updated_session = False
for key in ['uid','login','session_token']:
if tx_session.get(key):
if not request.session[key] or request.session[key] == False or request.session[key] == None :
request.session[key] = tx_session.get(key)
updated_session = True
if updated_session== True:
_logger.info("UPDATED request.session")
_logger.info(request.session)
tx.sudo().write({'moneris_session': False})
# ---------------------------------------------------------------------------
return {
'recall': order.payment_tx_id.state == 'pending',
'message': request.env['ir.ui.view'].render_template("website_sale.payment_confirmation_status", {
'order': order
})
}


Avatar
Discard
Related Posts Replies Views Activity
0
Oct 20
1486
2
Feb 18
2984
0
Feb 24
324
0
Oct 22
2480
0
Jun 20
7