def delete_customer_profile(self): """Delete the customer profile on payment gateway """ if self.customer_profile_id: has_other_rps = RecurringPayment.objects.filter( customer_profile_id=self.customer_profile_id ).exclude(id=self.id).exists() if not has_other_rps: cim_customer_profile = CIMCustomerProfile(self.customer_profile_id) cim_customer_profile.delete() # delete payment profile belonging to this recurring payment PaymentProfile.objects.filter(customer_profile_id=self.customer_profile_id).delete() return True return False