Jump to content

WHMCS & JROX integration


naichunlei

Recommended Posts

Hi,

I'm trying to integrate WHMCS & JROX. I'm using Paypal to accept payment.

I put the code for WHMCS & JROX integration found in JROX knowledge base in the checkout script.

The problem I'm having is that I have multiple programs in JROX. I have 6 products with different commission rate and different recurring periods.

(1) Monthly Payment Basic Package (1-tier:$10, 2-tier:$5)

(2) Monthly Payment Business Package (1-tier:$15, 2-tier:$5)

(3) Monthly Payment OnlineShop Package (1-tier:$20, 2-tier:$5)

(4) Annually Payment Basic Package (1-tier:$100, 2-tier:$50)

(5) Annually Payment Business Package (1-tier:$150, 2-tier:$50)

(6) Annually Payment OnlineShop Package (1-tier:$200, 2-tier:$50)

 

How do we know if different products purchased on WHMCS get traced correctly on JROX? Does the code on checkout script differentiate between different products?

Anyone has any luck integrating these 2 application with multiple products?

Link to comment
Share on other sites

I got replies from JROX folks:

 

====================================================================

 

If you can set some code that maps the products to the program ID, then you can do it.

 

Here's a logical example (not code)

 

If product A is purchased, then run this code for program ID 1:

 

$JAMIntegrate = file_get_contents("http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$ordernumber."&custom_mid=".$_COOKIE['jrox']."

&program_id=1");

 

If product B is purchased, then run trhis code for program ID 2:

 

$JAMIntegrate = file_get_contents("http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$ordernumber."&custom_mid=".$_COOKIE['jrox']."

&program_id=2");

 

If you notice the "&program_id=1", option in the integration code - this forces the commission to use the commission settings for that program in JAM.

 

This might be how you can integrate it according to your preferences. However, you'll have to turn the logic here into some code for WHMCS integration.

 

====================================================================

Link to comment
Share on other sites

checkoutscript.php:

 

<?php

/*

**************************************************

************** WHMCS CheckOut Script *************

**************************************************

You may enter code here which will be run when

a user checks out if you have enabled it in

Configuration > General Configuration > Other

of your WHMCS Admin Area. The following

variables are available to you:

**************************************************

Order ID: $orderid

Order Number: $ordernumber

Invoice ID: $invoiceid

Product ID: $productid

Domains Array: $domains

Addons Array: $addons

**************************************************

*/

// You got mail!

mail($emailto, $subject, $message, $headers);

 

$result=mysql_query("SELECT * FROM tblorders WHERE ordernum = '$ordernumber' LIMIT 1");

$row = mysql_fetch_array($result);

$amount = $row['amount'];

?>

Link to comment
Share on other sites

  • 2 months later...

# Open up your whmcs/includes/checkoutscript.php file for editing.

# Near the bottom of the file, add the following lines:

 

// You got mail!

mail($emailto, $subject, $message, $headers);

 

$result=mysql_query("SELECT * FROM tblorders WHERE ordernum = '$ordernumber' LIMIT 1");

$row = mysql_fetch_array($result);

$amount = $row['amount'];

 

$JAMIntegrate = file_get_contents("http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$ordernumber."&custom_mid=".$_COOKIE['jrox']."");

 

?>

# Make sure to point http://www.domain.com/affiliates to your JAM installation URL

 

 

Jrox tells me to do this there is no checkout.php helppppppppppp

Andy

Link to comment
Share on other sites

The proper file to use now is includes/actionhooks.php

 

You will want to put the code after

function actionhook_ShoppingCartCheckout($vars) {
# This function runs when the user checks out using the shopping cart
# $vars["OrderID"] - Order ID Number
# $vars["OrderNumber"] - 10 Digit Order Number
# $vars["InvoiceID"] - Invoice ID Number
# $vars["Products"] - Array of Product IDs from Order
# $vars["Addons"] - Array of Addon IDs from Order
# $vars["Domains"] - Array of Domain IDs from Order

Link to comment
Share on other sites

  • 3 weeks later...

Hi Brett,

 

So you are saying I should include the code as follows:

 

function actionhook_ShoppingCartCheckout($vars) {
# This function runs when the user checks out using the shopping cart
# $vars["OrderID"] - Order ID Number
# $vars["OrderNumber"] - 10 Digit Order Number
# $vars["InvoiceID"] - Invoice ID Number
# $vars["Products"] - Array of Product IDs from Order
# $vars["Addons"] - Array of Addon IDs from Order
# $vars["Domains"] - Array of Domain IDs from Order

// You got mail!
mail($emailto, $subject, $message, $headers);

$result=mysql_query("SELECT * FROM tblorders WHERE ordernum = '$ordernumber' LIMIT 1");
$row = mysql_fetch_array($result);
$amount = $row['amount'];

$JAMIntegrate = file_get_contents("http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$ordernumber."&custom_mid=".$_COOKIE['jrox']."");

?>

}

 

Cheers,

Marty

Link to comment
Share on other sites

  • 2 weeks later...

Hi to all, can some one assist me on what happens next I have entered that code in to the action hooks in fact on the other post about intergration has a better code to input do I use just the one or both.

What I need to know is how do I make sure the commissions are done how does it set off commissions is it with cookies

Has any one here sone it and can assist me with it

Thx Andy

Biz Global Solutions

Link to comment
Share on other sites

  • 7 months later...

Actionhooks are contained within the /includes/actionhooks.php file.

 

Functions defined in here are called by WHMCS at the appropriate time so any PHP code contained within the functions will also execute at that time.

 

Each function has a list of variables generated by WHMCS that you can access near the top of the function.

Link to comment
Share on other sites

  • 2 months later...

I have posted on the Jrox forum but definative answer yet..

 

http://forums.jrox.com/index.php/topic,3232.0.html

 

Latest version of WHMCS 3.8.1

 

Click are being tracked ok

 

I tested the commission generation through the browser:

http://www.domain.com/affiliates/sale.php?amount=20&trans_id=TEST

and it's OK. Commission is showing in the JAM admin area.

 

My code - ( I know there is no www - that how I set up JAM on this domain)

 

Code:

if (!empty($_COOKIE['jrox']))
   {
       $result=mysql_query("SELECT * FROM tblorders WHERE id = '" . $vars["InvoiceID"] ."' LIMIT 1");
       $row = mysql_fetch_array($result);

       $JAMIntegrate = file_get_contents("http://XXXXhost.com/partner/sale.php?amount=".$row['amount']."&trans_id=".$vars["InvoiceID"]."&custom_mid=".$_COOKIE['jrox']);

   }

 

 

 

I tried under the InvoicePaid Hook - function actionhook_InvoicePaid($vars)( Yes I entered a payment in WHMCS)

and also under the shopping cart checkout hook - function actionhook_ShoppingCartCheckout($vars)

 

Nothing...

 

then tried the following with the same result.

 

 

echo "http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$orderid."&custom_mid=".$_COOKIE['jrox'].""; exit();

and i tried to place an order in WHMCS shopping cart.

When i completed the order it appears a page with the following line:

http://www.domain.com/affiliates/sale.php?amount=&trans_id=&custom_mid=1%23%23%231%23%23%230%23%23%230%23%23%23Unknown

but i don't find a pending commission in the JAM admin area.

 

 

JRoxAdmin response:

the issue here is that the amount and trans_id variables are not showing up.

 

since we dont have a copy of WHMCS, we suggest asking the folks there what variable name we can use to be able to get the sale and transaction amounts.

 

Can someone confirm that this should work and how please.

Link to comment
Share on other sites

I am still trying to get Jrox Jam integrated with WHMCS

 

Has any one succesfully done this and will to share solution?

 

This was my post on the Jrox forum a couple of days ago and the answer from Jroxadmin.

 

Latest version of WHMCS 3.8.1

 

Click are being tracked ok

 

I tested the commission generation through the browser:

http://www.domain.com/affiliates/sale.php?amount=20&trans_id=TEST

and it's OK. Commission is showing in the JAM admin area.

 

My code - ( I know there is no www - that how I set up JAM on this domain)

 

Code:

if (!empty($_COOKIE['jrox']))
   {
       $result=mysql_query("SELECT * FROM tblorders WHERE id = '" . $vars["InvoiceID"] ."' LIMIT 1");
       $row = mysql_fetch_array($result);

       $JAMIntegrate = file_get_contents("http://XXXXhost.com/partner/sale.php?amount=".$row['amount']."&trans_id=".$vars["InvoiceID"]."&custom_mid=".$_COOKIE['jrox']);

   }

I tried under the InvoicePaid Hook - function actionhook_InvoicePaid($vars)( Yes I entered a payment in WHMCS)

and also under the shopping cart checkout hook - function actionhook_ShoppingCartCheckout($vars)

 

Nothing...

 

then tried the following with the same result.

 

 

echo "http://www.domain.com/affiliates/sale.php?amount=".$amount."&trans_id=".$orderid."&custom_mid=".$_COOKIE['jrox'].""; exit();

and i tried to place an order in WHMCS shopping cart.

When i completed the order it appears a page with the following line:

http://www.domain.com/affiliates/sale.php?amount=&trans_id=&custom_mid=1%23%23%231%23%23%230%23%23%230%23%23%23Unknown

but i don't find a pending commission in the JAM admin area.

 

Answer from Jroxadmin:

 

the issue here is that the amount and trans_id variables are not showing up.

 

since we dont have a copy of WHMCS, we suggest asking the folks there what variable name we can use to be able to get the sale and transaction amounts.

 

Help anyone?

Link to comment
Share on other sites

  • 3 weeks later...

Yes, I have a solution to your problem.

 

The problem is in the integration code. JRox is using the wrong variables to check the table

in WHMCS to get the amount. Here is the proper code to make it work:

 

if (!empty($_COOKIE['jrox'])){
       $result=mysql_query("SELECT * FROM tblorders WHERE invoiceid = '" . $vars["InvoiceID"] ."' LIMIT 1");
       $row = mysql_fetch_array($result);

	$JAMIntegrate = file_get_contents("http://www.yourdomain.com/affiliates/sale.php?amount=".$row['amount']."&trans_id=".$vars["InvoiceID"]."&custom_mid=".$_COOKIE['jrox']);
   }

 

The reason for the problem is in the mysql_query(). You need to change the id = '" .$vars["InvoiceID"] ."' to invoiceid = '" . $vars["InvoiceID"] . "'

 

And you are putting it in the right place function actionhook_InvoicePaid($vars)

 

Sorry this solution took so long to get to you, I just started integrating JAM last night and was running into this same

issue.

 

Hope this helps.

 

Regards,

Ray

Edited by Idealws
Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated