Paypal Showing a wrong percentual amount at checkout vm3.0.4

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Paypal Showing a wrong percentual amount at checkout vm3.0.4

Postby admin » Thu Feb 12, 2015 4:42 pm

Hello friends, we just discovered a small bug with Paypal payment in case you are using percentual fees within your checkout. The Paypal is not capable of calculating the percentual fee within the rendred payment's method output.

to fix this problem, open your:
\plugins\vmpayment\paypal\paypal.php

find this function:
public function plgVmDisplayListFEPayment(VirtueMartCart $cart, $selected = 0, &$htmlIn) {

the problem is caused by these lines:
Code: Select all
$cart_prices = array();
            $cart_prices['withTax'] = '';
            $cart_prices['salesPrice'] = '';


now update whole function so it looks like this (per standard payment method specifications):

Code: Select all
/**
    * * List payment methods selection
    * @param VirtueMartCart $cart
    * @param int $selected
    * @param $htmlIn
    * @return bool
    */

   public function plgVmDisplayListFEPayment(VirtueMartCart $cart, $selected = 0, &$htmlIn) {

      if ($this->getPluginMethods($cart->vendorId) === 0) {
         if (empty($this->_name)) {
            $app = JFactory::getApplication();
            $app->enqueueMessage(vmText::_('COM_VIRTUEMART_CART_NO_' . strtoupper($this->_psType)));
            return false;
         } else {
            return false;
         }
      }
      $method_name = $this->_psType . '_name';

      $htmla = array();
      foreach ($this->methods as $this->_currentMethod) {
         if ($this->checkConditions($cart, $this->_currentMethod, $cart->cartPrices)) {

            $html = '';
            if (empty($cart->cartPrices))
            {
             $cart_prices = array();
             $cart_prices['withTax'] = '';
             $cart_prices['salesPrice'] = '';
            }
            else
            $cart_prices= $cart->cartPrices;
         
            $methodSalesPrice = $this->setCartPrices($cart, $cart_prices, $this->_currentMethod);

            $this->_currentMethod->$method_name = $this->renderPluginName($this->_currentMethod);
            $html .= $this->getPluginHtml($this->_currentMethod, $selected, $methodSalesPrice);

            if ($this->_currentMethod->paypalproduct == 'api') {
               if (empty($this->_currentMethod->creditcards)) {
                  $this->_currentMethod->creditcards = PaypalHelperPaypal::getPaypalCreditCards();
               } elseif (!is_array($this->_currentMethod->creditcards)) {
                  $this->_currentMethod->creditcards = (array)$this->_currentMethod->creditcards;
               }
               $html .= $this->renderByLayout('creditcardform', array('creditcards' => $this->_currentMethod->creditcards,
                  'virtuemart_paymentmethod_id' => $this->_currentMethod->virtuemart_paymentmethod_id,
                  'method' => $this->_currentMethod,
                  'sandbox' => $this->_currentMethod->sandbox,
                  'customerData' => $this->customerData));
            }
            if ($this->_currentMethod->payment_type == '_xclick-auto-billing' && $this->_currentMethod->billing_max_amount_type == 'cust') {
               $html .= $this->renderByLayout('billingmax', array("method" => $this->_currentMethod, "customerData" => $this->customerData));
            }
            if ($this->_currentMethod->payment_type == '_xclick-subscriptions') {
               $paypalInterface = $this->_loadPayPalInterface();
               $html .= '<br/><span class="vmpayment_cardinfo">' . $paypalInterface->getRecurringProfileDesc() . '</span>';
            }
            if ($this->_currentMethod->payment_type == '_xclick-payment-plan') {
               $paypalInterface = $this->_loadPayPalInterface();
               $html .= '<br/><span class="vmpayment_cardinfo">' . $paypalInterface->getPaymentPlanDesc() . '</span>';
            }

            $htmla[] = $html;
         }
      }
      $htmlIn[] = $htmla;
      return true;

   }


enjoy, best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Paypal Showing a wrong percentual amount at checkout vm3.0.4

Postby admin » Thu Feb 12, 2015 4:50 pm

the problem is not related to opc and can also be seen on the classic VM checkout:


when you already have products in your cart the shown amount at the payment selection page is wrong:
Image

and changes only upon visiting the cart which hides the actual total from the rendered payment name:
Image

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x