OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Locale-aware formatting leads to problem with Paypal plugin

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.

Locale-aware formatting leads to problem with Paypal plugin

Postby springday » Sun Aug 19, 2012 3:56 am

There's a bug with paypal payments when the payment amount is containing a decimal mark and you're using OJS in a country / locale setting, where the decimal mark is represented by a comma instead of a period. The payment form page, as created by the template "paymentForm.tpl" will contain a locale-specific form of the amount to be paid, e.g. "amount=2,90" instead of "amount=2.90". Paypal reacts to the POST-message containing this number with an error message, saying that the number is not formatted correctly and thus the payment could not be processed.
I'm not sure where exactly the locale aware formatting of the payment amount takes place. However, a possible workaround is this:

In line 120 of "PayPalPlugin.inc.php" format the amount with the non-locale aware version of sprintf, i.e. %.2F:
Code: Select all
'amount' => sprintf('%.2F', $queuedPayment->getAmount()),


I've tested this workaround on a German system and it worked that way. Any better ideas for achieving this goal?
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Locale-aware formatting leads to problem with Paypal plu

Postby asmecher » Mon Aug 20, 2012 9:48 am

Hi springday,

Thanks for reporting; I've filed this at http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=7778. Feel free to CC yourself on the entry for updates. Meanwhile, your work-around looks good.

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

Re: Locale-aware formatting leads to problem with Paypal plu

Postby asmecher » Mon Aug 20, 2012 10:10 am

Hi springday,

Just a heads-up -- your fix turns out to work well for the general case (see the link cited in the Bugzilla entry). Thanks for contributing; this has been committed to OJS, OCS, and OMP and will be included in the next release of each.

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


Return to OJS Technical Support

Who is online

Users browsing this forum: Tiziano, Yahoo [Bot] and 4 guests