pythongoogle-app-enginepaypalpaypal-ipn

How to "run" a "Paypal Subscriptions Service" inside Google App Engine?


before anything, I want to you to Know that I'm a Complete Newbie in these things about developing "paid" webapps. I have been reading some posts about how to integrate PayPal's IPN with Google App Engine, and I have some questions about the topic, the thing is like this:

I want to use a PayPal's Subscribe button in my webapp (which is developed with GAE's Python base) so the users can subscribe to the premium version if they don't want to use the free one anymore...

I was reading that PayPal can help me to manage this thing about the users control via IPN but I have to setup that in my GAE App and I don't know how... For example:

Where the notification URL has to point to in PayPal's profile configuration? I believe it has to point to a Python script in my app but I'm not sure... If that is true, What does this Python script has to have?

Then, after that's finished, How can I make PayPal create usernames and passwords for my users in order to keep non premium users out of the "premium features"?? I don't want links to something, I need explanations on how to implement a "PayPal Subscriptions service" inside a Python based app on GAE in order to offer a "premium service" and a free one,

Thanks, hope you can help


Solution

  • To make a short answer (as I'm not exactly sure what's the scope of your question).

    1. It's not paypal's job to maintain your data model. You need to create a database entry with your users.

    For an example of that, look Google's documentation at

    http://code.google.com/appengine/docs/python/gettingstarted/usingusers.html and, more importantly, http://code.google.com/appengine/docs/python/gettingstarted/usingdatastore.html

    So you could create, for example, data model of this sort:

    class Users(db.Model):
      gae_user_object = db.UserProperty()
      premium_member = db.BooleanProperty(default=False)
    

    (of course, since you want to track subscriptions, this would be way too limited but you can get the idea).

    and make the script called by Paypal trigger a function to change the value of *premium_member*...

    1. Yes, paypal instant payment notification will call your app (you can specify somewhere in Paypal interface what uri, so you can choose what to map it to, preferably using your https appspot subdomain). Your app will need to store what paypal just sent and, before officializing anything, call Paypal servers back with the parameters that were just sent to know if the first was truly made by Paypal and not someone else.

    To see a working example of that, check http://blog.awarelabs.com/2008/paypal-ipn-python-code/ and http://groups.google.com/group/google-appengine-python/browse_thread/thread/d76701e774e308be, even if both these example sucks (it will probably work, but don't use them as is in production as you'll notably end up with real bad error management).