Search code examples
djangopython-2.7paypal-ipndjango-paypal

Django-paypal ipn notify_url not responding


My settings.py is:

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

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

My views.py is:

@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")

My urls.py is:

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

 )

My template is:

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

My problem is that the function "notify" in the views.py is not being called. Can you guys please guide me into the right direction. I am not getting what I am doing wrong. Thanks in advance.


Solution

  • As per the documentation, you have correctly added following line in urls.py

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

    Above code snippets means that https://example.com/notify url directly call the paypal pacakge views ipn funcation, which is actually designed for handling the ipn response.

    So @Shivratna you don't need to implement any other notify function in your views.

    Can you make sure following things are done, before you do the paypal transaction:

    1. notify url correct in your sandbox or live paypal account settings
    2. as well as in the config dict like paypal_dict_flexible
    3. assuming you have installed package properly, but don't forgot to run python manage.py syncdb which creates tables for django-paypal package

    I hope my suggestion will show you right direction ;)