How to save validated third party API data if form validation fails Here's my issue.  During user register I'm adding fields via form_alter and creating a stripe account.  When validation fails $form_state gets wiped out and when the user passes through validation again a second account gets created.

I'm thinking about using cache_set to hang on to the account info until the user gets through the registration process error free but is there a better way to do this?
It sounds like before your mymodule_form_validation($form, &amp;$form_state) function returns you want to store the Stripe information in the users $_SESSION array as a valid attempt/data.

You write to user session using the global session value in PHP and Drupal adds it to the Users' DB/Mongo user session info at the end of page execution. For example:

// in your form validation code ...
$_SESSION['stripe_username'] = 'john_doe';


On form load simply prepopulate the form data from $_SESSION. Eg, you're stuffing the content into session because it will be wiped on form reload -- then you're replacing it so a 2nd account isnt created.