For example if a product worth Rs 1000 is to be purchased and if the payment is made right away then the vendor may give a discount and the product can be purchased at a price lower than Rs 1000. This deal has mutual benefit. The customer gets the product at a lower price and the vendor gets the money to maintain his cash flow.
The discount is also availed if there is a clause in the contract that if the payment is made within a stipulated time then the customer is eligible for a discount. For example many vendors have this practice that if the payment is done within 10 days of procurement then they give discount. Else if the payment is done by 30th day then the customer is required to pay the full amount. Beyond that there will be interest charged on the payable amount.
But practically it is the negotiation which leads to discount. A customer asks for a discount by giving the money right away or within a few days.
Sometimes the discount is also availed by purchasing in bulk from the vendor. The vendor gets more of his inventory cleared and hence he is able to fulfill his target requirements and the customer enjoys the benefit of getting the discount.