J2 Store is a simple shopping cart application for Joomla.This integration method integrates offline sales and sales processed by PayPal.

1.

Offline sale

Open file plugins/j2store/payment_offline/payment_offline.php and find function _postPayment and this line within it:
        if ($orderpayment->save()) {

Add this code right above the line:
        $vars->order_id = $orderpayment->order_id;
        $vars->total_cost = $orderpayment->order_subtotal;

Save your work. Now open file plugins/j2store/payment_offline/payment_offline/tmpl/postpayment.php and add this code to the end of the file:

<script type="text/javascript">
	document.write(unescape("%3Cscript id=%27pap_x2s6df8d%27 src=%27" + (("https:" == document.location.protocol) ? "https://" : "http://") + "URL_TO_PostAffiliatePro/scripts/trackjs.js%27 type=%27text/javascript%27%3E%3C/script%3E")); 
</script>
 <script type="text/javascript">
  PostAffTracker.setAccountId('Account_ID');
  var sale = PostAffTracker.createSale();
  sale.setTotalCost('<?php echo $vars->total_cost; ?>');
  sale.setOrderID('<?php echo $vars->order_id; ?>');
  sale.setStatus('P');

  PostAffTracker.register();
  </script>

Save your work. This will create a pending commission for each offline transaction. You will have to approve or decline it manually later - based on the original transaction.

2.

PayPal step 1

Find file plugins/j2store/payment_paypal/payment_paypal/tmpl/prepayment.php and find the notify_url input field. It looks something like this:

<input type="hidden" name="notifyurl" value="<?php echo JRoute::( $vars->notify_url ); ?>" />

and into that field add:

id='pap_ab78y5t4a'

The updated field is supposed to look like this:

<input id='pap_ab78y5t4a' type="hidden" name="notifyurl" value="<?php echo JRoute::( $vars->notify_url ); ?>" />

Right under that _notifyurl input field (so right under that line of code) place this code below:

<!-- Post Affiliate Pro Integration snippet -->
<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"> </script>
<script type="text/javascript">
PostAffTracker.writeCookieToCustomField('pap_ab78y5t4a', '', 'pap_custom'); 
</script>
<!-- /Post Affiliate Pro Integration snippet -->

3.

PayPal step 2

Open file plugins/j2store/payment_paypal/payment_paypal.php and find function _process() and this line within it:

$data = $app->input->getArray($_POST);

Now add this code below right above that line:

 /* Post Affiliate Pro integration snippet */
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://URL_TO_PostAffiliatePro/plugins/PayPal/paypal.php?pap_custom=".@$_GET['pap_custom']);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
    curl_exec($ch);
  /* /Post Affiliate Pro integration snippet */


Do not forget to integrate you Joomla with the click tracking code and to activate the PayPal IPN Handling plugin in your installation of Post Affiliate Pro.