lmsqueezy/laravel

Webhook skipped due to invalid custom data.

Opened this issue · 7 comments

Lemon Squeezy for Laravel Version

1.5.2

Laravel Version

11.1.1

PHP Version

8.3.3

Description

In LemonSqueezy I have a product which is a one-time purchase.

When a customer makes a purchase, Laravel receives the webhook. The response of the webhook request is Webhook skipped due to invalid custom data.

That happens because at the time of requesting the webhook there is no billable_id and billable_type.

How to handle the case? When somebody buys a product, I need to

  1. Create a user with the email they specified when purchasing the product
  2. Make sure that the user has bought the product (= there should be a record in the customers taable)

Plus, the user might already exist but might not be a customer (in this case, the first step should be skipped)

Is it possible to realize this scenario? If not, is it possible to override the webhook?

Thanks

Steps To Reproduce

Since it's not a bug but rather a question, there is no specific steps to reproduce. I don't know how to mark the issue as a question.

Unfortunately there is currently no way to handle this case. All payments need to originate from this library in order to work. This is because at the time of development, using these ID's was the only way to connect a customer in the database to the Lemon Squeezy customer. It might become easier after #53 but I don't think it will since an incoming request for a customer that isn't created to a customer in the app database is impossible to map to billable in the app. There's no way to do that afaik.

That happens because at the time of requesting the webhook there is no billable_id and billable_type.

Just to be clear: how was this purchase performed? What did you do to offer this purchase without involving the app and this library?

I've just added their script:

  <a href="https://myshop.lemonsqueezy.com/buy/product-id">
    Buy
  </a>

Which calls webhook after purchasing

@victor-ponamariov you need to create a user beforehand and generate the link using the library. Otherwise this library cannot know who made the purchase in your app.

Hmm, actually now that I think deeper on this what we could do maybe is make the billable columns nullable in the database and still save the customer record and the order. That way the data is synced but there's still no user attached to the customer record. But we can leave that up the app to implement depending on incoming event. I'll try to get this in for v2.

Hi,
I was trying to use the LicenseKeyCreated event, but seems it throwing an InvalidCustomPayload exception for the license_key_created event. probably that's in TODO?

Thanks :)

@emtiazzahid Yeah License keys are still on the roadmap (see readme).