2015-09-13 54 views
2

我使用Django和django-paypal嘗試設置支付系統。他們在哪裏,Django-Paypal信號

使用developer IPN simulator我可以發送帖子到我的服務器進行測試。

[13/Sep/2015 18:54:08] "POST /paypal/ HTTP/1.1" 200 4 

有從模擬器通過的帖子,沒有問題。

現在我想讓信號激發。我把下面的在我的AP中的一個models.py中作爲documentation

from paypal.standard.models import ST_PP_COMPLETED 
from paypal.standard.ipn.signals import valid_ipn_received 

def show_me_the_money(sender, **kwargs): 
    print "Hello" 
    ipn_obj = sender 
    if ipn_obj.payment_status == ST_PP_COMPLETED: 
     # Undertake some action depending upon `ipn_obj`. 
     if ipn_obj.custom == "Upgrade all users!": 
      Users.objects.update(paid=True) 
    else: 
     #... 

valid_ipn_received.connect(show_me_the_money) 

但我從來沒有得到來自任何信號repsonse。

我不知道爲什麼?我不知道如何測試這個

回答

0

我不熟悉這個庫,但是你是否定義了你的receiversender

例如,在一個post_save信號,我想構建這樣的:

post_save.connect(receiver=my_function, sender=myModel) 

它看起來像show_me_the_money錢是信號的接收器,但在這裏並不清楚是什麼在激發信號。也許它應該是:

post_save.connect(receiver=my_function, sender=ST_PP_COMPLETED)