Un-paid appointments sticking to the calendar in infusionsoft

I am using REST api and have an issue when cancelling expired appointments . example payment where credit card authentication failed but still showing as appointment in calendar. can you tell me exact condition to check while cancelling appointments which are not paid or status is ‘Failed’ ? I will really appreciate if you can help

Appointments don’t have “Failed” states in Infusionsoft. You will probably need to delete the Appointment.