#Mr.Medi

1 messages · Page 1 of 1 (latest)

runic peakBOT
crisp root
#

Which integration do you use? Checkout Session (Stripe hosted payment page) or Subscription API?

stark glacier
#

the API

crisp root
#

With Subscription API, customer field is required, so customer has to be created if it hasn't be created yet

stark glacier
#

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
crisp root
#

In createOrGetStripeCustomer(), it should create a Stripe customer if doesn't exist

stark glacier
#

Wait, is due to yesterday I deleted the test stripe customers but in my local db it still have the stripe_id customer...

#

I will keep implementing that, thank you for confirming that I have to specify that argument 🙂