I'm out of ideas! Why is redirect not working!? What am I missing?
* * * * * * *
exampleValue = "Something very important"
_logger.warn("\n\n **exampleValue: %s" % exampleValue )
if exampleValue:
werkzeug.utils.redirect('http://www.google.com')
* * * *
Console log says:
2020-09-11 09:54:47,855 10184 WARNING swedbankpay odoo.addons.payment_swedbankpay.swedbankpay_controller:
* * exampleValue: Something very important
2020-09-11 09:54:47,855 10184 INFO swedbankpay werkzeug: 127.0.0.1 - - [11/Sep/2020 09:54:47] "POST /shop/payment/transaction/ HTTP/1.1" 200 - 3 0.001 0.256
* * * * * * *
"We are not able to redirect you to the payment form."
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
Ah! Thank you! Excuse me for bad post, but that code is including in the non-working code!
I've tried that and many alternatives...
Last Friday, however, we found out that it's the type='json' that's playing a trick!
@http.route('/shop/payment/transaction', type='json', auth='public', method='POST') ## Alternative link. Plan B.
# ~ @http.route('/payment/swedbankpay/initPayment', type='http', auth='public', method='POST')
Any advice in this field?
type JSON means you can only return JSON dict. SO find from where this is called and after processing the transaction data, return to other location from that end point
@http.route('/shop/payment/transaction', type='json', auth='public', method='POST')
def init_payment(self, **post):
"""
Contact Swedbank Pay and redirect customer.
"""
return werkzeug.utils.redirect("http://www.google.com")
* * * * * * * * * * * * * * * * * * * * * * *
This code is not working. No redirect. Why is that!?
How is it possible to combine json with redirect?
https://html.developreference.com/article/13893785/Odoo+redirect+with+JSON
A person explaining the same problem as I try to explain... This is a tricky one!
/usr/share/core-odoo/addons/payment/models//payment_acquirer.py
In this file, there's much vital information about these routing things.
However, all code still seems to be executed in random order...! :-)
_name = 'payment.acquirer'
_description = 'Payment Acquirer'
_order = 'website_published desc, sequence, name'
https://www.odoo.com/documentation/12.0/reference/http.html#routing
"Decorator marking the decorated method as being a handler for requests. The method
must be part of a subclass of Controller."
From the manual.Two lines! Where are the hands-on example?
https://docs.xojo.com/Category:Language_Reference
Example of helpful and useful Language Guide taken from another modern cross platform framework.
This is the correct way.
return werkzeug.utils.redirect('http://www.google.com')
#In Your case
if exampleValue:
return werkzeug.utils.redirect('http://www.google.com')
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
abr 24
|
2130 | ||
|
3
dic 18
|
6572 | ||
Error 400 : redirect_uri_mismatch
Resuelto
|
|
8
feb 25
|
23399 | |
|
1
dic 24
|
1861 | ||
|
0
sept 24
|
1262 |