我的 models.py 文件末尾有这段代码
from paypal.standard.ipn.signals import payment_was_successful
def confirm_payment(sender, **kwargs):
# it's important to check that the product exists
logging.debug('** CONFIRMED PAYMENT ***') #never reached this point
try:
bfeat = BuyingFeature.objects.get(slug=sender.item_number)
except BuyingFeature.DoesNotExist:
return
# And that someone didn't tamper with the price
if int(bfeat.price) != int(sender.mc_gross):
return
# Check to see if it's an existing customer
try:
customer = User.objects.get(email=sender.payer_email)
except User.DoesNotExist:
customer = User.objects.create(
email=sender.payer_email,
first_name=sender.first_name,
last_name=sender.last_name
)
# Add a new order
CustomerOrder.objects.create(customer=customer, feature=bfeat, quantity=1, paypal_email=sender.payer_email, invoice=sender.invoice, remarks='')
payment_was_successful.connect(confirm_payment)
整个过程运行正常。付款完成。return_url 和 cancel_url 工作正常。notify_url 已通过 paypal 沙箱的测试工具进行了测试,并且工作正常。但是,从来没有收到信号。
信号代码放在 models.py 的末尾,django-paypal 代码放在我的项目目录中。
(代码从这里“被盗” )
我一定做错了什么。任何帮助,将不胜感激!