I'm using django and I want to integrate stripe using the abstraction layer dj-stripe.
From what I understand from the documentation, ElementJs with Payment Intent is the preferred way to allow users to enter their payment details. see https://dj-stripe.dev/stripe_elements_js/
However, there is no documentation on how to connect dj-stripe with stripe.js. The first step of the usage documentation in dj-stripe already assumes payment methods have been connected (https://dj-stripe.dev/usage/subscribing_customers/). I looked through the code of dj-stripe and it seems to have Payment Intent classes, but I can't figure out how to use them.
How can I generate a client secret for customers created in dj-stripe that can then be used in stripe.js? (Or if I'm not on the right path, what should I do instead to allow adding payment details to be used in dj-stripe)
dj-stripe is a Python backend framework, and theoretically it should work with any frontend including pure stripe.js. You should follow Stripe official Doc and adapt. They also have an example project in Python (not Django though).
Related
I am currently at the planning stage of an app that will consist of standard
Django part for supervisors that can perform all CRUD operations on employee users mostly add, delete and view statistics - viewed in browser (no frontend framework just using Djangos server side rendering), two step email authentication on each login, session based auth
DRF part for employees - API connected to mobile app, authentication based on device ID. (no username, or password)
DRF part for clients to contact the supervisors if employees do something wrong - Token or JWT based authentication using passcode delivered by mail.
I am not used to splitting Django projects into multiple sub-projects (or using same database for different projects) but it feels like every part of the project should be a standalone app due to different authentication type and the fact of simultaniousily using DRF with standard Django
Can anyone who had similar problem or has some experience, advise what should I do considering different authentications and overall different user types in this project? What would be pros and cons of going into solo or multiple projects? Thanks in advance!
You're asking for opinions, so don't be surprised if the question gets closed, but I'll answer with facts:
A split over different projects using the same database has the following issue: shared migrations. They all use built-in users, so require some standard apps to be enabled that have migrations and they won't run on the 2nd and 3rd project.
You're going to need a custom user model to support the device id authentication method: You need information that is not on the standard user model to be available at authentication time - the number 1 reason to create a custom user model. Ties into migrations and also a synchronization hell code-wise.
Django's Authentication Backends system allows for different authentication methods to exist at the same time, so there is no need to split anything. If you're worried about security, you can always use different hostnames and the Sites framework to add an extra layer of protection, but they would still use the same code.
DRF started as an addition to Django's view-based approach, not a replacement to make part of a project's code available as an API. While current usage is more "DRF or templates" this is a result of people increasingly becoming binary ("this" or "that") and wanting to be in the cool club, but has nothing to do with technical reasons. They can and always will be able to co-exist as they solve different problems. In fact, DRF's generic views make use of Django's CBV's and the built-in browsable API makes use of templates. Also, the admin is template/view based and it's convenient to develop the app or manage data with the built-in admin.
In djangorestframework, there is a browsable api. But how do I show a user an entire bird's eye view of all the possible API calls that he/she can make? I can only see one at a time right now and the user would have to already know the correct URL beforehand
i.e.,
http://localhost:8000/users
http://localhost:8000/books
http://localhost:8000/book/1/author
Thank you!
The answer is as Klahnen said. Use this:
https://django-rest-swagger.readthedocs.io/en/latest/
It works out of the box for me and it is exactly what I was hoping for.
I still maintain, though, that the term browsable API implies that there is a table of contents available for consumers of your API to see. This app is a lifesaver and perhaps it should be included!
Django-Rest-Swagger as mentioned in the accepted answer is no longer maintained.
This is a good alternative
https://github.com/axnsan12/drf-yasg
Django-Rest-Swagger doesn't support OpenAPI 3.0 and is unlikely to support it soon, so if you want an actively maintained library that supports OpenAPI 3.0 then you should use drf-spectacular. It mostly works out of the box, and you can customize it a lot.
A side note:
Your api client needs access to the internet so that it gets the swagger UI or ReDoc from CDNs. Alternatively you can serve those static files from your service with an optional additional package, the drf-spectacular-sidecar
I want to integrate a payment gateway with oscar. I have integrated oscar-paypal it works fine. Should I follow oscar-paypal and try to emulate it ?
This document doesn't gives the starting information but not exactly ?
I need this. To create order, change basket status, make payments, send email, and many other steps that oscar-paypal is doing.
I think you can use payu which is also very easyily available and can be customized.
pip install git+https://github.com/SalahAdDin/django-oscar-payu#egg=payu
this would clone the payu application which has similar implementation as oscar-paypal. then edit the views.py in the nonseamless navigate to through the code and change the self.sessions.['currency'] to the currency which u want to use but the default currency it works with is INR. Then your payment_detail.html just replicate what you have as in paypal and change the paypal url to payu. Just switch paypal to payu. That is all.
credit to https://github.com/SalahAdDin/
Following the steps of Oscar Paypal is a pretty good idea. It's a pretty well written project. There are facades written that abstract the details of communicating with the Paypal Express and PayFlow APIs. The facade functions are then called from the views.py in each package, which is where the real integration with Oscar begins.
The Paypal Express implementation for example is integrated with Oscar pretty much by subclassing the PaymentDetailsView class and calling the necessary functions implemented in the paypal.express.facade package. There is also a ShippingOptionsView that provides some linkage with Paypal shipping.
I have a medium sized Drupal 6 site running (around 5 million page views per month and more than 30K registered users) and I need to integrate OSQA, a Django application, with it. I already have many users, roles and permissions in my Drupal database and I'd like to point the Django app to use the sign up and login pages I already have in Drupal to give my users a single point on entrance.
I want to keep the Django authentication part because I think OSQA would work better. I also have performance reasons in mind, the Drupal site already gets a lot of traffic and has a very busy database and I think that using a separate database for Django would help.
After some research I think I could make the Drupal sign up and login pages call Django in the background to sign up or login to the Django app. I plan to do this writing a couple of views in Django, one for sign up and another for login, and Drupal would post the username and password to those views. Of course I'd need to disable CSRF in Django for those views and probably also post some secret key that only my Drupal and Django applications know about to avoid external sites trying to use this "unprotected" Django views.
I know that my Django application may need some user data from Drupal at some points and I'm planning on using the Drupal services module for that.
Would this be a good approach? Any suggestions?
Thanks a lot!
Are there any plugins for OSQA to expose an authentication service that Drupal can talk to? (OpenID or similar).
Alternatively, check out Drupal's ldap_integration module for an example of a module that uses an external authentication service. Consider that you will need to create Drupal user accounts for each login.
Finally, why not just build the essential parts of OSQA's functionality with Drupal? Seems like the key functionality could be replicated quite easily using Taxonomy, Vote Up and Userpoints/User Badges... potentially easier to do than shared authentication, especially on a large site.
I once created a very simple [sql_authentication][1] module, which you can probably simply re-create for a more recent version of Drupal.
The idea is simple: provide Drupal with an alternative authentication callback.
In that callback-function, just check against the Django database, and return TRUE if you think the user is correct.
You could look at how openid.module (in core) extends the user-authentication for a simple example.
If you can post to the Django form, you may be able to use drupal_http_request to handle the call to Django. After using the ldap_integration module for a while, I worked on a custom authentication module that calls a Java-based REST authentication API using drupal_http_request. If you're interested in the code, let me know.
I'm trying to build an online recruitment site using the Zend/CodeIgniter framework. I wanted to know which of the two frameworks is the easiest to use and which gives support for templates.I want to write minimum code as possible.
I has hoping I could use a template or some form of CMS that would allow me to quickly create (or automatically provide) an admin and user profile section. Users will need to enter their CV details, modify their account, search and apply for jobs. The admin will then be able to search for applicants based on qualifications, job role, etc.
are there any templates I can use on top of the Zend or CodeIgniter framework to get done the majority of the work?
Thanks
With your needs i like to go with cakePHP, it just need models to be ready and with scaffolding admin panel is good, with Auth and causal baking user section is ready too
With Zend, it usually takes some time to get the things done.