Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook skipped due to invalid custom data. #57

Open
VitalijOd opened this issue Nov 13, 2023 · 9 comments
Open

Webhook skipped due to invalid custom data. #57

VitalijOd opened this issue Nov 13, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@VitalijOd
Copy link

Hello! I'm catching an error 'Webhook skipped due to invalid custom data' for the 'order_created' and 'subscription_created' webhooks.

According to the source code, the webhook should contain 'billable_id' and 'billable_type' in the custom data, but I'm receiving webhooks without these fields.

Do I need to pass these fields manually? Sorry to bother you, but I'm struggling to find any info on this.

@driesvints
Copy link
Contributor

Hi there. Can you provide some code to reproduce this issue?

@driesvints driesvints added the bug Something isn't working label Nov 14, 2023
@atmonshi
Copy link

I am getting the same thing Webhook skipped due to invalid custom data
with no exceptions or any other logs

would it be a good idea if the WebhookController reports the exception when caught, so we get better tracing?

try {
    $this->{$method}($payload);
} catch (InvalidCustomPayload $e) {
    report($e);
    return new Response('Webhook skipped due to invalid custom data.');
}

thank you for the package btw :)

@VitalijOd
Copy link
Author

VitalijOd commented Nov 22, 2023

Hi there. Can you provide some code to reproduce this issue?

No custom code is required. I've simply set up the webhooks to target the '/lemon-squeezy/webhook' route.

In the package WebhookController.php, the handleOrderCreated method calls the 'resolveBillable' method, which requires the attribute $payload['meta']['custom_data']['billable_id']. However, this attribute is missing in the webhook payload, resulting in the 'InvalidCustomPayload' error being thrown.

SCR-20231122-prlp

@driesvints
Copy link
Contributor

@VitalijOd but that's what I mean. This package requires you to use the code of the package to start subscriptions and perform orders. If you don't do that then those custom data keys aren't present in your payloads.

So the right question might be: how are your customers buying your products? Is there code involved? And if not, how are you serving them the checkout page?

@driesvints
Copy link
Contributor

@atmonshi heya thanks!

This exception will go away once #53 is implemented so hopefully that's not much longer.

@VitalijOd
Copy link
Author

@VitalijOd but that's what I mean. This package requires you to use the code of the package to start subscriptions and perform orders. If you don't do that then those custom data keys aren't present in your payloads.

So the right question might be: how are your customers buying your products? Is there code involved? And if not, how are you serving them the checkout page?

Thank you for the clarification. I generated the payment link without this package and intended to use it solely for handling webhooks. I now understand this is likely why the webhook payload didn't contain billable_id. I think #53 will resolve my problem in this case.

@driesvints
Copy link
Contributor

Right, yeah right now that won't work. You need to use the package itself in order to make the webhooks work.

@calebporzio
Copy link
Contributor

So this has been baffling me as well and I think I found my issue:

  • Orders created from "recovered cart" emails sent by LS by default.

I disabled those emails and we'll see if it fixes it. However, it would be nice to have the cart recovery features, so hoping #53 gets built as well!

Just came here to provide more context on a solution for people.

I also disabled my storefront that LS creates by default. That was another area that could have been leaking purchases.

@driesvints
Copy link
Contributor

Thanks for that feedback @calebporzio. I'll try to see if I can get #53 in soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants