Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

RBS World Pay Junior callback


Guest

Recommended Posts

Hi, I am having problems with the callback feature with worldpay junior. I have had this successfully working in test and I have changed nothing but all of a sudden the callback doesnt work. Transactions complete ok and I get to the page 'thank you for your transcation' but then I dont get redirected back to my sight.

 

Worldpay are saying that this is a problem with my junior_callback.php file but no changes have been made to this file since it was working about 2-3 weeks ago. This is the code in my callback.php file:

 

<?php

/*

$Id: junior_callback.php 1807 2008-01-13 00:50:08Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

*/

 

if (isset($HTTP_POST_VARS['M_sid']) && !empty($HTTP_POST_VARS['M_sid'])) {

chdir('../../../../');

require ('includes/application_top.php');

 

if ($HTTP_POST_VARS['transStatus'] == 'Y') {

$pass = false;

 

if (isset($HTTP_POST_VARS['M_hash']) && !empty($HTTP_POST_VARS['M_hash']) && ($HTTP_POST_VARS['M_hash'] == md5($HTTP_POST_VARS['M_sid'] . $HTTP_POST_VARS['M_cid'] . $HTTP_POST_VARS['cartId'] . $HTTP_POST_VARS['M_lang'] . number_format($HTTP_POST_VARS['amount'], 2) . MODULE_PAYMENT_WORLDPAY_JUNIOR_MD5_PASSWORD))) {

$pass = true;

}

 

if (isset($HTTP_POST_VARS['callbackPW']) && ($HTTP_POST_VARS['callbackPW'] != MODULE_PAYMENT_WORLDPAY_JUNIOR_CALLBACK_PASSWORD)) {

$pass = false;

}

 

if (tep_not_null(MODULE_PAYMENT_WORLDPAY_JUNIOR_CALLBACK_PASSWORD) && !isset($HTTP_POST_VARS['callbackPW'])) {

$pass = false;

}

 

if ($pass == true) {

include('includes/languages/' . basename($HTTP_POST_VARS['M_lang']) . '/modules/payment/worldpay_junior.php');

 

$order_query = tep_db_query("select orders_status, currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_POST_VARS['cartId'] . "' and customers_id = '" . (int)$HTTP_POST_VARS['M_cid'] . "'");

if (tep_db_num_rows($order_query) > 0) {

$order = tep_db_fetch_array($order_query);

 

if ($order['orders_status'] == MODULE_PAYMENT_WORLDPAY_JUNIOR_PREPARE_ORDER_STATUS_ID) {

$order_status_id = (MODULE_PAYMENT_WORLDPAY_JUNIOR_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_WORLDPAY_JUNIOR_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID);

 

tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . (int)$HTTP_POST_VARS['cartId'] . "'");

 

$sql_data_array = array('orders_id' => $HTTP_POST_VARS['cartId'],

'orders_status_id' => $order_status_id,

'date_added' => 'now()',

'customer_notified' => '0',

'comments' => 'WorldPay: Transaction Verified');

 

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

if (MODULE_PAYMENT_WORLDPAY_JUNIOR_TESTMODE == 'True') {

$sql_data_array = array('orders_id' => $HTTP_POST_VARS['cartId'],

'orders_status_id' => $order_status_id,

'date_added' => 'now()',

'customer_notified' => '0',

'comments' => MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_WARNING_DEMO_MODE);

 

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

}

?>

<style>

.pageHeading {

font-family: Verdana, Arial, sans-serif;

font-size: 20px;

font-weight: bold;

color: #9a9a9a;

}

 

.main {

font-family: Verdana, Arial, sans-serif;

font-size: 11px;

line-height: 1.5;

}

</style>

<p class="pageHeading"><?php echo STORE_NAME; ?></p>

 

<p class="main" align="center"><?php echo MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_SUCCESSFUL_TRANSACTION; ?></p>

<META http-equiv="refresh" content="4;URL=http://www.kilt-sporran.co.uk/checkout_process.php?osCsid=<?php echo $_POST['M_sid']; ?>&hash=<?php echo $_POST['hash']; ?>">

 

<p align="center">

<a href ="http://www.kilt-sporran.co.uk/checkout_process.php?osCsid=<?php echo $_POST['M_sid']; ?>&hash=<?php echo $_POST['hash']; ?>">If you are not automatically returned after 5 seconds - Click here to return to the store to complete your order</a>

</p>

 

<p> </p>

 

<WPDISPLAY ITEM=banner><?php

}

}

}

}

}

?>

 

 

many thanks

iain

Link to comment
Share on other sites

  • 1 month later...

Extra white space in the latest Junior Callback file was causing me headaches that went away when I removed them...

The latest META update download adds in extra space that can safely be removed...

 

So the beginning of the file where the comments are (Starting line 18):

=================================================================

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

*/

 

?>

 

<?php

 

if (isset($_POST['M_sid']) && !empty($_POST['M_sid'])) {

=================================================================

 

Can be changed to :

=================================================================

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

 

*/

 

if (isset($_POST['M_sid']) && !empty($_POST['M_sid'])) {

=================================================================

 

the closing and re-opening of the php comments basically ads one line of whitespace, which Worldpay doesn't seem to like.

 

Hope that helps somebody!

Link to comment
Share on other sites

  • 1 month later...

Please can someone help because I am starting to lose the will to live trying to get Worldpay callback to work.

 

I have tried everything on this post plus others twice and still can get it to work. Having built my site and eager to get it live this is really starting to do me in.

 

I can successfully make a payment but when it come to the callback it just hangs on a white screen.

 

I am running v2.2 RC2a.

 

Payment Response URL http://<WPDISPLAY ITEM=MC_callback>

Payment Response enabled? checked

Enable Recurring Payment Response checked

Enable the Shopper Response checked

 

I have MD5 and Payment Response password set and is correctly inputted in OSC admin.

 

 

Junior_callback.php file:

 

$Id: junior_callback.php 1807 2008-01-13 00:50:08Z hpdl $

 

Any point would be great fully received.

 

Thanks in advance.

 

Sarah

Edited by turbo1982
Link to comment
Share on other sites

im in the same boat , Still cant get the the darn thing to work correctly.

 

:(

 

thinking about ditching worldpay. that would solve my problem.

 

Hi Guys, just realsied there's been responses to this thread and that someone's made an alteration.

 

I'll look over it tonight and see if I can get you guy's a remedy.

 

Pete

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

Hi Guys, just realsied there's been responses to this thread and that someone's made an alteration.

 

I'll look over it tonight and see if I can get you guy's a remedy.

 

Pete

 

 

Hi Pete ,

 

I think you could be a hero if you can solve this issue.

 

:thumbsup:

Link to comment
Share on other sites

Ok Guys, try this.

 

I've added some code to help you debug any issues. Enter your email address in the field below and you'll get sent an email with WorldPay values in it. This is good for two things, 1 to make sure WorldPay is accessing the script (if you dont receive an email then Worldpay cannot access the page) and 2 you can make sure you're recieving the values you need.

 

Give it a go and let me know the results, I'll add it to the package later tonight if it all goes well.

 

<?php
/*
 UPDATED 26-05-2010
 Added Debugging Support Via Email
 Included Meta Refresh Redirect
 Removed whitespace added by user g_p causing PHP Header/Session Errors
 Removed unknown post variables added by user g_p ($_POST['hash'] should be $_POST['M_hash'])

 UPDATED 04-12-2009
 Deprecated $HTTP_POST_VARS replaced with $_POST to enable callback on all platforms/php versions.
 Javascript dependancy for page redirection replaced with form action otherwise Worldpay removes javascript and leaves
 visitors stranded.

 Updated By Pete Batin (petebuzzin in Oscommerce forums)
 Based on Contribution by Harald Ponce de Leon ($Id: junior_callback.php 1807 2008-01-13 00:50:08Z hpdl $)

 No gaurantees are expressed in anyway, always backup and test before production usage

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Released under the GNU General Public License
*/


// Define your debug email address
$RBSPostEmail = '[email protected]';

$RBSDebugActive = true; //Change to false to disable debug emails.

// Build Email
$message = "RBS WorldPay Post Values\n".'\n';
foreach($_POST as $name => $value) {
$message .= "$name : $value
";
}
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

if($RBSDebugActive){
// Send Email
mail($RBSPostEmail, 'RBS WorldPay Post Values', $message);
}


 if (isset($_POST['M_sid']) && !empty($_POST['M_sid'])) {
   chdir('../../../../');
   require ('includes/application_top.php');

   if ($_POST['transStatus'] == 'Y') {
     $pass = false;

     if (isset($_POST['M_hash']) && !empty($_POST['M_hash']) && ($_POST['M_hash'] == md5($_POST['M_sid'] . $_POST['M_cid'] . $_POST['cartId'] . $_POST['M_lang'] . number_format($_POST['amount'], 2) . MODULE_PAYMENT_WORLDPAY_JUNIOR_MD5_PASSWORD))) {
       $pass = true;
     }

     if (isset($_POST['callbackPW']) && ($_POST['callbackPW'] != MODULE_PAYMENT_WORLDPAY_JUNIOR_CALLBACK_PASSWORD)) {
       $pass = false;
     }

     if (tep_not_null(MODULE_PAYMENT_WORLDPAY_JUNIOR_CALLBACK_PASSWORD) && !isset($_POST['callbackPW'])) {
       $pass = false;
     }

     if ($pass == true) {
       include('includes/languages/' . basename($_POST['M_lang']) . '/modules/payment/worldpay_junior.php');

       $order_query = tep_db_query("select orders_status, currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . (int)$_POST['cartId'] . "' and customers_id = '" . (int)$_POST['M_cid'] . "'");
       if (tep_db_num_rows($order_query) > 0) {
         $order = tep_db_fetch_array($order_query);

         if ($order['orders_status'] == MODULE_PAYMENT_WORLDPAY_JUNIOR_PREPARE_ORDER_STATUS_ID) {
           $order_status_id = (MODULE_PAYMENT_WORLDPAY_JUNIOR_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_WORLDPAY_JUNIOR_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID);

           tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . (int)$_POST['cartId'] . "'");

           $sql_data_array = array('orders_id' => $_POST['cartId'],
                                   'orders_status_id' => $order_status_id,
                                   'date_added' => 'now()',
                                   'customer_notified' => '0',
                                   'comments' => 'WorldPay: Transaction Verified');

           tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

           if (MODULE_PAYMENT_WORLDPAY_JUNIOR_TESTMODE == 'True') {
             $sql_data_array = array('orders_id' => $_POST['cartId'],
                                     'orders_status_id' => $order_status_id,
                                     'date_added' => 'now()',
                                     'customer_notified' => '0',
                                     'comments' => MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_WARNING_DEMO_MODE);

             tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
           }
?>
<meta http-equiv="refresh" content="10; url=<?php echo tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . $_POST['M_sid'] . '&hash=' . $_POST['M_hash'], 'SSL', false); ?>">
<style>
.pageHeading {
 font-family: Verdana, Arial, sans-serif;
 font-size: 20px;
 font-weight: bold;
 color: #9a9a9a;
}

.main {
 font-family: Verdana, Arial, sans-serif;
 font-size: 11px;
 line-height: 1.5;
}
</style>
<p class="pageHeading"><?php echo STORE_NAME; ?></p>
<p class="main" align="center"><?php echo MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_SUCCESSFUL_TRANSACTION; ?></p>
<form action="<?php echo tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . $_POST['M_sid'] . '&hash=' . $_POST['M_hash'], 'SSL', false); ?>" method="post">
<div align="center">
  <input name="submit" type="submit" value="<?php echo sprintf(MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_CONTINUE_BUTTON, addslashes(STORE_NAME)); ?>" />
   </div>
</form>

<p> </p>

<WPDISPLAY ITEM=banner>
<?php
         }
       }
     }
   }else{
	include('includes/languages/' . basename($_POST['M_lang']) . '/modules/payment/worldpay_junior.php');
  ?>
<meta http-equiv="refresh" content="10; url=<?php echo tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $_POST['M_sid'] . '&hash=' . $_POST['M_hash'], 'SSL', false); ?>">
<style>
.pageHeading {
 font-family: Verdana, Arial, sans-serif;
 font-size: 20px;
 font-weight: bold;
 color: #9a9a9a;
}

.main {
 font-family: Verdana, Arial, sans-serif;
 font-size: 11px;
 line-height: 1.5;
}
</style>
<p align="center" class="pageHeading"><?php echo STORE_NAME; ?></p>
<p class="main" align="center"><?php echo MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_UNSUCCESSFUL_TRANSACTION;?></p>
<form action="<?php echo tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $_POST['M_sid'] . '&hash=' . $_POST['M_hash'], 'SSL', false); ?>" method="post">
<div align="center">
  <input name="submit" type="submit" value="<?php echo sprintf(MODULE_PAYMENT_WORLDPAY_JUNIOR_TEXT_CONTINUE_BUTTON, addslashes(STORE_NAME)); ?>" />
   </div>
</form>
<p align="center"> </p>

<div align="center">
 <WPDISPLAY ITEM=banner>
 </div>
 	<?php
}
 }
?>

If it still don't work, hit it again!

Senior PHP Dev with 18+ years of commercial experience for hire, all requirements considered, see profile for more information.

Is your version of osC up to date? You'll find the latest osC version (the community-supported responsive version) here.

Link to comment
Share on other sites

Ok Guys, try this.

 

I've added some code to help you debug any issues. Enter your email address in the field below and you'll get sent an email with WorldPay values in it. This is good for two things, 1 to make sure WorldPay is accessing the script (if you dont receive an email then Worldpay cannot access the page) and 2 you can make sure you're recieving the values you need.

 

Give it a go and let me know the results, I'll add it to the package later tonight if it all goes well.

 

 

Hi there Pete,

 

Mailed you my email i recieved from Worldpay of the transaction not quite sure what it is telling me? Is this what i should expect to see? Is there any chance it is getting stuck on my passwards? Passwards set in Worldpay do match ones stated in OSC admin,have triple checked. Is there something i am missing?

 

Thanks in advance

 

Sarah

Link to comment
Share on other sites

ok ,

 

i installed the latest script

 

Here is the Update.

 

I now get two emails back from worldpay instead of 1 before .

--------------------------------------

1st did not get this before.

 

Transaction Confirmation

Please retain for your records

Thank you

Your transaction has been processed by RBS WorldPay, on behalf of mysite.co.uk.

 

 

Transaction details:

Transaction for the value of: GBP 0.10

Description: www.mysite.co.uk

From: mysite.co.uk

Merchant's cart ID: 1078

Authorisation Date/Time: 31/May/2010 08:45:47

RBS WorldPay's transaction ID: 883650343

This is not a tax receipt.

---------------------------------------

2nd got this one before.

 

Your cart ID: 1078

 

 

Purchase transaction ID: 883650343

 

Generated at: 31/May/2010 08:45:47

Sale value: GBP 0.10

Description: www.mysite.co.uk

Shopper's Name: trtrytrytry

Shopper's Address: 13 sbunvfysid87686oad

Shopper's Telephone No.: 343434343

Shopper's Postcode: fuuup

Shopper's Country: United Kingdom

Shopper's IP address: 90.88979872

Shopper's Email: [email protected]

 

The above payment has been processed..co.uk

AVS results:

security code comparison - matched

postcode comparison - matched

address comparison - matched

 

The above payment has been processed.

 

 

1) Still shows Preparing [WorldPay] . does not show in pending.

2) still does not direct back to website automatically . Stays at this page https://secure.wp3.rbsworldpay.com/wcc/card

3) Still no email saying what the order was for , only way to check is looking in Preparing [WorldPay] and manualy changing to Pending.

4) No email from my website telling me any order details.

 

 

Not sure is anyone gets any different results.

Edited by filmcell
Link to comment
Share on other sites

ok ,

 

i installed the latest script

 

Here is the Update.

 

I now get two emails back from worldpay instead of 1 before .

--------------------------------------

1st did not get this before.

 

Transaction Confirmation

Please retain for your records

Thank you

Your transaction has been processed by RBS WorldPay, on behalf of mysite.co.uk.

 

 

Transaction details:

Transaction for the value of: GBP 0.10

Description: www.mysite.co.uk

From: mysite.co.uk

Merchant's cart ID: 1078

Authorisation Date/Time: 31/May/2010 08:45:47

RBS WorldPay's transaction ID: 883650343

This is not a tax receipt.

---------------------------------------

2nd got this one before.

 

Your cart ID: 1078

 

 

Purchase transaction ID: 883650343

 

Generated at: 31/May/2010 08:45:47

Sale value: GBP 0.10

Description: www.mysite.co.uk

Shopper's Name: trtrytrytry

Shopper's Address: 13 sbunvfysid87686oad

Shopper's Telephone No.: 343434343

Shopper's Postcode: fuuup

Shopper's Country: United Kingdom

Shopper's IP address: 90.88979872

Shopper's Email: [email protected]

 

The above payment has been processed..co.uk

AVS results:

security code comparison - matched

postcode comparison - matched

address comparison - matched

 

The above payment has been processed.

 

 

1) Still shows Preparing [WorldPay] . does not show in pending.

2) still does not direct back to website automatically . Stays at this page https://secure.wp3.rbsworldpay.com/wcc/card

3) Still no email saying what the order was for , only way to check is looking in Preparing [WorldPay] and manualy changing to Pending.

4) No email from my website telling me any order details.

 

 

Not sure is anyone gets any different results.

Hi Bob

 

Do you have a unique order number generator installed?

 

If you have then that is prob. causing a lot of your issues, it did for me.

 

Will tidy my code up tonight and will publish my fix.

 

I am one happy lady.

 

Sarah

Link to comment
Share on other sites

Extra white space in the latest Junior Callback file was causing me headaches that went away when I removed them...

The latest META update download adds in extra space that can safely be removed...

 

So the beginning of the file where the comments are (Starting line 18):

=================================================================

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

*/

 

?>

 

<?php

 

if (isset($_POST['M_sid']) && !empty($_POST['M_sid'])) {

=================================================================

 

Can be changed to :

=================================================================

Copyright © 2008 osCommerce

 

Released under the GNU General Public License

 

*/

 

if (isset($_POST['M_sid']) && !empty($_POST['M_sid'])) {

=================================================================

 

the closing and re-opening of the php comments basically ads one line of whitespace, which Worldpay doesn't seem to like.

 

Hope that helps somebody!

 

 

Thanks I was head scratching over this error - never occured to me that one empty line counted as output.

Link to comment
Share on other sites

  • 2 weeks later...

This seems to work :rolleyes:

Simple but works.

 

<html>

<head>

<title>completed transaction</title>

</head>

<body>

<META http-equiv="refresh"

content="1;URL=http://www.YOURSITE.co.uk/checkout_process.php?osCsid=<?php

echo $_POST['M_sid']; ?>&hash=<?php echo $_POST['hash']; ?>"> </p> </body> </html>

Link to comment
Share on other sites

  • 2 weeks later...

This seems to work :rolleyes:

Simple but works.

 

<html>

<head>

<title>completed transaction</title>

</head>

<body>

<META http-equiv="refresh"

content="1;URL=http://www.YOURSITE.co.uk/checkout_process.php?osCsid=<?php

echo $_POST['M_sid']; ?>&hash=<?php echo $_POST['hash']; ?>"> </p> </body> </html>

 

Hi Can you tell me where you are putting this to make it work. I cannot for the life of me make the callback work!

Edited by ccakes74
Link to comment
Share on other sites

Hi Can you tell me where you are putting this to make it work. I cannot for the life of me make the callback work!

 

 

hi

 

/ext/modules/payment/worldpay look for file junior_callback.php . Edit it with notepad . Delete all the old code and add the code i said worked .

 

Backup your junior_callback.php first Just incase.

 

Still works for me :thumbsup:

Link to comment
Share on other sites

  • 4 weeks later...

Anyone else tried my fix. I posted this a few weeks ago , But no one has said if it has fixed there problem.

would be nice to know if it has helped you , Or if you found a better solution.

Its still seems good for me

Link to comment
Share on other sites

  • 1 month later...

Anyone else tried my fix. I posted this a few weeks ago , But no one has said if it has fixed there problem.

would be nice to know if it has helped you , Or if you found a better solution.

Its still seems good for me

 

Hi filmcell, i never got to try your idea but i did get junior Worldpay to work ok in the end, so if anyone else needs help on this I'd be happy to take you through it step by step, and tell you exactly what i did. Hopefully it will work for everyone else to. Just ask here and I'll be happy to help.

Link to comment
Share on other sites

Hi Filmcell,

 

I used your fix and it's done the trick for now - many thanks. Only minor (at this stage) issues are that the order amount in my admin appears without VAT for shipping though the customer is getting charged the correct amount. Also it seems to have skipped my UHTML Email module and takes the original email that oscommerce came with but I can live with that. I'm too tired to think about why, just glad I can switch Worldpay on again.

 

Would certainly be keen on finding out full solution.

 

Cheers,

 

Jaya

Link to comment
Share on other sites

Ok, further testing shows that a cancellation in the worldpay payment process will look like a successful payment to me but obviously the customer hasn't paid anything - is this why you mentioned you needed to check in the worldpay admin to confirm payment?

 

Jaya

Link to comment
Share on other sites

this is how you setup RBS Worldpay

Payment Response URL http://<WPDISPLAY ITEM=MC_callback>

Payment Response enabled? tick

Enable Recurring Payment Response tick

Enable the Shopper Response tick

Payment Response failure email address yes your email here

Attach HTTP(s) Payment Message to the failure email? tick

Payment Response password yes

MD5 secret for transactions yes

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...