Reputation: 1057
my stripe account is configured with test
. and using test
keys into my laravel application.
While posting, i am creating new stripe user
if not exist like this,
Stripe::setApiKey(Config::get('constants.features.stripe.secret'));
$token = $input['_token'];
$customer = Stripe_Customer::create(array(
"description" => "#{$user->id} / {$user->username} / {$user->email}",
"source" => $token,
"email" => $user->email
));
And creating charge like this,
$charge = Stripe_Charge::create(array(
"amount" => '5000',
"currency" => "gbp",
"customer" => $customer->id,
"description" => 'description',
"statement_descriptor" => strtoupper("test desc")
));
But it return error Stripe_InvalidRequestError No such token:
Upvotes: 3
Views: 5728
Reputation: 9883
The _token
input from Laravel is the CSRF token. This is not the token you should be passing to stripe in the source
field. The token in the source
field should be the token generated by the stripe.js library which allows you to identify a customers credit card without actually seeing the card details.
The stripe documentation explains how you should be handling this https://stripe.com/docs/stripe.js
Upvotes: 2