Are you sure the $token is getting the correct stripeToken?
Jan 9, 2017
14
Level 1
Stripe Token Error !
This is my view code
<form action="{{route('payment.store')}}" method="POST" id="payment-form">
{{csrf_field()}}
<span class="payment-errors"></span>
<div class="form-row">
<label>
<span>Card Number</span>
<input class="form-control" type="text" size="20" data-stripe="number">
</label>
</div>
<div class="form-row">
<label>
<span>Expiration (MM/YY)</span>
<input class="form-control" type="text" size="2" data-stripe="exp_month">
<span> / </span>
<input class="form-control" type="text" size="2" data-stripe="exp_year">
</label>
</div>
<div class="form-row">
<label>
<span>CVC</span>
<input class="form-control" type="text" size="4" data-stripe="cvc">
</label>
</div>
<input type="submit" class="submit thm-btn" value="Submit Payment">
</form>
And this is my controller. When I use dd(); for token. It returns null.
{
// 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_1QiGpAEaK2pEWeXemc6HIMRE");
dd($token = $request->stripeToken);
// Create a charge: this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => Cart::total() * 100, // Amount in cents
"currency" => "usd",
"source" => $token,
"description" => "Example charge"
));
} catch (\Stripe\Error\Card $e) {
// The card has been declined
}
}
I am sorry. I am new on laravel. I checked stripe error logs too.
And Error looks like :
Parsed Request POST Body
{ "amount": "12100", "currency": "usd", "description": "Example charge" } Response body
{ "error": { "type": "invalid_request_error", "message": "Must provide source or customer." } }
I don't know why. If someone help. I will be grateful.
Please or to participate in this conversation.