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
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

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: 10015
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: 10015
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

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