Followed "Manage Subscriptions and Protect Content With Stripe" and getting a webhook error in Stripe

Can anyone help point me to where this error maybe coming from please…

Background I am following this great blog/article Learn How to Add Subscriptions and Protected Content With Stripe wow, helped me a lot and 99% there yet just getting an issue with Stripe webhook processing on subscription updates.

I am getting this error in Stripe “Webhook Error: Cannot read property ‘split’ of null”

Stripe support says it must the code thats receiving the webhook and what are they splitting on.

On searching on demo source code it maybe looks to be around this area in handle-subscription-change.js “maybe”:

// take the first word of the plan name and use it as the role
const plan = subscription.items.data[0].plan.nickname;
const role = plan.split(’ ')[0].toLowerCase();

Can anyone help me out with why Stripe is posting the “400 (Bad Request)” to any subscription updates please.

Thank you and appreciate any help
Neil

Hey @neilellis, I know exactly what this error is!
The tutorial is out of sync with Stripe’s current dashboard. It’s looking for a “nickname value” that has been changed in the dashboard to the “description” field for the price. You have to toggle it open, it is in the advanced or additional settings (I forget what its called) of the price variant of the product.

Basically, you’re missing that value, and that is what the webhook is trying split to create the name for the role. (turning “Pro Monthly Plan” into “Pro”)

[edit, adding a screenshot below and link to where I encountered and resolved the same issue]

Perfect, thank you @hwlmatt, much appreciated.

1 Like