cancel
Showing results for 
Search instead for 
Did you mean: 

Line Item Quantity With 2 Decimals Fails - 10413 Error

SOLVED

Line Item Quantity With 2 Decimals Fails - 10413 Error

I'm running Woocommerce in a WordPress website using the Divi theme.

 

OS:  CentOS Linux release 7.5.1804 (Core)

PHP 7.1.22 (cli) (built: Sep 13 2018 16:54:21) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

    with Zend OPcache v7.1.22, Copyright (c) 1999-2018, by Zend Technologies

    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

WordPress:  4.9.8

 

I am running Woocommerce and I've modified the standard install to allow for a quantity out to 2 decimal places.

1.57, 2.39, 3.17, etc ...

 

The mods work great, and they're working well inside Woocommerce, however, when I submit for payment I get:

PayPal error (10413): An error (10413) occurred while processing your PayPal payment.

 

Of course, the line item amounts are not adding up to the order total amount.

 

Here's the API request and error:

[01-Dec-2018 16:53:22 UTC] WC_Gateway_PPEC_Client::_request: remote request to https://api-3t.sandbox.paypal.com/nvp with params: Array

(

    [LOGOIMG] => https://example.com/wp-content/uploads/2018/07/logo-150x150.png

    [HDRIMG] =>

    [PAGESTYLE] =>

    [BRANDNAME] => CodeMilitant

    [RETURNURL] => https://example.com/checkout/?woo-paypal-return=true

    [CANCELURL] => https://example.com/cart/?woo-paypal-cancel=true

    [ADDROVERRIDE] => 1

    [LANDINGPAGE] => Login

    [SOLUTIONTYPE] => Sole

    [PAYMENTREQUEST_0_PAYMENTACTION] => sale

    [PAYMENTREQUEST_0_INSURANCEAMT] => 0

    [PAYMENTREQUEST_0_HANDLINGAMT] => 0

    [PAYMENTREQUEST_0_CUSTOM] =>

    [PAYMENTREQUEST_0_INVNUM] =>

    [PAYMENTREQUEST_0_CURRENCYCODE] => USD

    [PAYMENTREQUEST_0_AMT] => 141.92

    [PAYMENTREQUEST_0_ITEMAMT] => 141.92

    [PAYMENTREQUEST_0_SHIPPINGAMT] => 0

    [PAYMENTREQUEST_0_TAXAMT] => 0

    [PAYMENTREQUEST_0_SHIPDISCAMT] => 0

    [NOSHIPPING] => 1

    [PAYMENTREQUEST_0_SHIPTONAME] => Tom <removed>

    [PAYMENTREQUEST_0_SHIPTOSTREET] => <removed>

    [PAYMENTREQUEST_0_SHIPTOSTREET2] =>

    [PAYMENTREQUEST_0_SHIPTOCITY] => Bristol

    [PAYMENTREQUEST_0_SHIPTOSTATE] => TN

    [PAYMENTREQUEST_0_SHIPTOZIP] => 37620

    [PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE] => US

    [L_PAYMENTREQUEST_0_NAME0] => Freelance Hourly Rate - 57

    [L_PAYMENTREQUEST_0_DESC0] =>

    [L_PAYMENTREQUEST_0_QTY0] => 1.23

    [L_PAYMENTREQUEST_0_AMT0] => 57

    [L_PAYMENTREQUEST_0_NAME1] => Freelance Hourly Rate - 43

    [L_PAYMENTREQUEST_0_DESC1] =>

    [L_PAYMENTREQUEST_0_QTY1] => 1.67

    [L_PAYMENTREQUEST_0_AMT1] => 43

    [METHOD] => SetExpressCheckout

    [VERSION] => 120.0

    [USER] => <removed>

    [PWD] => *******************

    [SIGNATURE] => ************************************************

)

 

[01-Dec-2018 16:53:23 UTC] WC_Gateway_PPEC_Client::_process_response: acknowleged response body: Array

(

    [TIMESTAMP] => 2018-12-01T16:53:23Z

    [CORRELATIONID] => d829ab70e4feb

    [ACK] => Failure

    [VERSION] => 120.0

    [BUILD] => 000000

    [L_ERRORCODE0] => 10413

    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.

    [L_LONGMESSAGE0] => The totals of the cart item amounts do not match order amounts.

    [L_SEVERITYCODE0] => Error

)

 

I removed my private info.

 

As you can see, the quantities for each line item and out to 2 decimal places, and when added together, the line item totals are an exact match to the order total, however, it all fails.

 

Since I'm sending the correct info, and the line items and order total match, my guess is that PayPal does not allow for decimal quantities.

Does anyone have a suggestion for correcting this?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Thank you @angelleye!  I appreciate all the updates and the real answer is for PayPal to update their API to handle a very basic function.   There's nothing difficult about this for PayPal to implement.

 

From a business standpoint, having documented evidence of work performed in the payment transaction is vital.  This is a vulnerability for any business owner to lack proper documentation.

 

SOLUTION:  PayPal needs to update their APIs to accept quantities out to 2 decimal places, just like they have to do with dollar amounts.

 

Thank you for all your help @angelleye!

8 REPLIES
Highlighted
Volunteer Advisor

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

You're right, PayPal isn't going to accept decimals with the QTY values.

 

You're going to either calculate differently so the QTY are whole numbers, or remove the line item details from the request altogether so that you're sending nothing but a total to PayPal.

 

If you use the PayPal for WooCommerce plugin there is an option to disable the line items. Looks like maybe you're using a custom plugin here..??

 

 

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Thank you @angelleye for the reply.  This is the Woocommerce extension, the results I posted above are from the WordPress debug.log.

 

I believe you when you say PayPal won't accept decimals for quantities, but that doesn't fix my issue.  I'm a little surprised this hasn't been a standard feature for many years now.  As a freelance coder, I never have a whole number for a quantity value.

 

If PayPal will not accept decimals for quantities, which makes no sense at all, then how can we put in such a request for them to improve their platform?

 

The best answer to this problem is for PayPal to make a simple change in their processing to move from "intval" to "floatval".

Volunteer Advisor

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

As I mentioned previously, you could leave the line items out of the PayPal payment and just sent them the order total to process.  That would eliminate this problem.

 

If you want to keep the line items then you'll need to add some logic to change it up so the math works with whole numbers.  For example, if you're showing QTY 1.5 @ $40.00, just make it QTY 1 @ $60.00 instead, or QTY 2 @ $20.00.  

 

It's very rare for people to use QTY's like you're trying to do here.  Even when charging for time people typically do 15/30/60 min increments, in which case you could price per unit and the whole number QTY would work fine.

 

You're working with the Classic APIs, which are being labeled as deprecated.  They aren't going away, and you can still use it as-is, but they aren't going to be actively changing anything in them either.  I have not yet tested the REST APIs to see if they would accept this, but I doubt it.  

 

Sorry I don't have the answer you're wanting.  Come to think of it, though, I don't know that I've seen any payment processor that accepts decimals for quantity values.  That said, I don't specifically try it all that often, so maybe I just haven't come across it yet.

 

 

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Thank you @angelleye!  I appreciate all the updates and the real answer is for PayPal to update their API to handle a very basic function.   There's nothing difficult about this for PayPal to implement.

 

From a business standpoint, having documented evidence of work performed in the payment transaction is vital.  This is a vulnerability for any business owner to lack proper documentation.

 

SOLUTION:  PayPal needs to update their APIs to accept quantities out to 2 decimal places, just like they have to do with dollar amounts.

 

Thank you for all your help @angelleye!

Volunteer Advisor

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

For small businesses like you and me, yeah, this seems like it should be a very simple fix.

PayPal is a big ship, and big ships turn slowly.

They've got road maps planned out for a while already, and adding stuff like this would be difficult. Especially on deprecated APIs. It's just not going to happen.

We are the builders of PayPal for WooCommerce. WooCommerce allows you to use fractional quantities. We give our users the option to either skip out on sending line item details to PayPal at all, or allowing us to restructure the request so that it will work.

The true details are still available inside the WooCommerce order itself, so there is still record of all those details, of course.

I've worked with Stripe, Authorize.net, Group ISO, PayLeap, MojoPay, and quite a few more. I honestly can't think of any gateways where the QTY field was documented as allowing fractional values (but I could be wrong.)

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
New Community Member

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Hi .

 

how can I remove the line items out of the PayPal payment and just sent them the order total to process ? 

 

Thank you. 

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Hi @bmpf,

 

I'm running Woocommerce for my online store.  In this store, you simply visit:

 

Woocommerce >> Settings >> PayPal Checkout >> Subtotal Mismatch Behavior

 

Then select "Do not send line items to PayPal"

 

This will turn off the matching behavior, and send only the total to PayPal.

 

Screen Shot 2018-12-12 at 10.43.27 AM.png

New Community Member

Re: Line Item Quantity With 2 Decimals Fails - 10413 Error

Hi thanks for the time to reply me.

 

But there is no such option in my woocommerce (version 3.5.1)