Function or hook to assign membership

I have made a custom script to capture payment gateway response to add members. i.e
Payment gateway sends me payment response on URL
I add the customer info to Wordpress as "Subscriber" by using their function wp_insert_user().

Now I want to assign the Membership to Subscriber. So this becomes completely automated. Is there any custom function call or hook for that purpose ?