paypal handler for cartridge?

802 views
Skip to first unread message

Tom von Schwerdtner

unread,
Mar 24, 2011, 3:14:34 PM3/24/11
to mezzani...@googlegroups.com
I don't suppose anyone has one they'd like to share?

I'm trying to limit the time I have to spend dealing with paypal...

-Tom

Andrew Fisher

unread,
Mar 24, 2011, 5:18:37 PM3/24/11
to mezzani...@googlegroups.com

Steve, didn't Luke build one?

Luke Miller

unread,
Mar 24, 2011, 7:11:58 PM3/24/11
to mezzani...@googlegroups.com
Hi Tom,

I did do basic paypal integration for a project on an older version of
cartridge.

The main problem for me was that it involved handing over to paypal
and relying on a callback view from paypal, which then did not have
the session data for the original user, which is how cartridge stored
a lot of its pre-final-order information. This was different to our
credit card processor that did the connection and processing using
urllib internally (so we never left the user's session).

The main links I used were:
- instructions courtesy
http://uswaretech.com/blog/2008/11/using-paypal-with-django/
- for a paypal django module courtesy: http://djangosnippets.org/snippets/1181/
- all bundled into an app at https://github.com/johnboxall/django-paypal

What I did to get it working:

1. Modify the Order model to allow "in process" or incomplete orders
and a special paypal flag
2. Before going to paypal, create an "in process" Order object and save it
3. Creating the paypal button (a PayPalPaymentsForm) and rendering it
(as per the app instructions)
4. Having a paypal_success view that paypal calls when a successful
payment goes through.
5. Use the information passed back from paypal to reload the "in
process" order and complete it.

Regards,
Luke

Tom von Schwerdtner

unread,
Mar 25, 2011, 11:37:06 PM3/25/11
to mezzani...@googlegroups.com, Luke Miller
Thanks for the info Luke, I appreciate it.

-Tom

Josh Cartmell

unread,
May 5, 2011, 7:02:33 PM5/5/11
to Mezzanine Users
Hey guys I am looking at integrating paypal into a Cartridge site now
and I was wondering if either of you could post your code somewhere
accessible.

Also Steve, or anyone else, I was wondering what you guys think the
best practice for integrating paypal with cartridge is considering
that to complete the paypal transaction you leave your site and as
Luke pointed out lose your session.

Any thoughts?

Thanks,
Josh

On Mar 25, 8:37 pm, Tom von Schwerdtner <tomv...@gmail.com> wrote:
> Thanks for the info Luke, I appreciate it.
>
> -Tom
>
>
>
>
>
>
>
> On Thu, Mar 24, 2011 at 7:11 PM, Luke Miller <dodgyvi...@gmail.com> wrote:
> > Hi Tom,
>
> > I did do basicpaypalintegration for a project on an older version of
> > cartridge.
>
> > The main problem for me was that it involved handing over topaypal
> > and relying on a callback view frompaypal, which then did not have
> > the session data for the original user, which is how cartridge stored
> > a lot of its pre-final-order information. This was different to our
> > credit card processor that did the connection and processing using
> > urllib internally (so we never left the user's session).
>
> > The main links I used were:
> > - instructions courtesy
> >http://uswaretech.com/blog/2008/11/using-paypal-with-django/
> > - for apaypaldjango module courtesy:http://djangosnippets.org/snippets/1181/
> > - all bundled into an app athttps://github.com/johnboxall/django-paypal
>
> > What I did to get it working:
>
> > 1. Modify the Order model to allow "in process" or incomplete orders
> > and a specialpaypalflag
> > 2. Before going topaypal, create an "in process" Order object and save it
> > 3. Creating thepaypalbutton (a PayPalPaymentsForm) and rendering it
> > (as per the app instructions)
> > 4. Having a paypal_success view thatpaypalcalls when a successful
> > payment goes through.
> > 5. Use the information passed back frompaypalto reload the "in
> > process" order and complete it.
>
> > Regards,
> > Luke
>
> > On 25 March 2011 08:18, Andrew Fisher <ajfisher...@gmail.com> wrote:
> >> Steve, didn't Luke build one?
>

Lee Matos

unread,
Jun 16, 2011, 8:38:07 AM6/16/11
to Mezzanine Users
Hey Guys,

Did anything ever come of this? Sorry for the kinda necro. :-/

On May 5, 7:02 pm, Josh Cartmell <gro...@j.oshua.net> wrote:
> Hey guys I am looking at integratingpaypalinto a Cartridge site now
> and I was wondering if either of you could post your code somewhere
> accessible.
>
> Also Steve, or anyone else, I was wondering what you guys think the
> best practice for integratingpaypalwith cartridge is considering
> that to complete thepaypaltransaction you leave your site and as

Daryl Antony

unread,
Jun 16, 2011, 6:50:27 PM6/16/11
to mezzani...@googlegroups.com
I'll need to tackle this too soon.... so happy to update and join in on the discussion :)

Tom von Schwerdtner

unread,
Jun 17, 2011, 8:14:07 AM6/17/11
to Daryl Antony, mezzani...@googlegroups.com
FWIW, I ended up using django-paypal-driver:


I have used the more common django-paypal lib in another site and found it to be a little less friendly, though I believe it supports more PayPal features. 

kenb...@gmail.com

unread,
Oct 25, 2011, 1:08:35 PM10/25/11
to mezzani...@googlegroups.com, Daryl Antony
Anybody else looking at this thread should be aware that the version of django-paypal-driver at https://github.com/leepa/django-paypal-driver is pip-ready. About to dive into the integration with Cartridge right now...

Sebastián Magrí

unread,
Nov 27, 2011, 10:03:10 PM11/27/11
to mezzani...@googlegroups.com, Daryl Antony
Any news about this?

I would like to look at this to take inspiration for moneybookers integration.

Regards,

Kenneth Bolton

unread,
Nov 28, 2011, 11:08:36 AM11/28/11
to mezzani...@googlegroups.com
I ended up forking Leepa's version, then merging in the direct
payments from http://code.google.com/p/django-paypal-driver/. My code
is here: https://github.com/kenbolton/django-paypal-driver/.

I made it aware of mezzanine.conf.settings. I will add sample payment
processor code later today and a defaults.py.

ken


2011/11/27 Sebastián Magrí <sebas...@gmail.com>:

Kenneth Bolton

unread,
Nov 28, 2011, 3:27:19 PM11/28/11
to mezzani...@googlegroups.com
Updated at https://github.com/kenbolton/django-paypal-driver/.

I should note that direct payments requires a Paypal Website Pro account.

If there is interest, I could break this out into two separate express
checkout and direct payments processor versions for Cartridge, to live
alongside the existing payment processors.

ken

Stephen McDonald

unread,
Nov 28, 2011, 3:29:46 PM11/28/11
to mezzani...@googlegroups.com

+1 would love to have those included

Sebastián Magrí

unread,
Nov 28, 2011, 7:38:50 PM11/28/11
to mezzani...@googlegroups.com
+1

Kenneth Bolton

unread,
Nov 29, 2011, 12:29:17 AM11/29/11
to mezzani...@googlegroups.com
https://github.com/kenbolton/cartridge/commit/23eaae3cfe861b41aeed5e31235481462f30c6c4

I tested nearly identical code tonight for a project, but am simply
too burnt to give this a thorough going-over right now.

I appreciate any feedback you have.

cheers,
ken

2011/11/28 Sebastián Magrí <sebas...@gmail.com>:
> +1
>

Kenneth Bolton

unread,
Nov 29, 2011, 12:36:27 AM11/29/11
to mezzani...@googlegroups.com
https://github.com/kenbolton/cartridge/tree/paypal

I will get a chance to test this tomorrow, but nearly identical code
has been working for me tonight on a project.

I appreciate any feedback you have.

cheers,
ken

Stephen McDonald

unread,
Dec 3, 2011, 5:15:03 AM12/3/11
to mezzani...@googlegroups.com
Brilliant work Ken, thanks so much for this. This'll open up Cartridge to a much wider audience!

I've merged your work in and included it in a new 0.3.5 release which is up on pypi now.
--
Stephen McDonald
http://jupo.org

Kenneth Bolton

unread,
Dec 3, 2011, 9:54:06 AM12/3/11
to mezzani...@googlegroups.com
shoulders of giants, my friend. thanks!

ken

Sebastián Magrí

unread,
Dec 3, 2011, 9:37:26 PM12/3/11
to mezzani...@googlegroups.com
Kudos!

Mathias Ettinger

unread,
Oct 30, 2012, 7:38:02 PM10/30/12
to mezzani...@googlegroups.com
Thanks for the great work, it works like a charm. At least with a US account in Sandbox.

I tried to use this handler in production and PayPal returns me an error claiming that merchant country is not supported. According to the doc, only US, UK and Canada merchant can use the DirectPayment API.

So I started back from django-paypal-driver and I ended with https://github.com/Kniyl/cartridge to integrate PayPal ExpressCheckout API into cartridge. I removed the driver.PayPal.DoDirectPayment method since Kenneth handler already cover this part.

Yet one has to change the {% url "shop_checkout" %} in templates/shop/cart.html (href for the "Go to Checkout" link) into {% url "paypal_checkout" %} in order to correctly initialize the transaction. I don’t find it very userfriendly.

Any suggestions ?


Le dimanche 4 décembre 2011 03:37:26 UTC+1, Sebastián Magrí a écrit :
Kudos!

Ken Bolton

unread,
Oct 31, 2012, 7:11:43 AM10/31/12
to mezzani...@googlegroups.com
Hi Mathias,

I am glad you found the payment processor I contributed useful. As you
discovered, it can serve as a foundation on which to build additional
PayPal functionality.

The solution to the issue you found with the name in the URL template
tag is to create a new named URL in your ulrpatterns. For example:

url("^store/checkout/$", "apps.paypal.views.checkout_steps",
name="shop_checkout"),

In the pattern above, apps.paypal.views.checkout_steps is a custom
view that mostly copies cartridge.shop.view.checkout_steps. Tacking
the `name="shop_checkout"` on the end and placing it above the core
mezzanine url include will make your URL templatetag work.

Hope this helps.

best,
ken

Mathias Ettinger

unread,
Oct 31, 2012, 10:39:08 AM10/31/12
to mezzani...@googlegroups.com
Hi Ken,

Your solution was the first I tried but I don't like the idea of code duplication. So I reverse("shop_checkout") in my own view (cartridge.views.paypal_checkout_step) to keep the old behaviour after paypal account/cart identification.

I prefer this approach since template modification is more likely to happen from a user perpective but I still don't like adding an other required modification (after payment handler and order form).

Am I taking things the wrong way or isn't there any optimal approach ?

Thanks,
Mathias

Ken Bolton

unread,
Oct 31, 2012, 10:45:51 AM10/31/12
to mezzani...@googlegroups.com
Hi Mathias,

I had similar misgivings. I would love to hear other approaches to this.

ken
Reply all
Reply to author
Forward
0 new messages