Jump to content

Stripe payment form help


oxhey

Recommended Posts

Iv got the stripe checkout button working with its own static fields.

 

Iv got a form which I want to pass the name , email and amount data to the stripe charge page.

 

the amount is calculated and stored in this variable : grand_total

 

here is the code for the charge page :

<?php require_once(dirname(__FILE__) . '/config.php');
 
$token  = $_POST['stripeToken'];
 
$customer = Stripe_Customer::create(array(
      "email" => 'email',
      "card"  => $token,
));
 
$charge = Stripe_Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 2499,
      'currency' => 'usd'
));
 
echo '<h1>Successfully charged $24.99!</h1><br/>';
 
$_SESSION['stripeToken'] = $token;
?>

Here is the code for the form fields : 

<div class="formfield"><label for="Name" class="formlabel">Name</label><input type="text" name="Name" id="Name" size="50" /></div>

<div class="formfield"><label for="Email_Address" class="formlabel">Email</label><input type="text" name="Email_Address" id="Email_Address" size="50" /></div>

Thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/282101-stripe-payment-form-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.