Jump to content

Archived

This topic is now archived and is closed to further replies.

Guest krypton1

paypal direct payment FIX for lack of errors

Recommended Posts

Guest krypton1

Many people on this forum have comments about how the Paypal direct payment gateway has a major flaw: it doesn't provide any useful error message back to the customer when the order has failed. No matter how it fails, it says the same thing: "Order failed!". Not helpful! This could be the customers card was declined, wrong address, maybe they typed in the expiration year with 2 digits instead of 4, etc. They would never know, and probably never make the purchase!

These error messages are also quite useful when you are trying to get the module installed. If you are having trouble getting it installed, you should probably read this thread:

http://www.cubecart.com/site/forums/index....showtopic=11714

Bottom line, it is probably costing cube cart store owners a small fortune in lost orders from customers who got frustrated and just gave up!

So anyway, here is the fix. There are 3 files to edit:

1. Edit

cart\modules\gateway\DirectPayment\form.inc.php

around line 141, change

		//if(Services_PayPal::isError($response))

		//	echo $response->getMessage();



		header("Location: confirmed.php?f=1");

		exit;

to


		//	if(Services_PayPal::isError($response))

		//  echo $response->getMessage();

		

		$errs = $response->getErrors();

		$message = "";

		if(is_array($errs)){

			foreach($errs as $err){

				$m = $err->getLongMessage();

				if(substr_count($message,$m) == 0) 

					$message .= $m . "<BR>";

			}

		}else{

			$message = $errs->getLongMessage() . "<BR>";

		}



		header("Location: confirmed.php?f=1&err=".urlencode($message));

		exit;



2. Edit

cart\includes\content\confirmed.inc.php



around line 126 change


$confirmation->assign("LANG_ORDER_FAILED",$lang['front']['confirmed']['order_fail']);

		$confirmation->assign("LANG_ORDER_RETRY",$lang['front']['confirmed']['try_again_desc']);

		$confirmation->assign("LANG_RETRY_BUTTON",$lang['front']['confirmed']['try_again']);

		$confirmation->parse("confirmation.session_true.order_failed");

to


$confirmation->assign("LANG_ORDER_FAILED",$lang['front']['confirmed']['order_fail']);

		$confirmation->assign("LANG_ORDER_FAILED_ERRORS",$_GET['err']);

		$confirmation->assign("LANG_ORDER_RETRY",$lang['front']['confirmed']['try_again_desc']);

		$confirmation->assign("LANG_RETRY_BUTTON",$lang['front']['confirmed']['try_again']);

		$confirmation->parse("confirmation.session_true.order_failed");

The only thing different is one line gets inserted (the second one).



3. Edit

cart\skins\[NAME OF THE SKIN YOU ARE USING]\styleTemplates\content\confirmed.tpl



around line 20 change


<!-- BEGIN: order_failed -->

		<p>{LANG_ORDER_FAILED}</p>

		<p>{LANG_ORDER_RETRY}</p>

to


<!-- BEGIN: order_failed -->

		<p>{LANG_ORDER_FAILED}</p>

		<p><font color=red>{LANG_ORDER_FAILED_ERRORS}</font></p>

		<p>{LANG_ORDER_RETRY}</p>

Again, only the one line is inserted.

This should fix it (if not let me know, maybe I forgot something, its been a long day). I know a lot of people were offering money for this fix, but I decided to post it for free to keep with the spirit of open source cube cart. :)

Hope this helps some people!

Brian

Share this post


Link to post
Share on other sites

Guest krypton1

Here is another fix, I put on my cart. This will eliminate the screen that allows the user to select their payment method. In my case, I only have one payment method I want them to use (Paypal Direct Payment) so this screen is unecessary and confusing for the customer. Also, I have no idea what the purpose of the "Your comments" box is.....once again, unecessary and confusing for the customer.

The fix is easy. Edit this file:

cart\includes\content\gateway.inc.php

Around line 47, right after this line:

$gateway->assign("LANG_COMPLETE",$lang['front']['gateway']['complete']);



Add in this:


//permantently set the gateway variable here to avoid the "select a payment method screen"

$_POST['gateway'] = "DirectPayment";

You can use this fix to automatically select any payment method. In the added line just change "DirectPayment" to "Whichever gateway you want to use"

To find the correct name to put there, browse to:

cart\modules\gateway

and use the name of the folder of the gateway you want automatically selected.

Regards,

Brian

Share this post


Link to post
Share on other sites
Guest jaycarney

Fatal error: Call to a member function getLongMessage() on a non-object in .../music/modules/gateway/DirectPayment/form.inc.php on line 147

what am i doing wrong here?

Share this post


Link to post
Share on other sites
Guest krypton1

Hi,

Another user posted an error like this, but then later found out it actually was working. He just had to exit the check out and start over from the homepage. Seems strange, but this might work. If not, PM me and I will take a closer look at it.

Thanks,

Brian

Share this post


Link to post
Share on other sites
Guest pacoferia

Many thanks Krypton, I´ve just added your code...and bingo!! this is the first time I dare to change code lines, for me all those parentheses, lines and words is like chinese but I did it with yours because it looked clear and short, well this encourages me to try with longest and complicate codes running around this forum,

PD- ey man, what were you doing at your childhood??? I said because I would need all my life to learn such thing and I presume you haven´t had much time for playing while learning that gibberish .... but despite that it´s incredible for me.... it works!!

Here is another fix, I put on my cart. This will eliminate the screen that allows the user to select their payment method. In my case, I only have one payment method I want them to use (Paypal Direct Payment) so this screen is unecessary and confusing for the customer. Also, I have no idea what the purpose of the "Your comments" box is.....once again, unecessary and confusing for the customer.

The fix is easy. Edit this file:

cart\includes\content\gateway.inc.php

Around line 47, right after this line:

$gateway->assign("LANG_COMPLETE",$lang['front']['gateway']['complete']);



Add in this:


//permantently set the gateway variable here to avoid the "select a payment method screen"

$_POST['gateway'] = "DirectPayment";

You can use this fix to automatically select any payment method. In the added line just change "DirectPayment" to "Whichever gateway you want to use"

To find the correct name to put there, browse to:

cart\modules\gateway

and use the name of the folder of the gateway you want automatically selected.

Regards,

Brian

Share this post


Link to post
Share on other sites
Guest

Fatal error: Call to a member function on a non-object in /home/pwhole/public_html/store/modules/gateway/DirectPayment/form.inc.php on line 145

I am getting it again now it was working now its not not sure what would have changed to get the error again but something is not working right

line 145 =

if(substr_count($message,$err->getLongMessage()) == 0)

Share this post


Link to post
Share on other sites
Guest krypton1

viper, PM me. If you can setup a tmp login/pass on your server I will be happy to look into this further.

Share this post


Link to post
Share on other sites
Guest Insurrectus

Same error here www.onecraftymama.com

Fatal error: Call to a member function on a non-object in /home/pwhole/public_html/store/modules/gateway/DirectPayment/form.inc.php on line 146

line 146 =

if(substr_count($message,$err->getLongMessage()) == 0)

Any thoughts?

Thanks,

Clint

Share this post


Link to post
Share on other sites
Guest

I was hopeing that some one could maybe fix it it was working but I thank It stoped after I turned off register_globals could this have an effect on the code above?

Share this post


Link to post
Share on other sites
Guest krypton1

Hey Guys, I have fixed this error (thanks go to Insurrectus for helping me recreate the error).

It was working in some cases, and failing in others. For the programmers out there, here is the explanation: paypal's function had an inconsistant return type (which is allowed for some reason in PHP but a very bad idea). When there were multiple errors, it would return an array of errors. When it was one error, it would return just the error itself, not an array with one error in it.

Anyway, the code in the first file should look like this now:

cart\modules\gateway\DirectPayment\form.inc.php

around line 141

		//	if(Services_PayPal::isError($response))

		//  echo $response->getMessage();

		

		$errs = $response->getErrors();

		$message = "";

		if(is_array($errs)){

			foreach($errs as $err){

				$m = $err->getLongMessage();

				if(substr_count($message,$m) == 0) 

					$message .= $m . "<BR>";

			}

		}else{

			$message = $errs->getLongMessage() . "<BR>";

		}



		header("Location: confirmed.php?f=1&err=".urlencode($message));

		exit;

I've updated the first post on this thread so it is correct up above as well. If you guys test it out and come across any more errors, please let me know and I will fix it!! I'm using this mod on my site too, and its always better for us to find an error before a customer does.

Thanks,

Brian

Share this post


Link to post
Share on other sites
Guest Insurrectus

Brian,

Works great - thanks a bunch.

Clint

Share this post


Link to post
Share on other sites
Guest mashurst

worked well for me also. Installed your fix because it looks like I lost a sale today because of this. Sending paypal extra value meal money to your address.

-M :D

Share this post


Link to post
Share on other sites
Guest JABevan

Hi, I applied this fix and now my shopping cart jumps straight from the form of payment page to "Thank you, your order was successful! Please visit again soon." ...without prompting for the credit card number.

Also, I noticed that even when the orders failed CC sends an order email and lists the order in its database...

Any help would be much appreciated!

Thanks,

JAB*

Share this post


Link to post
Share on other sites
Guest Insurrectus

Also, I noticed that even when the orders failed CC sends an order email and lists the order in its database..

This has nothing to do with this fix, it is a CubeCart default.

Share this post


Link to post
Share on other sites
Guest krypton1

Hi, I applied this fix and now my shopping cart jumps straight from the form of payment page to "Thank you, your order was successful! Please visit again soon." ...without prompting for the credit card number.

Also, I noticed that even when the orders failed CC sends an order email and lists the order in its database...

Any help would be much appreciated!

Thanks,

JAB*

Hi JABevan,

Can you set me up with a temp pass on your website so I can ftp in a see what is happening. This is what I did with Insurrectus and it helped solve the last problem.

Thanks,

Brian

Share this post


Link to post
Share on other sites
Guest

Hi All

Does anybody know if PayPal API works in the UK yet? I tried it before christmas and it was not working.

Cheers

A

Share this post


Link to post
Share on other sites
Guest JABevan

Brian,

I switched from PayPal IPN to PayPal Pro, had some issues there, canceled my account and am now switching to Authorize.net. I'm debating whether to support PayPal at all....

JAB*

Share this post


Link to post
Share on other sites
Guest krypton1

Brian,

I switched from PayPal IPN to PayPal Pro, had some issues there, canceled my account and am now switching to Authorize.net. I'm debating whether to support PayPal at all....

JAB*

I understand. The paypal pro mod really was more confusing than it needed to be. Cubecart isn't 100% user friendly yet.

Brian

Hi All

Does anybody know if PayPal API works in the UK yet? I tried it before christmas and it was not working.

Cheers

A

I haven't tried it. But from other posts I've seen on here, you aren't the only one having problems.

Brian

Share this post


Link to post
Share on other sites
Guest mashurst

Also, I noticed that even when the orders failed CC sends an order email and lists the order in its database..

This has nothing to do with this fix, it is a CubeCart default.

What is the usual rate of failed orders that make it to the pending stage, but fail to get to the processing stage because something happened during payment?

It seems like I get too many of these.

-m :alien:

Share this post


Link to post
Share on other sites
Guest shopsarc

I had a succesful first sale the other day, then subsequent failures - several. I installed this mod to get a better idea on what was happening and got the error message:

Username/Password is incorrect

This is with a brand new created customer. Thoughts or theories?!?!?

Share this post


Link to post
Share on other sites
Guest krypton1

Hi Shopsarc,

If that is the error message coming from my mod....then you have to keep in mind that is a paypal error message.

So it most likely means that you username and password for your paypal website payments pro account is incorrect. And has nothing to do with customer's username/pass with cubecart.

Just a guess tho.

Brian

Share this post


Link to post
Share on other sites
Guest

Hi Krypton...

I applied your mod to my cart (TYVM) and am now having the same issue as JEBevan...jumps right from address info to "order complete."

I am fairly new to cube cart so would appreciate any assistance you might provide...

TY in advance,

V

let me know if you can take a closer look

Hi, I applied this fix and now my shopping cart jumps straight from the form of payment page to "Thank you, your order was successful! Please visit again soon." ...without prompting for the credit card number.

Also, I noticed that even when the orders failed CC sends an order email and lists the order in its database...

Any help would be much appreciated!

Thanks,

JAB*

Hi JABevan,

Can you set me up with a temp pass on your website so I can ftp in a see what is happening. This is what I did with Insurrectus and it helped solve the last problem.

Thanks,

Brian

Share this post


Link to post
Share on other sites
Guest shopsarc

Just as a followup, somehow my Username/Pssword for my API Cert was corrupted. After hours of teeth grinding and hair pulling it was a matter of downloading a new cert and creating a new username and password. I'm still a bit nervous as to why there was a failure on my original after several succesful orders, but all is well.

Now if I could just get tax working correctly...

Share this post


Link to post
Share on other sites
Guest krypton1

Glad you got it figured out Shopsarc.

Veepir: PM me a temporary username/pass and i will try to take a look at it in the next week some time.

JABevan never gave me access to look at it, so I wasn't able to resolve it.

Thanks,

Brian

Share this post


Link to post
Share on other sites

×
×
  • Create New...