function after_process() { global $_GET; $data = ''; if (isset($_POST['Status'])) { $_GET = $_POST; } foreach ($_GET as $key => $value) { $data .= $key . ': ' . "\n"; $data .= $value . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("icepay", "' . $data . '", NOW())'); tep_db_query('DELETE FROM payment_log WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY)'); switch ($_GET["Status"]) { case "OK": if ($order->info['order_status'] == MODULE_PAYMENT_ICEPAY_ORDER_STATUS_ID || $order->info['order_status'] == MODULE_PAYMENT_ICEPAY_OPEN_ORDER_STATUS_ID) { send_order_mail($_GET['OrderID']); } tep_db_query('UPDATE orders SET orders_status = "' . MODULE_PAYMENT_ICEPAY_SUCCESS_ORDER_STATUS_ID . '" WHERE orders_id = "' . $_GET['OrderID'] . '"'); break; case "OPEN": //send_order_mail($_GET['OrderID']); tep_db_query('UPDATE orders SET orders_status = "' . MODULE_PAYMENT_ICEPAY_OPEN_ORDER_STATUS_ID . '" WHERE orders_id = "' . $_GET['OrderID'] . '"'); break; case "ERR": tep_db_query('UPDATE orders SET orders_status = "' . MODULE_PAYMENT_ICEPAY_CANCELLED_ORDER_STATUS_ID . '" WHERE orders_id = "' . $_GET['OrderID'] . '"'); send_order_error_mail(Translate('Icepay betaling geannuleerd voor bestelling') . ': ' . $_GET['OrderID'], sprintf(Translate('De betaling voor bestelling %s is geannuleerd.'), $_GET['OrderID'])); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); break; case "REFUND": tep_db_query('UPDATE orders SET orders_status = "' . MODULE_PAYMENT_ICEPAY_REFUND_ORDER_STATUS_ID . '" WHERE orders_id = "' . $_GET['OrderID'] . '"'); send_order_error_mail(Translate('Icepay terugbetaling voor bestelling') . ': ' . $_GET['OrderID'], sprintf(Translate('De betaling voor bestelling %s is terugbetaald.'), $_GET['OrderID'])); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); break; case "CBACK": tep_db_query('UPDATE orders SET orders_status = "' . MODULE_PAYMENT_ICEPAY_CHARGEBACK_ORDER_STATUS_ID . '" WHERE orders_id = "' . $_GET['OrderID'] . '"'); send_order_error_mail(Translate('Icepay terugboeking voor bestelling') . ': ' . $_GET['OrderID'], sprintf(Translate('Voor bestelling %s is een terugboeking aangevraagd.'), $_GET['OrderID'])); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); break; case "VALIDATE": tep_db_query('UPDATE orders SET orders_status = 29 WHERE orders_id = "' . $_GET['OrderID'] . '"'); send_order_error_mail(Translate('Wachten op Icepay validatie') . ': ' . $_GET['OrderID'], sprintf(Translate('Voor bestelling %s wordt nog op validatie gewacht.'), $_GET['OrderID'])); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); break; } if (isset($_POST['Status'])) { die; } return false; }
function after_process() { global $_GET; tep_db_query('DELETE FROM payment_log WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY)'); $req = 'cmd=_notify-synch'; $tx_token = $_GET['tx']; $auth_token = PAYPAL_PDT_ID; $req .= "&tx={$tx_token}&at={$auth_token}"; $header = ''; $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') { $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); } else { $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30); } if (!$fp) { $data = ''; foreach ($_GET as $key => $value) { $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($value) . "\n\n"; } $order_id = substr($_GET['cm'], strpos($_GET['cm'], '[-]') + 3); tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("paypal", "' . $data . '", NOW())'); send_order_error_mail(Translate('Er is iets fout gelopen met paypal bestelling') . ' ' . $order_id, sprintf(Translate('Voor bestelling %s is er een fout gegenereerd! Controleer dit a.u.b. voordat u deze bestelling verder verwerkt.<br />Als u vragen hebt i.v.m. de fout contacteer dan ABO Service!'), $order_id)); } else { fputs($fp, $header . $req); $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets($fp, 1024); if (strcmp($line, "\r\n") == 0) { $headerdone = true; } else { if ($headerdone) { $res .= $line; } } } $lines = explode("\n", $res); $keyarray = array(); $data = ''; if (strcmp($lines[0], "SUCCESS") == 0) { for ($i = 1; $i < count($lines); $i++) { list($key, $val) = explode("=", $lines[$i]); $keyarray[urldecode($key)] = urldecode($val); $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($val) . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("paypal", "' . $data . '", NOW())'); if (empty($keyarray['invoice'])) { $order_id = substr($keyarray['custom'], strpos($keyarray['custom'], '[-]') + 3); } else { $order_id = $keyarray['invoice']; } /*COMPLETED OR PROCESSED*/ if ($keyarray['payment_status'] == 'Completed' || $keyarray['payment_status'] == 'Processed') { send_order_mail($order_id); tep_db_query('UPDATE orders SET orders_status = 1 WHERE orders_id = "' . $order_id . '"'); /*EXPIRED*/ } else { if ($keyarray['payment_status'] == 'Expired') { send_order_mail($order_id); send_order_error_mail(Translate('Status onzeker paypal bestelling') . ': ' . $order_id, sprintf(Translate('De status voor bestelling %s is onzeker doordat de autorisatie verlopen was op het moment dat de klant terug op de shop kwam.'), $order_id)); tep_db_query('UPDATE orders SET orders_status = 21 WHERE orders_id = "' . $order_id . '"'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); /*FAILED*/ } else { if ($keyarray['payment_status'] == 'Failed') { tep_db_query('UPDATE orders SET orders_status = 22 WHERE orders_id = "' . $order_id . '"'); tep_redirect(tep_href_link(FILENAME_CHECKOUT_ERROR, '', 'SSL')); /*PENDING*/ } else { if ($keyarray['payment_status'] == 'Pending') { send_order_mail($order_id); send_order_error_mail(Translate('Afwachten betaling paypal bestelling') . ': ' . $order_id, sprintf(Translate('Voor bestelling %s is de betaling nog niet bevestigd! Controleer dit a.u.b. voordat u deze bestelling verder verwerkt.'), $order_id)); } } } } } else { if (strcmp($lines[0], "FAIL") == 0) { for ($i = 1; $i < count($lines); $i++) { list($key, $val) = explode("=", $lines[$i]); $data .= urldecode($key) . ': ' . "\n"; $data .= urldecode($val) . "\n\n"; } tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("paypal", "' . $data . '", NOW())'); send_order_error_mail(Translate('Er is iets fout gelopen met paypal bestelling') . ' ' . $order_id, sprintf(Translate('Voor bestelling %s is er een fout gegenereerd! Controleer dit a.u.b. voordat u deze bestelling verder verwerkt.<br />Als u vragen hebt i.v.m. de fout contacteer dan ABO Service!'), $order_id)); } } } fclose($fp); return false; }