In your contract, you should have acceptance tests specified. The contractor that hires you should test and approve the product. If it's not what they want, contains bugs, or is not as specified by them, they should not accept. When they have accepted the product, they should pay for bugs. You should agree about this before starting.
For now, fix those bugs, and think of it as a good and valuable lesson.