Django 3 + oscar 3.0/ with Paypal ?

386 views
Skip to first unread message

Stéphane Rodriguez

unread,
Nov 28, 2020, 3:35:00 AM11/28/20
to django-oscar
Hello,

I'm struggling to configure Paypal on my site.

Do you already manage to have it working with Django 3 ?
Every time I have a conflict as only 2.x is supported.

Any help/advice/howto is appreciated.

Thanks in advance.
Stephane

Kevin Muturi

unread,
Nov 28, 2020, 3:45:23 AM11/28/20
to django...@googlegroups.com
I hope you have already created sandbox app in your business paypal. Or please be specific what struggle you come up with

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/3b87faae-7097-4b59-b50f-513f82ef54f4n%40googlegroups.com.

Stéphane Rodriguez

unread,
Nov 28, 2020, 4:55:37 AM11/28/20
to django-oscar
yes, already did it :)

The problem is not how to configure it, it's how to have the django-oscar-paypal installed with Django 3.x
Actually any Paypal solution with Django 3.x

When I install this module, Django 3.x is un-installed.
I did a lot of search in google &  co but I didn't find how using a paypal solution with Django 3.x and oscar.

If you can help me, thanks in advance

Stéphane Rodriguez

unread,
Nov 28, 2020, 5:23:04 PM11/28/20
to django-oscar
at the end, I did the following and it's working.

un-install all previous paypal installation
download the master branch of the django-oscar-paypal and copy to a paypal folder. Add the paypal application + paypal.express.... and paypal.payflow.... (cf sandbox example)

Install theses modules:
pip3 install paypalhttp
pip3 install paypal-checkout-serversdk

Then, do not follow the doc as it's outdated, instead open the sandbox files and do the same.

Now, I have Paypal working with Django 3.x and oscar 3.0 a ;)

PS: with MySQL and Django 3.X, you will have to update the length of the status field in the ExpressCheckoutTransaction Class.

Ben Stähli

unread,
Nov 30, 2020, 3:05:33 AM11/30/20
to django...@googlegroups.com, Stéphane Rodriguez
django-paypal seems to be in maintainance mode...maybe it's missing a
release, for supporting latest django versions?
> <https://groups.google.com/d/msgid/django-oscar/3b87faae-7097-4b59-b50f-513f82ef54f4n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> https://github.com/django-oscar/django-oscar
> http://django-oscar.readthedocs.org/en/latest/
> ---
> You received this message because you are subscribed to the Google
> Groups "django-oscar" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-oscar...@googlegroups.com
> <mailto:django-oscar...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/django-oscar/3b64871b-ccd7-4a2e-a5ab-97499f0bb4ddn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-oscar/3b64871b-ccd7-4a2e-a5ab-97499f0bb4ddn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Ben Stähli
bn...@bnzk.ch
+41 22 575 25 77
bnzk.ch
--

MUGOYA DIHFAHSIH

unread,
Dec 1, 2020, 1:48:51 AM12/1/20
to django...@googlegroups.com
Am having the same issue of django-oscar-paypal conflicting with the django 3 version, i have tried Rodriguez's solution but it seems I need more elaboration on how to implement it. Your help is much appreciated.

Ben Stähli

unread,
Dec 1, 2020, 2:06:18 AM12/1/20
to django...@googlegroups.com, MUGOYA DIHFAHSIH
hi mugoya

without any pointers, it's hard to help.

best
ben
> kevinm...@gmail.com <mailto:kevinm...@gmail.com> a
> >     écrit :
> >
> >         I hope you have already created sandbox app in your business
> >         paypal. Or please be specific what struggle you come up with
> >
> >         On Sat, 28 Nov 2020, 11:35 am Stéphane Rodriguez,
> >         <stepro...@gmail.com <mailto:stepro...@gmail.com>> wrote:
> >
> >             Hello,
> >
> >             I'm struggling to configure Paypal on my site.
> >
> >             Do you already manage to have it working with Django 3 ?
> >             Every time I have a conflict as only 2.x is supported.
> >
> >             Any help/advice/howto is appreciated.
> >
> >             Thanks in advance.
> >             Stephane
> >
> >             --
> > https://github.com/django-oscar/django-oscar
> > http://django-oscar.readthedocs.org/en/latest/
> >             ---
> >             You received this message because you are subscribed
> to the
> >             Google Groups "django-oscar" group.
> >             To unsubscribe from this group and stop receiving emails
> >             from it, send an email to
> django-oscar...@googlegroups.com
> <mailto:django-oscar...@googlegroups.com>.
> >             To view this discussion on the web, visit
> >
> https://groups.google.com/d/msgid/django-oscar/3b87faae-7097-4b59-b50f-513f82ef54f4n%40googlegroups.com
> >
>  <https://groups.google.com/d/msgid/django-oscar/3b87faae-7097-4b59-b50f-513f82ef54f4n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> >
> > --
> > https://github.com/django-oscar/django-oscar
> > http://django-oscar.readthedocs.org/en/latest/
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "django-oscar" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to django-oscar...@googlegroups.com
> <mailto:django-oscar%2Bunsu...@googlegroups.com>
> > <mailto:django-oscar...@googlegroups.com
> <mailto:django-oscar%2Bunsu...@googlegroups.com>>.
> bn...@bnzk.ch <mailto:bn...@bnzk.ch>
> bnzk.ch <http://bnzk.ch>
> --
>
> --
> https://github.com/django-oscar/django-oscar
> http://django-oscar.readthedocs.org/en/latest/
> ---
> You received this message because you are subscribed to the Google
> Groups "django-oscar" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-oscar...@googlegroups.com
> <mailto:django-oscar%2Bunsu...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/django-oscar/0d0188bc-628d-0d2f-c196-4f175f4a5608%40bnzk.ch.
>
> --
> https://github.com/django-oscar/django-oscar
> http://django-oscar.readthedocs.org/en/latest/
> ---
> You received this message because you are subscribed to the Google
> Groups "django-oscar" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-oscar...@googlegroups.com
> <mailto:django-oscar...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/django-oscar/CAP%3DJD9zWxWtiWJvLn8s%3DhYcHCvgQMkSZZdQ67ZkgDGHvA2U-Fw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-oscar/CAP%3DJD9zWxWtiWJvLn8s%3DhYcHCvgQMkSZZdQ67ZkgDGHvA2U-Fw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Stéphane Rodriguez

unread,
Dec 1, 2020, 2:30:54 AM12/1/20
to django-oscar
right, I forgot some points.

To install oscar with django 3.x, do the following:

pip3 install django-tables2
pip3 install django-oscar==3.0a0
pip3 install Django==3.1.3

MUGOYA DIHFAHSIH

unread,
Dec 1, 2020, 2:43:07 AM12/1/20
to django...@googlegroups.com
hi Rodriguez, i have installed the three requirements you suggested into my venv, but am get this error ModuleNotFoundError: No module named 'paypalwidget_tweaks'

To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/53367e56-2eaf-45c7-9752-ffcdffc4dfc7n%40googlegroups.com.

MUGOYA DIHFAHSIH

unread,
Dec 2, 2020, 12:51:44 AM12/2/20
to django...@googlegroups.com
After a full day of debugging, I had missed a comma between paypal and widget_tweaks in the INSTALLED_APPS in the settings.py file. Now am good to go, Thanks for your help fellow devs, stay safe.

MUGOYA DIHFAHSIH

unread,
Dec 2, 2020, 2:55:13 AM12/2/20
to django...@googlegroups.com
Hello Rodriguez, using the procedures you gave me, i was successful.

Now how can i customize the oscar payment templates to implement paypal method

Stéphane Rodriguez

unread,
Dec 2, 2020, 10:25:38 AM12/2/20
to django-oscar
glad to hear that.

After it's quiet straightforward :)

In the settings file:
INSTALLED_APPS = [
...
    # Paypal
    'paypal.express.dashboard.apps.ExpressDashboardApplication',
    'paypal.express_checkout.dashboard.apps.ExpressCheckoutDashboardApplication',
    'paypal.payflow.dashboard.apps.PayFlowDashboardApplication',
....
    'django.contrib.sitemaps',
    'paypal',

and also:
from django.utils.translation import ugettext_lazy as _
OSCAR_DASHBOARD_NAVIGATION.append(
    {
        'label': _('PayPal'),
        'icon': 'icon-globe',
        'children': [
            {
                'label': _('PayFlow transactions'),
                'url_name': 'payflow_dashboard:paypal-payflow-list',
            },
            {
                'label': _('Express transactions'),
                'url_name': 'express_dashboard:paypal-express-list',
            },
            {
                'label': _('Express Checkout transactions'),
                'url_name': 'express_checkout_dashboard:paypal-transaction-list',
            },
        ]
    })

PAYPAL_SANDBOX_MODE   = True
PAYPAL_CALLBACK_HTTPS = False
PAYPAL_API_VERSION    = '119'
PAYPAL_CURRENCY       = 'EUR'

makemigrations + migrate

In the urls file:
1. add the import
from paypal.express.dashboard.apps import ExpressDashboardApplication

2. update the urls
    # PayPal Express integration...
    path('checkout/paypal/', include('paypal.express_checkout.urls')),
    # Dashboard views for Payflow Pro
    path('dashboard/paypal/payflow/', apps.get_app_config("payflow_dashboard").urls),
    # Dashboard views for Express
    path('dashboard/paypal/express/', apps.get_app_config("express_dashboard").urls),
    # Dashboard views for Express Checkout
    path('dashboard/paypal/express-checkout/', apps.get_app_config('express_checkout_dashboard').urls),


In the settings, you need to configure your paypal account: login into Payapal development dashboard: create a sandbox api
Copy from the user the PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET

As I wrote in my previous answer, change the length of the status and again makemigrations + migrate

Hope it will save you some time.

meig...@meigallodixital.com

unread,
Feb 15, 2021, 10:29:11 AM2/15/21
to django-oscar
As there is no official version too, I am following this thread  method (clone and configure as repository sandbox is done) to try to use paypal express.

But oscar register an error when finishing order leaving the basket frozen and I don't see the reason. 

The message error is: A problem occurred while placing this order. Please contact customer services. Does the error sound familiar to anyone? I've already done copy/paste of the sandbox in clean installation too, and the same behaviour.

One doubt is that on sandbox is used api params (api_username, api_password and api_signature) and in this thread is cofigured client_id and client_secret

The paypal log at Dashboard is (400 one is the sum/merge of the two 200):

checkout.png

meig...@meigallodixital.com

unread,
Feb 15, 2021, 12:22:23 PM2/15/21
to django-oscar
After debugging, I see that order number 100001 is always set -> unhandled exception when ordering (there is already an order with number 100001). The first time give error too but creates the order :? 

I have overwritten OrderNumberGenerator to get this pattern: year [2:] + month.zfill (2) + str (code_new) .zfill (4) So I don't know where he got that order number from.

Another thing that I have observed is that in the order it saves the data of Paypal not of the logged User, for example the mail is the paypal one.

meig...@meigallodixital.com

unread,
Feb 15, 2021, 1:08:44 PM2/15/21
to django-oscar
The problem I think is that, although I am logged in, it is making them anonymous (as guest).

meig...@meigallodixital.com

unread,
Feb 15, 2021, 1:59:31 PM2/15/21
to django-oscar
I think I found the issue with the email notification. 

Even if the PayPal payment goes OK, if the system is unable to send the email confirmation the user will get stuck in the PayPal payment screen. 

The problem is the payment goes through, even if the user gets an error (the error is cause the email could not be sent, not cause the payment did not go through). So the user can be in a situation where he got like 4-5 errors but the product was ordered 4-5 times..

Another error is that the order is marked as a guest user, not as the user who made the purchase ... even with the email working. I save in  the field 'guest_email' the email of the payment account in Paypal. Basket id is always 1 too, that's where the 100001 error comes from.

Mehfooz Ali

unread,
Feb 19, 2023, 9:45:05 AM2/19/23
to django-oscar
Hey Developers,
I have tried connecting/integrating paypal with django-oscar . But didn't resolve my issue, yet. I have read the above conversation but didn't resolve my issue.

I have did the same thing as above mentioned.

pip3 install django-tables2
pip3 install django-oscar==3.0a0
pip3 install Django==3.1.3

Please any senior guide me about it. I am working on the project i need help.

11111.JPG

Mehfooz Ali

unread,
Feb 19, 2023, 10:52:57 AM2/19/23
to django...@googlegroups.com
Any one can help me?

Reply all
Reply to author
Forward
Message has been deleted
0 new messages