I have setup the stripe payment system but i am getting Fatal error like this: {Fatal error: Uncaught (Status 400) (Request req_f142wGYY4VDGXx) You cannot use a Stripe token more than once: tok_1PPNrbGMcptyt0mO8IbOzi1T. thrown in C:xampphtdocsjoinstripe-phplibExceptionApiErrorException.php on line 38}
I want to to store the stripe payment info from user, but the problem is I am receiving the the amount into stripe dashboard but not into my database and getting this fatal errors!
here is my code:
// set API Key
$stripe = array(
"SecretKey"=>"sk_test_51PNnHTGMcptyt0mOGyt8G6VmAvXhlJ7ojBpzdlI1Ey2JLrDghSZ2Nz5UszwSJr9madoDm5TrxeQzQ4W73G5X3qd100EzKqncvh",
"PublishableKey"=>"pk_test_51PNnHTGMcptyt0mOSgd8HrIaMr0mj0DM6lyd7W2EqlnzL3L4CHKJ0Yf2EPd9Qid8dOeGXNcwK8jIuj5k8yqmKNra00ECPFYvnv"
);
StripeStripe::setApiKey($stripe['SecretKey']);
// Add customer to stripe
$customer = StripeCustomer::create(array(
'email' => $email,
'source' => $token,
'name' => $name,
'description'=>$des
));
// Generate Unique order ID
$orderID = strtoupper(str_replace('.','',uniqid('', true)));
// Convert price to cents
$itemPrice = ($price*100);
$currency = "usd";
// Charge a credit or a debit card
$charge = StripeCharge::create(array(
'amount' => $itemPrice,
'currency' => $currency,
'customer' => $customer->id,
'description' => $des
));
Anyone can able to solve and tell me where is the problem in this code?
Thank you!