HI everyone,
I'm just setting up a basic account with the checkout feature.
I'm currently getting this error and do not know how to fix it:
Uncaught exception 'Stripe\Error\InvalidRequest' with message 'Must provide source or customer.'
I've installed composer, have all of the stripe files etc..
Here is my code;
<?php
// This charge script is getting JWT and send it to stripe as one-time chage
// Author: @greenido
// Date: 28.2.2015
// Get the latest version from:
//
https://github.com/stripe/stripe-php/releasesrequire_once('vendor/autoload.php');
require_once("vendor/stripe/stripe-php/lib/Stripe.php");
// Set your secret key: remember to change this to your live secret key in production
// See your keys here
https://dashboard.stripe.com/account/apikeys\Stripe\Stripe::setApiKey("sk_test_tNNbXLsv3VsnAR2FKGs4fY3l");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => 1000, // amount in cents, again
"currency" => "usd",
"source" => $token,
"description" => "Example charge")
);
} catch(\Stripe\Error\Card $e) {
// The card has been declined
}
?>
<form action="" method="POST">
<script
src="
https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_5zhgzJy1wb4cRwDOBnmeOPoi"
data-amount="2000"
data-name="Demo Site"
data-description="2 widgets ($20.00)"
data-image="/128x128.png">
</script>
</form>
If anyone can help out then thanks in advance! :)