I've been having some trouble as I'm testing this method of payment. I get through checkout and then the redirect to paypal breaks and starts a loop in which the redirecting to paypal form page loads over and over.

Here's the error message from the logs:

The PayPal EC API call failed. Array ( [TIMESTAMP] => 2012-09-17T19:34:11Z [CORRELATIONID] => 3ddd435226e09 [ACK] => Failure [VERSION] => 88.0 [BUILD] => 3622349 [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've tried out various cominations of settings and looked at the request sent to paypal and it looks like there's one of two things going on:

  1. The shipping cost is always set to zero in commerce_paypal_ec_order_form:
     // Total shipping costs for this order.
        'PAYMENTREQUEST_0_SHIPPINGAMT' => 0,
  2. The line items, when they are included are repeats (at least for me) of the base price and shipping

I put together a little patch which I'll include in a comment below. It's working without problems for me now.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markisatacomputer’s picture

ok. this is a quick fix. but it worked for me. hopefully useful to someone else.

citlacom’s picture

Status: Active » Needs review

Hi @markisatacomputer thanks for the report. I found the root cause of the problem and did a more extensible solution due many times the shipping price components could have a identifier different than "shipping" one example is the shipping commerce flat rate.

Please try the last dev code and let me know if is working as expected. I did some testing with commerce flat rate and it works.

For the changes details see: http://drupalcode.org/project/commerce_paypal_ec.git/blobdiff/7a3097a692...

Thanks.

beringstrasse’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta1

I seem to get the same error when I try to buy an item with a price of $0. Even if the shipping is more than zero so the total is $5 i get an error and get stuck in a loop when trying to redirect to paypal. Is this by design or should you be able to buy a free product?

kingman1016’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev

I get this error also using Commerce Sale Price. I tried the latest dev version but the problem still exists.

jwilson3’s picture

Status: Needs review » Needs work

marking NW based on #3 and #4.

rfulcher’s picture

I am having the same issue. I have had a cart working and was ready to go live. The client wanted to make sure that there was a processing fee on the order. So we added a 50 cent processing fee and it started doing this.

strings6’s picture

Issue summary: View changes

I got a similar "loop of death" when I tax the shipping amount. Taxing shipping on an order causes the individual tax amounts to not add up to the total tax, because the little bit of tax from taxing shipping is not being passed in.

Does anyone know if the above patch would fix that or is this a different issue? This was the closest thing I found when I searched the issue queue. I'm running the alpha-3 version by the way.

Thanks.

strings6’s picture

Is anyone able to respond to my above question?

jwilson3’s picture

@strings6, could you try the patch and see if it resolves your problem, and report your findings? Thanks.

strings6’s picture

Hello,

I decided to update to the latest and greatest dev version instead of trying to make an old alpha version work, but it did not resolve my loop of death issue. I still get a loop of death when I tax shipping. Besides that, I got a new error. On the review page, right before the redirect, now I also was seeing the error:

Notice: Undefined variable: currency_code in _commerce_paypal_ec_add_items_list_params() (line 723 of /sites/all/modules/commerce_paypal_ec/commerce_paypal_ec.module).

Line 723 showed:
$new_item['L_PAYMENTREQUEST_0_TAXAMT' . $item_no] = commerce_paypal_ec_format_amount($line_item_tax_amount, $currency_code);

I changed it to the following to clear that bug up.:
$new_item['L_PAYMENTREQUEST_0_TAXAMT' . $item_no] = commerce_paypal_ec_format_amount($line_item_tax_amount, $item_price['currency_code']);

So, not a fix for me. Any ideas? Do you want this posted to a new issue?

jwilson3’s picture

Do you want this posted to a new issue?

yes, that probably makes more sense as a separate issue to not muddy the waters.

Please note that simply updating to the latest dev does not include the patch in question above. It's still not clear if you tested that specific patch or not.

strings6’s picture

Back to the original issue, I found a second thing that causes the "loop of death". If you have an item on sale, and have your sale line item components setup to be classified as discount instead of base price, then you will see the error as well. Changing the sale price component for me is at:

/admin/config/workflow/rules/components
/admin/config/workflow/rules/components/manage/rules_commerce_saleprice_component/edit/8

When I switched it to "base price", the problem went away for this particular flavor of the problem. I still can't use this payment method when an order has tax though, as I described in a previous post.

torgosPizza’s picture

This error is usually caused by rounding errors. Note that tax types and Discounts can all have rounding schemes. We are discussing a fix for Discounts issues here: #2468943: Ensure proper rounding of price amounts and components when components are added via discounts so this is probably a duplicate.

infinet’s picture

I found that the Tax amount in orders was not being passed to Paypal.

In commerce_paypal_ec.module this line calculates the tax amount for an item
$taxamt = commerce_round(COMMERCE_ROUND_HALF_UP, commerce_tax_total_amount($order_total['data']['components'], FALSE, $currency_code));

The 'FALSE' parameter says don't include tax that is already in the price amount. So in my Drupal Commerce implementation this means the Tax amount returns 0 as it's already included in the total.

If I change that parameter to 'TRUE' then it will return the correct tax amount.

Here is an example of the price components
http://i.imgur.com/cfnyVzj.png

However, in this case Paypal returns the error in this thread, namely "The totals of the cart item amounts do not match order amounts".

Has anyone had similar issues with passing the tax amount or the above error when it is passed?

Thanks