« lib/WebService/Braintree/ValidationError.pm
↑ Summary
lib/WebService/Braintree/WebhookNotification/Kind.pm »
| 1 | # vim: sw=4 ts=4 ft=perl | ||
| 2 | |||
| 3 | package WebService::Braintree::WebhookNotification; | ||
| 4 | 22 | $WebService::Braintree::WebhookNotification::VERSION = '1.7'; | |
| 5 | 22 | ▶ | use 5.010_001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 22 | ▶ | use strictures 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | WebService::Braintree::WebhookNotification | ||
| 11 | |||
| 12 | =head1 PURPOSE | ||
| 13 | |||
| 14 | This class parses and verifies webhook notifications. | ||
| 15 | |||
| 16 | =head1 NOTES | ||
| 17 | |||
| 18 | Unlike all other classes, this class does B<NOT> interact with a REST API. | ||
| 19 | Instead, this takes data you provide it and either parses it into a usable | ||
| 20 | object or provides a verification of it. | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | 22 | ▶ | use WebService::Braintree::WebhookNotification::Kind; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | 22 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | |||
| 28 | 22 | with 'WebService::Braintree::Role::Interface'; | |
| 29 | |||
| 30 | =head1 CLASS METHODS | ||
| 31 | |||
| 32 | =head2 parse() | ||
| 33 | |||
| 34 | This takes a signature and a payload and returns a parsing of the notification | ||
| 35 | within that payload. The payload is validated against the signature before | ||
| 36 | parsing. | ||
| 37 | |||
| 38 | The return is an object of this class. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | 15 | ▶ | sub parse { |
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
documented
| |||
| 43 | 15 | my ($class, $signature, $payload) = @_; | |
| 44 | 15 | $class->gateway->webhook_notification->parse($signature, $payload); | |
| 45 | } | ||
| 46 | |||
| 47 | =head2 verify() | ||
| 48 | |||
| 49 | This takes a challenge and returns a proper response. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | 2 | ▶ | sub verify { |
|
Subroutine
verify: called CC=1 SCAR=0.0
Pod
documented
| |||
| 54 | 2 | my ($class, $challenge) = @_; | |
| 55 | 2 | $class->gateway->webhook_notification->verify($challenge); | |
| 56 | } | ||
| 57 | |||
| 58 | 22 | __PACKAGE__->meta->make_immutable; | |
| 59 | |||
| 60 | 22 | 1; | |
| 61 | __END__ | ||