Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing number format for line items for paypalexpress method #504

Closed
nongio-zz opened this issue Jul 11, 2016 · 6 comments
Closed

missing number format for line items for paypalexpress method #504

nongio-zz opened this issue Jul 11, 2016 · 6 comments
Milestone

Comments

@nongio-zz
Copy link

nongio-zz commented Jul 11, 2016

when sending order items to payal I am getting this error:

Item total is invalid.

I am referring to the function calculate in the file: paypal-for-woocommerce.php:807

I think it's because the wrong format is being sent and the amt value is not passed to the function number_format:

(
    [USER] => *****
    [PWD] => *****
    [VERSION] => 124.0
    [BUTTONSOURCE] => AngellEYE_SP_WooCommerce
    [SIGNATURE] => *****
    [METHOD] => DoExpressCheckoutPayment
    [TOKEN] => 
    [PAYERID] => 
    [RETURNFMFDETAILS] => 1
    [PAYMENTREQUEST_0_AMT] => 19.90
    [PAYMENTREQUEST_0_CURRENCYCODE] => EUR
    [PAYMENTREQUEST_0_INVNUM] => 30383
    [PAYMENTREQUEST_0_PAYMENTACTION] => Sale
    [PAYMENTREQUEST_0_TAXAMT] => 3.18
    [PAYMENTREQUEST_0_SHIPPINGAMT] => 2.95
    [PAYMENTREQUEST_0_ITEMAMT] => 13,77
    [PAYMENTREQUEST_1_SHIPTONAME] => 
    [PAYMENTREQUEST_1_SHIPTOSTREET] => 
    [PAYMENTREQUEST_1_SHIPTOSTREET2] => 
    [PAYMENTREQUEST_1_SHIPTOCITY] => 
    [PAYMENTREQUEST_1_SHIPTOZIP] => 
    [PAYMENTREQUEST_1_SHIPTOCOUNTRYCODE] => DE
)

07-11-2016 @ 12:20:29 - Response: Array
(
    [TIMESTAMP] => 2016-07-11T10:20:29Z
    [CORRELATIONID] => 74770812b0a4
    [ACK] => Failure
    [VERSION] => 124.0
    [BUILD] => 23255924
    [L_ERRORCODE0] => 10426
    [L_ERRORCODE1] => 10413
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_SHORTMESSAGE1] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_LONGMESSAGE0] => Item total is invalid.
    [L_LONGMESSAGE1] => The totals of the cart item amounts do not match order amounts.
    [L_SEVERITYCODE0] => Error
    [L_SEVERITYCODE1] => Error
)


@angelleye
Copy link
Collaborator

It's not liking the comma in the ITEMAMT value: 13,77

What's strange is that seems to be the only value coming out with a comma instead of a period. PayPal will only accept the period.

I haven't had any other reports of this, so there must be something unique there causing this. Are you working with a plugin or anything that would be doing something with the format of the cart subtotal?

@danielschwab
Copy link

We use qtranslate-x to have multilanguage support. This plugin uses setlocale and your plugin calls the php round function which formats its result in dependency of the current locale set.
I think the missing call to "self::number_format" in paypal-for-woocommerce.php (line 803) is the problem.
We changed the line to:
'amt' => self::number_format(self::round( $item['line_subtotal'] / $qty), 2, '.', ''), // Cost of item.

This seems to work.

Can you please tell us if using "self::number_format" at this line is correct and dont cause additional problems.

@angelleye
Copy link
Collaborator

I'm sorry for the delay responding.

That should work just fine. Have you been running it that way the past few days? Any issues?

@angelleye angelleye added this to the 1.2.4 milestone Jul 15, 2016
@angelleye
Copy link
Collaborator

@kcppdevelopers we should make sure to use number_format on this, but check the locale code to see if it should use . or , and format accordingly.

@nongio-zz
Copy link
Author

@angelleye, until now is working as expected, no issues after this fix

@kcppdevelopers
Copy link
Contributor

@angelleye we have made our own number_format function because of some currency like Hungarian Forint, Japanese Yen and Taiwan New Dollar don't support Decimal amounts.
Our own number_format function only accepts one parameter (amount) and return as PayPal currency support format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants