v4.01 payment processor drama

Sorry for placing in the wrong forum but can't post it anywhere else. I'm using cscart v4 free mode and I would like to use “Mollie iDeal”. Therefore I modified the old plugin for v2 which isn't fully working yet. I can receive payments but it's not getting processed by cscart? (When customer has payed a order isn't created and when the payment is done the customer see: Ooops! something went wrong error.)



The following code is what is use where does it go wrong??


```php

//CSCART4
use Tygh\Http;
use Tygh\Registry;
if (defined('PAYMENT_NOTIFICATION')) {
if ($mode == 'notify') {
if(isset($_GET['order_id']) && isset($_GET['order_code']))
{
$sOrderId = $_GET['order_id'];
$sOrderCode = $_GET['order_code'];
$sql = "SELECT * FROM `" . TABLE_PREFIX . "transactions` WHERE (`order_id` = '" . addslashes($sOrderId) . "') AND (`order_code` = '" . addslashes($sOrderCode) . "') ORDER BY `id` DESC LIMIT 1;";
$aRecord = db_get_row($sql);
if($aRecord)
{
$pp_response['transaction_id'] = $aRecord['transaction_id'];
if (in_array($aRecord['transaction_status'], array('SUCCESS'))) {
$pp_response['order_status'] = 'P';
$pp_response['reason_text'] = 'Payment processed.';
} elseif (in_array($aRecord['transaction_status'], array('PENDING'))) {
$pp_response['order_status'] = 'O'; // still waiting for the response
$pp_response['reason_text'] = 'Payment open.';
} else {
$pp_response['order_status'] = 'F';
$pp_response['reason_text'] = 'Payment failed.';
}
fn_finish_payment($sOrderId, $pp_response, false);
fn_order_placement_routines($sOrderId);
}
}
}
} else {
// Load ideal utils
require_once(dirname(dirname(__FILE__)) . '/payments/ideal/config.php');
$aGatewaySettings = gateway_getSettings();
// Load gateway file
require_once($aGatewaySettings['GATEWAY_FILE']);
$sOrderId = $order_id;
$sOrderCode = GatewayCore::randomCode(32);
$sTransactionId = GatewayCore::randomCode(32);
$sTransactionCode = GatewayCore::randomCode(32);
$sTransactionMethod = $aGatewaySettings['GATEWAY_METHOD'];
$fTransactionAmount = number_format($order_info['total'], 2, '.', '');
$sTransactionDescription = 'Webshop bestelling';
$sTransactionPaymentUrl = Registry::get('config.current_location') . '/index.php?dispatch=payment_notification.notify&payment=ideal_checkout&order_id=' . $order_id . '&order_code=' . $sOrderCode;
//$sTransactionPaymentUrl = fn_url("payment_notification.notify?payment=ideal_checkout&order_id=$order_id", AREA, 'current');
$sTransactionSuccessUrl = $sTransactionPaymentUrl;
$sTransactionPendingUrl = $sTransactionPaymentUrl;
$sTransactionFailureUrl = $sTransactionPaymentUrl;
$aTransactionParams = array();
// Insert into #_transactions
$sql = "INSERT INTO `cscart_transactions` SET
`id` = NULL,
`order_id` = '" . addslashes($sOrderId) . "',
`order_code` = '" . addslashes($sOrderCode) . "',
`transaction_id` = '" . addslashes($sTransactionId) . "',
`transaction_code` = '" . addslashes($sTransactionCode) . "',
`transaction_method` = '" . addslashes($sTransactionMethod) . "',
`transaction_date` = '" . addslashes(time()) . "',
`transaction_amount` = '" . addslashes($fTransactionAmount) . "',
`transaction_description` = '" . addslashes($sTransactionDescription) . "',
`transaction_status` = NULL,
`transaction_url` = NULL,
`transaction_payment_url` = '" . addslashes($sTransactionPaymentUrl) . "',
`transaction_success_url` = '" . addslashes($sTransactionSuccessUrl) . "',
`transaction_pending_url` = '" . addslashes($sTransactionPendingUrl) . "',
`transaction_failure_url` = '" . addslashes($sTransactionFailureUrl) . "',
`transaction_params` = '" . addslashes(serialize($aTransactionParams)) . "',
`transaction_log` = NULL;";
db_query($sql);
echo '';
exit;
}
?>

```

You'll need to look at an XHR response in firebug (or similar browser) to see what the data is. More than likely it is a PHP Notice of some sort that's coming back from the server and the JS ajax parser is not prepared to ignore PHP notifications.

[quote name='tbirnseth' timestamp='1376794431' post='166988']

You'll need to look at an XHR response in firebug (or similar browser) to see what the data is. More than likely it is a PHP Notice of some sort that's coming back from the server and the JS ajax parser is not prepared to ignore PHP notifications.

[/quote]



Thanks for your reply, I also tryed an other payment processor (iDeal) and I get the exact same result. After selecting an bank and proceed with checkout I get a response which says that payment can't be done at the moment.



this is the other code:

```php

/***************************************************************************
* *
* Copyright (c) 2012 Sisow B.V. All rights reserved. *
* *
****************************************************************************/
//
// $Id: base.php 2011-05-24
//
use Tygh\Registry;
use Tygh\Http;
use Tygh\Session;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
include_once 'sisow.cls5.php';

if (defined('PAYMENT_NOTIFICATION')) {
$order_id = $_REQUEST['ec'];
if ($mode == 'return') {
if (fn_check_payment_script($filename.'.php', $order_id)) {
fn_order_placement_routines($order_id);
}
}
elseif ($mode == 'notify') {
$pp_response = array();
$payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i", $order_id);
$processor_data = fn_get_payment_method_data($payment_id);
$order_info = fn_get_order_info($order_id);
$sisow = new Sisow($processor_data['processor_params']['merchantid'], $processor_data['processor_params']['merchantkey']);
$trxid = $_REQUEST['trxid'];
if ($sisow->StatusRequest($trxid) != 0) {
exit('StatusRequest failed');
}
$pp_response['transaction_id'] = $trxid;
if ($sisow->status == Sisow::statusSuccess || $sisow->status == 'Pending' || $sisow->status == 'Reservation') {
if (isset($processor_data['processor_params']['statussuccess']) && $processor_data['processor_params']['statussuccess'] != "") {
$st = $processor_data['processor_params']['statussuccess'];
}
else {
$st = 'P';
}
$pp_response['order_status'] = $st;
$pp_response['reason_text'] = 'Approved by Sisow';
$pp_response['consumerAccount'] = $sisow->consumerAccount;
$pp_response['consumerName'] = $sisow->consumerName;
$pp_response['consumerCity'] = $sisow->consumerCity;
}
else {
if (isset($processor_data['processor_params']['statusfailed']) && $processor_data['processor_params']['statusfailed'] != "") {
$st = $processor_data['processor_params']['statusfailed'];
}
else {
$st = 'I';
}
$pp_response['order_status'] = $st;
$pp_response['reason_text'] = $sisow->status;
}
//fn_change_order_status($data['order'], $pp_response['order_status'], '', $force_notification);
if (fn_check_payment_script($filename.'.php', $order_id)) {
fn_finish_payment($order_id, $pp_response, false);
}

if($_GET['payment'] == 'sisowob' || $_GET['payment'] == 'sisowebill' || $_GET['payment'] == 'sisowecare')
{
if (fn_check_payment_script($filename.'.php', $order_id)) {
fn_order_placement_routines($order_id);
}
}
}
exit;
}
else
{
echo 'payment logo ';
$arg = array();
$currency = $processor_data['processor_params']['currency'];
$amount = round(fn_format_price($order_info['total'], $currency) , 2);

//wanneer ideal is geselecteerd
//actie: controleren of er een bankkeuze is gemaakt
//uitvoer: bij geen bankkeuze wordt er een foutmelding gegeven en een redirect geplaatst
if($paymentcode == 'ideal' && (!isset($order_info['payment_info']['issuerid']) || $order_info['payment_info']['issuerid'] == ''))
{
fn_set_notification('E', fn_get_lang_var('warning'), 'Kies een bank', false, 'no_bank');
fn_redirect(Registry::get('config.current_location') . "/index.php?dispatch=checkout.checkout&order_id=".$order_id, true);
exit;
}

//wanneer ecare is geselecteerd
//actie: controleren of alle gegevens aanwezig zijn
//uitvoer: bij onjuiste gegevens wordt er een foutmelding gegeven en een redirect geplaatst
if($paymentcode == 'ecare' && ($order_info['payment_info']['sisow_gender'] == '' || $order_info['payment_info']['sisow_voor'] == '' || $order_info['payment_info']['days'] < 0 || $order_info['payment_info']['days'] > 31 || $order_info['payment_info']['month'] < 0 || $order_info['payment_info']['month'] > 12 || $order_info['payment_info']['year'] == ''))
{
if($order_info['payment_info']['sisow_gender'] == '')
fn_set_notification('E', fn_get_lang_var('warning'), 'Kies een aanhef', false, 'no_gender');

if($order_info['payment_info']['sisow_voor'] == '')
fn_set_notification('E', fn_get_lang_var('warning'), 'Vul uw voorletter(s) in.', false, 'no_initials');

if($order_info['payment_info']['days'] < 0 || $order_info['payment_info']['days'] > 31 || $order_info['payment_info']['month'] < 0 || $order_info['payment_info']['month'] > 12 || $order_info['payment_info']['year'] == '')
fn_set_notification('E', fn_get_lang_var('warning'), 'Vul een juiste geboortedatum in.', false, 'invalid_date');

fn_redirect(Registry::get('config.current_location') . "/index.php?dispatch=checkout.checkout&order_id=".$order_id, true);
exit;
}
//alle variabelen zetten voor de betaling
{
$arg['ipaddress'] = $_SERVER['REMOTE_ADDR'];
$arg['shipping_firstname'] = $order_info['s_firstname'];
$arg['shipping_lastname'] = $order_info['s_lastname'];
$arg['shipping_mail'] = $order_info['email'];
//$arg['shipping_company'] = $order_info[''];
$arg['shipping_address1'] = $order_info['s_address'];
$arg['shipping_address2'] = $order_info['s_address_2'];
$arg['shipping_zip'] = $order_info['s_zipcode'];
$arg['shipping_city'] = $order_info['s_city'];
//$arg['shipping_country'] = $order_info[''];
$arg['shipping_countrycode'] = $order_info['s_country'];
$arg['shipping_phone'] = $order_info['s_phone'];
$arg['shipping'] = $order_info['shipping_cost'];

$arg['billing_firstname'] = $order_info['b_firstname'];
$arg['billing_lastname'] = $order_info['b_lastname'];
$arg['billing_mail'] = $order_info['email'];
//$arg['billing_company'] = $order_info[''];
$arg['billing_address1'] = $order_info['b_address'];
$arg['billing_address2'] = $order_info['b_addresb_2'];
$arg['billing_zip'] = $order_info['b_zipcode'];
$arg['billing_city'] = $order_info['b_city'];
//$arg['billing_country'] = $order_info[''];
$arg['billing_countrycode'] = $order_info['b_country'];
$arg['billing_phone'] = $order_info['b_phone'];


//ecare
//extra variabelen zetten voor ecare
if($paymentcode == 'ecare')
{
if($order_info['payment_info']['year'] < 100)
{
$jaar = $order_info['payment_info']['year'] + 1000;
}
else
{
$jaar = $order_info['payment_info']['year'];
}
$arg['birthdate'] = sprintf('%02d%02d%04d', $order_info['payment_info']['days'], $order_info['payment_info']['month'], $jaar);
$arg['gender'] = $order_info['payment_info']['sisow_voor'];
$arg['initials'] = $order_info['payment_info']['sisow_gender'];
$arg['makeinvoice'] = 'false';
$arg['mailinvoice'] = 'false';

if($order_info['payment_method']['processor_params']['makeinvoice'] == 'on')
$arg['makeinvoice'] = 'true';

if($order_info['payment_method']['processor_params']['mailinvoice'] == 'on')
$arg['mailinvoice'] = 'true';
}

//producten en taxes
//kijken hoeveel btw aanwzig is
$arg['tax'] = 0;
foreach ($order_info['taxes'] as $tax)
{
$arg['tax'] += $tax['tax_subtotal'];
}

$arg['currency'] = $order_info['payment_method']['processor_params']['currency'];


//producten
//producten ophalen en prijzen berekenen
$prodnr = 0;
foreach($order_info['items'] as $product)
{
$prodnr ++;

$arg['product_id_'.$prodnr] = $product['product_code'];
$arg['product_description_'.$prodnr] = $product['product'];
$arg['product_quantity_'.$prodnr] = $product['amount'];

$netprice = fn_format_price($product['price'], $currency);
$taxrate = 0;

$product_data = fn_get_product_data($product['product_id'], $_SESSION['auth'], $order_info['lang_code'], '', true, true, true, true, false, true, true);

foreach ($order_info['taxes'] as $key => $tax)
{
if(in_array($key, $product_data['taxes']) && $tax['price_includes_tax'] == 'Y')
{
if($tax['rate_type'] == 'P')
{
$netprice = ($netprice * 100.0) / (100.0 + $tax['rate_value']);
}
}
}

$arg['product_netprice_'.$prodnr] = round($netprice * 100.0, 0);
$arg['product_nettotal_'.$prodnr] = $arg['product_netprice_'.$prodnr] * $arg['product_quantity_'.$prodnr];

$total = $arg['product_nettotal_'.$prodnr];
$taxrate = 0;
foreach ($order_info['taxes'] as $key => $tax)
{
if(in_array($key, $product_data['taxes']))
{
if($tax['rate_type'] == 'P')
{
$total = $total * ((100.0 + $tax['rate_value']) / 100.0);
$taxrate += ($tax['rate_value'] * 100.0);
}
}
}
$total = round($total, 0);

$arg['product_total_'.$prodnr] = $total;
$arg['product_taxrate_'.$prodnr] = $taxrate;

$arg['product_tax_'.$prodnr] = $arg['product_total_'.$prodnr] - $arg['product_nettotal_'.$prodnr];
}

//producten
//verzendkosten toevoegen aan de producten
if($order_info['shipping_cost'] > 0)
{
$prodnr ++;

$arg['product_id_'.$prodnr] = 'Shipping';
$arg['product_description_'.$prodnr] = 'Verzendkosten';
$arg['product_quantity_'.$prodnr] = '1';

$netprice = fn_format_price($order_info['shipping_cost'], $currency);

foreach ($order_info['taxes'] as $key => $tax)
{
if($tax['applies']['S'] > 0 && $tax['price_includes_tax'] == 'Y')
{
if($tax['rate_type'] == 'P')
{
$netprice = $netprice /((100.0 + $tax['rate_value']) / 100);
}
}
}

$taxamount = 0;
$taxrate = 0;
foreach ($order_info['taxes'] as $key => $tax)
{
if($tax['applies']['S'] > 0)
{
if($tax['rate_type'] == 'P')
{
$taxamount += $netprice * ($tax['rate_value'] / 100);
$taxrate += $tax['rate_value'];
}
}
}
$arg['product_netprice_'.$prodnr] = round($netprice * 100.0, 0);
$arg['product_total_'.$prodnr] = round(($netprice + $taxamount) * 100.0, 0);
$arg['product_nettotal_'.$prodnr] = $arg['product_netprice_'.$prodnr];
$arg['product_tax_'.$prodnr] = round($taxamount * 100.0, 0);
$arg['product_taxrate_'.$prodnr] = round($taxrate * 100.0, 0);
}

//producten
//payment fee toevoegen aan de producten
if( isset($order_info['payment_surcharge']) && $order_info['payment_surcharge'] > 0)
{
$prodnr ++;

$arg['product_id_'.$prodnr] = 'Fee';
$arg['product_description_'.$prodnr] = 'Paymentfee';
$arg['product_quantity_'.$prodnr] = '1';

$netprice = fn_format_price($order_info['payment_surcharge'], $currency);

foreach ($order_info['taxes'] as $key => $tax)
{
if(in_array($key, $order_info['payment_method']['tax_ids']) && $tax['price_includes_tax'] == 'Y')
{
if($tax['rate_type'] == 'P')
{
$netprice = $netprice /((100.0 + $tax['rate_value']) / 100);
}
}
}

$taxamount = 0;
$taxrate = 0;
foreach ($order_info['taxes'] as $key => $tax)
{
if(in_array($key, $order_info['payment_method']['tax_ids']))
{
if($tax['rate_type'] == 'P')
{
$taxamount += $netprice * ($tax['rate_value'] / 100);
$taxrate += $tax['rate_value'];
}
}
}
$arg['product_netprice_'.$prodnr] = round($netprice * 100.0, 0);
$arg['product_total_'.$prodnr] = round(($netprice + $taxamount) * 100.0, 0);
$arg['product_nettotal_'.$prodnr] = $arg['product_netprice_'.$prodnr];
$arg['product_tax_'.$prodnr] = round($taxamount * 100.0, 0);
$arg['product_taxrate_'.$prodnr] = round($taxrate * 100.0, 0);
}

//producten
//eventuele korting toevoegen
if(isset($order_info['discount']) && $order_info['discount'] > 0)
{
$prodnr ++;

$arg['product_id_'.$prodnr] = 'Disc';
$arg['product_description_'.$prodnr] = 'Koring';
$arg['product_quantity_'.$prodnr] = '1';
$arg['product_netprice_'.$prodnr] = round(fn_format_price($order_info['discount'], $currency) * 100.0, 0);
$arg['product_total_'.$prodnr] = $arg['product_netprice_'.$prodnr];
$arg['product_nettotal_'.$prodnr] = $arg['product_netprice_'.$prodnr];
$arg['product_tax_'.$prodnr] = '0';
$arg['product_taxrate_'.$prodnr] = '0';
}

//omschrijving inladen
if (isset($processor_data['processor_params']['description']) && $processor_data['processor_params']['description'] != "") {
$descr = str_replace("ORDER_ID", $order_id, $processor_data['processor_params']['description']);
}
else {
$descr = "Order " . $order_id;
}

//urls voor terugkoppeling inladen
$notifyurl = Registry::get('config.current_location') . "/index.php?dispatch=payment_notification.notify&payment=".$filename;
$returnurl = Registry::get('config.current_location') . "/index.php?dispatch=payment_notification.return&payment=".$filename;

//kijken of de testmodues geactiveerd moet worden
if ($processor_data['processor_params']['test'] == 'on') {
$arg['test'] = 'true';
}
else {
$arg['test'] = 'false';
}

//class sisow inladen en ontbrekene attributen inladen
$sisow = new Sisow($processor_data['processor_params']['merchantid'], $processor_data['processor_params']['merchantkey']);
$sisow->amount = $amount;
$sisow->payment = $paymentcode;
$sisow->purchaseId = $order_id;
$sisow->description = $descr;
$sisow->notifyUrl = $notifyurl;
$sisow->returnUrl = $returnurl;

if(isset($order_info['payment_info']['issuerid']) && $order_info['payment_info']['issuerid'] > 0)
$sisow->issuerId = $order_info['payment_info']['issuerid'];

//transaction request starten!
if(($ex = $sisow->transactionRequest($arg)) < 0)
{
fn_set_notification('E', fn_get_lang_var('warning'), 'Betalen met '.$order_info['payment_method']['payment'].' is nu niet mogelijk, betaal anders. ('. $ex . ', ' . $sisow->errorCode . ')' , false, 'invalid_date');
fn_redirect(Registry::get('config.current_location') . "/index.php?dispatch=checkout.checkout&order_id=".$order_id, true);
}
else
{
$url = $sisow->issuerUrl;

if($paymentcode == 'ebill' || $paymentcode == 'overboeking' || $paymentcode == 'ecare')
{
if(($sisow->StatusRequest()) < 0)
{
fn_set_notification('E', fn_get_lang_var('warning'), 'Betalen met '.$order_info['payment_method']['payment'].' is nu niet mogelijk, betaal anders. ('. $ex . ', ' . $sisow->errorCode . ')' , false, 'invalid_date');
fn_redirect(Registry::get('config.current_location') . "/index.php?dispatch=checkout.checkout&order_id=".$order_id, true);
}
else
{
//$url = $returnurl;
$url = Registry::get('config.current_location') . "/index.php?dispatch=payment_notification.notify&payment=".$filename."&status=".$sisow->status."&trxid=".$sisow->trxId."&ec=".$order_id;
}
}
?>

	   
}
exit;
}
}
?>

```



Here is the error message:


//transaction request starten!
if(($ex = $sisow->transactionRequest($arg)) < 0)
{
fn_set_notification('E', fn_get_lang_var('warning'), 'Betalen met '.$order_info['payment_method']['payment'].' is nu niet mogelijk, betaal anders. ('. $ex . ', ' . $sisow->errorCode . ')' , false, 'invalid_date');
fn_redirect(Registry::get('config.current_location') . "/index.php?dispatch=checkout.checkout&order_id=".$order_id, true);
}

dumping the code on here doesn't help without the PHP notification of the problem/line that is causing the message.