gform_after_submission not working as expected [closed]

It looks like your code is testing to see where every field on the form has class ‘payment_name’. If you instead only want to find one field with class ‘payment_name’, then you need to break out of the for loop once you’ve found that field.

Also, strpos only returns false or an integer index into the haystack where it found the needle, not true; test instead for strpos($field['cssClass'], 'payment_name') !== false