[insert_php] // Create a customer using a Stripe token

// If you’re using Composer, use Composer’s autoload:
require_once(‘vendor/autoload.php’);

// Be sure to replace this with your actual test API key
// (switch to the live key later)
\Stripe\Stripe::setApiKey(“pk_live_MU2zdyOxfdNHIDUSslN4B88O”);

try
{
$customer = \Stripe\Customer::create(array(
’email’ => $_POST[‘stripeEmail’],
‘source’ => $_POST[‘stripeToken’],
));

$subscription = \Stripe\Subscription::create(array(
‘customer’ => $customer->id,
‘items’ => array(array(‘plan’ => ‘weekly_box’)),
));

header(‘Location: thankyou.html’);
exit;
}
catch(Exception $e)
{
header(‘Location:oops.html’);
error_log(“unable to sign up customer:” . $_POST[‘stripeEmail’].
“, error:” . $e->getMessage());
}