OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Problems to pass the users' data to Paypal system.

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Problems to pass the users' data to Paypal system.

Postby yaliang » Fri Jun 22, 2007 8:36 am

Dear Friends,

Currently, I am implementing the Subscription page (for print version) with simple login/register function and the Paypal Subscription Button. Most of the functions have been coded. For improving the user experience, I plan to pass the users’ data to Paypal’s system with following codes:
Code: Select all
<input type="hidden" name="first_name" id="first_name" value="{$user->getFirstName()|escape}" />
<input type="hidden" name="last_name" id="last_name" value="{$lastName|escape}" />

However, it seems that the usage of the variables are incorrect. The user’s data was not returned and passed to the Paypal’s system. Is it necessary to add any handler or function in the template file (about/subscriptions.tpl)?
Welcome your suggestions to solve this problem. Thank you very much.

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Fri Jun 22, 2007 3:46 pm

Hi Yaliang,

Try calling functions on the $currentUser variable, e.g:
Code: Select all
<input type="hidden" name="first_name" id="first_name" value="{$currentUser->getFirstName()|escape}" />
Using this, see if the proper value appears in the generated HTML of the form to submit to Paypal.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Fri Jun 22, 2007 5:03 pm

Dear Alec,

Sorry, the $currentUser variable still didn't work. The value passed to Paypal was "{$currentUser->getFirstName()|escape}", not the user's firstname. I wonder that is it available to call the function in the about/subscriptions.tpl, I tested it in the about/subscriptions.tpl bellow the {if $isUserLoggedIn} condition, but a fatal error was returned:
Code: Select all
Fatal error: Call to a member function getFirstName() on a non-object in C:\Program Files\...\ojs\cache\t_compile\%%D0^D01^D01ECFAE%%subscriptions.tpl.php on line 93

Should I initialize the handler or function in the Template?
Thank you very much.

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby yaliang » Fri Jun 22, 2007 5:16 pm

Dear Alec,

I didn't find the $currentUser variable in all of the OJS's files. Is it available to be used in version 2.1.1? Many thanks.

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Sat Jun 23, 2007 9:11 am

Hi yaliang,

My mistake -- I forgot to add a snippet for classes/core/TemplateManager.inc.php. Find the line that reads:
Code: Select all
$this->assign('isUserLoggedIn', $isUserLoggedIn);
...at approximately line 87. Add after it:
Code: Select all
$templateMgr->assign_by_ref('currentUser', Request::getUser());
That should give you access to the $currentUser variable from your templates.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Sun Jun 24, 2007 7:01 am

Hi Alec,

Sorry, there is a problem with the file you referred. The file classes/core/TemplateManager.inc.php was not existed (OJS 2.1.1), but I found the
Code: Select all
$this->assign('isUserLoggedIn', $isUserLoggedIn);
only in the classes/template/TemplateManager.inc.php file.
Then, I added the code into it. The scripts from line 78 to line 86 are as following:
Code: Select all
if (!defined('SESSION_DISABLE_INIT')) {
   /* Kludge to make sure no code that tries to connect to the database is executed
    * (e.g., when loading installer pages). */
   $sessionManager = &SessionManager::getManager();
   $session = &$sessionManager->getUserSession();
   $isUserLoggedIn = Validation::isLoggedIn();
   $this->assign_by_ref('userSession', $session);
   $this->assign('isUserLoggedIn', $isUserLoggedIn);
   $templateMgr->assign_by_ref('currentUser', Request::getUser());
   $this->assign('loggedInUsername', $session->getSessionVar('username'));

   $journal = &Request::getJournal();
   $site = &Request::getSite();

However, when I access the OJS, a fatal error message was returned:
Code: Select all
Notice: Undefined variable: templateMgr in C:\...\ojs\classes\template\TemplateManager.inc.php on line 82.
Fatal error: Call to a member function assign_by_ref() on a non-object in C:\...\ojs\classes\template\TemplateManager.inc.php on line 82

Is there any error in assigning the variable?
Thank you very much.

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Sun Jun 24, 2007 10:07 am

Hi yaliang,

Sorry, my mistake again -- there's a typo. Change $templateMgr to $this in the added line.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Mon Jul 09, 2007 9:48 pm

Dear Alec,

In OJS (v.2.1.1), the user's MailingAddress is created and saved in a single field. However, the Paypal system separate the data into several fields, including Billing Address Line 1/2, City, State, Zip, etc. Is it possible to retrieve the first two lines of MailingAddress and pass them to Billing Address Line 1 & 2? Currently, I use the following code to pass the data to Line 1:
Code: Select all
<input type="hidden" name="address1" value="{$currentUser->getMailingAddress()|escape}">

Please give me your suggestions. Thank you very much.

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Mon Jul 09, 2007 11:26 pm

Hi yaliang,

Are these the paying user's fields (e.g. their city etc.)? If so, I'd suggest letting the user fill in the details rather than trying to tease apart the mailing address field or adding more fields to OJS, particularly since the billing address (which can be used to validate credit card information) may be different than the mailing address.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Tue Jul 10, 2007 4:39 am

Dear Alec,

Thanks for your suggestion. Yes, I understand your point. However, there is a strange scenario that when a new user just registers with the OJS system, then he/she has to input the same data again within a few minutes. Excuse me, what does the "|escape}" mean? Is there any other function can be used to retrieve specific data?

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Tue Jul 10, 2007 8:26 am

Hi Yaliang,

The "escape" function is used to prevent XSS attacks and add proper escape sequences to certain types of special characters. For example, if you're coding an input field:
Code: Select all
<input type="text" name="myField" value="Here is "some text in quotes" that will cause problems" />
...it's necessary to treat quotes within the field value (e.g. using backslashes) otherwise the browser won't know how to parse them.

The only solution I can think of for your request is to divide OJS's mailing address field into its constituent parts -- street, city, etc. -- and then use those to fill in the billing address. If you decide to go that route, I'd suggest waiting until OJS 2.2 is available, as we're overhauling many table designs and upgrading will be difficult if you modify this part of the installation.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron