PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

Lemon squeezy integration question(s)

Solved
alexmorning

Jul 13th, 2023 11:27 PM

Once I get this done I will do a write-up so hopefully others can benefit from my frustration. In the mean time, I have a question about something.

The docs have a section about creating a checkout and it is confusing me. In this following instructions, it says to "create a checkout", is this a new file I will need to create for this? Or multiple? I just cannot figure out where to put the snippet of code it's giving, or what file I should create for it, and then how to call that file. I've tried to put that code in a few different spots and then initiate a checkout with their supplied button code, but I am getting Undefined variable $checkout error, so clearly i'm missing something. Here is the instructions/code.

For example, to create a checkout for a single-payment, use a variant ID of a product variant you want to sell and create a checkout using the snippet below:

use Illuminate\Http\Request;
 
Route::get('/buy', function (Request $request) {
    $checkout = $request->user()->checkout('variant-id');

    return view('billing', ['checkout' => $checkout]);
});

Any tips? Thanks!

alexmorning

Jul 13th, 2023 11:41 PM

Update, figured out that "/buy" was intending for me to have a page at this URL, so I changed it to my existing checkout page, which seems to have fixed it, and i'm now getting this error.

Call to a member function checkout() on null

So it seems it's now seeing the correct route, but something about this route is not working with the current wave configuration. Do you see what this might be? Thank you.

Update: gotta be logged in when this runs otherwise there is no user. duh.

superdev

Jul 14th, 2023 05:18 PM

Best Answer

what I would do to prevent this is by using Auth::check() in your middlewawre for this route