PDA

View Full Version : Miscellaneous Hacks - vBulletin and iDevAffiliate Integration


vb_mp
09-13-2008, 10:00 PM
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:

/* 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:


/* 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:


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:


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 (http://www.dnxpert.com/forum)

vb_mp
09-13-2008, 10:05 PM
Reserving this spot for future updates.

Hornstar
09-13-2008, 10:15 PM
Thanks for sharing this, I am going to give this a go next week on my holidays and will see how it goes. I have been meaning to do something like this for a while now, so many thanks for sharing. will let you know how things go. thanks.

vb_mp
09-13-2008, 10:19 PM
No worries, it was fun to do - and it's useful :). I look forward to you trying it out.

creativepart
09-13-2008, 10:42 PM
Sorry to sound dumb, but what the heck is iDevAffiliate? I went to their website and I still don't know what this program does. Can you explain it please?

vb_mp
09-13-2008, 11:14 PM
Sorry to sound dumb, but what the heck is iDevAffiliate? I went to their website and I still don't know what this program does. Can you explain it please?

It's an affiliate management software. Let's people sign up to your affiliate program and earn commissions for promoting your paid subscriptions (or other products).

bada_bing
09-14-2008, 02:17 AM
Wow this is great I have been waiting for this for a couple of years not as I purchased the iDev software but could not effectively use it...

Question is because my one site is on 3.5.x version I would have to get verification that this hack works with that version before I hack up my payment.php file and install the plugin and risk my database getting corrupted.. CAN SOMEONE VERIFY THIS WORKS WITH VB 3.5.x PLEASE.

Thank You

creativepart
09-14-2008, 03:14 AM
OK, I see. I'm used to being an affiliate for others not having others be affiliates for me. Thanks for the description.

vb_mp
09-14-2008, 10:00 AM
Wow this is great I have been waiting for this for a couple of years not as I purchased the iDev software but could not effectively use it...

Question is because my one site is on 3.5.x version I would have to get verification that this hack works with that version before I hack up my payment.php file and install the plugin and risk my database getting corrupted.. CAN SOMEONE VERIFY THIS WORKS WITH VB 3.5.x PLEASE.


Thank You

I haven't got a dev server so I am not able to install 3.5.x anywhere to test it. Perhaps someone else can and let us know.

TeelK
09-14-2008, 11:39 AM
tagged.. but i would never edit any original vb files as because when and upgrade comes out you have to do it all again, al wait see if someone can make it so no edit of files is possible.

vb_mp
09-14-2008, 01:15 PM
tagged.. but i would never edit any original vb files as because when and upgrade comes out you have to do it all again, al wait see if someone can make it so no edit of files is possible.

I could make it so that no original files are edited if they put a hook in the right place (in the payment and payment_gateway files).

Currently, there are no hooks, but I think there is a place around here where I can request hooks for new upgrades so I will do that.

mambomouth
09-14-2008, 07:20 PM
fantastic work I can't wait to try this.
Thanks a "vb_mp"

vb_mp
09-14-2008, 08:52 PM
fantastic work I can't wait to try this.
Thanks a "vb_mp"

No probs :). Let me know how you go. It's currently live and counting commissions for my affiliates on my site.

jasculs
09-15-2008, 03:39 PM
Hey vb_mp have you tested this out with some of your members already getting recorded commissions? If so then you're the best person ever because I've been looking for a paid subscription affiliate system for a very very long time.

vb_mp
09-15-2008, 09:09 PM
Yea I have tested it - it is currently working and functional on my forum ( link is above in the original post ). People are spreading the affiliate link around and commissions are being generated on subscription purchases.

The things to note - according to iDevAffiliate they will be releasing a new release that will enable deletion of commissions on payment reversal... currently when a payment is reversed (for example on a refund) you have to manually cancel the subscription in iDevAffiliate... this is not a vBulletin problem though, rather a iDevAffiliate deficiency.

The guys from iDevAffiliate have promised that this payment reversal curl target url will be released in new upgrade, once that's there I will add it to this mod.

jasculs
09-15-2008, 09:29 PM
Yea I have tested it - it is currently working and functional on my forum ( link is above in the original post ). People are spreading the affiliate link around and commissions are being generated on subscription purchases.

The things to note - according to iDevAffiliate they will be releasing a new release that will enable deletion of commissions on payment reversal... currently when a payment is reversed (for example on a refund) you have to manually cancel the subscription in iDevAffiliate... this is not a vBulletin problem though, rather a iDevAffiliate deficiency.

The guys from iDevAffiliate have promised that this payment reversal curl target url will be released in new upgrade, once that's there I will add it to this mod.

Great Thank You!!...I just wanted to be sure before I purchased the software. I know it may be a little off topic, but how do you like the affiliate software?

Also if I have people on recurring billing can I have it work with recurring commissions?

Thanks a lot!!
Jason

vb_mp
09-15-2008, 09:50 PM
I like iDevAffiliate, easy to install, works well.

Paypal recurring commissions (I have them on my forum (http://www.dnxpert.com/forum)) are treated as individual payments each month - it works quite well.

User signs up - iDevAffiliate records payment information, affiliate gets commission. Next month, PayPal triggers IPN on recurring payment, idevaffiliate checks payment info and credits affiliate with another commission - and so on.

iDevAffiliate has some internal recurring commissions setup - make sure you ignore that - it's some manual recurring commissions crap.

Also, once you install iDevAffiliate, make sure you download this patch that fixes a bug of approving/unapproving commissions:
http://www.idevsupport.com/index.php?_m=downloads&_a=viewdownload&downloaditemid=16&nav=0

Cheers

Quarterbore
09-16-2008, 12:50 AM
You listed some pros in your credits but I likewise really would prefer not install this until it is plugin based. I would rather add a couple queries on the occasion where I get a purchase then to have to risk that there is an upgrade out and I need to deal with hardcoded file edits.

vb_mp
09-16-2008, 10:57 AM
You listed some pros in your credits but I likewise really would prefer not install this until it is plugin based. I would rather add a couple queries on the occasion where I get a purchase then to have to risk that there is an upgrade out and I need to deal with hardcoded file edits.

That's totally cool with me. I posted this mod to allow the people that have been searching for a mod for this for ages to get it and use it.

I will however fix it to use hooks as soon as some hooks are made available by vBulletin.com

mambomouth
09-16-2008, 10:23 PM
I have installed but have not recorded any sales.
Wait traffic site to send a sale ;).

yahoooh
09-17-2008, 01:19 AM
is integrated for users in vbulletin?

Quarterbore
09-17-2008, 01:53 AM
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:

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 :eek: 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

vb_mp
09-17-2008, 01:59 PM
Thanks for your comments Ken.

I have left my answers below each part of yours:

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.


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!

mambomouth
09-17-2008, 02:06 PM
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/setup.php?action=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:D

Cheers,
Brian

vb_mp
09-17-2008, 02:09 PM
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.

mambomouth
09-17-2008, 02:23 PM
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

mambomouth
09-17-2008, 02:50 PM
You know that another good mod for this is to add Google analytics code for sale
on ROI for ad's.

vb_mp
09-17-2008, 05:59 PM
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?

Quarterbore
09-17-2008, 06:16 PM
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:

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.

Quarterbore
09-17-2008, 06:38 PM
Edit - never mind I had the wrong hook :o

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...

$vars = get_defined_vars();
print_r($vars);
exit();

I need to look at this later.

mambomouth
09-18-2008, 02:12 AM
Ok i'm jack A**.
I did not upload one the files I needed edited for the Mod to work.
Anyhow it should work now.

Correction Idevaffiliate does have a API key see there demo and see PDF manual
See link:>
http://demo.idevdirect.com/admin/idev_info.php


As for the hook questions?
I'm not sure but in the past looking for a solution I found in the Phrase Manager
that info needed is inside both Phrase emails etc.

See this link:
https://vborg.vbsupport.ru/showpost.php?p=1226988&postcount=4

I understand what the hook system does but it may help one of you.

mambomouth
09-22-2008, 05:06 PM
Hello All,

Great after fixing own error by not uploading the edit files.
I everything is working well.

Now only a few things Idev lets you pass
:>Additional Order Details (optional pass-thru variables) via the >Alternate Cart Integration.
There are three Variables one can add to:

With I guess can be added to the
$idevQuery = "idev_saleamt=" . $apiobj->paymentinfo['amount'] . "&ip_address=" . $apiobj->paymentinfo['ipaddress'] . "&idev_ordernum=" . $apiobj->paymentinfo['paymentinfoid'];


Concatenating the optional variables that you have set in Idev-affiliate.
"&idev_custom1=" . $apiobj->paymentinfo['extra'];

also I noticed that variable for the order ID being passed is the table ID in a database. Not a transaction number or hash needed to look up the status of the order in the back end.
You cannot search this ID number in the back of Vbulletin administrator for transactions logs etc.

Also we should look into payment reversals.
To take away the commission in case of payment reversal.


Still this is fantastic progress.

mambomouth
09-22-2008, 08:01 PM
As for the Hooks question?

In the includes/class_paid_subscription.php
which is called by both the payment_gateway.php and payments.php.

There are two hooks
1. "paidsub_build" which adds the user to a subscription group.
If paid this execute credit to Affiliate.

2. "paidsub_delete" which deletes the user a subscription group.
If revered this execute minus credit to Affiliate.

What do you guys think?
This way we would not to hand code mod's on updates.

vb_mp
09-23-2008, 11:11 AM
As for the Hooks question?

In the includes/class_paid_subscription.php
which is called by both the payment_gateway.php and payments.php.

There are two hooks
1. "paidsub_build" which adds the user to a subscription group.
If paid this execute credit to Affiliate.

2. "paidsub_delete" which deletes the user a subscription group.
If revered this execute minus credit to Affiliate.

What do you guys think?
This way we would not to hand code mod's on updates.

iDevAffiliate still doesn't handle reversed payments. They say it will be handled in the next upgrade.

As for the hooks - we mentioned in a couple of earlier posts - but we are not sure where to get the data from to process idev calls at present hook locations.

There is also still not a hook that can be used to insert IP address into paymentinfo only on first payment and not on recurring payments ... so payments.php would still need to be hand edited.

WIHEE
09-27-2008, 01:49 AM
I have installed it without any problem and is working 100%

Thanks

nibb
09-27-2008, 08:18 AM
Hi everyone, im looking this for since I own Vbulletin. I have Idev for 3 years. Its great, it can be integrated with almost anything and Vbulletin was really missing.
My question is, is this really working? I mean like without bugs or errors, for a commercial site? Im even willing to pay for this mod. Also my current Idev install is already integrated with a shopping cart, i suppose it will no hurt to have it with vbulletin at the same time since all this mods seems to do is pass to idev when a payment is made. Is this correct?

gwerzal
10-11-2008, 11:54 PM
Does idevaffiliate need to be installed on the same website for this to work

vb_mp
10-19-2008, 02:07 PM
Nope, from the above curl call you have to specify the website and idevaffiliate directory where you notify of commissions:
http://www.YOURDOMAINNAME.com/YOURIDEVINSTALATIONFOLDER/sale.php

RS25com
01-28-2009, 02:59 PM
Has anyone installed this on 3.8? :)

fionix
02-14-2009, 09:01 AM
Yes would be nice to know it works with 3.8.

Anyway I go and try to install it now and will post back here if my forum crashed :)

fionix
02-14-2009, 09:17 AM
Yes it works perfectly on V.3.8

Only little probolem is if you want to customize the code to have different comissions, don't know how to do that. Any help?

In the video it says you have to put this code on the line: &idev_commission=XX

CRP
02-18-2009, 01:24 AM
Just tested on V3.8.1 and it worked great. Well, I have to charge tax and it calculated commission on gross, but I can live with that for now.

I had bought Idevaffiliate for another part of my site, and still not able to get it working with software that was supposed to be already integrated with each other. But, this one worked perfect first try. Thanks so much for doing this.

Installed.

forumguy1
03-05-2010, 03:50 PM
will this work with vb 4.0?

benative
03-10-2010, 03:14 AM
ya seriously!!! does it work with vbulletin 4.0??????

forumguy1
03-11-2010, 02:54 PM
Can any shed some light on this and let us know if it works with vb 4.0?

I am willing to pay someone as well to port it over if necessary.

benative
03-14-2010, 04:17 AM
There's

Standard Edition
Gold Edition
Platinum Edition

on http://www.idevdirect.com

what should I purchase to get this working???

forumguy1
03-15-2010, 01:27 PM
Either will work fine from those 3. Were just not sure it if works with VB 4.0.

benative
03-16-2010, 01:26 AM
Please let us know if it works with VB 4.0

MichaelaS
08-31-2010, 05:42 PM
I'm running 3.8.3 and I've been using this mod for a year with my forum. The tracking is not working properly for me at all. It's dropping commissions on active (paying) members, double paying occasionally, and all sorts of random issues. Nothing consistent at all so as to troubleshoot and track down where the problem is occurring.

Since I get an Order Number in iDev, with no association to the actual forum user or username, I've had to track every single one back to orders by the date & timestamp - to figure out what kind of issues I was having in the first place. It's a real mess. I had iDev support look into it with me, but have no choice but to close my affiliate program at this point.

Anyone else had these tracking issues (that you know of) - and/or know a solution I can try?

Thank you