I am working on stripe to integrate in the website but I am having an issue. There are 2 forms,
Stripe Payment Form
The users Data Form
The Stripe Payment Form works Perfect. When It triggers the Form 2. then Stripe Payment Form's Response again run and it makes Payment again. and I know why this is happening.. Here is the code
if($_POST) { Stripe::setApiKey($config['secret-key']);
// POSTed Variables $token = $_POST['stripeToken']; $first_name = $_POST['first-name']; $last_name = $_POST['last-name']; $name = $first_name . ' ' . $last_name; $amount = (float) $_POST['amount']; try { if ( ! isset($_POST['stripeToken']) ) { throw new Exception("The Stripe Token was not generated correctly"); } // Charge the card $donation = Stripe_Charge::create(array( 'card' => $token, 'description' => 'Payment by ' . $name, 'amount' => $amount * 100, 'currency' => 'usd' )); // Build and send the email // Forward to "Thank You" page //header('Location: ' . $config['thank-you']); echo 'The Payment Has Been Done'; exit; } catch (Exception $e) { $error = $e->getMessage(); }
}
So What I assume is the if($_POST) {
this is the issue. It gets all the forms posted. So i want to make it specific to get only the Stripe Fomr's data Only.
So i tried it with if(isset($_POST['stripeSubmit']))
And Placing this name to strip Form submit button <input type="submit" name="stripeSubmit" value="Pay">
But It not works. it not even charges with it.
Please help me in this regard