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
评论列表
文章目录