Zen Cart Logo
Forums / Addon Payment Modules / Developing a new payment module for Posnet - need a professional advice!

Developing a new payment module for Posnet - need a professional advice!

Locked

Views: 2,226

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
4 Dec 2009, 11:26 AM
#1
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Developing a new payment module for Posnet - need a professional advice!

I am a newbie in Zencart, but that did not discourage me from commencing to design a new credit card payment module! :flex:
(Well, to be honnest, i have mostly converted it from Paypal's payment module :wink:
Nevertheless, i have some issues that i need desperate help
:frusty:

The cc payment module works for a local bank here, in the way that the customer is directed to the banks payment page. Upon entering the details, customer is redirected back to the site (but not the zencart store) where a local php file asks for confirmation, and back to the bank, and finally back to the site again, with success or failure code. Now, this part is performed by an already existing PHP code given by the bank -and i have slightly modified it - so no trouble with this.

I have written an additional piece of code -posnet_merchant_return.php - which more or less works a bit like paypal's ipn_main_handler. Upon completion of the payment process, posnet_merchant_retrurn redirects to the Checkout Process page by:

zen_redirect(zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=posnetoos&stat=success&xid=' . $oosData['XID'] , 'SSL'));

It works fine in the way the checkout success or failure information is presented in the zencart store, and an order e-mail is being produced etc. However, the cart items are being confused. The items that seems to be sold are totally different.

I am probably doing something really silly, but i have no idea of what it is :unsure:

Can somebody tell me what do i need to do (what parameters to pass) along with the html redirect so that correct order is generated!
Thanks for any kind of help in advance!

4 Dec 2009, 11:37 AM
#2
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Developing a new payment module for Posnet - need a professional advice!

By the way, I recognized that in ipn_main_handler the order creation is done within this exteranal routine:

zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
    if ($extraDebug) ipn_debug_email('Breakpoint: 5k - OSH update done');
    $order->create_add_products($insert_id, 2);
    if ($extraDebug) ipn_debug_email('Breakpoint: 5L - adding products');
    $order->send_order_email($insert_id, 2);
    if ($extraDebug) ipn_debug_email('Breakpoint: 5m - emailing customer');
    $_SESSION['cart']->reset(true);
    if ($extraDebug) ipn_debug_email('Breakpoint: 5n - emptying cart');

I have recognized this sytem, but have not adoped it, since i didn't know how to commence after this, i mean which page to call? I have concluded that redirecting to checkout_success was a more reasonable way? Or is it?

9 Dec 2009, 9:28 PM
#3
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Developing a new payment module for Posnet - need a professional advice!

Forgot to mention earlier that I am using Zencart version 1.3.8a.
My site is on a Linux machine with Apache 2 server where PHP 5.2.9 and MySQL 5.0.77 is running.

Now i have read in another thread http://www.zen-cart.com/forum/showthread.php?t=86662 where its suggested that the session may need to be recreated, however i do not think that it is my exact problem, because i am checking in debug mode zen session id is correct, however when the order is placed the customer name and contents are totally wrong.
Any ideas I would really appreciate! :cry:

11 Dec 2009, 9:08 AM
#4
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Developing a new payment module for Posnet - need a professional advice!

Well, i will continue my monolog and hope somebody is listening:

I have made the following test:
I have email logged zen_session_id() and $_SESSION['customer_id'] to see where the session information is lost.
It seems that the session id is always correct, however $_SESSION['customer_id'] is lost/changed somewhere along the way.
The customer id is correct last in the payment module's process_button() function. After here there is a browser redirect to the payment gateway address as it is given by form_action_url.

Now, upon return from the payment gateway (and some intermediate files which are isolated from Zen-store) posnet_merchant_return.php is called. As i mentioned earlier this is cloned and modified from ipn_main_handler.php.
In almost beginning of posnet_merchant_return.php application_top is included:

/**
 * Include custom application_top.php
 */
$show_all_errors = true;
$current_page_base = 'posnetoos';
$loaderPrefix = 'posnet_oos';

require('includes/application_top.php');

So, $_SESSION['customer_id'] is changed/lost right after that.
Is it possible to mess up logged in customer with application_top initalization?!

(There is also a posnet_oos.core.php file present in the auto_loaders folder, which only loads some extra functions in breakpoint 60!)

/**
 * Breakpoint 60.
 * 
 * require('includes/init_includes/init_general_funcs.php'); 
 * require('includes/init_includes/init_tlds.php'); 
 * 
 */
  $autoLoadConfig[60][] = array('autoType'=>'init_script',
                                'loadFile'=> 'init_general_funcs.php');
  $autoLoadConfig[60][] = array('autoType'=>'init_script',
                                'loadFile'=> 'init_tlds.php');
/**
 * Include Posnet-specific functions
 * require('includes/modules/payment/posnet/posnet_functions.php');
 */

  $autoLoadConfig[60][] = array('autoType'=>'include',
                                'loadFile'=> DIR_WS_MODULES . 'payment/posnet/posnet_functions.php');
12 Dec 2009, 9:30 AM
#5
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

Re: Developing a new payment module for Posnet - need a professional advice!

Actually i lied, there is one another change at posnet_oos.core.php at breakpoint 70:

/**
 * Breakpoint 70.
 * 
 * require('includes/init_includes/init_sessions.php'); 
 * 
 */
  $autoLoadConfig[70][] = array('autoType'=>'init_script',
                                'loadFile'=> 'init_sessions.php');
  $autoLoadConfig[71][] = array('autoType'=>'init_script',
                                'loadFile'=> 'init_posnet_oos_sessions.php');

the init_posnet_oos_sessions.php function there has a paypal ipn inherited function (ipn_get_stored_session) which modifies the session! Somehow it had got a wrong variable, and the session was mixed :smartalec:
So, this concludes my monologue!