Easy Stripe Subscription in Laravel Cashier: Payment by Checkout::guest()-create() object

Let's demonstrate by making a subscription from the Checkout object.

Before finishing this block with stripe here I also wanted to make a small reminder and remember that we can process the order or payment that the user wants to make directly if we return the session object which was the test we did before when we were creating the session ID so here we return the session ID because it is what we need and that is why we placed the pencil here but again we could return this which already brings us an object internally there to redirect to the Stripe page and everything else and everything else according to the configuration that we have placed here:

function createSession(string $priceId, string $successURL = 'http://laravelbaseapi.test/vue/stripe/success', string $cancelUrl = 'http://laravelbaseapi.test/vue/stripe/cancel')
    {
      
        $session = Checkout::guest()->create($priceId, [
            // 'mode' => 'payment',
            'mode' => 'subscription',
            'success_url' => $successURL . '?session_id={CHECKOUT_SESSION_ID}',
            'cancel_url' => $cancelUrl
        ]);

        // return $session; // retorna la pagina de https://checkout.stripe.com/c/pay/c
        return $session->id;
}

Note that the subscribe window now appears to me as well, I'm not going to continue because I think it's pretty well understood, obviously the stripe application is not going to fail but what I wanted to get to was a bit of what was mentioned in the previous class, mind you, I love the integration with strike here, all the advantages that it brings you, all the features of including cards and everything that we have presented up to this point and what we have not presented since you can also go to the official documentation to obtain the complete information but but but for applications that are usually simple that we do not want to add so much logic, that is to say, tell me or think of an application in which it has this type of strong integrations, perhaps it would be a bit like the Amazon website that allows you to add cards and you can delete them and you can manage them from there and we are talking about Amazon being an immense website but for most mortals such integration is not necessary therefore it would be more work and therefore it would not make much sense to be that the client's card is registered and assuming that the client will also want to register it in your application since it is very different from the client registering it register here that you see that there is the strike page to register it locally here in your application obviously here there will be some distrust and going on from that we have to do a lot more work as we saw before to get to see if the user has any credit instrument if he doesn't have it add it remove it do all that logic then also verify the The response is more laborious than simply making a redirection to another page in this case the strive page that does whatever we want to do in this case the subscription or a recurring payment and returns the response And from there we can thanks to the integration that we have with the viable object and the user Ask what interests us that in this case again is the subscription so nothing I wanted to leave it there pending that you can use this either through a Vue plugin highly recommended if you are using Vue obviously but if you do not want to use Vue with Stripe perfectly you can also use here the checkout object which is create the whole thing return the session you put the subscription here if you want to manage the subscription if not the fixed payment and the matter is over and again I'm going to leave it Once commented here so that you have it there for reference and without further ado we will see you in another class

- Andrés Cruz

En español

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 0d 03:50!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

View books
¡Become an affiliate on Gumroad!