Retrieve User by Custom Field Value

I am struggling with this. I am building a script to work with S2 member Remote API and sometimes I only have the user S2member paid subscribe ID (which is provided by a custom payment gateway). I need to retrieve the user object with this, but I don't know how.

Paid subscribe ID is a custom field on the user profile, provided by S2Member.

So I need a code to retrieve a user from that.

Any help available on this?