order.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:cetusshop 作者: icetusorg 项目源码 文件源码
def paypal_notify(sender, **kwargs):
    logger.debug(str('??paypal??????'))
    ipn_obj = sender
    logger.debug(str('STEP_0:????????????????'))
    order = None
    try:
        order = Order.objects.get(order_number=ipn_obj.custom)
    except Exception as e:
        logger.debug('??????' + str(ipn_obj.custom))
        return

    logger.debug(str('STEP_1:?????????'))
    if abs(float(ipn_obj.mc_gross)-order.order_amount) > 0.01:
        logger.debug(str('?????????????[%s]?????[%s],???????[%s]' % [order.order_number,order.order_amount,ipn_obj.mc_gross]))
        reason = 'amount not equal'
        detail = str('???????????ID[%s]?????[%s],???????[%s]' % [order.id,order.order_amount,ipn_obj.mc_gross])
        logger.debug(detail)
        logger.debug(str('?????????????????????'))
        abnormal_order = Abnormal_Order.create(order=order,reason=reason,detail=detail)
        order.status = Order.ORDER_STATUS_ERROR
        order.pay_status = 'Payment amount not equal'
        order.save()
        return
    logger.debug(str('STEP_3:??????????????'))
    paypal_account = System_Config.objects.get(name='paypal_account').val
    if ipn_obj.receiver_email != paypal_account:
        logger.debug(str('????????????[%s]????????[%s]??????????[%s]' % [order.order_number,ipn_obj.receiver_email,paypal_account]))
        reason = 'receiver not correct'
        detail = str('??????????ID[%s]????????[%s]??????????[%s]' % [ipn_obj.receiver_email,paypal_account])
        logger.debug(detail)
        abnormal_order = Abnormal_Order.create(order=order,reason=reason,detail=detail)
        order.status = Order.ORDER_STATUS_ERROR
        order.pay_status = 'Payment receiver not correct'
        order.save()
        return

    logger.debug(str('STEP_4:????????????????'))
    order.status = Order.ORDER_STATUS_PAYED_SUCCESS
    order.pay_status = 'Paid Successfully'
    order.money_paid = ipn_obj.mc_gross
    order.save()

    #?????????
    from shopcart import signals
    signals.order_was_payed.send(sender="Order",order=order)
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号