How to integrate Stripe payments gateway with Django Oscar?

ε祈祈猫儿з 提交于 2019-12-05 19:25:52

I have found a way to integrate Stripe with Django Oscar, this is one of the easy ways to do it.

  1. Create a stripe account first from here:https://stripe.com/, you will get a publishable key and a secret key, you can view them after logging in into the stripe dashboard under Developers > API keys.

  2. In your django oscar code side. Fork the checkout app from oscar, add it to the INSTALLED_APPS+=get_core_apps(['checkout']).To know how to fork an app you can follow this link from the docs:https://django-oscar.readthedocs.io/en/latest/topics/customisation.html#fork-oscar-app

  3. Create a file called facade.py under checkout, copy the keys from your dashboard into the settings.py file and do the other changes as suggested in this link: Stripe payment gateway integration on the django oscar groups, it just happens to be titled wrong.Just follow this whole page and it's done.

When you check the logs in your Stripe Dashboard ("Developer > Logs" section) do you see requests for the creation of the Token, Customer and Charges? Were these requests successful? Do you see any errors?

In relation to Django Oscar, I'm not familiar with it so not sure if the below would help.

But I had a look at the Django Oscar code and it seems that the "No payment was required" message is shown by the thank_you template when the Order record doesn't have any sources added to it (i.e order.sources.all returning empty):

https://github.com/django-oscar/django-oscar/blob/master/src/oscar/templates/oscar/checkout/thank_you.html#L94

So it could be that in your handle_payment code you may be not properly adding the source record to the current Order record as suggested in this recipe or the email thread you listed.

For debugging this further, I would suggest to:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!