Forums / Addon Payment Modules / Create a new module for International Checkout payment module

Create a new module for International Checkout payment module

Locked

Started by icecold on 3 Dec 2009, 8:09 PM · Views: 13,224

Results 41 to 60 of 64
This thread is locked. New replies are disabled.
5 Apr 2010, 2:52 PM
#41
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Create a new module for International Checkout payment module

I have errors and the admin section is not listing the module as expected, I am not sure if there is a problem with a parameter, that fails to create the entries in the config file.

Here is the script so far:

check function

function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_IC_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }

Install function

function install() {
 	global $db;

   $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable International Checkout Module', 'MODULE_PAYMENT_IC_STATUS', 'True', 'Do you want to accept International Checkout payments?', '6', '130', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_IC_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '131' , now())");
 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Checkout Company ID', 'MODULE_PAYMENT_IC_COMPANY', '', 'Company used for International Checkout payments', '6', '132', now())");
}
function remove() {
   $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 }
function keys() {
    return array('MODULE_PAYMENT_IC_STATUS', 'MODULE_PAYMENT_IC_SORT_ORDER', 'MODULE_PAYMENT_IC_COMPANY');

When I move it to includes/modules/payment/ I get errors and nothing is written to the db ...

5 Apr 2010, 3:35 PM
#42
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

Apparently the problem was a missing language file ... but I still have another error in one of the loops that traverses the product array and creates the form:

foreach ($productArray as $product) {
	
     // Comment the string until it has proper form
	 
	 $process_button_string = zen_draw_hidden_field('ItemQuantity',$product['quantityField'] . 
							  zen_draw_hidden_field('ItemImage',$product['productsImage']) . 
				              zen_draw_hidden_field('ItemDescription',$product['productsName']) . 
							  zen_draw_hidden_field('ItemPrice',$product['productsPrice']);

// echo $process_button_string;



     // $process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
      return $process_button_string;
    }

I get a parsing error unexpected semicolon at the end of the active $process_button_string,
don't know why, is the syntax wrong?

5 Apr 2010, 3:58 PM
#43
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

Looks like you're missing a closing parenthesis on your ItemQuantity line.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Apr 2010, 6:41 PM
#45
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

ok, the module is now listed in Admin, so the next step will be to go into testing phase, to see if the values are retrieved from the shopping cart and the string properly filled, but what should I use to draw a button(use an image), linked to the process button class? I mean do I have to make it separately from the class?

5 Apr 2010, 6:42 PM
#46
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

You don't. The submit button on the page takes care of that for you.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Apr 2010, 7:38 PM
#47
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

You don't. The submit button on the page takes care of that for you.

Do you mean the SUBMIT button in the shopping cart page?
but I need to draw a new button, such as the one Google Checkout does, before going to checkout, I was looking all google checkout and Paypal files to see how they do it, but couldn't find a single reference?

My class supposed to do this:

Read and list all products and image locations from the cart plus the company's id and session's id, after that is ready submit the hidden fields, using an image submit.

So far the module is installed but don't know where I can place the code for the button. I noticed a nice Install button in Admin as soon as the class was listed and recognized, but what I need is the submit button for the end user to click, this button is a custom image ...

5 Apr 2010, 7:45 PM
#48
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

I was referring to the Submit button on the checkout-confirmation page. That's what uses the process_button() "function".

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Apr 2010, 8:09 PM
#49
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

I was referring to the Submit button on the checkout-confirmation page. That's what uses the process_button() "function".

ok, but that draws the standard checkout button pages, and that is not what I want, I need to draw a button below the cart the way paypal and google checkout do, because the standard checkout process, has to be avoided, the only thing my process_button() method(sorry for the function thing), needs to do is submit these data, using a custom International Checkout button, that will not interfere with the standard checkout process. That's why I wanted to know if the code can go withing the class or I have to write in other file, or somewhere in the shopping cart.

5 Apr 2010, 8:28 PM
#50
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

icecold:

ok, but that draws the standard checkout button pages, and that is not what I want, I need to draw a button below the cart the way paypal and google checkout do, because the standard checkout process, has to be avoided, the only thing my process_button() method(sorry for the function thing), needs to do is submit these data, using a custom International Checkout button, that will not interfere with the standard checkout process.LOL - sounds like it is absolutely interfering with the standard checkout process, by bypassing it entirely!
icecold:

That's why I wanted to know if the code can go withing the class or I have to write in other file, or somewhere in the shopping cart.I don't know how GC does it.
The PayPal button is simply drawn within the template where it's required.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Apr 2010, 9:05 PM
#51
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

LOL - sounds like it is absolutely interfering with the standard checkout process, by bypassing it entirely!
I don't know how GC does it.
The PayPal button is simply drawn within the template where it's required.

Lol, it does :blush:

ok, so that's std way GC process_button() is empty!

BTW is there an easier such as writing the code in a separate file and require it or inside the class?

Because in my case I just need to write button the way Paypal does, but there is no need for a handler.

5 Apr 2010, 9:18 PM
#52
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

I don't see why you couldn't do it that way.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

5 Apr 2010, 11:23 PM
#53
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

I don't see why you couldn't do it that way.

I read Paypal files, and the Paypal template button file, and is calling ipn_main_handler.php, linking to it,

<div id="PPECbutton" class="buttonRow">
  <a href="<?php echo zen_href_link('ipn_main_handler.php', 'type=ec', 'SSL', true, true, true); ?>"><img src="<?php echo MODULE_PAYMENT_PAYPALWPP_EC_BUTTON_IMG ?>" alt="<?php echo MODULE_PAYMENT_PAYPALWPP_TEXT_BUTTON_ALTTEXT; ?>" /></a>
</div>

so in my case do you you think if I link directly to my payment class will work? Won't it try to write to CONFIGURE table and return an error?

I know you can instantiate a class, but my understanding of PHP Objects is still limited, so I am not sure how that will behave, If that specific method will make a new conflict ... or if I can have new instance, and don't worry about it ...

5 Apr 2010, 11:48 PM
#54
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

icecold:

I read Paypal files, and the Paypal template button file, and is calling ipn_main_handler.php, linking to it,

so in my case do you you think if I link directly to my payment class will work? Won't it try to write to CONFIGURE table and return an error?

I know you can instantiate a class, but my understanding of PHP Objects is still limited, so I am not sure how that will behave, If that specific method will make a new conflict ... or if I can have new instance, and don't worry about it ...

Sorry I forgot to mention this code is inside Paypal's button template, the tpl_shopping_cart_default, just links to this template.

6 Apr 2010, 2:31 AM
#55
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

Yes, but that's just the URL that the button goes to when you click it. You don't need to use ipn_main_handler or anything like that. Use whatever you want for your unique needs. PayPal does way more than what you're talking about, so has only marginal similarities to your needs.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Apr 2010, 3:25 AM
#56
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

Yes, but that's just the URL that the button goes to when you click it. You don't need to use ipn_main_handler or anything like that. Use whatever you want for your unique needs. PayPal does way more than what you're talking about, so has only marginal similarities to your needs.

ok I managed to display the nice button ... but when I click the link I got a permission problem ...

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
https://www.store.com
04/06/10 00:22:47
Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6

6 Apr 2010, 5:43 PM
#57
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

icecold:

ok I managed to display the nice button ... but when I click the link I got a permission problem ...

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
https://www.store.com
04/06/10 00:22:47
Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6

I fixed the problem but now I get a blank page I created a handler, where the class is instantiated and echoed some vars inside the class, but the output is a black screen ...

I draw the button and call the handler using a link

<div id="ICbutton" class="buttonRow">
  <a href="<?php echo zen_href_link('ic_main_handler.php', 'type=ic', 'NONSSL', true, true, true); ?>"><img src="<?php echo MODULE_PAYMENT_IC_BUTTON_IMG; ?>" alt="<?php echo MODULE_PAYMENT_IC_TEXT_BUTTON_ALTTEXT; ?>" /></a>
</div>

Here is my handler's code(I am not sure those requires are needed, tested both ways and same result, blank page):

/**
 * handle International Checkout processing:
 */
if (isset($_GET['type']) && $_GET['type'] == 'ic') {
  // this is an ic handler request
//  require('includes/application_top.php');
//  require(DIR_WS_CLASSES . 'payment.php');
 
  // See if the ic module is enabled.
  if (defined('MODULE_PAYMENT_IC_STATUS') && MODULE_PAYMENT_IC_STATUS == 'True') {
    $ic_module = 'ic';
    // init the payment object
    $payment_modules = new ic();
	$payment_modules->ic();
	//Test class internal vars
	
	echo $payment_modules->test; // Test variable assigned with a value to check output
	echo $payment_modules->code;
	echo $payment_modules->title;
	echo $payment_modules->description;
	echo $payment_modules->enabled;
	
	
   
   
    }
  }

I even created a $test var inside the class and echoed it in the handler along with some variables, to see if I can get some output but it's not working ...

18 Apr 2010, 11:27 PM
#58
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

I can't get any values from the vars inside the shopping cart, inside my method process_button I tested the $_SESSION['cart'] and it returned true for both is set and is an object ...
but $products is still empty ...

 function process_button() {
    global $products, $currencies;
    //Test and return
      if (isset($_SESSION['cart'])) {echo 'Session variable is already created.';}
else {echo 'Session variable is not yet created.';}
if (is_object($_SESSION['cart'])) {echo 'Session variable is an object type.';}
else {echo 'Session variable is not an object type.';} 
    echo"<br />";
   
   
    $products = $_SESSION['cart']->get_products();
    echo $products; 
    return; // test if anything is inside $products so far is empty
19 Apr 2010, 7:39 PM
#59
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Create a new module for International Checkout payment module

get_products() will return an array ... which you can't display by merely using echo(). You would need to echo print_r($products, TRUE) if you wanted to see the array contents that way

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Apr 2010, 10:27 PM
#60
icecold avatar

icecold

Zen Follower

Join Date:
Jul 2008
Posts:
360
Plugin Contributions:
0

Re: Create a new module for International Checkout payment module

DrByte:

get_products() will return an array ... which you can't display by merely using echo(). You would need to echo print_r($products, TRUE) if you wanted to see the array contents that way

ok, I
made a modification but now I don't get anything from that function ...

function process_button() {
            global $products, $currencies, $results;

            if (isset($_SESSION['cart'])) {
                echo 'Session variable is already created.';
            } else {  
                echo 'Session variable is not yet created.';
            }
            if (is_object($_SESSION['cart'])) {
                echo 'Session variable is an object type.';
            } else { 
                echo 'Session variable is not an object type.';
            } 
          
       echo"<br />";   
            $products = $_SESSION['cart']->get_products();  
            $results = print_r($products, true);
            echo $results;
            return;  

        }

I am getting an empty string ... so far ...
My output is:

ic
Admin title for the module International Checkout Payments
Admin description for the module International Checkout Payments
True, the number 1 means is enabled
products in cart:

and it's coming from my modified Paypal IPN handler

if (isset($_GET['type']) && $_GET['type'] == 'ic') {
  // this is an ic handler request
 require_once('includes/modules/payment/ic.php');
 //require_once('includes/modules/pages/shopping_cart/header_php.php');
 require('includes/application_top.php');
 require(DIR_WS_CLASSES . 'payment.php');
 include('includes/languages/english/modules/payment/ic.php');
 
  // See if the ic module is enabled.
  if (defined('MODULE_PAYMENT_IC_STATUS') && MODULE_PAYMENT_IC_STATUS == 'True') {
    $ic_module = 'ic';
    // init the payment object
    $payment_modules = new ic();
	$payment_modules->ic();
	//Test class internal vars
	
    //$products=$_SESSION['cart'];
    //echo $products;
	echo $payment_modules->code . "<br />";
	echo "Admin title for the module " . $payment_modules->title . "<br />";
	echo "Admin description for the module " . $payment_modules->description . "<br />";
	echo "True, the number " . $payment_modules->enabled . " means is enabled<br />";
    echo "products in cart: " . $payment_modules->results . "<br />";
	
	
   
   
    }
  }