add routes
This commit is contained in:
parent
859122139f
commit
be1b4bca26
|
@ -8,6 +8,10 @@ from . import mercado_libre
|
|||
from . import shopify
|
||||
from . import api_log
|
||||
from . import ir
|
||||
from . import routes
|
||||
|
||||
|
||||
__all__ = ['register', 'routes']
|
||||
|
||||
|
||||
def register():
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import json
|
||||
import logging
|
||||
import http.client
|
||||
|
||||
import stripe
|
||||
from werkzeug.exceptions import abort
|
||||
from werkzeug.wrappers import Response
|
||||
|
||||
from trytond.wsgi import app
|
||||
from trytond.protocols.wrappers import with_pool, with_transaction
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.route(
|
||||
'/<database_name>/sale_web_channel/mercadolibre/login_app',
|
||||
methods=['POST'])
|
||||
@with_pool
|
||||
@with_transaction(context={'_skip_warnings': True})
|
||||
def login_app(request, pool):
|
||||
return Response(
|
||||
'<body onload="window.close()"> Login Success </body>', 200, content_type='text/html')
|
||||
|
||||
|
||||
@app.route(
|
||||
'/<database_name>/sale_web_channel/mercadolibre/webhook',
|
||||
methods=['POST'])
|
||||
@with_pool
|
||||
@with_transaction(context={'_skip_warnings': True})
|
||||
def webhooks_endpoint_mercadolibre(request, pool):
|
||||
request_body = request.get_data(as_text=True)
|
||||
payload = json.loads(request_body)
|
||||
Channel = _pool.get('sale.web_channel.mercado_libre')
|
||||
Channel.create_sale(payload)
|
||||
print(payload, 'validate payload')
|
||||
return True
|
||||
|
||||
|
||||
@app.route(
|
||||
'/<database_name>/sale_web_channel/shopify/webhook',
|
||||
methods=['POST'])
|
||||
@with_pool
|
||||
@with_transaction(context={'_skip_warnings': True})
|
||||
def webhooks_endpoint_shopify(request, pool):
|
||||
request_body = request.get_data(as_text=True)
|
||||
payload = json.loads(request_body)
|
||||
Channel = _pool.get('sale.web_channel.shopify')
|
||||
res = Channel.request_api(request)
|
||||
return True
|
|
@ -1,9 +1,10 @@
|
|||
[tryton]
|
||||
version=6.0.2
|
||||
version=6.0.3
|
||||
depends:
|
||||
sale_pos
|
||||
product_reference
|
||||
log
|
||||
ir
|
||||
xml:
|
||||
web_channel.xml
|
||||
sale.xml
|
||||
|
|
Loading…
Reference in New Issue