Hi there, we are based in NZ. and a lot of our customers use PayMate for their payment processing (www.paymate.com)
I have hacked apart the paypal.php payment file, which is working fine for sending the order through to PayMate, but I can not work out the return side of things.
Lots of info available at:
[url]http://www.paymate.com.au/help/paymate/payments/tools.html[/url]
Would someone be keen to do this for us?
I have pasted the code that we are using so far below:
```php
/******************************************************************************
-
*
-
Copyright (c) 2004-2007 CS-Cart.com. All rights reserved. *
-
*
*******************************************************************************
-
*
- CS-Cart is commercial software, only users who have purchased a valid *
- license through https://www.cs-cart.com/ and accept to the terms of this *
- License Agreement can install this product. *
-
*
*******************************************************************************
- THIS CS-CART SHOP END-USER LICENSE AGREEMENT IS A LEGAL AGREEMENT BETWEEN *
- YOU AND YOUR COMPANY (COLLECTIVELY, “YOU”) AND CS-CART.COM (HEREINAFTER *
- REFERRED TO AS “THE AUTHOR”) FOR THE SOFTWARE PRODUCT IDENTIFIED ABOVE, *
- WHICH INCLUDES COMPUTER SOFTWARE AND MAY INCLUDE ASSOCIATED MEDIA, PRINTED *
- MATERIALS, AND “ONLINE” OR ELECTRONIC DOCUMENTATION (COLLECTIVELY, THE *
- “SOFTWARE”). BY USING THE SOFTWARE, YOU SIGNIFY YOUR AGREEMENT TO ALL *
- TERMS, CONDITIONS, AND NOTICES CONTAINED OR REFERENCED HEREIN. IF YOU ARE *
- NOT WILLING TO BE BOUND BY THIS AGREEMENT, DO NOT INSTALL OR USE THE *
- SOFTWARE. *
-
*
- PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE “COPYRIGHT” *
- FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE *
- AT THE FOLLOWING URL: License Agreement on the Use of CS-Cart *
******************************************************************************/
//
// $Id: paypal.php 5000 2008-03-27 09:43:46Z imac $
//
if ( !defined(‘IN_CSCART’) ) { die(‘Access denied’); }
// Return from paypal website
if (defined(‘PAYMENT_NOTIFICATION’)) {
if ($mode == ‘notify’) {
$pp_response = array();
if (stristr($_POST[‘payment_status’], ‘Completed’)) {
$payment_id = db_get_field(“SELECT payment_id FROM $db_tables[orders] WHERE order_id=‘$order_id’”);
$params = db_get_field(“SELECT params FROM $db_tables[payments] WHERE payment_id=‘$payment_id’”);
$params = unserialize($params);
$paypal_host = ($params[‘mode’] == ‘test’ ? “www.sandbox.paypal.com” : “www.paypal.com”);
$post_data = array();
$paypal_post = $_POST;
unset($paypal_post[$target_name], $paypal_post[$mode_name], $paypal_post[$action_name]);
$paypal_post[“cmd”] = “_notify-validate”;
foreach ($paypal_post as $k => $v) {
$post_data[] = “$k=”.fn_stripslashes($v);
}
list($headers,$result) = fn_https_request(“POST”,“https://$paypal_host:443/cgi-bin/webscr”, $post_data);
if (stristr($result, ‘VERIFIED’)) {
$pp_response[‘order_status’] = ‘P’;
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$_POST[‘txn_id’];
} elseif (stristr($result, ‘INVALID’)) {
$pp_response[‘order_status’] = ‘D’;
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$_POST[‘txn_id’];
} else {
$pp_response[‘order_status’] = ‘F’;
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$_POST[‘txn_id’];
}
} elseif (stristr($_POST[‘payment_status’], ‘Pending’)) {
$pp_response[‘order_status’] = ‘O’;
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$_POST[‘txn_id’];
} elseif (stristr($_POST[‘payment_status’], ‘Refunded’)) {
$_order = db_get_row(“SELECT status, total FROM $db_tables[orders] WHERE order_id=‘$order_id’”);
$pp_response[‘order_status’] = (floatval($_order[‘total’]) - abs(floatval($_POST[‘payment_gross’])) == 0) ? ‘I’ : $_order[‘status’];
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$_POST[‘txn_id’];
} else {
$pp_response[‘order_status’] = ‘D’;
$pp_response[‘reason_text’] = ‘’;
$pp_response[‘transaction_id’] = @$POST[‘txn_id’];
}
include PAYMENT_FILES_DIR . ‘payment_cc_complete.php’;
} elseif ($mode == ‘return’) {
$order_info = fn_get_order_info($order_id);
if ($order_info[‘status’] == ‘O’) {
$pp_response[‘order_status’] = ‘F’;
$pp_response[“reason_text”] = fn_get_lang_var(‘text_transaction_declined’);
include PAYMENT_FILES_DIR . ‘payment_cc_complete.php’;
}
if (!defined(‘ORDER_NOTIFICATION_SENT’)) {
define(‘ORDER_NOTIFICATION_SENT’, true);
}
fn_order_placement_routines($order_id, @$notify_user);
}
}
else {
$paypal_account = $processor_data[‘params’][‘account’];
$paypal_charsets = array (
‘big5’, ‘euc-jp’, ‘euc-kr’, ‘euc-tw’, ‘gb2312’, ‘gbk’, ‘hz-gb-2312’,
‘ibm-862’, ‘iso-2022-cn’, ‘iso-2022-jp’, ‘iso-2022-kr’, ‘iso-8859-1’,
‘iso-8859-2’, ‘iso-8859-3’, ‘iso-8859-4’, ‘iso-8859-5’, ‘iso-8859-6’,
‘iso-8859-7’, ‘iso-8859-8’, ‘iso-8859-9’, ‘iso-8859-13’, ‘iso-8859-15’,
‘koi8-r’, ‘shift_jis’, ‘utf-7’, ‘utf-8’, ‘utf-16’, ‘utf-16be’,
‘utf-16le’, ‘utf-32’, ‘utf-32be’, ‘utf-32le’, ‘us-ascii’,
‘windows-1250’, ‘windows-1251’, ‘windows-1252’, ‘windows-1253’,
‘windows-1254’, ‘windows-1255’, ‘windows-1256’, ‘windows-1257’,
‘windows-1258’, ‘windows-874’, ‘windows-949’, ‘x-mac-greek’,
‘x-mac-turkish’, ‘x-maccentraleurroman’, ‘x-mac-cyrillic’,
‘ebcdic-cp-us’, ‘ibm-1047’
);
global $languages, $cart_language, $http_location;
if (!empty($languages)) {
$paypal_charset = strtolower($languages[$cart_language][‘charset’]);
if (!in_array($paypal_charset, $paypal_charsets)) {
$paypal_charset = “ISO-8859-1”;
}
} else {
$paypal_charset = “ISO-8859-1”;
}
if ($processor_data[‘params’][‘mode’] == ‘test’) {
$paypal_url = “https://www.paymate.com/PayMate/TestExpressPayment?mid=testuser”;
} else {
$paypal_url = “https://www.paymate.com/PayMate/ExpressPayment?mid=photosales”;
}
$paypal_currency = $processor_data[‘params’][‘currency’];
$paypal_item_name = $processor_data[‘params’][‘item_name’];
//Order Total
$paypal_total = fn_format_price($order_info[‘total’] - fn_order_shipping_cost($order_info));
$paypal_shipping = fn_order_shipping_cost($order_info);
$paypal_order_id = $processor_data[‘params’][‘order_prefix’].(($order_info[‘repaid’]) ? ($order_id .'‘. $order_info[‘repaid’]) : $order_id);
$_phone = str_replace(array(’-‘,’(‘,’)‘,’ ‘), ‘’,$order_info[‘phone’]);
if (strlen($_phone) == 10) {
$_ph_a = substr($_phone, 0, 3);
$_ph_b = substr($_phone, 3, 3);
$_ph_c = substr($_phone, 6, 4);
} else {
$_ph_a = ‘555’;
$_ph_b = ‘555’;
$_ph_c = ‘5555’;
}
$msg = fn_get_lang_var(‘text_cc_processor_connection’);
$msg = str_replace(’[processor]', ‘PayPal’, $msg);
echo <<
EOT;
$i = 1;
// Products
if (!empty($order_info[‘items’])) {
foreach ($order_info[‘items’] as $k => $v) {
$suffix = ‘_’.($i++);
$v[‘product’] = htmlspecialchars($v[‘product’]);
$v[‘price’] = fn_format_price(($v[‘subtotal’] - fn_external_discounts($v)) / $v[‘amount’]);
echo <<
EOT;
if (!empty($v[‘product_options’])) {
foreach ($v[‘product_options’] as $_k => $_v) {
$_v[‘option_name’] = htmlspecialchars($_v[‘option_name’]);
$v[‘variant_name’] = htmlspecialchars($v[‘variant_name’]);
echo <<
EOT;
}
}
}
}
// Gift Certificates
if (!empty($order_info[‘gift_certificates’])) {
foreach ($order_info[‘gift_certificates’] as $k => $v) {
$suffix = '
$v[‘gift_cert_code’] = htmlspecialchars($v[‘gift_cert_code’]);
$v[‘amount’] = (!empty($v[‘extra’][‘exclude_from_calculate’])) ? 0 : $v[‘amount’];
echo <<
EOT;
}
}
// Payment surcharge
if (floatval($order_info[‘payment_surcharge’])) {
$suffix = '
$name = fn_get_lang_var(‘surcharge’);
echo <<
EOT;
}
echo <<
EOT;
fn_flush();
}
exit;
?> ```