JAM Affiliate Tracking
From PhpCOIN Documentation
Please Note: The instructions and functionality contained within this page have not been tested by phpCOIN support staff. This page
is reprinted as-is from the JAM documentation, with the exception of:- Using sanitized variables rather then potentially unclean $_POST variables the original page states to use, and
- Making the code slightly more readable without changing any of the original logic.
- Additional information has been provided by phpCOIN Support Forums user nimasdj
- config.autosignup.inc.php and edited api.php are available on phpCOIN download page.
Contents |
JAM Installation
JAM Installation Requirements
Integration with PayPal
Requirements
To integrate JAM with phpCOIN, there are a few requirements:
- You must have Curl compiled with PHP. To check, view your php configuration (phpinfo()) and see if there is an entry for Curl.
- You must have register_globals setting in PHP set to On. [Ed. Note: this is not a requirement of phpCOIN]
To integrate JAM with phpCOIN using Paypal, follow these instructions:
- Within JAM, click on Settings>System Integration then select Paypal IPN on the Integration Type drop down list.
- Eter "$paypal_amount" for amount as the Sale Amount variable to use.
- Enter "$txn_id" for transaction or order ID as the Transaction ID variable to use.
- Click Save Integration Settings
Integration
There are two ways to integrate JAM with phpCOIN using Paypal. First if you are not using the Paypal IPN module, you can just add the Paypal IPN integration code to your Paypal buy now buttons. If you are using the IPN module for phpCOIN, there are a few things you must do:
- On your phpCOIN powered website, open up and edit /coin_modules/ipn/vendors/paypal/paypal.php
- Copy and Paste the following integration code in between these lines:
# should we accept data?
IF (!$_ACFG['IPN_ACCEPT_INCOMING']) {exit;}
###################################
## INTEGRATE JAM AFFILIATE CODE ##
###################################
if (isset($_GPV['txn_id']) AND isset($_GPV['custom'])) {
$JAM_Affiliate_URL = "http://www.yourdomain.com/affiliates"; //DO NOT ADD TRAILING SLASH
if (function_exists(curl_init)) {
if (isset($_GPV['reason_code']) AND $_GPV['reason_code'] == 'refund') {
$secret = 'yoursecretword'; //ENTER YOUR SECRET CODE FOR AUTOMATIC REFUND MODULE
$url = $JAM_Affiliate_URL . "/refund.php?transaction_id=".
$_GPV['parent_txn_id'] ."&secret=".$secret;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$resp = curl_exec($ch);
curl_close ($ch);
} else {
$url = $JAM_Affiliate_URL . "/sale.php?amount=".$_GPV['mc_gross']
."&trans_id=".$_GPV['txn_id']."&custom_mid=".$_GPV['custom'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$resp = curl_exec($ch);
curl_close ($ch);
}
}
}
################################
## END JAM INTEGRATION CODE ##
###############################
# read the post from PayPal and add 'cmd'
$req = 'cmd=_notIF y-validate';
<script language="JavaScript" type="text/javascript" src="http://www.yourdomain.com/affiliates/showaff.php?id=paypal"></script>
Integration with Offline Payments (e.g. cheque or Bank Transfer)
- In admin area-> vendor settings look at:
Buy Return Param Name:
Buy Return Param Value:
of your desired vendor option which you want to integrate with JAM. For example if you want to call jam for cheque option the variables above would be:
Buy Return Param Name: cheque
Buy Return Param Value: 1
or for Bank Transfer would be:
Buy Return Param Name: transfer
Buy Return Param Value: 1
so in api.php in the location mentioned in next step, you should have something like:
if ($_APIO_AData['Buy Return Param Name'] == 'Buy Return Param Value') {
$JAMIntegrate = file_get_contents("http://www.yourdomain.com/affiliates/sale.php?amount=".$_APIO_AData['ord_unit_cost']."&trans_id=".$_APIO_AData['ord_id']."&custom_mid=".$_COOKIE['jrox']."");
}
function APIO_order_ret_proc ($_APIO_AData)
Write the codes mentioned in next step after:
# Do whatever, set returns
and before:
$_APIO_Ret['dn'] = 1;
if ($_APIO_AData['cheque']== '1') {
$JAMIntegrate = file_get_contents("http://www.yourdomain.com/affiliates/sale.php?amount=".$_APIO_AData['ord_unit_cost']."&trans_id=".$_APIO_AData['ord_id']."&custom_mid=".$_COOKIE['jrox']."");
}
if ($_APIO_AData['transfer']== '1') {
$JAMIntegrate = file_get_contents("http://www.yourdomain.com/affiliates/sale.php?amount=".$_APIO_AData['ord_unit_cost']."&trans_id=".$_APIO_AData['ord_id']."&custom_mid=".$_COOKIE['jrox']."");
}
if ($_APIO_AData['transfer']== '1' || $_APIO_AData['cheque']== '1') {
$JAMIntegrate = file_get_contents("http://www.yourdomain.com/affiliates/sale.php?amount=".$_APIO_AData['ord_unit_cost']."&trans_id=".$_APIO_AData['ord_id']."&custom_mid=".$_COOKIE['jrox']."");
}
Integration with 2Checkout
Automatic Signup Module (ASM)
<?php $JAM_First_Name = $_APIO_AData['ord_name_first']; $JAM_Last_Name = $_APIO_AData['ord_name_last']; $JAM_Primary_Email = $_APIO_AData['ord_email']; $JAM_Username = $_APIO_AData['ord_user_name']; $JAM_Company = $_APIO_AData['ord_company']; $JAM_Address_1 = $_APIO_AData['ord_addr_01']; $JAM_City = $_APIO_AData['ord_city']; $JAM_State = $_APIO_AData['ord_state_prov']; $JAM_Country = $_APIO_AData['ord_country']; $JAM_Zip = $_APIO_AData['ord_zip_code']; $JAM_Phone = $_APIO_AData['ord_phone']; $JAM_Website = "http://www.".$_APIO_AData['ord_domain']; ?>
function APIO_order_new_client ($_APIO_AData) {
# Do whatever, set returns
Before:
$_APIO_Ret['dn'] = 1;
//BLOCK FOR JAM-ASM MODULE INTEGRATION $JAM_Aff_Directory = '/home/username/public_html/affiliates_directory'; $JAM_ASM_Type = 'phpcoin'; require $JAM_Aff_Directory . '/plugins/signup_automation/external/plugin.autosignup.php'; //END JAM-ASM MODULE INTEGRATION
//SET JAM VARIABLES $JAM_Secret = "secretword"; //SET THIS VARIABLE TO ENABLE SECURITY CHECK OF AUTOSIGNUP $JAM_Affiliate_URL = "http://www.domain.com/affiliates"; //DO NOT ADD TRAILING SLASH

