As a merchant, you're able to define a store-wide default commission rate as well as custom-define a rate for an individual affiliate. You can read more about those settings here.
Commission is determined including discounts and excluding shipping and tax.
So, for an example, you have a product that's being sold as follows:
$5 flat shipping
Let's assume you have a 5% commission rate on your store. A shopper then purchases this product via an affiliate link.
The shopper's total will be $93:
$80 ($100 product plus 20% discount)
$8 for tax (10% tax)
Your affiliate will be owed $4 (5% x $80 = $4), based on the price of the product, less discount and not including tax and shipping.