I've been working on integrating a Stripe checkout form into my website for customers to sign up for a subscription. I've downloaded the Stripe library via composer and it is up to date, here is my file structure
My Stripe API Keys have been replaced with Asterisks for obvious reasons.
The files are the same as the one in my test. The test worked and sent it to Stripe and everything worked. In this new site the form won't even open and I get the error:
{"error":{"type":"invalid_request","message":"Invalid
keyparameter."}}
When I do put in my stripe TEST keys, I copy and paste them and make sure there are no spaces between the key and the quotes. My thought is that something is wrong with a connection somewhere because the form won't even open. I've been working on this the last 3 days and have read all of Stripe's Docs. My questions are: Can a stripe subscription button be integrated if i'm using Bootstrap?, If I have Stripe in test mode and i'm using the test keys do I still have to have it under an SSL and HTTPS just to test it?, and is there an error in my code that would make the API Key Invalid? Here is the index.php and charge.php for the stripe checkout form.
Index.php
<?php require_once('./config.php'); ?>
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-image="https://pixel.nymag.com/imgs/daily/science/2014/11/13
data-amount="1200"
data-name="Remember My People"
data-description="RMP Monthly subscription"
data-label="Sign Me Up!"
data-billing-address="true"
>
</script>
</form>
Charge.php
<?php
require_once('./config.php');
$token = $_POST['stripeToken'];
try {
$customer = \Stripe\Customer::create(array(
'email' => $_POST['stripeEmail'],
'source' => $_POST['stripeToken'],
'plan' => 'rmp_monthly'
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 1200,
'currency' => 'usd'
));
header('Location: https://remembermypeople.com');
exit;
}
catch (Exception $e) {
// header('Location:oops.html');
error_log("unable to sign up customer" . $_POST['stripeEmail']. ", error" . $e->getMessage());
}