latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

How to change transaction failure message

Home Forums Community Forum How to change transaction failure message

This topic contains 9 replies, has 3 voices. Last updated by  AnotherOpus 4 years, 3 months ago.

Topic Author Topic
Posted: Wednesday Sep 19th, 2012 at 11:55 am #25811

Hello,

I’ve searched the forum and Google and I’ve dug around inside the s2M tabs on my sites and I cannot find where to do this.

How and where do I change the text of this message:

Error #36. Transaction failed: Fail to obtain approval for the online transaction.

I want to reword the message so it is clear to the user that their bank caused this message and not my site.

I want the member, or would be member to contact their bank and not me when their card doesn’t work.

If this message comes from inside of s2M, the default message could be improved so that people understand the failure is not with the website but instead with their bank or their bank account balance.

This change in the next release of s2M would be a benefit to all s2M owners.

I hope you can point me in the right direction to where I can change this in each of my s2M sites.

Thank you for your help,

Chris

List Of Topic Replies

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Wednesday Sep 19th, 2012 at 1:46 pm #25835
David Welch
Username: dwbiz05

I believe this message may actually come from the processor, not S2 but I’m not 100% sure. I’ve seen the code for this but I’ll have to look it back up.

What payment option are you using?

Dave

Posted: Wednesday Sep 19th, 2012 at 2:39 pm #25841
Mark R.
Username: marktyt

Interesting idea

  • This reply was modified 4 years, 3 months ago by  Mark R..
Posted: Wednesday Sep 19th, 2012 at 3:01 pm #25844

Hello Dave,

We’re using PayPal Pro, and PayFlow, as well as the mix of other default s2M payment gateways.

I really hope this message is editable. If not it’d be a super trick to grab it as it comes into s2M and change it.

We can’t be the only ones dealing with members calling because their card didn’t work when our site (and s2M) are doing what they should do.

Thanks,

Chris

Posted: Wednesday Sep 19th, 2012 at 3:55 pm #25847
David Welch
Username: dwbiz05

OK Folks…

Here is the deal. These messages are a compilation of multiple pieces from the payment processor(s).

Of course they all send different variables, so S2member handles each one individually instead of with one function… lol

The short answer is, yes you can change the message. The long answer is that it will take some “programming.”

If you don’t have this directory/file, make it now:

yourdomain.com/wp-content/mu-plugins/s2-hacks.php

Now, in this file (s2-hacks.php), let’s put the following code:

<?php
//Dave Welch - Filter CC Error Message #36

//Hook Into the filter where this error is processed.
add_filter('ws_plugin__s2member_paypal_api_response','change_error_36',10,2);

//Function our hook above will call.
function change_error_36($bool,$vars=array()){

	//Checking to see if the response code is #36.
	if(isset($vars["response"]["L_ERRORCODE0"]) && $vars["response"]["L_ERRORCODE0"] == 36){
	
		//If it is #36, we are changing the error message here.
		$vars['response']['__error'] = "Your New Message Here."; //Change the text in the quotes to the left to change the message.
	}

	//Sending the response variable back to the s2member function.
	return $vars["response"];
}
?>

Now, that *should* hook into the process and change the message. The issue is that this function is only set up to work with Paypal (not sure it that includes pro).

If I get time later tonight, I’ll see if I can put together a switch function to handle more than one payment type. I don’t use Paypal, but I tested it with Auth.net and this solution worked for me.

Hope that helps and let me know if you have any questions.

Dave

Posted: Wednesday Sep 19th, 2012 at 4:08 pm #25848

Hello Dave,

I hope you don’t get your cape caught on anything when you take off.

Thank you for this. I will be glad to test it out.

And forgive me for something I don’t understand–I’m not a pro coder–why is the directory /mu-plugins/ ?

And how will s2M know to leverage the code in that folder?

Thank you, seriously, thank you!

Chris

Note to s2M. This would be a goooooood s2M feature.

Posted: Wednesday Sep 19th, 2012 at 4:10 pm #25849
David Welch
Username: dwbiz05

Another issue is that in order to program for a specific code, you have to know which code it is that is being thrown. Which means you won’t know ahead of time what to filter until it happens to a user.

One option would be to not filter the message code and just print it out with an explanation that the processor sent it, like this function below:

//Function our hook above will call.
function change_error_36($bool,$vars=array()){
	$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["L_ERRORCODE0"].": ".$vars["response"]["L_SHORTMESSAGE0"]." - ".$vars["response"]["L_LONGMESSAGE0"]; //Change the text in the quotes to the left to change the message.
	
	//Sending the response variable back to the s2member function.
	return $vars["response"];
}

This would return:

PayPal sent the following error:
Error #36: Transaction failed - Fail to obtain approval for the online transaction.

Hope that makes sense.

Dave

Posted: Wednesday Sep 19th, 2012 at 4:13 pm #25850
David Welch
Username: dwbiz05

It stands for Must Use Plugins.

Here is a link to a very detailed page on the wordpress codex:

http://codex.wordpress.org/Must_Use_Plugins

S2member uses a function called apply_filters();

This searches for any “add_filter()” functions created by any plugin or mu-plugin that calls it’s specific “tag.”

Wordpress handles all of this in the background. But as long as you add_filter() using the same tag that S2member used, you can “break in” to the s2member processes without messing with their original code. (good for updates)

Dave

  • This reply was modified 4 years, 3 months ago by  David Welch.
Posted: Wednesday Sep 19th, 2012 at 4:23 pm #25853
David Welch
Username: dwbiz05

ok, so it looks like Payflow might use some different variables… of course.. lol.

You might try this if you aren’t getting any success with the other one:

//Function our hook above will call.
function change_error_36($bool,$vars=array()){
	if(isset($vars["response"]["L_ERRORCODE0"])){
		//PayPal Variables
		
		$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["L_ERRORCODE0"].": ".$vars["response"]["L_SHORTMESSAGE0"]." - ".$vars["response"]["L_LONGMESSAGE0"]; //Change the text in the quotes to the left to change the message.
	
		//Sending the response variable back to the s2member function.
		return $vars["response"];
	}
	else if(isset($vars["response"]["TRXRESULT"])){
		//Payflow Variables - I think
		
		$vars['response']['__error'] = "PayPal sent the following error:<br>Error #".$vars["response"]["TRXRESULT"].": ".$vars["response"]["TRXRESPMSG"]; //Change the text in the quotes to the left to change the message.
	
		//Sending the response variable back to the s2member function.
		return $vars["response"];
	}
}

Hope that helps,

Dave

Posted: Thursday Sep 20th, 2012 at 10:45 am #25955

Thank you again Dave,

I also appreciate the education about the Must Use Plugins–I haven’t had time to read all of the codex yet ;)

We’re building a new version of our site and I will test your code (above) as we get to this piece.

When I learn about the success or discover something needs tuning, I’ll be back here with results.

Thank you again for your contribution.

Chris

Viewing 9 replies - 1 through 9 (of 9 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.