Oscommerce discount amount not being passed to paypal

Hello,

I have an oscommerce shop and I am using Paypal payments direct which is a variation of paypal payments pro. I have installed a module on my site called discount codes. This module allows me to set up promo discount codes that can be applied at checkout.

I use only 2 forms of payment. I use the regular paypal module that takes you to the paypal site and I use Paypal payments direct for processing credit cards on my site.

The regular Paypal module passes the discount without any issues.
However, during checkout with the Paypal payments direct the discount is not passed to the paypal account.
The discount amount shows on the checkout page on the site but when I go to my account and check the transaction details it charges the full price instead of giving a discount.

This is the code for the Paypal payments direct module. I contacted the developer of the discount module and they told me that I should change the following:

[b][size=8pt]Hello Sir,

Please try to replace

$order_total->setval(number_format($order->info[‘total’], 2));

with

global $discount;
$order_total->setval(number_format($order->info[‘total’] -
(empty($discount) ? 0 : $discount), 2));[/size][/b]

This is a small portion of the code in question from the Paypal payments direct module:

[php]$order_total =& Services_PayPal::getType(‘BasicAmountType’);
$order_total->setval(number_format($order->info[‘total’], 2));
$order_total->setattr(‘currencyID’, $order->info[‘currency’]);
$pdt->setOrderTotal($order_total);

if($order->info['total'] == ($order->info['subtotal'] + $order->info['shipping_cost']+ $order->info['tax'])) {
  $item_total =& Services_PayPal::getType('BasicAmountType');
  $item_total->setval(number_format($order->info['subtotal'], 2));
  $item_total->setattr('currencyID', $order->info['currency']);

  $ship_total =& Services_PayPal::getType('BasicAmountType');
  $ship_total->setval(number_format($order->info['shipping_cost'], 2));
  $ship_total->setattr('currencyID', $order->info['currency']);

  $tax_total =& Services_PayPal::getType('BasicAmountType');
  $tax_total->setval(number_format($order->info['tax'], 2));
  $tax_total->setattr('currencyID', $order->info['currency']);

  $pdt->setItemTotal($item_total);
  $pdt->setShippingTotal($ship_total);
  //$pdt->setHandlingTotal($handling_total);
  $pdt->setTaxTotal($tax_total);

/*
$payment_item = array();
$item_tax = 0;
$item_amount = 0;

  for($i = 0; $i < sizeof($order->products); $i++) {
    $payment_item[$i] =& Services_PayPal::getType('PaymentDetailsItemType');
    $payment_item[$i]->setName($order->products[$i]['name']);
    $amount =& Services_PayPal::getType('BasicAmountType');
    $amount->setval(number_format($order->products[$i]['final_price'], 2));
    $amount->setattr('currencyID', $order->info['currency']);
    $payment_item[$i]->setAmount($amount);
    $payment_item[$i]->setNumber($order->products[$i]['id']);
    $payment_item[$i]->setQuantity($order->products[$i]['qty']);
    $tax =& Services_PayPal::getType('BasicAmountType');
    $tax->setval(number_format($order->products[$i]['tax'], 2));
    $tax->setattr('currencyID', $order->info['currency']);
    $payment_item[$i]->setTax($tax);
    //$payment_item[$i]->setSalesTax(number_format($order->products[$i]['tax'], 2));
    $item_amount += $order->products[$i]['final_price'] * $order->products[$i]['qty'];
    $item_tax += $order->products[$i]['tax'] * $order->products[$i]['qty'];
  }

  if($item_amount == $order->info['subtotal'] && $item_tax == $order->info['tax']) {
    $pdt->setPaymentDetailsItem($payment_item);
  }*/

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service