django-registration with paypal integration - django

I'm trying to figure out how to integrate django-registration with django-paypal. Being a Django n00b, I'm trying to figure out how to implement a flow like this:
User signs up using django-registation with 'active' flag set to 0
After registering, send user to PayPal for a subscription
When they come back from PayPal successfully, I want to set 'active' to 1
I've been looking at the django-registration documentation and don't quite understand how to use different backends or implement a flow the way I want.
Any tips on how to accomplish this would be greatly appreciated. django-paypal won't be a problem for me as I've done PayPal integration before (in PHP for a self-published book about CakePHP).

To have registration not send an email you pass send_email=False to the RegistrationManager.create_inactive_user call in your view to register a user. After you create the user, you probably want to create a landing page with the paypal buttons for payment. Instruct the user to click a payment button to pay. Generally I send the user.id in the custom field for the payment button.
Then, in django-paypal, use the IPN signal handlers to activate the user based on the user.id in the custom field of the IPN query. You might want to send a modified registration email at this point, welcoming the user to your site and telling them you have received payment and have activated their account, but those are details for you to define.

Related

How to send notification from admin to user in Django

I am building an online shopping website using Django framework. I want to implement an order approval system where Django Admin will approve the order request from the user and at that time a notification or message will be sent to the user.
Currently I have an order request model with an order status field. When the value of that field will be set approved by the admin a notification will be sent to that user.
I want a push notification system here. How can I implement this in Django?

How to handle in django user going back after payment confirmation?

After payment confirmation, I can go back to payment page and view the details on what user entered. This should not happen
Tried using java script to disable back button but read few recommendations saying its not a good practice to stop user going back. Not sure if there are any decorators like #login_required in django.
How can I force user to see home page even if back button is click on browser after payment confirmation? Does django provide any decorator for the same?

Calling Zapier trigger from Django Code

Is there any way I can call the "Zapier trigger" from my Django Code,
Basically, I am having a Django form where the user will enter several email-id and when the user clicks on send button then I want to send this form data to Zapier in order to do the next action like writing in google spreadsheet or sending email to everyone.
David here, from the Zapier Platform team. The easiest way to do this is to have the form submit against your server and use a library like requests to POST to Zapier. This way, you don't have to worry about CORS or revealing the hook url to your users.
Hope that makes sense. ​Let me know if you've got any other questions!
I am not sure from your question if this is related to how to make the call from Python (which #xavdid answered) or how to trigger a zap. If this is about triggering a Zap, here's the answer.
Setup a Zap by choosing the Webhooks by Zapier app as the trigger. Choose catch a raw hook, if you need more control. In the next step, you will receive a URL where you can POST your form-data.
Everytime you POST data the Zap will be triggered. You can use the data available from your request in the action step for Google Sheets or Emails.
Here are a few Zap Templates that you could start from.
Add info to Google Sheets from a Webhook POST
Send emails from a Webhook POST (Using Zapier's email app)
Send emails from a Webhook POST (using Gmail)

Django user registration - email invitations?

I am trying to hack my way through the wonderful django-registration app, and add the ability to send email invitations for the site.
The sending of invitations is trivial: the user enters an email, and the view sends an email to the recipient with a random alphanumeric sequence in the activation link.
I largely took the code from Ayman Hourieh's book on Django. The problem is that in the book Ayman develops a custom made registration system, and then adds the variable invitation to the session. I don't know how to do it with Bennett's django-registration, so that when somebody follows the link, and performs the activation, he can become friend with the user than sent the invitation. This is crucial for me because I need the ability to track the number of users that each user drove to the site. Anyone had experience with this problem?
Have you had a look at django-invitation? It's build on django-registration
http://code.welldev.org/django-invitation/wiki/Home
EDIT
I haven't used it before so I don't know its exact functionality, but looking at the code, when an invitation is sent, an InvitationKey object is created which has a from_user and registrant so the functionality is there whether it's documented or not.

Django, PayPal IPNs & User Names - concept issues

I'm trying to sell virtual goods using PayPal (already implemented Zong+) in Django. I decided to use django-paypal to handle the IPN for me (decided that IPN was the best fully automated option.)
I've currently made a buy-now button using the PayPal button wizard on their website, ie it's secure and saved on paypal to protect against tampering. (I'm very new to PayPal, not living in a fully supported country, so haven't used it myself.)
My questions:
How do I include the username that made the purchase or a similar means of identifying the user that made the purchase with the IPN callback later and retrieve that with django-paypal? Preferably with no means for the user to mess with it.
Should i ditch the auto-generated button and roll my own instead? Will that let me pass extra invisible parameters that PayPal will send in the IPN later?
The Sandbox doesn't let me make User Accounts that I can test on the real site, right? Unless I make a merchant in the Sandbox and make a button for that merchant, I think.
1: If you use the django-paypal PayPalPaymentsForm you can specify a "custom" field containing the username. This will be posted back to you with the IPN. If your buttons are encrypted the user will be unable to tamper with this.
2: Yes, see 1 :-)
3: No, but you can create buyer and seller accounts on the Sandbox.