I am attempting to set up the Stripe checkout payment system, but am having trouble with the PHP. When I run the console log, everything executes, except the piece that actually posts the charge to my Stripe dashboard, which is crucial. Below I highlighted some of the potential areas that error my lie. Please let me know if you need more information, as I am glad to help.
Note: the line below "//charge card is where I think the problem is, but I may be mistaken.
`
require_once('Stripe.php');
$stripe = array(
**'secret_key' => 'secret key',**
'publishable_key' => 'publishable key'
);
**\Stripe\Stripe::setApiKey($stripe['secret key']);**
if($_POST) {
$error = NULL;
try{
if (isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
//charge the card
**$charge = \Stripe\Charge::create(array(**
'card' => $_POST['stripeToken'],
'amount' => 2000,
'currency' => 'usd'
));
}
catch(Exception $e) {
$error = $e->getMessage();
}
$quotes= array(
"A",
"B",
"C"
);
echo "<h1>Here is your quote!</h1>";
echo "<h2>" . $quotes[array_rand($quotes)]. "</h2>";
} else{
//show the welcome screen
?>
<form action="index.php" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="publishable key"
data-amount="2000"
data-name="BB Traders"
data-description="Wiping Rags Order"
data-image="/128x128.png">
</script>
</form>
`