# Path: openunipay/models.py
# PAY_WAY_WEIXIN = 'WEIXIN'
# 
# Path: openunipay/paygateway/unipay.py
# _PAY_GATEWAY = {PAY_WAY_WEIXIN: weixin.WeiXinPayGateway(),
#                 PAY_WAY_ALI: alipay.AliPayGateway(), }
# def create_order(orderno, payway, clientIp, product_desc, product_detail, fee, user=None, attach=None, expire=1440, **kwargs):
# def query_order(orderno):
# def process_notify(payway, requestContent):
# def is_supportted_payway(payway):
# def _update_order_pay_result(payResult):
# def generate_qr_pay_url(payway, productid):
# def process_qr_pay_notify(payway, requestContent):


import logging
from django.http import HttpResponse
from openunipay.models import PAY_WAY_WEIXIN
from openunipay.paygateway import unipay


_logger = logging.getLogger('weixin_pay_notificaiton')


def process_notify(request):
    _logger.info('received weixin pay notification.body:{}'.format(request.body))
    unipay.process_notify(PAY_WAY_WEIXIN, request.body)
    return HttpResponse('<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>', 'application/xml', 200)


def process_qr_notify(request):
    _logger.info('received weixin qr pay notification.body:{}'.format(request.body))
    try:

# Path: openunipay/models.py
# PAY_WAY_WEIXIN = 'WEIXIN'
# 
# Path: openunipay/paygateway/unipay.py
# _PAY_GATEWAY = {PAY_WAY_WEIXIN: weixin.WeiXinPayGateway(),
#                 PAY_WAY_ALI: alipay.AliPayGateway(), }
# def create_order(orderno, payway, clientIp, product_desc, product_detail, fee, user=None, attach=None, expire=1440, **kwargs):
# def query_order(orderno):
# def process_notify(payway, requestContent):
# def is_supportted_payway(payway):
# def _update_order_pay_result(payResult):
# def generate_qr_pay_url(payway, productid):
# def process_qr_pay_notify(payway, requestContent):


# Path: openunipay/api/views_weixin.py
import logging
from django.http import HttpResponse
from openunipay.models import PAY_WAY_WEIXIN
from openunipay.paygateway import unipay


_logger = logging.getLogger('weixin_pay_notificaiton')


def process_notify(request):
    _logger.info('received weixin pay notification.body:{}'.format(request.body))
    unipay.process_notify(PAY_WAY_WEIXIN, request.body)
    return HttpResponse('<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>', 'application/xml', 200)


def process_qr_notify(request):
    _logger.info('received weixin qr pay notification.body:{}'.format(request.body))
    try:

        responseData = unipay.process_qr_pay_notify(PAY_WAY_WEIXIN, request.body)
