At work (well more like an apprenticeship, dunno) I'm making a wordpress plugin that allows users to submit their posts (it's for a website catalog) with the ability to pay for some premium features. For this I'm using PayU.
I have a shortcode which I put on a page where users end up after the payment, and the shortcode shows appropiate message depending on GET variables. Eg. "your post awaits moderation" with a free post, "payment was successful" when it was so etc.
So when payment in PayU fails it will stick &error=501
to the end of the url, so my code detects that and tells the user their payment failed and their post won't be submitted. And here's the thing.
When the confirmation page url is itself a variable, eg. ?post_id=71, everything works as expected. So for mywebsite.com/?post_id=71&posttype=paid&error=501
the error is read and shortcode acts appropiately. But when the address in folder-like (sorry, really dunno how to call that) eg. /confirmation
, error
variable gets unnoticed. So with an address like mywebsite.com/confirmation?posttype=paid&error=501
the result is a "payment successful" message. Order of variables doesn't seem to matter, posttype
is always interpreted and error
is always omitted.
I don't have access to the code right now but it's basically this:
function my_shortcode() {
if(!isset($_GET['posttype'])) {
// some generic text to handle this unexpected condition
}
else if($_GET['posttype'] == 'free') {
// nice message on how the post awaits moderation
}
else if($_GET['posttype'] == 'paid') {
if(isset($_GET['error'])) {
if($_GET['error'] == '501') {
// payment was unsuccessful
} else {
// some generic text cause this isn't supposed to happen too
}
} else {
// payment was successful
}
}
}
As I said, I'd expect the error value to modify the behavior accordingly, instead it only does so when page address is itself a query.