VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Payment VM 1.1 => PayPal / PayPal Pro VM 1.1 => Topic started by: Anthony C. on September 11, 2010, 01:45:01 AM

Title: Error: PayPal returned: Order total is invalid.
Post by: Anthony C. on September 11, 2010, 01:45:01 AM
Use Paypal_api module. When the total is 0 (100% off coupon applied), the api returns that value.

Is there a way to skip the paypal_api when the total is 0?

The old paypal and other CC payment are skipped when total is 0.

Thank you

Anthony
Title: Re: Error: PayPal returned: Order total is invalid.
Post by: Claude LaBadie on October 14, 2010, 05:01:57 AM
Hi,

Today I am happy I can give back to our great community by sharing how I solved this problem for myself. :D

The fact I found is that it is around lines 1190-1200 in the virtuemart file administrator/components/com_virtuemart/classes/ps_checkout.php that you can fix the erroneous checkout behavior.

The checkout process checks for the existence of payment processing capabilities before testing for a 0.00 total order amount.  ???

The solution I chose is to switch the order of those 2 tests, checking for a total of zero, then else for payment processing. ;D

on my version here is the code before my change:

      if (isset($_PAYMENT)) {
          if( $enable_processor == "Y" || stristr($_PAYMENT->payment_code, '_API' ) !== false ) {
         if( $d['new_order_status'] != 'P' ) {
             $d['order_status'] = $d['new_order_status'];
             $update_order = true;
         } elseif( defined($_PAYMENT->payment_code.'_VERIFIED_STATUS')) {
             $d['order_status'] = constant($_PAYMENT->payment_code.'_VERIFIED_STATUS');
             $update_order = true;
         }
          }
      } elseif( $order_total == 0.00 ) {
          // If the Order Total is zero, we can confirm the order to automatically enable the download
          $d['order_status'] = ENABLE_DOWNLOAD_STATUS;
          $update_order = true;
      }


and the code after the change:

      // If the Order Total is zero, we can confirm the order to automatically enable the download
      if ( $order_total == 0.00 ) {
          $d['order_status'] = ENABLE_DOWNLOAD_STATUS;
          $update_order = true;

      } elseif ( isset($_PAYMENT) ) {
          if( $enable_processor == "Y" || stristr($_PAYMENT->payment_code, '_API' ) !== false ) {
         if( $d['new_order_status'] != 'P' ) {
             $d['order_status'] = $d['new_order_status'];
             $update_order = true;
         } elseif( defined($_PAYMENT->payment_code.'_VERIFIED_STATUS')) {
             $d['order_status'] = constant($_PAYMENT->payment_code.'_VERIFIED_STATUS');
             $update_order = true;
         }
          }
      }



Have a nice day. :-*

[attachment cleanup by admin]
Title: Re: Error: PayPal returned: Order total is invalid.
Post by: forresttw on July 01, 2011, 04:14:20 AM
Which version of VM are you on? I'm on VM1.1.5 and it didn't work
Title: Re: Error: PayPal returned: Order total is invalid.
Post by: Claude LaBadie on July 08, 2011, 03:42:32 AM
The version this change worked on was VM 1.1.15