1

settings.py的是:

INSTALLED_APPS = (
.......,
'paypal.standard.ipn',
)

PAYPAL_RECEIVER_EMAIL = "coolakashsaikia-facilitator@gmail.com"
PAYPAL_TEST = True

views.py的是:

@csrf_exempt
def pricing(request):
  paypal_dict_flexible = {
     "business": "coolakashsaikia-facilitator@gmail.com",
     "amount": "100.00",
     "item_name": "Flexible Subscription",
     "invoice": "10",
     "notify_url": "https://example.com/notify",
     "return_url": "http://example.com/signup",
     "cancel_return": "",
 }

 form = PayPalPaymentsForm(initial=paypal_dict_flexible)
 context = {"form": form, 'current_page': 'pricing'}
 return render_to_response("leavebuddyapp/pricing.html", context)

 @csrf_exempt
 def notify(request):
     return HttpResponse("Notify called")

urls.py的是:

 urlpatterns = patterns('',
   #Paypal
   (r'^notify', include('paypal.standard.ipn.urls')),

 )

我的模板是:

 <div class="test">
       {{ form.render }}
       <a href="/signup/flexible" class="btn">Buy now</a>
  </div>

我的问题是函数“ notifyviews.py没有被调用。你们能引导我走向正确的方向吗?我没有得到我做错了什么。提前致谢。

4

2 回答 2

2

根据文档,您已在 urls.py 中正确添加以下行

(r'^notify', include('paypal.standard.ipn.urls')),

以上代码片段https://example.com/notify的意思是url直接调用paypal pacakgeviews ipn函数,其实是为处理ipn响应而设计的。

所以@Shivratna 你不需要notify在你的视图中实现任何其他功能。

在进行贝宝交易之前,您能否确保完成以下事项:

  1. 在您的沙盒或实时贝宝帐户设置中通知 url 正确
  2. 以及在配置字典中like paypal_dict_flexible
  3. 假设您已经正确安装了包,但不要忘记运行python manage.py syncdb它为 django-paypal 包创建表

我希望我的建议能给你指明正确的方向;)

于 2014-06-10T19:55:56.620 回答
0

我不知道你为什么认为/notifyurl 应该调用你的视图。您的 url 配置通过包含 paypal url 配置将您的/notifyurl 指向视图。paypal.standard.ipn.views.ipn

如果你想调用你的notify视图,你应该将它包含在你的 url 配置中:

urlpatterns = patterns('',
    ...
    (r'^notify/$', myapp.views.notify),
)

但是,我非常怀疑您是否想为 paypal ipn 回调编写自己的视图。Django-paypal 的默认 ipn 视图包括信号挂钩,您可以在其中轻松添加自己的自定义逻辑。

于 2014-06-10T13:34:23.473 回答