Your performance in the class and your ability to pass the AP test are very different things. At some schools the class is more rigorous than the test but that is generally not the case. Be open with your teacher He or she may suggest not taking exam so you don’t have a poor score. Some colleges require all scores to be submitted.
Depending on your school, there may be a way to move to a lower level math class, complete some of the missed work, or otherwise improve your grade. Be humble, take responsibility, and don’t try and shift the blame. Talk to the teacher and counselor. Occasionally failing vs. a D actually triggers more options like the ability to retake a class like Business Calculus and replace the grade vs. a D as an earned grade.