#Mr.Medi
1 messages · Page 1 of 1 (latest)
Which integration do you use? Checkout Session (Stripe hosted payment page) or Subscription API?
the API
With Subscription API, customer field is required, so customer has to be created if it hasn't be created yet
Oh I see. Im doing something like this:
$stripeCustomer = Auth::user()->createOrGetStripeCustomer();
$priceId = $request->input('priceId');
try {
// Crear la suscripción en Stripe
$subscription = Subscription::create([
'customer' => $stripeCustomer,
'items' => [['price' => $priceId]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
``` But in the frontend I get that the customer is not found. When in case that the customer doesnt exists I create it in the backend
In createOrGetStripeCustomer(), it should create a Stripe customer if doesn't exist