When PayPal for Payment redirects me to PayPal I get the error message: "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

The first thing I could think of is that PayPal doesn't like my currency format. So I checked that, but it seems to be okay.

Also after doing some Google search with the error message and found that you must use two digits after the decimal marker in order to make the total amount work correctly with PayPal. But I have that already so that shouldn't be the problem either.

I also tried to replace the commas with points but all with no avail.

My current format example is:
€1.000,12

Maybe the problem can be in the encryption the site uses to send the information to Paypal? The site uses https. If this could be the problem why is the PayPal module that's included with Ubercart is just working fine?

Comments

atiba’s picture

StatusFileSize
new23.48 KB
new7.42 KB

I forgot to mention, i'm using the PayPal Payments Standard type.
I also added screenshots of the error message.

xano’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide step-by-step instructions on how to reproduce the problem using a clean installation of the dev versions of all required projects.

xano’s picture

Bump. Can you provide instructions to reproduce the problem?

atiba’s picture

Yeh, I will try later. Sorry, I was travelling.

otouma’s picture

I ran into the same problem.

I discovered that in the paypal_payment_pps.module (function paypal_payment_pps_form_redirect) line 197,
$payment->totalAmount(TRUE) uses a float format (in my case I get 3 decimals).

To fix the issue, I added the round function.
'amount_1' => round($payment->totalAmount(TRUE), 2),

otouma

xano’s picture

Can you provide a patch that makes the change and a link to the relevant part of Paypal's documentation that describes why the module's current behavior is incorrect?

atiba’s picture

I tried to reproduce this on a clean install and the problem persist.
Did a clean install with every Ubercart module except for the payment section.

If otouma can provide a patch I'll be happy to test it out.

mvdve’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new816 bytes

Same issue here. In my case the error was caused by a discount on a product in drupal commerce. This generates an order total with more then two digits after the decimal marker.

Status: Needs review » Needs work

The last submitted patch, paypal_for_payment-2055665-8.patch, failed testing.

xano’s picture

The patch no longer applies.

xano’s picture

@mvdve: it would be nice if this patch can be included in version 7.x-1.1. Can you re-roll it?

mvdve’s picture

Missed your last post sorry, the updates are not yet shown properly on the new drupal 7 dashboard. I will upload a new patch tonight.

mvdve’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new795 bytes

New patch for re-roll.

xano’s picture

And I missed your last patch for the exact same reason, it seems. Thanks! QA requires me to repeat my question from #6 again, though: Can you provide a link to the relevant part of Paypal's documentation that describes why the module's current behavior is incorrect? We need to make sure that this fix is the correct one.

mvdve’s picture

The PayPal API says "Any valid currency amount" (page 116).
It is possible to send a amount with more then two digits after the decimal pointer when for example a discount rule is used.

xano’s picture

Status: Needs review » Fixed

The thing is that some of the world's currencies actually have more than a 100 subunits (and thus more than 2 decimals). PayPal's documentation is absolutely unclear about these things.

Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mvdve’s picture

Version: 7.x-1.x-dev » 7.x-1.1
Status: Closed (fixed) » Needs review
StatusFileSize
new806 bytes

The result from issue 2063119 has overwritten this patch.

Status: Needs review » Needs work

The last submitted patch, 18: paypal_payment-2055665-18.patch, failed testing.

xano’s picture

Version: 7.x-1.1 » 7.x-1.x-dev

The PayPal API says "Any valid currency amount" (page 116).

The link doesn't seem to work anymore. Do you know where the information can be found now?

mfrosch’s picture

Hi,

got the same Problem also on 1.1. (incorrectly formatted item amount).

Had to replace on paypal_payment_pps.module line 196
$data['amount_' . $index] = $line_item->totalAmount(TRUE);
with
$data['amount_' . $index] = (string) round($payment->totalAmount(TRUE), 2); // HACK PATCH

Cheers,
Matthias

vincent rommelaars’s picture

Priority: Normal » Major
Status: Needs work » Needs review

If you're using discounts you'll get the same error when passing your shopping cart to PayPal because it doesn't accept negative values.
Proposed solution to work with discounts:
Alter for each command on line 193 of paypal_payment_pps.module to

foreach ($payment->line_items as $line_item) {
	  if ($line_item->unitAmount(TRUE) > 0) {
    //$data['amount_' . $index] = $line_item->unitAmount(TRUE);
	$data['amount_' . $index] = (string) round($line_item->unitAmount(TRUE), 2);
	//$data['amount_' . $index] = (string) round($payment->totalAmount(TRUE), 2);
    $data['item_name_' . $index] = $line_item->description;
    $data['quantity_' . $index] = $line_item->quantity;
    $index++;
	  }
	  if ($line_item->unitAmount(TRUE) < 0) {
		  $data['discount_amount_cart'] = (string) abs(round($line_item->unitAmount(TRUE), 2));
	  }
  }

I don't know how to write a patch, so I suggest to review this alter and create a patch.

Greetz

Vincent

  • Xano committed c8e81d4 on 8.x-1.x
    Issue #2055665 by mvdve: PayPal error: The link you have used to enter...
torotil’s picture

Why don't we use the currency module's capabilities Currency::roundAmount() to round to the right number of decimal places for all currencies?

torotil’s picture

StatusFileSize
new3.01 KB

Here is a patch that uses Currency::roundAmount() to solve this properly.

Status: Needs review » Needs work

The last submitted patch, 25: 2055665-25-use-currency-roundAmount.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

ronino’s picture

@Vincent Rommelaars: I think discounts are a separate issue. I have fixed that in #2981152: Payment fails if line item has negative amount (e.g. for discounts).

  • torotil committed 125efe9 on 7.x-1.x
    Issue #2055665 by torotil, atiba: PayPal error: The link you have used...
torotil’s picture

Status: Needs work » Fixed

Committed #25 to 7.x-1.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.