in reply to Re: What to test in a new module
in thread What to test in a new module

Brief reply as I'm about to go to bed but I'll reply to this one now and look properly at the rest over the next few days...

Why are you doing an eval on this line... you do nothing at all if eval fails: $vars{'webhook'} = eval { decode_json($vars{'payload'});};

It is quite possible that $vars{'payload'} could contain badly formed JSON. If it does, decode_json calls die (or something equally terminal). I want to catch that so that my module doesn't exit. Then the user of the module can handle the error as they need. If the module were to die, the return to Stripe would be invalid or, more likely, non-existent which may cause issues with future webhook calls.

You can interpolate hash values. Instead of my $signed_payload = $sig_head{'t'} . '.' . $self->{'payload'};, you can simply do: my $signed_payload = "$sig_head{t}.$self->{payload}";

I'm aware that I can but that doesn't mean I should.
To my mind, referenced variables are clearer outside interpolation

There's no need for a return; at the end of a sub if nothing's being returned (unless you intentionally are returning under;

I am intentially returning under. The value is returned earlier in the method.
It is possible that a rogue return may have been left in. However, I've been bitten in the past with a sub returning an unexpected value because there was no explicit return statement. So I now nearly always include one...

However, hopefully you find some use in my quick code review here.

Yes, very useful. Thank you for taking the time to review the code.