Dynamically add User into a role I have set up a Drupal site to connect to an external payment gateway (not using Drupal Commerce) for subscription-based billing. So making use of Drupal Webform, I have created forms for users to provide their payment information. Live site will be behind SSL.

What I would like to know is:


Where do I start by taking the details of the completed Webform and submitting it to the Payment Gateway's XML web service? Essentially, what I'm looking for is some hook into when the form is filled in, to trigger some code (which I already have setup and tested in a separate plain PHP app) to call the Web Service; and then
Based on the response that I get from the Payment Gateway, to add the logged in user to a specific role?


Your help will be greatly appreciated! Thank you in advance
While you could utilize hooks like hook_form_FORM_ID_alter setting custom #validate &amp; #submit functions or hook_webform_submission_insert, I've had better success using the Payment module and writing a custom Payment Method class.