JAM Affiliate Tracking

From PhpCOIN Documentation

Jump to: navigation, search

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

  • Download JAM from here and follow their manual to install it.


JAM Installation Requirements

  • PHP safe_mode set to Off
  • Curl + SSL option compiled into PHP.
  • Ability to load Ioncube Loaders
  • For Zend, you will need to have the Zend Optimizer installed on your Web Server


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. [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';
    
  • Add this line within your PayPal button form:
  • <script language="JavaScript" type="text/javascript"
     src="http://www.yourdomain.com/affiliates/showaff.php?id=paypal">
    </script>
    
  • Make sure to edit http://www.yourdomain.com/affiliates to your affiliates url.
  • If you are using the Paypal Automatic Refund Module, set the $secret = 'yoursecretword'; to your secret word
  • Run some test transactions.
  • If it records both the Paypal sale and the commission, then you have JAM properly setup with phpCOIN

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']."");
    }
    
  • Open /coin_includes/api.php and find:
  • 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;
    
  • for cheque option you should have:
  • 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']."");
    }
    
  • for transfer:
  • 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 you are using both cheque and transfer methods, then obviously:
  • 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']."");
    }<
    
  • Make sure to edit http://www.yourdomain.com/affiliates to your affiliates url.
  • Turn On API settings in phpCOIN admin area

Integration with 2Checkout


Automatic Signup Module (ASM)

  • Create a file named as config.autosignup.inc.php with the following contents:
  • <?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'];
    ?>
    
  • Create a folder named as 'phpcoin' in [affiliates_folder]/plugins/signup_automation/external/ and upload the file there. (so the file will be located at: /plugins/signup_automation/external/phpcoin/config.autosignup.inc.php)
  • Open coin_includes/api.php and find:
  •  function APIO_order_new_client ($_APIO_AData) {
    

    After this line:

    # Do whatever, set returns
    

    And before this line:

    $_APIO_Ret['dn'] = 1;
    

    Add this block:

    //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
    
  • Make sure to edit $JAM_Aff_Directory
  • Open [affiliates_folder]/plugins/signup_automation/external/plugin.autosignup.php and edit:
  • //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
    
  • Make sure $JAM_Secret is the same as what you set at your JAM admin area at "Settings > Signup Settings"
  • Make sure you did enable Automatic Signup Module at your JAM admin area at "Settings > Signup Settings"
Personal tools

Inscrita el Registro Mercantil de Mallorca Tomo 2140, Hoja No. PM-51034, Folio 135
This website owned and operated by: Technology Services RPVW S.L. CIF# B57345084
Avda Constitucion 48 Bajos Alaro 07340 Baleares SPAIN
Tel:+34 971518362    Fax: +34 971518368    eMail: support@phpcoin.com