hi, this is a code to test ur responsehandler.php
it emulates Google Checkout.
Code:
<?php
/*
* Created on 06/11/2006
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
list($start_m, $start_s) = explode(' ', microtime());
$start = $start_m + $start_s;
send_google_req('http://ur-site/googlecheckout/responsehandler.php');
list($end_m, $end_s) = explode(' ', microtime());
$end = $end_m + $end_s;
echo "\n\nTime to response: ". ($end-$start) ." segs";
function send_google_req($url) {
// Get the curl session object
$session = curl_init($url);
$merid = '';
$merkey = '';
$header_string_1 = "Authorization: Basic ".base64_encode($merid.':'.$merkey);
$header_string_2 = "Content-Type: application/xml";
$header_string_3 = "Accept: application/xml";
// here put the xml u want to emulate! u can take the ones from catalog/googlecheckout/response_message.log
$postargs = '<xml replace!>';
//fwrite($message_log, sprintf("\r\n%s %s %s\n",$header_string_1, $header_string_2, $header_string_3));
// Set the POST options.
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_HTTPHEADER, array($header_string_1, $header_string_2, $header_string_3));
curl_setopt($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// set to valir ssl.crt certification
//curl_setopt($session, CURLOPT_CAINFO, "C:\\Program Files\\xampp\\apache\\conf\\ssl.crt\\ca-bundle.crt");
// Do the POST and then close the session
$response = curl_exec($session);
if (curl_errno($session)) {
echo (curl_error($session));
} else {
curl_close($session);
}
//fwrite($message_log, sprintf("\r\n%s\n",$response));
// Get HTTP Status code from the response
$status_code = array();
echo "<xmp>";
print_r($response);
preg_match('/\d\d\d/', $response, $status_code);
//fwrite($message_log, sprintf("\r\n%s\n",$status_code[0]));
// Check for errors
switch( $status_code[0] ) {
case 200:
// Success
break;
case 503:
echo ('Error 503: Service unavailable. An internal problem prevented us from returning data to you.');
break;
case 403:
echo ('Error 403: Forbidden. You do not have permission to access this resource, or are over your rate limit.');
break;
case 400:
echo ('Error 400: Bad request. The parameters passed to the service did not match as expected. The exact error is returned in the XML response.');
break;
default:
echo ('Error :' . $status_code[0]);
}
}
?>
make sure to change the url to yours and set the correct merchant id/key.
in the $postargs variable put an XML with the request you want to emulate (there are plenty of examples in response_message.log),they can be merchant calculations, new order notifications, or any valid GC Request.
hope this helps to debug
ropu
Bookmarks