Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons

Reply
 
Thread Tools
vBulletin and iDevAffiliate Integration Details »»
vBulletin and iDevAffiliate Integration
Version: 1.00, by vb_mp vb_mp is offline
Developer Last Online: Sep 2010 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.7.2 Rating:
Released: 09-13-2008 Last Update: Never Installs: 17
Uses Plugins
Re-useable Code Code Changes Translations Is in Beta Stage  
No support by the author.

NOTE: I have it installed on 3.7x, I haven't tried earlier versions.

Description: I have been searching around for a plugin to allow vBulletin and iDevIntegration (for affiliate management of vbulletin paid subscriptions) and could not find any.

I contacted iDevAffiliate and their response was that they did not know enough
about vbulletin to create a plugin themselves but they explain what I had to do
on the iDevAffiliate side to make things work.

Thanks to vbulletin.org members Marco van Herwaarden, Dismounted, Delphiprogrammi, Opserty for pointing me in the right direction as this is my first vbulletin plugin.

This mod integrates iDevAffiliate commission tracking.

NOTE: Keep in mind, I assume that you are fairly well versed and comfortable with editing files/templates and following the flow of things.

Installing:

*********************************
STEP 1
*********************************
In payments.php in your forum root find the following code lines:

Code:
    /* insert query */
    $db->query_write("
        INSERT INTO " . TABLE_PREFIX . "paymentinfo
            (hash, completed, subscriptionid, subscriptionsubid, userid)
        VALUES
            ('" . $db->escape_string($hash) . "', 0, $subscriptionid, $subscriptionsubid, " . $vbulletin->userinfo['userid'] . ")
    ");
Replace them with the following:

Code:
    /* insert query */
    $insertQuery = "INSERT INTO " . TABLE_PREFIX . "paymentinfo
            (hash, completed, subscriptionid, subscriptionsubid, userid";
    $insertQuery .= $vbulletin->options['idevaffiliate_active'] ? ", ipaddress)" : ")";
    $insertQuery .= "VALUES
            ('" . $db->escape_string($hash) . "', 0, $subscriptionid, $subscriptionsubid, " . $vbulletin->userinfo['userid'];
    $insertQuery .= $vbulletin->options['idevaffiliate_active'] ? ", '" . IPADDRESS . "')" : ")";
    $db->query_write($insertQuery);
*********************************
STEP 2
*********************************
In payment_gateway.php file in your forum root find the following code lines:

Code:
    
if ($apiobj->type == 1)
{
    $subobj->build_user_subscription($apiobj->paymentinfo['subscriptionid'], $apiobj->paymentinfo['subscriptionsubid'], $apiobj->paymentinfo['userid']);
Add the following code under the above code ( make sure you replace YOURDOMAINNAME with your domain name and YOURIDEVINSTALLATIONFOLDER with your idev installation folder:

Code:
if ($vbulletin->options['idevaffiliate_active'] AND function_exists('curl_init') AND $ch = curl_init())
{
    $idevQuery = "idev_saleamt=" . $apiobj->paymentinfo['amount'] . "&ip_address=" . $apiobj->paymentinfo['ipaddress'] . "&idev_ordernum=" . $apiobj->paymentinfo['paymentinfoid'];
    curl_setopt($ch, CURLOPT_URL, "http://www.YOURDOMAINNAME.com/YOURIDEVINSTALATIONFOLDER/sale.php");
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDSIZE, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $idevQuery);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'vBulletin via cURL/PHP');

    $result = curl_exec($ch);
    curl_close($ch);
}
*********************************
STEP 3
*********************************
Install the idevaffiliate_integration Product via the Plugin Manager

*********************************
STEP 4
*********************************
Go to AdminCP -> vBulletin Options -> iDevAffiliate Integration Settings and enable use of iDevAffiliate by selecting 'Yes' and saving.

That's it, you are ready to use iDevAffiliate with vBulletin.

Dont Forget To MARK AS INSTALLED
And Also Don't Forget To Visit DNXpert.com

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 09-17-2008, 01:19 AM
yahoooh yahoooh is offline
 
Join Date: Oct 2002
Posts: 567
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is integrated for users in vbulletin?
Reply With Quote
  #23  
Old 09-17-2008, 01:53 AM
Quarterbore Quarterbore is offline
 
Join Date: Mar 2005
Location: Valley Forge PA
Posts: 538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I am looking at the code and I do not have an iDevAffilaite package (yet) so I need to guess a little what is going on here so bear with me as I try to summarize what this is doing.

Step 1: payments.php simply adds the IP address of the person who has purchased the subscription.

Comment: It really is too bad vBulletin doesn't have a hook right after the code you quote as we could simply run an update where "hash" = $hash. The hook that is in the while loop could be used however if we added a variable for example:

paidsub_order_paymentbit Plugin:

PHP Code:
if($vbulletin->options['idevaffiliate_active'] AND $ipsaved != '1'){
$escapedhash $db->escape_string($hash);

      
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "paymentinfo
      SET ipaddress = " 
IPADDRESS "
      WHERE hash = " 
$escapedhash "
      "
);
     
$ipsaved '1';

Question - Is this IP information important and required (remember I don't use the script)? I ask as with vBulletin we know more about a user then just the IP they used to pay including registration IP, all IPs they used, plus e-mail, etc. Again, I have not used the affiliate script so just curious why this matters as we know who the user is and that is the most important matter for us.

Step 2: payment_gateway.php saves the sale in the affiliate script

This is really an amazing file in vBulletin as there is not a single hook in this file There is no way around a file edit in this file but I am not convinced we have to use the file to do this. I say this as we do have hooks in class file that does subscriptions:

./includes/class_paid_subscription.php

I am curious why we can't use the paidsub_build hook to log the sale into the affiliate script? There could also be a plugin added to paidsub_delete to handle reversals too (I think).

Summary:

I am really not trying to be critical as I am very thankful you shared your work as I have been considering adding an affiliate script to my own premium site. I am really not going to be able to test this without buying the software but I think that if you look at the possibility of moving the STEP 2 of this to the Class that you may be able to remove the file edits.

Also, as I said above, I don't see the value in the "Step 1" addition as vBulletin allows us to know a whole lot about our users that are far above the IP they are using when they pay for a subscription

I welcome feedback on my humble oppinions as I know there are developers and coders on here with far more skill then I have.

Cheers,
Ken
Reply With Quote
  #24  
Old 09-17-2008, 01:59 PM
vb_mp vb_mp is offline
 
Join Date: Feb 2008
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your comments Ken.

I have left my answers below each part of yours:

Quote:
Step 1: payments.php simply adds the IP address of the person who has purchased the subscription.
iDevAffiliate tracks recurring commissions by IP. Since we can't guarantee the same IP on each recurring payment, the only way to solve this is to save the IP on initial payment in the vbulletin database and pull it out on recurring payment to pass to iDevAffiliate.
(In iDevAffiliate they use the IP on recurring payment to give the commission to the right person since on recurring payment there is no other way to figure out what belongs to whom). I guess they could have solved it by just using a payment id or hash or whatnot but that is up to idevaffiliate not vbulletin.

It is also important that the IP is stored on the initial payment and not on the recurring payments... hence the insert at the point in payments.php where the insert to paymentinfo table happens.


Quote:
Step 2: payment_gateway.php saves the sale in the affiliate script
Excellent observation here. As I mentioned in my original post I am new to vBulletin and I could not find the hooks to do that part.

I will modify the plugin to include the calls to the two hooks - this will eliminate 1 file edit and leave us with just the one file edit in payments.php

Thanks!
Reply With Quote
  #25  
Old 09-17-2008, 02:06 PM
mambomouth mambomouth is offline
 
Join Date: May 2005
Location: NYC/NJ
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello Ken,

idevaffiliate is limited to what one can do with extra information.
Most of the files are encoded so there not much on the Idev script that one can edit.

There are three Optional Variables that one can pass to the sales.php page
which records the sales of products etc.

See Variables setting page:
http://demo.idevdirect.com/admin/set...tion=37&type=4

I own another script called Jam:
http://jam.jrox.com/

Which I think is a better script because you can reverse charge backs plus
it more secure because it uses a key API to make sure that it your script calling
the sales page.

Personally I love to see an affiliate system finished in VB it has a refer hook built in.
I think they started it but did not finish it.

If a hook in the payment class etc. and there was maybe another two to three tables added to VB this could be done.



By the way still testing this mod but it has not record any sales on it at this point.

As you can see I have been at this for some time old post:
https://vborg.vbsupport.ru/showthread.php?t=140446

Again thanks vb_mp and all for taking the steps to get this done

Cheers,
Brian
Reply With Quote
  #26  
Old 09-17-2008, 02:09 PM
vb_mp vb_mp is offline
 
Join Date: Feb 2008
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Brian,

You can test it with a family member's paypal.

Clear your cookies and reset your IP (switch DSL OFF and ON) then purchase through your affiliate link.

I have got affiliates making commissions on my forum.
Reply With Quote
  #27  
Old 09-17-2008, 02:23 PM
mambomouth mambomouth is offline
 
Join Date: May 2005
Location: NYC/NJ
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi VB_MP,

Thanks believe it works I have been getting sales.
But its just not been recorded I'll wait a day or two more.
Where I setup aff's links are on Google ad and other links so It should work etc.

Cheers,
Brian
Reply With Quote
  #28  
Old 09-17-2008, 02:50 PM
mambomouth mambomouth is offline
 
Join Date: May 2005
Location: NYC/NJ
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You know that another good mod for this is to add Google analytics code for sale
on ROI for ad's.
Reply With Quote
  #29  
Old 09-17-2008, 05:59 PM
vb_mp vb_mp is offline
 
Join Date: Feb 2008
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hm @Quarterbore,

I am trying to move the payment_gateway edit code above into a plugin on the paidsub_build hook.

When in the build_user_subscription method in class_paid_subscriptions, we don't have direct access to paymentinfo data including

paymentinfo['amount']
paymentinfo['ipaddress']
paymentinfo['paymentinfoid'];

How do you suggest I retrieve them? With an extra query?
Reply With Quote
  #30  
Old 09-17-2008, 06:16 PM
Quarterbore Quarterbore is offline
 
Join Date: Mar 2005
Location: Valley Forge PA
Posts: 538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vb_mp View Post
Hm @Quarterbore,

I am trying to move the payment_gateway edit code above into a plugin on the paidsub_build hook.

When in the build_user_subscription method in class_paid_subscriptions, we don't have direct access to paymentinfo data including

paymentinfo['amount']
paymentinfo['ipaddress']
paymentinfo['paymentinfoid'];

How do you suggest I retrieve them? With an extra query?
I can help with that tonight after work as I don't need to have the idevaffiliate script to work on that

Now, I do see that the hook is inside of a function so the only values I expect we have to work in there are the ones defined:

PHP Code:
    function build_user_subscription($subscriptionid$subid$userid$regdate 0$expirydate 0$checkperms true
That will likely mean a query would be needed but I would need to drop some test code into that hook to see what variables are in memory that we can use. I hope I didn't waste a bunch of your time with my suggestion and I will see what I can get out of here after work.
Reply With Quote
  #31  
Old 09-17-2008, 06:38 PM
Quarterbore Quarterbore is offline
 
Join Date: Mar 2005
Location: Valley Forge PA
Posts: 538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Edit - never mind I had the wrong hook

You can get the variables in memory from this code if you add it to a plugin off the hook we need to test but it didn't work for me when I just did a test subscription via PayPal so I am not sure why...

PHP Code:
$vars get_defined_vars();
print_r($vars);
exit(); 
I need to look at this later.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:11 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04810 seconds
  • Memory Usage 2,328KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete