Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2007
    Posts
    6
    Plugin Contributions
    0

    Default SafePay Payment Module

    im in the process of completing a payment module for safe pay, with one REAL annoying error. i cant tell if this is on my part or theres, but...

    when i go to checkout, evreything is fine, until i decide to go to the very last step where they transfer me to the safe pay page. all i see is 1 item (does not have a name) totaling 1 usd. Is there anything i can do to get safepay to actually register the items in my cart? ill go ahead and post the code here so someone can look over it.

    PHP Code:
    <?php
    /*
      $Id: safepay.php,v 1.0 2006/03/28 16:22:25 SPSTeam Exp $

      SafePaySolutions Payment module for OSCommerce
      http://www.safepaysolutions.com

      Copyright © 2006 SafePay Solutions, All Rights Reserved
    */

      
    class safepay {
        var 
    $code$title$description$enabled;

    // class constructor
        
    function safepay() {
          global 
    $order;

          
    $this->code        'safepay';
          
    $this->title       MODULE_PAYMENT_SAFEPAY_TEXT_TITLE;
          
    $this->description MODULE_PAYMENT_SAFEPAY_TEXT_DESCRIPTION;
          
    $this->sort_order  MODULE_PAYMENT_SAFEPAY_SORT_ORDER;
          
    $this->enabled     = ((MODULE_PAYMENT_SAFEPAY_STATUS == 'True') ? true false);

          if((int)
    MODULE_PAYMENT_SAFEPAY_ORDER_STATUS_ID>0
          {
            
    $this->order_status MODULE_PAYMENT_SAFEPAY_ORDER_STATUS_ID;
          }

          if(
    is_object($order)) $this->update_status();

          
    $this->form_action_url 'https://www.safepaysolutions.com/index.php';
        }

    // class methods
        
    function update_status() 
        {
          global 
    $order;

          if((
    $this->enabled==true) && ((int)MODULE_PAYMENT_SAFEPAY_ZONE>0)) 
          {
            
    $check_flag   false;
            
    $check_query  $db->Execute("SELECT `zone_id` FROM ".TABLE_ZONES_TO_GEO_ZONES." WHERE `geo_zone_id`='".MODULE_PAYMENT_SAFEPAY_ZONE."' AND `zone_country_id`='".$order->billing['country']['id']."' ORDER BY `zone_id`");

            while(!
    $check->EOF
            {
              if(
    $check->fields['zone_id']<1
              {
                
    $check_flag true;
                break;
              } 
              elseif(
    $check['zone_id'] == $order->billing['zone_id']) 
              {
                
    $check_flag true;
                break;
              }
              
    $check->MoveNext();
            }

            if(
    $check_flag==false
            {
              
    $this->enabled false;
            }
          }
        }


        function 
    javascript_validation() 
        {
          return 
    false;
        }


        function 
    selection() 
        {
          return array(
    'id' => $this->code'module' => $this->title);
        }


        function 
    pre_confirmation_check() 
        {
          return 
    false;
        }


        function 
    confirmation() 
        {
          return 
    false;
        }


        function 
    process_button() 
        {
          global 
    $order$currencies$currency;

          if (
    MODULE_PAYMENT_SAFEPAY_CURRENCY == "Selected Currency"
          {
            
    $my_currency $currency;
          } 
          else 
          {
            
    $my_currency substr(MODULE_PAYMENT_SAFEPAY_CURRENCY5);
          }

          if (!
    in_array($my_currency, array('CAD''EUR''GBP''JPY''USD'))) 
          {
            
    $my_currency 'USD';
          }
     
          
    $process_button_string 
              
    "\n".zen_draw_hidden_field("notifyURL"zen_href_link('modules/payment/safepay_ipn/ipn.php'"""SSL"falsefalse)) .
              
    "\n".zen_draw_hidden_field("returnURL"zen_href_link(FILENAME_CHECKOUT_PROCESS""'SSL')) .
              
    "\n".zen_draw_hidden_field("cancelURL"zen_href_link(FILENAME_CHECKOUT_PAYMENT"""SSL")) .
              
    "\n".zen_draw_hidden_field("_ipn_act",  "_ipn_payment") .
              
    "\n".zen_draw_hidden_field("iamount",   number_format(($order->info['total']) * $currencies->currencies['USD']['value'], $currencies->currencies['USD']['decimal_places'])) .
              
    "\n".zen_draw_hidden_field("iowner",    MODULE_PAYMENT_SAFEPAY_ID) .
              
    "\n".zen_draw_hidden_field("itemName",  MODULE_PAYMENT_SAFEPAY_PRODUCT_TYPE) .
              
    "\n".zen_draw_hidden_field("itemNum",   MODULE_PAYMENT_SAFEPAY_ID) .
              
    "\n".zen_draw_hidden_field("ireceiver"MODULE_PAYMENT_SAFEPAY_ID) .
              
    "\n".zen_draw_hidden_field("idescr",    MODULE_PAYMENT_SAFEPAY_ID) .
              
    "\n".zen_draw_hidden_field("idelivery""") .
              
    "\n".zen_draw_hidden_field("imultiplyPurchase""") .
              
    "\n".zen_draw_hidden_field("colortheme""DefaultSystemTheme") .
              
    "\n".zen_draw_hidden_field("iquantity""");

          return 
    $process_button_string;
        }


        function 
    before_process() 
        {
          return 
    false;
        }


        function 
    after_process() 
        {
          return 
    false;
        }


        function 
    output_error() 
        {
          return 
    false;
        }


        function 
    check() 
        {
          global 
    $db;
          if (!isset(
    $this->_check)) 
          {
            
    $check_query  $db->Execute("SELECT `configuration_value` FROM ".TABLE_CONFIGURATION." WHERE `configuration_key`='MODULE_PAYMENT_SAFEPAY_STATUS'");
            
    $this->_check $check_query->RecordCount();
          }
          return 
    $this->_check;
        }


        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 SafePay Module', 'MODULE_PAYMENT_SAFEPAY_STATUS', 'True', 'Do you want to accept safepay payments?', '6', '3', '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 ('SafePay Account', 'MODULE_PAYMENT_SAFEPAY_ID', 'username', 'Account to use for the SafePay service', '6', '4', now())");
          
    $db->Execute("INSERT INTO " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Transaction Currency', 'MODULE_PAYMENT_SAFEPAY_CURRENCY', 'Selected Currency', 'The currency to use for credit card transactions', '6', '6', 'zen_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only CAD\',\'Only EUR\',\'Only GBP\',\'Only JPY\'), ', 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_SAFEPAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
          
    $db->Execute("INSERT INTO " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('Payment Zone', 'MODULE_PAYMENT_SAFEPAY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
          
    $db->Execute("INSERT INTO " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) VALUES ('Set Order Status', 'MODULE_PAYMENT_SAFEPAY_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('General product description.', 'MODULE_PAYMENT_SAFEPAY_PRODUCT_TYPE', '', 'Need to complete Safepay process.', '6', '5', now())");
        }


        function 
    remove() 
        {
          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')");
        }


        function 
    keys() 
        {
          return array(
    "MODULE_PAYMENT_SAFEPAY_STATUS""MODULE_PAYMENT_SAFEPAY_ID",'MODULE_PAYMENT_SAFEPAY_PRODUCT_TYPE'"MODULE_PAYMENT_SAFEPAY_CURRENCY""MODULE_PAYMENT_SAFEPAY_ZONE""MODULE_PAYMENT_SAFEPAY_ORDER_STATUS_ID""MODULE_PAYMENT_SAFEPAY_SORT_ORDER");
        }
      }

    ?>

  2. #2
    Join Date
    Sep 2007
    Posts
    6
    Plugin Contributions
    0

    Default Ok...i see it also uses IPN

    it uses ipn from what i see, so i tryed to edit the code some but it still seems like zen is not calling up it, which i think is making the cart seem empty to safepay.

    PHP Code:
    <?php
    /*
      $Id: ipn.php,v 1.0 2006/05/15 16:22:25 SPSTeam Exp $

      Copyright © 2006 SafePay Solutions, All Rights Reserved
    */
      
    require('includes/application_top.php');


      foreach (
    $_POST as $key => $value) {
        
    $parameters .= '&' $key '=' urlencode(stripslashes($value));
      }


      
    $cart->reset(true);


      if(
    $_POST["result"]=="1"
      {
        if(
    $_POST["tid"]!=""
        {
          
    $order_query $db->Execute("SELECT currency, currency_value FROM ".TABLE_ORDERS." WHERE orders_id='".$_POST["custom1"]."'");
          if(
    tep_db_num_rows($order_query)>0
          {
            
    $order $db->Execute($order_query);

            
    $total_query $db->Execute("SELECT value FROM ".TABLE_ORDERS_TOTAL." WHERE orders_id='".$_POST["custom1"]."' AND class='ot_total' LIMIT 1");
            
    $total $db->Execute($total_query);


            
    $status_query $db->Execute("SELECT `orders_status_id` FROM ".TABLE_ORDERS_STATUS." WHERE `orders_status_name`='Preparing [SafePay IPN]' LIMIT 1");
            
    $status $db->Execute($status_query);

            
    $order_status_id DEFAULT_ORDERS_STATUS_ID;

            if(
    $status["orders_status_id"]>0
            {
              
    $order_status_id $status["orders_status_id"];
            }


           
    $db->Execute("UPDATE ".TABLE_ORDERS." SET orders_status='".$order_status_id."', last_modified=NOW() WHERE orders_id='".$_POST['custom1']."'");

            
    $sql_data_array = array('orders_id'         => $_POST['custom1'],
                                    
    'orders_status_id'  => $order_status_id,
                                    
    'date_added'        => 'NOW()',
                                    
    'customer_notified' => '0',
                                    
    'comments'          => 'SafePay IPN Verified ('.$parameters.')');

            
    zen_db_perform(TABLE_ORDERS_STATUS_HISTORY$sql_data_array);
          }
        }
      } 
      else 
      {
        if(isset(
    $_POST["custom1"]) && is_numeric($_POST["custom1"]) && ($_POST["custom1"]>0)) 
        {
          
    $check_query $db->Execute("SELECT orders_id FROM ".TABLE_ORDERS." WHERE orders_id='".$_POST["custom1"]."'");

          if(
    zen_db_num_rows($check_query)>0
          {
            
    $db->Execute("UPDATE ".TABLE_ORDERS." SET orders_status='".DEFAULT_ORDERS_STATUS_ID."', last_modified=NOW() WHERE orders_id='".$_POST["custom1"]."'");

            
    $sql_data_array = array('orders_id'         => $_POST['custom1'],
                                    
    'orders_status_id'  => DEFAULT_ORDERS_STATUS_ID,
                                    
    'date_added'        => 'NOW()',
                                    
    'customer_notified' => '0',
                                    
    'comments'          => 'SafePay IPN Invalid ('.$parameters.')');

            
    zen_db_perform(TABLE_ORDERS_STATUS_HISTORY$sql_data_array);
          }
        }
      }

      require(
    'includes/application_bottom.php');

    ?>

  3. #3
    Join Date
    Sep 2007
    Posts
    6
    Plugin Contributions
    0

    Default Re: SafePay Payment Module

    is it possible i could just take out the IPN and have it just read from the site without the need of callin that other file? (my 2nd post, ipn.php) i really want this module to work and i have been toying with it ALL morning!! Im going to bed now, hopefully i wake up to some fresh responses!! THANKS ahead of time!

  4. #4
    Join Date
    Sep 2007
    Posts
    6
    Plugin Contributions
    0

    Default Re: SafePay Payment Module

    if anyone can just point me in the direction of maybe a link or tutorial for ipn, ill do it myself :/

  5. #5
    Join Date
    Sep 2007
    Posts
    6
    Plugin Contributions
    0

    Default Re: SafePay Payment Module

    can anyone help me out? :/

  6. #6
    Join Date
    May 2005
    Location
    Western MA, USA
    Posts
    604
    Plugin Contributions
    6

    Default Re: SafePay Payment Module

    Hi there, I have to look in to doing this my self,
    could you attach the files that you have made so that I can take a look at them and try to work out some bugs w/ you.

 

 

Similar Threads

  1. Replies: 1
    Last Post: 12 Dec 2014, 05:37 AM
  2. Replies: 47
    Last Post: 7 Jul 2013, 10:36 PM
  3. v150 How do I set a Payment Zone into my payment module's settings?
    By apt763 in forum PayPal Express Checkout support
    Replies: 2
    Last Post: 2 Mar 2012, 07:10 PM
  4. Can i add more customized payment module to payment option?
    By naranbayar in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 12 Nov 2009, 09:22 PM
  5. SafePay, First Part Done.
    By JSurabian in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 23 Sep 2007, 06:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR