Need help with opening a new page

Discussion in 'Payment Processing' started by ibevamp, Oct 10, 2007.

  1. #1
    Hi guys,

    I'm new to the forum. I've searched the forum for a solution to my problem with no success. I'm hoping someone here can help.

    Ok, so im using Shop-Script's shopping cart software for my site.

    http://www.jsoutlet.net

    Heres my question/problem:

    I need a separate page to display after the transaction was successful when the user clicks "Place Order". I contacted the support team at Shop-Script, but they only told me what i have to do in order to get the results i need, they can't do the modding for me. However they said i need to add a function
    "function after_processing_html" at the end of the innovativegatway.php file. You can use the Authorizenet.php file as an example.​

    here is the code for the innovativegateway.php (the file i where i need to add the new function)

    I need to add the new function after the last function i guess


    <?php

    ?><?php
    /**
    * @connect_module_class_name InnovativeGateway
    *
    */
    include_once('./modules/payment/data.php');
    include_once('./modules/payment/innovativegateway/PostGateway.function');

    class InnovativeGateway extends PaymentModule {

    function _getStatuses(){

    $OStatuses = ostGetOrderStatues();
    $_OSt = array(
    INNOVATIVEGTW_TXT_DEFAULT.':-1'
    );
    $TC = count($OStatuses);
    for($_j = 0; $_j<$TC;$_j++){

    $_OSt[] = xHtmlSpecialChars($OStatuses[$_j]['status_name']).':'.$OStatuses[$_j]['statusID'];
    }
    return implode(',',$_OSt);
    }

    function _initVars(){

    $this->title = INNOVATIVEGTW_TTL;
    $this->description = INNOVATIVEGTW_DSCR;
    $this->sort_order = 1;

    $this->Settings = array(
    'CONF_PMNT_INNOVATIVEGTW_USERNAME',
    'CONF_PMNT_INNOVATIVEGTW_PWD',
    'CONF_PMNT_INNOVATIVEGTW_TRANTYPE',
    'CONF_PMNT_INNOVATIVEGTW_SHOPCUR',
    'CONF_PMNT_INNOVATIVEGTW_ORDERSTATUS',
    );
    }

    function _initSettingFields(){

    $this->SettingsFields['CONF_PMNT_INNOVATIVEGTW_USERNAME'] = array(
    'settings_value' => '',
    'settings_title' => INNOVATIVEGTW_CFG_USERNAME_TTL,
    'settings_description' => INNOVATIVEGTW_CFG_USERNAME_DSCR,
    'settings_html_function' => 'setting_TEXT_BOX(0,',
    'sort_order' => 1,
    );
    $this->SettingsFields['CONF_PMNT_INNOVATIVEGTW_PWD'] = array(
    'settings_value' => '',
    'settings_title' => INNOVATIVEGTW_CFG_PWD_TTL,
    'settings_description' => INNOVATIVEGTW_CFG_PWD_DSCR,
    'settings_html_function' => 'setting_TEXT_BOX(0,',
    'sort_order' => 1,
    );
    $this->SettingsFields['CONF_PMNT_INNOVATIVEGTW_TRANTYPE'] = array(
    'settings_value' => 'preauth',
    'settings_title' => INNOVATIVEGTW_CFG_TRANTYPE_TTL,
    'settings_description' => INNOVATIVEGTW_CFG_TRANTYPE_DSCR,
    'settings_html_function' => 'setting_RADIOGROUP(INNOVATIVEGTW_TXT_PREAUTH.":preauth,".INNOVATIVEGTW_TXT_SALE.":sale",',
    'sort_order' => 1,
    );
    $this->SettingsFields['CONF_PMNT_INNOVATIVEGTW_ORDERSTATUS'] = array(
    'settings_value' => '',
    'settings_title' => INNOVATIVEGTW_CFG_ORDERSTATUS_TTL,
    'settings_description' => INNOVATIVEGTW_CFG_ORDERSTATUS_DSCR,
    'settings_html_function' => 'setting_SELECT_BOX(InnovativeGateway::_getStatuses(),',
    'sort_order' => 1,
    );
    $this->SettingsFields['CONF_PMNT_INNOVATIVEGTW_SHOPCUR'] = array(
    'settings_value' => '',
    'settings_title' => INNOVATIVEGTW_CFG_SHOPCUR_TTL,
    'settings_description' => INNOVATIVEGTW_CFG_SHOPCUR_DSCR,
    'settings_html_function' => 'setting_CURRENCY_SELECT(',
    'sort_order' => 1,
    );
    }

    function payment_form_html($_Params = null){

    global $rMonths;

    if(xDataExists('_INNOVATIVEGTW_POST')){

    $_Params = xPopData('_INNOVATIVEGTW_POST');
    }

    if(isset($_Params['BillingAddressID'])){

    $baddress = regGetAddress($_Params['BillingAddressID']);
    }else{
    $baddress = $_Params;
    }

    $_Params['innovativegtw_country'] = cnGetCountryById($baddress['countryID']);
    $_Params['innovativegtw_country'] = $_Params['innovativegtw_country']['country_iso_2'];
    $_Params['innovativegtw_state'] = znGetSingleZoneById($baddress['zoneID']);
    $_Params['innovativegtw_state'] = $_Params['innovativegtw_state']['zone_code'];

    $CurrYear2d = date('y');
    $CurrYear4d = date('Y');
    $ExpYears = '';
    for($_Y = 0; $_Y<10; $_Y++){

    $_Selected = isset($_Params['innovativegtw_expyear'])?($_Params['innovativegtw_expyear']==($CurrYear2d+$_Y)):0;
    $ExpYears .= '<option value="'.($CurrYear2d+$_Y).'"'.($_Selected?' selected="selected"':'').'>'.($CurrYear4d+$_Y).'</option>';
    }

    $ExpMonths = '';
    for($_M = 1; $_M<=12; $_M++){

    $_Selected = isset($_Params['innovativegtw_expmonth'])?($_Params['innovativegtw_expmonth']==($_M)):0;
    $ExpMonths .= '<option value="'.$_M.'"'.($_Selected?' selected="selected"':'').'>'.$rMonths[$_M].'</option>';
    }

    global $CardNames;
    /*
    visa, mc, amex, diners, discover, jcb
    */
    $AvailableCreditCards = array(
    CCTYPE_VISA => 'visa',
    CCTYPE_MASTERCARD => 'mc',
    CCTYPE_AMEXPRESS => 'amex',
    CCTYPE_DINERS_CLUB => 'diners',
    CCTYPE_DISCOVER => 'discover',
    CCTYPE_JCB => 'jcb'
    );

    $ACreditCardsHTML = '<select name="innovativegtw_cctype">';
    foreach ($AvailableCreditCards as $CCTypeID=>$CCTypeCode){

    $_Selected = isset($_Params['innovativegtw_cctype'])?($_Params['innovativegtw_cctype']==$CCTypeCode?' selected':''):'';
    $ACreditCardsHTML .= '<option value="'.xHtmlSpecialChars($CCTypeCode).'"'.$_Selected.'>'.$CardNames[$CCTypeID].'</option>';
    }

    return '
    <input type="hidden" name="innovativegtw_country" value="'.xHtmlSpecialChars($_Params['innovativegtw_country']).'" />
    <input type="hidden" name="innovativegtw_state" value="'.xHtmlSpecialChars($_Params['innovativegtw_state']).'" />
    <table>
    <tr>
    <td>'.INNOVATIVEGTW_TXT_CCTYPE.'</td>
    <td>'.$ACreditCardsHTML.'</td>
    </tr>
    <tr>
    <td>'.INNOVATIVEGTW_TXT_CCNUMBER.'</td>
    <td><input type="text" name="innovativegtw_ccnumber" value="'.(isset($_Params['innovativegtw_ccnumber'])?$_Params['innovativegtw_ccnumber']:'').'" /></td>
    </tr>
    <tr>
    <td>'.INNOVATIVEGTW_TXT_CVV.'</td>
    <td><input type="text" name="innovativegtw_cvv" value="'.(isset($_Params['innovativegtw_cvv'])?$_Params['innovativegtw_cvv']:'').'" /></td>
    </tr>
    <tr>
    <td>'.INNOVATIVEGTW_TXT_EXPDATE.'</td>
    <td><select name="innovativegtw_expmonth">'.$ExpMonths.'</select>&nbsp;<select name="innovativegtw_expyear">'.$ExpYears.'</select></td>
    </tr>
    </table>
    ';
    }

    function payment_process($order){

    $transaction = array();

    // Required variables for authorization gateway
    $transaction["target_app"] = "WebCharge_v5.06";
    $transaction["response_mode"] = "simple";
    $transaction["response_fmt"] = "delimited";
    $transaction["upg_auth"] = "zxcvlkjh";
    $transaction["delimited_fmt_field_delimiter"] = "=";
    $transaction["delimited_fmt_include_fields"] = "true";

    $transaction["delimited_fmt_value_delimiter"] = "|";

    // Your Gateway Authorization Credentials:
    $transaction["username"] = $this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_USERNAME');
    $transaction["pw"] = $this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_PWD');

    $transaction["trantype"] = $this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_TRANTYPE');
    $transaction["reference"] = "";
    $transaction["trans_id"] = "";
    $transaction["authamount"] = "";

    // Credit Card information
    $transaction["cardtype"] = $_POST['innovativegtw_cctype'];
    $transaction["ccnumber"] = $_POST['innovativegtw_ccnumber'];
    $transaction["ccidentifier1"] = $_POST['innovativegtw_cvv'];
    // CC# may include spaces or dashes.
    $transaction["month"] = sprintf('%02d',$_POST['innovativegtw_expmonth']); // Must be TWO DIGIT month.
    $transaction["year"] = sprintf('%02d',$_POST['innovativegtw_expyear']); // Must be TWO or FOUR DIGIT year.

    $transaction["fulltotal"] = sprintf('%.2f',RoundFloatValue($this->_convertCurrency($order["order_amount"], 0, $this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_SHOPCUR'))));

    $transaction["ccname"] = $order['billing_info']['first_name'].' '.$order['billing_info']['last_name'];
    $transaction["baddress"] = $order['billing_info']['address'];
    $transaction["baddress1"] = "";
    $transaction["bcity"] = $order['billing_info']['city'];
    $transaction["bstate"] = $_POST['innovativegtw_state'];
    $transaction["bzip"] = $order['billing_info']['zip'];
    $transaction["bcountry"] = $_POST['innovativegtw_country']; // TWO DIGIT COUNTRY (United States = "US")
    $transaction["bphone"] = '';
    $transaction["email"] = $order['customer_email'];

    $response = PostTransaction($transaction);

    if ($response["approved"] != ""){

    return 1;
    } else {

    xSaveData('_INNOVATIVEGTW_POST', $_POST);
    return $response["error"];
    }
    }

    function after_processing_php($_OrderID){

    if($this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_ORDERSTATUS') != -1){

    ostSetOrderStatusToOrder($_OrderID, $this->_getSettingValue('CONF_PMNT_INNOVATIVEGTW_ORDERSTATUS'));
    }
    }
    }
    ?>


    =======================================
    This is the other file, where i can use as an Example.
    =======================================

    <?php
    /*****************************************************************************
    * *
    * Shop-Script PRO *
    * Copyright (c) 2005 WebAsyst LLC. All rights reserved. *
    * *
    *****************************************************************************/
    ?><?php
    // Authorize.Net SIM payment module (Simple Integration Method)
    // http://www.authorize.net
    /**
    * @connect_module_class_name CAuthorizeNetSIM
    *
    */

    class CAuthorizeNetSIM extends PaymentModule{

    function _initVars(){

    $this->title = CAUTHORIZENETSIM_TTL;
    $this->description = CAUTHORIZENETSIM_DSCR;
    $this->sort_order = 2;

    $this->Settings = array(
    "CONF_PAYMENTMODULE_AUTHNETSIM_LOGIN",
    "CONF_PAYMENTMODULE_AUTHNETSIM_TRAN_KEY",
    "CONF_PAYMENTMODULE_AUTHNETSIM_TESTMODE"
    );
    }

    function _initSettingFields(){

    $this->SettingsFields['CONF_PAYMENTMODULE_AUTHNETSIM_LOGIN'] = array(
    'settings_value' => '',
    'settings_title' => CAUTHORIZENETSIM_CFG_LOGIN_TTL,
    'settings_description' => CAUTHORIZENETSIM_CFG_LOGIN_DSCR,
    'settings_html_function' => 'setting_TEXT_BOX(0,',
    'sort_order' => 1,
    );

    $this->SettingsFields['CONF_PAYMENTMODULE_AUTHNETSIM_TRAN_KEY'] = array(
    'settings_value' => '',
    'settings_title' => CAUTHORIZENETSIM_CFG_TRAN_KEY_TTL,
    'settings_description' => CAUTHORIZENETSIM_CFG_TRAN_KEY_DSCR,
    'settings_html_function' => 'setting_TEXT_BOX(0,',
    'sort_order' => 1,
    );

    $this->SettingsFields['CONF_PAYMENTMODULE_AUTHNETSIM_TESTMODE'] = array(
    'settings_value' => '',
    'settings_title' => CAUTHORIZENETSIM_CFG_TESTMODE_TTL,
    'settings_description' => CAUTHORIZENETSIM_CFG_TESTMODE_DSCR,
    'settings_html_function' => 'setting_CHECK_BOX(',
    'sort_order' => 1,
    );
    }

    // *****************************************************************************
    // Purpose Makes HMAC MD5 hash of the $data
    // Inputs
    // Remarks Thank to lance @ http://www.php.net/manual/en/function.mhash.php
    // Returns hashed string
    function hmac ($key, $data)
    {
    // RFC 2104 HMAC implementation for php.
    // Creates an md5 HMAC.
    // Eliminates the need to install mhash to compute a HMAC
    // Hacked by Lance Rushing

    $b = 64; // byte length for md5
    if (strlen($key) > $b) {
    $key = pack("H*",md5($key));
    }
    $key = str_pad($key, $b, chr(0x00));
    $ipad = str_pad('', $b, chr(0x36));
    $opad = str_pad('', $b, chr(0x5c));
    $k_ipad = $key ^ $ipad ;
    $k_opad = $key ^ $opad;

    return md5($k_opad . pack("H*",md5($k_ipad . $data)));
    }

    function after_processing_html( $orderID )
    {
    $order = ordGetOrder( $orderID );
    $order_amount = $order["order_amount"] * $order["currency_value"];

    $res = "";

    $fp_timestamp = time();
    $fp_sequence = $orderID;
    $currency_code = $order["currency_code"];

    $testmode = $this->_getSettingValue('CONF_PAYMENTMODULE_AUTHNETSIM_TESTMODE') ? 'TRUE' : 'FALSE';

    $fp_hash = $this->hmac(
    $this->_getSettingValue('CONF_PAYMENTMODULE_AUTHNETSIM_TRAN_KEY'), $this->_getSettingValue('CONF_PAYMENTMODULE_AUTHNETSIM_LOGIN')."^".$fp_sequence."^".$fp_timestamp."^".$order_amount."^".$currency_code );

    $res .=
    "<table width='100%'>\n".
    " <tr>\n".
    " <td align='center'>\n".
    "<form method='POST' name='authSIMform' action='https://secure.authorize.net/gateway/transact.dll'>\n".
    "<input type=\"hidden\" name=\"x_login\" value=\"".$this->_getSettingValue('CONF_PAYMENTMODULE_AUTHNETSIM_LOGIN')."\">\n".
    "<input type=\"hidden\" name=\"x_test_request\" value=\"".$testmode."\">\n".
    "<input type=\"hidden\" name=\"x_show_form\" value=\"PAYMENT_FORM\">".
    "<input type=\"hidden\" name=\"x_fp_sequence\" value=\"".$fp_sequence."\">\n".
    "<input type=\"hidden\" name=\"x_fp_timestamp\" value=\"".$fp_timestamp."\">\n".
    "<input type=\"hidden\" name=\"x_fp_hash\" value=\"".$fp_hash."\">\n".
    "<input type=\"hidden\" name=\"x_amount\" value=\"".$order_amount."\">\n".
    "<input type=\"hidden\" name=\"x_currency_code\" value=\"".$currency_code."\">\n".
    // "<input type=\"hidden\" name=\"x_method\" value=\"CC\">\n".
    // "<input type=\"hidden\" name=\"x_type\" value=\"AUTH_ONLY\">\n".

    // "<input type=\"hidden\" name=\"x_card_num\" value=\"".cryptCCNumberDeCrypt($order["cc_number"],null)."\">\n".
    // "<input type=\"hidden\" name=\"x_exp_date\" value=\"".cryptCCNumberDeCrypt($order["cc_expires"],null)."\">\n".

    "<input type=\"hidden\" name=\"x_first_name\" value=\"".$order["billing_firstname"]."\">\n".
    "<input type=\"hidden\" name=\"x_last_name\" value=\"".$order["billing_lastname"]."\">\n".
    "<input type=\"hidden\" name=\"x_address\" value=\"".$order["billing_address"]."\">\n".
    "<input type=\"hidden\" name=\"x_city\" value=\"".$order["billing_city"]."\">\n".
    "<input type=\"hidden\" name=\"x_state\" value=\"".$order["billing_state"]."\">\n".
    "<input type=\"hidden\" name=\"x_zip\" value=\"".$order["billing_zip"]."\">\n".
    "<input type=\"hidden\" name=\"x_country\" value=\"".$order["billing_country"]."\">\n".
    // "<input type=\"hidden\" name=\"x_phone\" value=\"".$order["billing_phone"]."\">\n".
    "<input type=\"hidden\" name=\"x_email\" value=\"".$order["customer_email"]."\">\n".
    "<input type=\"hidden\" name=\"x_customer_ip\" value=\"".$order["customer_ip"]."\">\n".

    "<input type=\"hidden\" name=\"x_invoice_num\" value=\"".$orderID."\">\n".
    "<input type=\"hidden\" name=\"x_description\" value=\"Order #".$orderID."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_first_name\" value=\"".$order["shipping_firstname"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_last_name\" value=\"".$order["shipping_lastname"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_address\" value=\"".$order["shipping_address"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_city\" value=\"".$order["shipping_city"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_state\" value=\"".$order["shipping_state"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_zip\" value=\"".$order["shipping_zip"]."\">\n".
    "<input type=\"hidden\" name=\"x_ship_to_country\" value=\"".$order["shipping_country"]."\">\n".
    "<input type='hidden' name='x_relay_response' value='FALSE'>\n".

    "<input type=\"submit\" value=\"".CAUTHORIZENETSIM_TXT_1."\">\n".

    " </form>\n".

    " </td>\n".
    " </tr>\n".
    "</table>";

    return $res;
    }


    }
    ?>
     
    ibevamp, Oct 10, 2007 IP