Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

OScommerce returning error from paypal


squart

Recommended Posts

(I had posted this in another forum, apologies for the repost but it was in the wrong place)

 

After the payment is successfully processed via paypal I see this in OSCommerce:

 

PayPal IPN Verified [Completed (Verified; $1,036.67); PayPal transaction value (1036.67) does not match order value (1,036.67)]

 

 

K7gbQ.gif

 

 

It seems pretty logical that because it's an Italian Paypal account and in Europe the comma and decimal signs are used in exactly the opposite way as in the US (look at the totals above) and that mismatch is causing the error.

 

Would anyone know where and how I could fix this?

 

Thanks.

Link to comment
Share on other sites

if ($HTTP_POST_VARS['mc_gross'] != number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency']))) {

$comment_status .= '; PayPal transaction value (' . tep_output_string_protected($HTTP_POST_VARS['mc_gross']) . ') does not match order value (' . number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency'])) . ')';

}

is what check in IPN file.

 

Paste the IPN code that is on Your Paypal module.

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

if ($HTTP_POST_VARS['mc_gross'] != number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency']))) {

$comment_status .= '; PayPal transaction value (' . tep_output_string_protected($HTTP_POST_VARS['mc_gross']) . ') does not match order value (' . number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency'])) . ')';

}

is what check in IPN file.

 

Paste the IPN code that is on Your Paypal module.

 

Satish

 

Hi Satish, and thanks for responding. I was beginning to feel a bit stranded here :)

 

What file should I be looking in exactly? I opened up includes/modules/payment/paypal_standard.php and couldn't find the text you had posted.

 

Thanks.

Link to comment
Share on other sites

Here you go....looks to be identical to yours.

 

 	if ($HTTP_POST_VARS['payment_status'] == 'Pending') {
	$comment_status .= '; ' . $HTTP_POST_VARS['pending_reason'];
	} elseif ( ($HTTP_POST_VARS['payment_status'] == 'Reversed') || ($HTTP_POST_VARS['payment_status'] == 'Refunded') ) {
	$comment_status .= '; ' . $HTTP_POST_VARS['reason_code'];

Link to comment
Share on other sites

Paste the complete ipn file.

 

Satish

 

<?php
/*
$Id: standard_ipn.php 1778 2008-01-09 23:37:44Z hpdl $

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

Copyright (c) 2008 osCommerce

Released under the GNU General Public License
*/

chdir('../../../../');
require('includes/application_top.php');

$parameters = 'cmd=_notify-validate';

reset($HTTP_POST_VARS);
while (list($key, $value) = each($HTTP_POST_VARS)) {
$parameters .= '&' . $key . '=' . urlencode(stripslashes($value));
}

if (MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == 'Live') {
$server = 'www.paypal.com';
} else {
$server = 'www.sandbox.paypal.com';
}

$fsocket = false;
$curl = false;
$result = false;

if ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen('ssl://' . $server, 443, $errno, $errstr, 30)) ) {
$fsocket = true;
} elseif (function_exists('curl_exec')) {
$curl = true;
} elseif ($fp = @fsockopen($server, 80, $errno, $errstr, 30)) {
$fsocket = true;
}

if ($fsocket == true) {
$header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n" .
	'Host: ' . $server . "\r\n" .
	'Content-Type: application/x-www-form-urlencoded' . "\r\n" .
	'Content-Length: ' . strlen($parameters) . "\r\n" .
	'Connection: close' . "\r\n\r\n";

@fputs($fp, $header . $parameters);

$string = '';
while (!@feof($fp)) {
	$res = @fgets($fp, 1024);
	$string .= $res;

	if ( ($res == 'VERIFIED') || ($res == 'INVALID') ) {
	$result = $res;

	break;
	}
}

@fclose($fp);
} elseif ($curl == true) {
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://' . $server . '/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);

curl_close($ch);
}

if ($result == 'VERIFIED') {
if (isset($HTTP_POST_VARS['invoice']) && is_numeric($HTTP_POST_VARS['invoice']) && ($HTTP_POST_VARS['invoice'] > 0)) {
	$order_query = tep_db_query("select orders_status, currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . $HTTP_POST_VARS['invoice'] . "' and customers_id = '" . (int)$HTTP_POST_VARS['custom'] . "'");
	if (tep_db_num_rows($order_query) > 0) {
	$order = tep_db_fetch_array($order_query);

	if ($order['orders_status'] == MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID) {
	$sql_data_array = array('orders_id' => $HTTP_POST_VARS['invoice'],
	'orders_status_id' => MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID,
	'date_added' => 'now()',
	'customer_notified' => '0',
	'comments' => '');

	tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);


	tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . (MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . (int)$HTTP_POST_VARS['invoice'] . "'");
	}

	$total_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $HTTP_POST_VARS['invoice'] . "' and class = 'ot_total' limit 1");
	$total = tep_db_fetch_array($total_query);

	$comment_status = $HTTP_POST_VARS['payment_status'] . ' (' . ucfirst($HTTP_POST_VARS['payer_status']) . '; ' . $currencies->format($HTTP_POST_VARS['mc_gross'], false, $HTTP_POST_VARS['mc_currency']) . ')';

	if ($HTTP_POST_VARS['payment_status'] == 'Pending') {
	$comment_status .= '; ' . $HTTP_POST_VARS['pending_reason'];
	} elseif ( ($HTTP_POST_VARS['payment_status'] == 'Reversed') || ($HTTP_POST_VARS['payment_status'] == 'Refunded') ) {
	$comment_status .= '; ' . $HTTP_POST_VARS['reason_code'];
	}

	if ($HTTP_POST_VARS['mc_gross'] != number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency']))) {
	$comment_status .= '; PayPal transaction value (' . tep_output_string_protected($HTTP_POST_VARS['mc_gross']) . ') does not match order value (' . number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency'])) . ')';
	}

	$sql_data_array = array('orders_id' => $HTTP_POST_VARS['invoice'],
	'orders_status_id' => (MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID),
	'date_added' => 'now()',
	'customer_notified' => '0',
	'comments' => 'PayPal IPN Verified [' . $comment_status . ']');

	tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
	}
}
} else {
if (tep_not_null(MODULE_PAYMENT_PAYPAL_STANDARD_DEBUG_EMAIL)) {
	$email_body = '$HTTP_POST_VARS:' . "\n\n";

	reset($HTTP_POST_VARS);
	while (list($key, $value) = each($HTTP_POST_VARS)) {
	$email_body .= $key . '=' . $value . "\n";
	}

	$email_body .= "\n" . '$HTTP_GET_VARS:' . "\n\n";

	reset($HTTP_GET_VARS);
	while (list($key, $value) = each($HTTP_GET_VARS)) {
	$email_body .= $key . '=' . $value . "\n";
	}

	tep_mail('', MODULE_PAYMENT_PAYPAL_STANDARD_DEBUG_EMAIL, 'PayPal IPN Invalid Process', $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}

if (isset($HTTP_POST_VARS['invoice']) && is_numeric($HTTP_POST_VARS['invoice']) && ($HTTP_POST_VARS['invoice'] > 0)) {
	$check_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $HTTP_POST_VARS['invoice'] . "' and customers_id = '" . (int)$HTTP_POST_VARS['custom'] . "'");
	if (tep_db_num_rows($check_query) > 0) {
	$comment_status = $HTTP_POST_VARS['payment_status'];

	if ($HTTP_POST_VARS['payment_status'] == 'Pending') {
	$comment_status .= '; ' . $HTTP_POST_VARS['pending_reason'];
	} elseif ( ($HTTP_POST_VARS['payment_status'] == 'Reversed') || ($HTTP_POST_VARS['payment_status'] == 'Refunded') ) {
	$comment_status .= '; ' . $HTTP_POST_VARS['reason_code'];
	}

	tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . ((MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . $HTTP_POST_VARS['invoice'] . "'");

	$sql_data_array = array('orders_id' => $HTTP_POST_VARS['invoice'],
	'orders_status_id' => (MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID,
	'date_added' => 'now()',
	'customer_notified' => '0',
	'comments' => 'PayPal IPN Invalid [' . $comment_status . ']');

	tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
	}
}
}

require('includes/application_bottom.php');
?>

Link to comment
Share on other sites

if ($HTTP_POST_VARS['mc_gross'] != number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency']))) {

$comment_status .= '; PayPal transaction value (' . tep_output_string_protected($HTTP_POST_VARS['mc_gross']) . ') does not match order value (' . number_format($total['value'] * $order['currency_value'], $currencies->get_decimal_places($order['currency'])) . ')';

}

 

this is there in Your code.

 

block this part and test.If it fixes then You need to modify this part of code.

Apply some string formating.

 

Satish

 

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

That code part is to check if the invoide amount and the payment amount is same or different.

So we first block that code by applying either a // or /* code line */ and check if the error no more exist then we are confirmed that thats the line.

Now You need to just focus on those two lines to make the error fixed while the hack still remains in place.

 

Or If You are cross checking tha amount on Paypal no need to worry about fixing that just block it.

 

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

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