Persisting information across repeat form submission attempts
<p>Below is a simplified version of a sign-up page I'm working on. </p>

<p>When the user clicks the button I need to collect money from a credit card.  Then, if the transaction is successful, create the new user account. </p>

<p>My problem is handling the scenario where the credit card transaction succeeds but then the create-user transaction fails. If the user needs to correct some information in the form I don't want to charge their card again.<br>
My <code>PaymentStatus</code> variable contains a <code>1</code> or a <code>0</code> depending on whether or not the transaction succeeds. </p>

<p>Will this persist across multiple button clicks? And if it does, is this a reliable way of avoiding duplicate transactions in scenarios where the user needs to correct some data in the form?<br>
I could persist the information to the database, but my preference would be to do that later in the transaction when there exists a <code>UserID</code> to associate the payment with.</p>

<pre><code>protected void btn_Click(object sender, ImageClickEventArgs e)
{
    int PaymentStatus = ChargeCardForSignUpFee(userInfo);

    if (PaymentStatus == 0)
    {
         Label1.Text = "Your credit card is invalid.  Please try again.";
    }
    else
    {

        try
        {
        MembershipUser newUser = Membership.CreateUser(userInfo);
            if (newUser == null)
            {
                lblStatus.Text = GetErrorMessage(status);
            }
            else
            {
                CreateCustomer(userInfo);
                SendWelcomeEmail(userInfo.email);
                FormsAuthentication.SetAuthCookie(userName, true);

                Response.Redirect("welcomepage.aspx");
            }
        }
        catch
        {
            lblStatus.Text = "An error occurred while creating your account. "+
                "Please check your information and try again. "+ 
                ex.Message;
        }
    }
}
</code></pre>
