9 replies [Last post]
myke@drupal.org's picture
Offline
Joined: 04/12/2008
Juice: 189
Was this information Helpful?

Hi, I submitted this as a bug report to the Issue Queue for UC Discounts, but I might as well post it here as well.

http://drupal.org/node/346521

Discounts are being added at checkout, but when it sends it on to PayPal, they get charged the full, non-discounted price. It then shows a negative number, equaling the amount they were overcharged..

Needless to say, this is causing confusion for customers, as they are expecting the sale price, are being shown it in checkout, but then when they pay through PayPal, they get charged the full price..

It DOES work if you do Check/Money Order.. it shows the correct price.. so I'm not sure if this is specific to the PayPal module or not, as I don't have an Authorize.net account to try it out on..

Thanks in advance for any assistance anyone can provide on this..

-Myke

myke@drupal.org's picture
Offline
Joined: 04/12/2008
Juice: 189
Further info on the problem

I DID discover that the PayPal form is sending the Item's total, WITHOUT the discount, in the HTML Form. It DOES set the line_item correctly as far as I can tell, what do I need to do for those to show up in PayPal?

Thanks
-Myke

myke@drupal.org's picture
Offline
Joined: 04/12/2008
Juice: 189
Debugging with Drubuntu

Well, I DID finally get Drubuntu running with Eclipse for debugging all working, so I will be taking a look into the Discounts not transferring to PayPal problem now..

Will keep everyone updated if I find anything..

-Myke

myke@drupal.org's picture
Offline
Joined: 04/12/2008
Juice: 189
Bug found, but not fixed yet

Well I found where the bug is, but haven't fixed it yet... I found it using Drubuntu / PHPEclipse and stepping through the code with the debugger..

Turns out, it's NOT in the Ubercart Discounts module.. this module is using line_item just fine..

It's in the PayPal code.. somewhere.. here is the section where I believe the problem starts. The reason I believe this, is because when using the wps itemized method, the discounts are ignored, but when sent as one single item, the discount IS figured in!

Starting on Line 1280, in uc_paypal.module:

if (variable_get('uc_paypal_wps_submit_method', 'single') == 'itemized') {
    // List individual items
    $i = 0;
    foreach ($order->products as $item) {
      $i++;
      $data['amount_'. $i] = uc_currency_format($item->price, FALSE, FALSE, '.');
      $data['item_name_'. $i] = $item->title;
      $data['item_number_'. $i] = $item->model;
      $data['quantity_'. $i] = $item->qty;

      // PayPal will only display the first two...
      if (is_array($item->data['attributes']) && count($item->data['attributes']) > 0) {
        $o = 0;
        foreach ($item->data['attributes'] as $name => $setting) {
          $data['on'. $o .'_'. $i] = $name;
          $data['os'. $o .'_'. $i] = $setting;
          $o++;
        }
      }
    }
  }
  else {
    // List the whole cart as a single item to account for fees/discounts
    $data['amount_1'] = uc_currency_format($order->order_total - $shipping - $tax, FALSE, FALSE, '.');
    $data['item_name_1'] = t('Order @order_id at @store', array('@order_id' => $order->order_id, '@store' => variable_get('uc_store_name', url('<front>', NULL, NULL, TRUE))));
    $data['on0_1'] = t('Product count');
    $data['os0_1'] = count($order->products);
  }

Now at this point I have no clue what I'm looking at, just that it's not counting the line items properly in the itemized section. Not really sure why this would be, but I will try hacking on the code over the next couple days to try and fix it.. But I'm CONVINCED it's in this section. (Call it an intuition) =)

So, until the code is fixed, I would say setting this setting in the PayPal settings to Single and not Itemized would be the temporary solution, if you're using Discounts.

-Myke

schaub123's picture
Offline
Bug FinderGetting busy with the Ubercode.PayPal Hero
Joined: 10/08/2007
Juice: 458
Re: UC Discounts not sending discount info on to PayPal

You need to make sure that in your paypal wps settings you have it sending the data to paypal as a single line item, all rolled up. Paypal can't handle discounts as a line item. This works for me and is mentioned elsewhere in the ubercart forums. Hope it helps.

Christopher Schaub
LuteGrass, LLC
http://www.lutegrass.com

Christopher Schaub

myke@drupal.org's picture
Offline
Joined: 04/12/2008
Juice: 189
Re: Re: UC Discounts not sending discount info on to PayPal

Thanks for that.. =) I think what we need to do, is have the discounts subtracted from the item prices, and not trying to send a Discounts line on to PayPal..

Interesting how we both posted the fix same day, I didn't notice your post until after posting mine. =)

-Myke

human1101's picture
Offline
Joined: 05/01/2011
Juice: 29
The line-item thing

It seems no matter what i use to try to send the dicounts to paypal, or other payment gateways it just does not make it, even the workaround that you guys have been talking about has not worked for me, i am having alot of trouble here

any help would be much appreciated

thanks,

Jacob

DigitalD's picture
Offline
Joined: 03/08/2012
Juice: 3
A bug found

I am currently experiencing the same problem. I am using uc_discounts but no discount is being submitted to PayPal despite the fact that all throughout the checkout process the discount is being applied (except on the verify order screen where it displays the PayPal total which is the nondiscounted price - however the discount is being applied in the cart total in the line above it).

I found that this problem is caused when you disable the coupon panel on the checkout pane. If you enable this panel, then it works again. This is a bug that should be fixed as discounts should be applied if the coupon panel is enabled or not.

MDC_Admin's picture
Offline
Joined: 05/07/2012
Juice: 30
Re: UC Discounts not sending discount info on to PayPal

I'm also having a similar issue with the uc_discount module for D7. Except my problem is with the payment gateway cybersource.. You can follow that issue -> http://drupal.org/node/1785186#comment-6550144

lynnylove's picture
Offline
Joined: 10/30/2013
Juice: 3
Discounts don't work without Pane display

It's dumb to have to show the discounts pane which is ugly in checkout and has no effect other than to work around bug which is discounts don't get past to WePay or payment processing unless you show the useless pane? I've looked through many forums on this and seems to be consistent. how can I hide the discounts pane and trick ubercart into thinking its there but not showing. At least min would be to have it show collapsed as 2ndary possible. Ideal would be to have discounts work as expected (using for fixed amount off certain skus in date range) without having to enable extra pane causing me pain. Advice, fix, other?