PayPal in Joomla 2.5 error in json.php

180 views
Skip to first unread message

Nicholas Brick

unread,
Mar 21, 2012, 5:53:12 PM3/21/12
to Joomla! General Development
Hi all

I want to integrate PayPal into my own custom component, (PayPal
provide easy to follow php code and lengthy documentation)

First problem I saw was the PayPal code involved a call to header()
which I replaced with a javascript snippet to re-direct

When I run it I get a Joomla error

"Warning: [json] (json_encode_r) type is unsupported, encoded as null.
in ... /libraries/joomla/registry/format/json.php on line 33"

I've looked at the php file but know so little about the Joomla core
that I have no idea what to do next to rectify
I'll check to see if I'm sending in some null value - but I'm only
plugging values into a PayPal routine

I know there are probably extensions I could use, but PayPal provides
the bones of the code, so I'd prefer to get it working, I learn more

Also - I've read the discussion of mid last year about a unified
payment system for Joomla ( here
http://groups.google.com/group/joomla-dev-general/browse_thread/thread/a6876b6d61c93be5/1bf7eb084c9288d4?lnk=gst&q=paypal#1bf7eb084c9288d4
)

How would I check where that's at ?
Just trying to avoid hrs and hrs of digging

Thx

Naouak

unread,
Mar 21, 2012, 6:00:06 PM3/21/12
to joomla-de...@googlegroups.com
The best way to use paypal in joomla is to use either generated buttons (if it's good enough with your needs) or to generate yourself the form that redirects directly to paypal.

The paypal example use a buffer page that is not really useful if you can directly generate the form.

Naouak, Grade 2 de Kobal.
Site web: http://www.naouak.net



--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


Nicholas Brick

unread,
Mar 21, 2012, 6:12:35 PM3/21/12
to Joomla! General Development
Thx Naouak, I'll try that approach too
If that works I can progress and takes time pressure off coding the
way I'm going at it now

Nick

On Mar 21, 10:00 pm, Naouak <tard...@gmail.com> wrote:
> The best way to use paypal in joomla is to use either generated buttons (if
> it's good enough with your needs) or to generate yourself the form that
> redirects directly to paypal.
>
> The paypal example use a buffer page that is not really useful if you can
> directly generate the form.
>
> Naouak, Grade 2 de Kobal.
> Site web:http://www.naouak.net
>
> On Wed, Mar 21, 2012 at 22:53, Nicholas Brick <nicholasbr...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi all
>
> > I want to integrate PayPal into my own custom component, (PayPal
> > provide easy to follow php code and lengthy documentation)
>
> > First problem I saw was the PayPal code involved a call to header()
> > which I replaced with a javascript snippet to re-direct
>
> > When I run it I get a Joomla error
>
> > "Warning: [json] (json_encode_r) type is unsupported, encoded as null.
> > in ... /libraries/joomla/registry/format/json.php on line 33"
>
> > I've looked at the php file but know so little about the Joomla core
> > that I have no idea what to do next to rectify
> > I'll check to see if I'm sending in some null value - but I'm only
> > plugging values into a PayPal routine
>
> > I know there are probably extensions I could use, but PayPal provides
> > the bones of the code, so I'd prefer to get it working, I learn more
>
> > Also - I've read the discussion of mid last year about a unified
> > payment system for Joomla ( here
>
> >http://groups.google.com/group/joomla-dev-general/browse_thread/threa...

Nicholas Brick

unread,
Mar 23, 2012, 1:12:24 PM3/23/12
to joomla-de...@googlegroups.com
Success !!

Just for anyone else reading this later
I got the std PayPal supplied php files working with very few mods just by taking this outside of Joomla into std php
There's no need for displaying anything in these files (other than for debugging/testing), so in a production system they're invisible to the user, they just handle comms chatter back & forth with paypal

Initially, Joomla gave me problems linking outside the domain to PayPal, but easily linked within the Domain to php files, which is what I did
It's still fully integrated with the Joomla site - user sees nothing different Joomla site first then PayPal then Joomla again
But behind the scenes

1) I gather all my details in Joomla
2) I create a link to one of the std PayPal php files (outside Joomla in same domain) with all I need to send as parameters in the URL
3) Std php talks to PayPal back & forth
4) Final Step std php re-calls my Joomla site & component handing in all the data received from PayPal via URL (there's quite a lot of data)

Very few mods to the PayPal supplied php files
Happily when the final PayPal php file runs it calls joomla, and it's happy to carry-on where it left off, even though I logged into PayPal along the way
Joomla/php Session seems remarkably persistant

Nicholas Brick

unread,
Mar 23, 2012, 1:33:54 PM3/23/12
to joomla-de...@googlegroups.com
Ref "The best way to use paypal in joomla is to use either generated buttons (if it's good enough with your needs) or to generate yourself the form that redirects directly to paypal."

I think the problem with a form is having to include your API credentials in hidden fields ??

Naouak

unread,
Mar 23, 2012, 2:20:03 PM3/23/12
to joomla-de...@googlegroups.com

you don't need to put inside your credential:
you put a mail address associated with your merchant account and you just have to check when you receive a message from paypal, fram where it's comming and if nothing has been tampered with. (it can be achieved by cross checking with your database or adding a hash based verification, nothing hard to do).

Le 23 mars 2012 18:33, "Nicholas Brick" <nichol...@gmail.com> a écrit :
Ref "The best way to use paypal in joomla is to use either generated buttons (if it's good enough with your needs) or to generate yourself the form that redirects directly to paypal."

I think the problem with a form is having to include your API credentials in hidden fields ??

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/wew2VA_wnJoJ.

Naouak

unread,
Mar 23, 2012, 2:21:08 PM3/23/12
to joomla-de...@googlegroups.com

and also, the base paypal api is using your credential in a buffer page that will just load the form and submit it using javascript( unless their example has changed lately)

Le 23 mars 2012 18:33, "Nicholas Brick" <nichol...@gmail.com> a écrit :
Ref "The best way to use paypal in joomla is to use either generated buttons (if it's good enough with your needs) or to generate yourself the form that redirects directly to paypal."

I think the problem with a form is having to include your API credentials in hidden fields ??

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/wew2VA_wnJoJ.

Nicholas Brick

unread,
Mar 24, 2012, 3:07:04 PM3/24/12
to joomla-de...@googlegroups.com
The examples I saw at PayPal included hidden field credentials, so I avoided them

I got it working well now anyway and the routines hand back a token and an unique transaction ID from PayPal and return my own generated UID as well so I can reconcile automatically immediately.  Works very well.

Thanks again for taking the time to help out

Nicholas Brick

unread,
Mar 24, 2012, 3:10:37 PM3/24/12
to joomla-de...@googlegroups.com
The routines I have from PayPal use cURL to send data, I have no idea how cURL works

Reply all
Reply to author
Forward
0 new messages