Missing Steps
Describe the bug
Webhook fails to update Netlify Identity user role.
It appears that in the payload sent to webhook, the nickname
value used to update the Netlify Identity role is null
.
In example, this is the stripeEvent.data.object.plan
assigned to subscription
sent in payload:
`
{
id: 'price_1IE***********,
object: 'plan',
active: true,
aggregate_usage: null,
amount: 4000,
amount_decimal: '4000',
billing_scheme: 'per_unit',
created: 1611793975,
currency: 'usd',
interval: 'month',
interval_count: 1,
livemode: false,
metadata: {},
nickname: null,
product: 'prod_I***********',
tiers_mode: null,
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
}
`
This causes an error of "cannot read property split of null" in reference to line 38 of functions/handle-subscription-change, and visible in the Stripe webhook log.
`
// lines 36-39 below
// 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();`
Why ?
There doesn't seem to be an option to set nickname
in dashboard during product/price creation. The UI is definitely different now than in the video showing this setup.
Screengrab from tutorial vid with @jlengstorf and @thorsten-stripe
What I see today adding a pricing:
Was told in stripe chat that product/price may need be created/updated via api rather than dashboard to add nickname value.
Seems like maybe a UI change in the dashboard has kinda messed up the straightforwardness of this.
To Reproduce
I just followed the tutorial. But the key points of it:
Creating product and pricing in dashboard of test account doesn't offer ability to set nickname
1.) create at least two products
2.) create customer with subscription
3.) change customer's subscription
Webhook fails with cannot read property split of null
- visible in webhook log of Stripe dashboard
Expected behavior
Webhook would update Netlify Identity user role.
A Note
A put this here even though it isn't a "bug" (everything code wise clearly working as intended), but since the nickname
is integral to the user -> customer -> purchase -> role -> content gate
concept and the repo and tutorial as-is appear to run into this issue where the nickname
can't be set by the UI. (unless, as is always possible, I have missed some glaring and important step ;) )
But I have to add the tutorial was wonderful