View Single Post
  #14  
Old 08-14-2004, 06:31 PM
nick_1 nick_1 is offline
 
Join Date: Jan 2002
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll see about getting my version written up for 2checkout 1. I've had it running ages but haven't had time to sort it out.

The basis of the hack was simply to replace the authorise.net payment code a modification which points at 2co's payment gateway. They are quite similar but not a perfect replacement so i duplicated much of the code.

As far as i remember the main changes were in includes/functions_subscriptions.php This is what i did...

find:
PHP Code:
 // ######################## Define payment bits ###################
$_SUBSCRIPTIONS['methods'] = array(
    
'paypal'    =>    1,
    
'nochex'    =>    2,
    
'worldpay'    =>    4,
    
'authorize'    =>    8,
); 
Replace with:
PHP Code:
 // ######################## Define payment bits ###################
$_SUBSCRIPTIONS['methods'] = array(
    
'paypal'    =>    1,
    
'nochex'    =>    2,
    
'worldpay'    =>    4,
    
'authorize'    =>    8,
    
'2checkout'    =>    16
); 
Find:
PHP Code:
// ######################## Define supported curencies ###################
$_SUBSCRIPTIONS['curencies'] = array(
    
'paypal'    =>    array('usd' => true'gbp' => true'eur' => true),
    
'nochex'    =>    array('gbp' => true),
    
'worldpay'    =>    array('usd' => true'gbp' => true'eur' => true),
    
'authorize'    =>    array('usd' => true'gbp' => true'eur' => true)
); 
Replace with:
PHP Code:
// ######################## Define supported curencies ###################
$_SUBSCRIPTIONS['curencies'] = array(
    
'paypal'    =>    array('usd' => true'gbp' => true'eur' => true),
    
'nochex'    =>    array('gbp' => true),
    
'worldpay'    =>    array('usd' => true'gbp' => true'eur' => true),
    
'authorize'    =>    array('usd' => true'gbp' => true'eur' => true),
    
'2checkout'    =>    array('usd' => true)
); 
Find:
PHP Code:
        case 'authorize':
            
$form construct_authorize_form($cost$item$currency);
            break; 
Add below:
PHP Code:
        case '2checkout':
            
$form construct_2checkout_form($cost$item$currency);
            break; 
This is my replacement of construct_authorize_form() add to the bottom of the file.
PHP Code:
function construct_2checkout_form($amount$id$currency 'USD')
{
    global 
$vboptions$authorize_txnkey;

    
$sequence vbrand(11000);
    
$fingerprint hmac($authorize_txnkey$vboptions['authorize_loginid'] . '^' $sequence '^' TIMENOW '^' $amount '^' $currency);
    
$timenow TIMENOW;

    
$id .= "_$currency";

    
//$form['action'] = 'https://secure.authorize.net/gateway/transact.dll';
    
$form['action'] = 'https://www.2checkout.com/cgi-bin/Abuyers/purchase.2c';
    
$form['method'] = 'post';
    
$form['hiddenfields'] = <<< HTML
    <input type="hidden" name="x_fp_hash" value="$fingerprint" />
    <input type="hidden" name="x_login" value="
$vboptions[authorize_loginid]" />

    <input type="hidden" name="x_amount" value="
$amount" />
    <input type="hidden" name="x_currency_code" value="
$currency" />
    <input type="hidden" name="x_invoice_num" value="
$id" />
HTML;
    return 
$form;

I'm sure 2co should accept more variables than that but thats all it seems to accept for me. Also, 2co ignores your currency code so don't change the code to allow other types of currency. I have actually used the same authorize_txnkey for both 2co and authorize.net payments but you might wish to change this to improve security.

Once thats all done set the shopping cart preferences in your 2co admin panel to point back at the authorize.net payment page which will accept the payment correctly (/subscriptions/authorize.php). Try it out in test mode with garbage card numbers to check it all works and you should find its working nicely.

I hope this helps, it was rather important to my site as we were trying to improve our payment system after using a poorly intergrated one.

Nick
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01359 seconds
  • Memory Usage 1,829KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete