I worked now through the "Subscriptions with card payments" https://stripe.com/docs/billing/subscriptions/overview
but I always get the exception
This customer has no attached payment source or default payment method.
My Form and my Backend Code
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
// This creates a new Customer and attaches the default PaymentMethod in one API call.
$customer = \Stripe\Customer::create([
'payment_method' => $request->stripeToken,
'email' => '[email protected]',
'invoice_settings' => [
'default_payment_method' => $request->stripeToken
]
]);
auth()->user()->newSubscription('primary',$request->plan)->create($request->stripeToken);
<form id="subscription-form" action="{{ url('settings/subscription') }}" method="post" >
@csrf
<select name="plan">
<option value="small">Small 9,90EUR</option>
</select>
<div id="card-element" class="MyCardElement">
<!-- Elements will create input elements here -->
</div>
<!-- We'll put the error messages in this element -->
<div id="card-errors" role="alert"></div>
<button type="submit">Subscribe</button>
</form>
The js is copied from the tutorial so I think its not necessary to post it here.
Maybe someone knows whats wrong with my code