php - Stripe: "Must provide source or customer"

PaymentController:
class PaymentController extends Controller
{
public function paymentProcess()
{
\Stripe\Stripe::setApiKey("sk_test_1M123Dge214GicrsW30adwG12X1");
$token = $request->get('stripetoken');
$charge=\Stripe\Charge::create([
'amount'=>1000,
'currency'=>'usd',
'description'=>'Example charge',
'source'=>$token,
]);
}
}
index.blade.php:
<div class="content">
<div class="title m-b-md">
Laravel + Stripe
</div>
<div class="links">
<form action="/api/payment" method="POST">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key='pk_test_zWfsa5k3D21cq1hPA39FmIdMJfkG3Taf74LD'
data-amount="100000"
data-name="My Name"
data-description="Test"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-currency="USD">
</script>
</form>
</div>
</div>
api.php:
Route::post('/payment','PaymentController@paymentProcess');
it keeps giving me this error Must provide source or customer. and on my stripe test dashboard its still 0, no money has been added. Any help is highly appreciated, Thank you in advance
Answer
Solution:
The input name that has the token is probablystripeToken
notstripetoken
.
$token = $request->input('stripeToken');
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: target class [commandmakecommand] does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.