PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Incorrectly Formatted Item Amount

  1. I had a form that at one time was working perfectly. It seems like randomly it decided to stop working. So it seems.

    I wrote some custom code to check a text field for a discount code entered and then add a product with a negative amount and pass it through gform_product_info. I can no longer get gform_product_total to dynamically update my front end total (but that's a different problem) and while testing my form to see if the backend stuff still worked, I got this error from paypal:

    "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

    I've been hunting around for a couple of hours now and can't figure out what paypal has an issue with. I thought it might suddenly have a problem with negative amounts, but according to the item price can be positive or negative, but not zero. When no discount code is used paypal brings up a total summary just fine.

    The relevant products part of the URL being sent to paypal is:


    My code for sending the discount info to paypal is:

    function update_product_info($product_info, $form, $entry) {
        $code = $entry[88];
    	if($code == 'MLD2012' || $code == 'mld2012'){
    		$total = get_total($product_info);
    	    $discount = -30;
    	    $product_info['products']['tax'] = array(
    	        'name' => 'Discount MLD2012', // name that will appear in PayPal and pricing summary tables
    	        'price' => $discount, // amount of total discount
    	        'quantity' => 1
      return $product_info;
    add_filter('gform_product_info_9', 'update_product_info', 10, 3);

    You can see the form live at: (if you feel like checking the script I'm loading with the gform_pre_render filter and seeing if you can tell why it won't change my front end total, then that's a bonus)

    in summary, paypal is annoying. hopefully you guys can see quickly what may be going wrong. I always appreciate the quality support here.



    Posted 12 years ago on Friday January 13, 2012 | Permalink
  2. Hi Jarrod,

    The documentation you found is for PayPal's express checkout service. Gravity Forms currently only integrates with PayPal's Website Payments Standard service. As far as I know, Website Payments Standard does not like negative numbers at all.

    The solution is the pass the discount as a coupon amount rather than a product. Here are a list of variables that you can pass:

    You'll see "discount_amount" for single items or "discount_amount_cart" for the entire order. You can update the query sent to PayPal via the gform_paypal_query hook.

    Posted 12 years ago on Wednesday January 18, 2012 | Permalink
  3. red

    Thanks for the tip on the hook! Put this together to work for multiple negative items/discounts and coupons, in a form:

    - keeps all non-negative items as is
    - adds up discount and coupon items
    - clears out those discount and coupon items and $0 value items from the cart
    - sends to PayPal only non-negative cart items and one grand total discount amount for the cart

    This way you still get itemized checkouts and receipts and can show the discount separate, without passing negative numbers.

    Posted 12 years ago on Sunday May 20, 2012 | Permalink