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.
Related
I am working on a beta-stage writing tool SaaS that is built with NextJS, React, and Django REST. As I’m gaining some user base, I am starting to research on introducing a premium plan to the mix using Stripe.
As most other SaaSs, I will have a subscription-based premium plan which grants access to premium-only features. However, even after days of research, I am still lost how this is commonly implemented in Django/Backend. Here is what I’ve thought of so far, but again, I am not sure if it’s the best/common way to accomplish this.
User model has a ‘premium’ field which is either True or False
Whenever user clicks on a premium-only API call, Django will check if user is premium or not to decide whether to make the actual API call. I currently have a '/user/me/' route which returns basic user information as API GET call.
Upon successful stripe payment, stripe redirects user to the success_url. Then, somehow I will detect when user lands on success_url and then set that user’s premium field to True.
I know this is not the ideal way, because I already see lots of issues/hurdles:
How will I set ‘premium’ field back to False after user’s payment stops
How can I ‘detect’ stripe’s payment to set user’s premium field
Is this feature supposed to be implemented with Stripe customer objects instead? I would appreciate any guidance on where I should be looking for solutions.
If you use subscription on Checkout Session (low code solution), you can add additional key-value pair data such as premium: true in metadata and subscription_data.metadata fields when creating a subscription.
Once the payment is completed, those metadata will appear in checkout.session.completed and customer.subscription.updated webhook events, which you can then set the user as premium in your own database.
A customer object in Stripe can have multiple subscriptions, so this feature will be implemented on subscription object instead.
A company I help out have signed up to sell their magazine and newspaper products via an online affiliate.
The affiliate link directs users to a payment page on the client site, but they are using paypal for payments which as you know takes you away from the site.
I'd updated the paypal accounts to redirect back to the client site, where the affiliate tracking code sits, but I believe because we go off to paypal in the middle of the payment, no tracking is sent back.
Essentially, I need Paypal to send a specific code (in this case the merchant ID) and the order value when it redirects.
What would be the best way of doing this?
Thanks
Tom
I would send the affiliate ID in the CUSTOM parameter of your PayPal request and then setup an IPN solution to log the transaction in your database accordingly.
The CUSTOM parameter will come back in IPN so you can easily update your system with the affiliate ID.
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.
I have a web service at which users can buy reports made on the fly using PayPals Express checkout process. I want to make sure that no matter how the user returns to the site (through paypals callback or by himself) he could download the report he payed for. For that I need to keep the report ID he has bought somewhere. Where and how would it be best to do that? (Cookies? Sessions Parameters?)
I am using ASP .Net C#.
Thanks,
Wess
Do the users have logins that are managed by you in your database? If so and you want the user to be able to return at any time to your page and download the report, then you'll need to use a PayPal callback to store in your database what report ID the user has purchased.
If you don't manage your users then I'm not sure how this can be accomplished because cookies are limited (and can be disabled by users) and sessions expire.
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.