Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HTTP Post Response


dstu

Recommended Posts

Hello,

 

My online payment processor sends me a HTTPS POST response to the POST that I'm sending him to a URL that I ask him.

 

In that URL, I prepared the following file, but the redirection to the checkout_success (in case the response code is not 1) or checkout_payment do not work:

<?php

 

 

include ('includes/application_top.php');

 

//Get all the variables received in the POST

foreach($_POST as $key => $value)

{

$$key = $value;

}

 

//Assign the received variables to local variables

foreach($_POST as $variable => $value) {

switch ($variable) {

case 'OrderID':

$OrderID = $value;

break;

case 'ResponseCode':

$ResponseCode = $value;

break;

}

}

 

 

// If the payment is rejected, go back to the payment page

//

 

if ($ResponseCode != '1') {

 

echo '<div align=center>Transaction Refused<br>';

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $cartId, 'SSL', true, true));

}

 

// If the payment is approved, redirect to the checkout success

//

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, $cartId, 'SSL', true, true));

 

?>

 

I know that the variables get the right values (I tested with echos).

 

Does anyone have an idea why?

 

Thanks,

 

David

Link to comment
Share on other sites

Hi,

 

Does anyone have an idea why the tep_redirects doesn't work after I check the response?

 

I'm sure there has to be something minor that I neglected, but I have no idea what it is.

 

I really need help and this is the last point before I can start service.

 

Thanks,

 

David

 

Hello,

 

My online payment processor sends me a HTTPS POST response to the POST that I'm sending him to a URL that I ask him.

 

In that URL, I prepared the following file, but the redirection to the checkout_success (in case the response code is not 1) or checkout_payment do not work:

I know that the variables get the right values (I tested with echos).

 

Does anyone have an idea why?

 

Thanks,

 

David

Link to comment
Share on other sites

What happens if you change these:

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $cartId, 'SSL', true, true));

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, $cartId, 'SSL', true, true));

 

to this:

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Link to comment
Share on other sites

Unfortunately, nothing. It's just stuck in the same place and doesn't redirect.

 

I suspect that there must be some globals or variables or includes/requires that are missing from this page.

 

In my opinion, it doesn't recognize the tep_redirect & tep_href_link commands.

 

I checked (by echo) to see if it knows the file names, and it does.

 

Any other trick under your sleeve? :-"

 

Thanks,

 

David

Link to comment
Share on other sites

Put this at the top of your script and post the errors that are generated:

 

ini_set('error_reporting', E_ALL);

Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Link to comment
Share on other sites

Put this at the top of your script and post the errors that are generated:

 

ini_set('error_reporting', E_ALL);

 

 

Hi Brian,

 

Thanks for your help.

 

I put it just above the include line, and nothing is displayed on the screen (except for the echos that I put, according to the response codes).

 

Any other idea?

 

David

Link to comment
Share on other sites

In order to try to isolate the problem, I separated the tep_href_link from tep_redirect, by entering the following:

$next_page = tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL');

echo 'That\'s the full link: '.$next_page;

tep_redirect($next_page);

 

instead of:

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 

I did the same thing for a failed payment, but changed the destination to FILENAME_CHECKOUT_PAYMENT.

 

1. The redirect didn't work, but the good "full" link was properly displayed.

2. When I went (manually, since the redirect didn't work) to the checkout_success page, the cart was not emptied and the order was not really processed, although it gave me the "standard" success text.

 

I still think that some includes or variables/globals are needed, in order to solve this problem.

 

Regards,

 

David

Link to comment
Share on other sites

Since tep_redirect() uses PHP's header function, it should generate an error if you try outputting text before you issue the redirect command. Remove any echo statements before them in your script.

 

Also, put an exit; statement after each redirect. Another thing to check is your configure.php file. You need a full domain name for it to redirect correctly and it has to be the same domain as the current site you're on.

Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Link to comment
Share on other sites

Hello,

 

First, I added the line

ini_set('display_errors', true);

after

ini_set('error_reporting', E_ALL);

 

That (with your comments) showed me that the echos were indeed the cause of the redirect problem.

 

Now, the following issues remain:

1. If the transaction is rejected, how can I tell it to the client before rerouting him to the payment page again, if I can't echo the error?

 

2. Even if the payment is approved and I'm routed to the success page, the order is not really processed (the cart remains full and nothing happens in the back). Some info seems to get lost on the way :( .

I tried using the old redirect command

$next_page = tep_href_link(FILENAME_CHECKOUT_SUCCESS, $cartId, 'SSL', true, true);

tep_redirect($next_page);

instead of

$next_page = tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL');

tep_redirect($next_page);

but it didn't help, either.

 

Regards,

 

David

Link to comment
Share on other sites

OK, I solved question 1 above, by chaging the link to

 

$next_page = tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('Transaction Declined - Please try again or choose an alternate payment method'), 'SSL');

 

As for the 2nd problem, I think that I have a more general problem, because even with another payment method, the order was not processed fully, i.e. the items are seen in my order history, but no order is really registered.

 

David

 

PS. I hope that all these exchanges contribute to other people :-)

Link to comment
Share on other sites

Try processing an order with the Cash on Delivery module. If the order doesn't get saved there, then you have a larger problem. If it does work properly, the problem is contained in the payment modules, the processor, or the information that's sent to the processor.

Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.

Link to comment
Share on other sites

OK,

 

I reinstalled the whole osCommerce all over again.

 

I have 4 payment methods activated:

C.O.D., Check/MO, Wire Transfer (EUBank Transfer contribution) and my Credit Card processing module.

 

All the other 3 are now working fine.

 

The problem with my module remains, and it's clear that the fact that the order is accepted is not passed on to the next page and all the database queries are not performed.

 

Any idea?

 

Thanks,

 

David

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...