OK, this was hellish for me because I was a PHP noob. (Note the past tense.)
What I finally did is steeped in a healthy dose of PHP superstition, but it works.
Nothing I did worked on the JAM PHP integration, and I still don't know why, and maybe I never will. I ended up going with the image tag implementation, but that was meant for an HTML page, not a PHP page, but I adjusted it to work on a PHP page.
First, I found that JAM has good code to avoid duplicate commissions, so putting the image tag on the checkout_success.php page is just fine.
I did set the necessary variables as my own session variables over in the /webassist/plugins/shopping_cart/cart_readonly.php page, and there I did the math that Jason provided. I put this right before the final <script> tag:
// Affiliate Code Math Here
(My initials are EPC.)
Then, on the checkout_success.php, I put this code right after this line:
<div class="contentBox ps_pod1 borderColor">
(this is the inserted code now):
echo ('<img border="0" src="https://mydomain.com/affiliate_folder/sale.php?amount='.$FINALamount.'&trans_id='.$FINALtrans_id.'" width="1" height="1">')
As I said, superstitious, but this went on for 4 days for me. Then I learned about escaping the quotes. I could have just written--
echo ('<img border="0" src="https://mydomain.com/affiliate_folder/sale.php?amount='.$_SESSION['EPCamount'].'&trans_id='.$_SESSION['EPCtrans_id'].'" width="1" height="1">')
-- and done it in one line. Maybe I could have done the "math" here as well (probably), but I went through a bit of hell with this, so I hope it helps you if you need it. It works!
Also, note the "https://" action. My PowerStore is secure, but if your's isn't, drop the "s" and make it "http://". Good luck!