Skip to content

Commit

Permalink
update some perldoc relating to Webhooks and Events
Browse files Browse the repository at this point in the history
was out of date and needs clarifying w/r/t to using ->events and how to
actually use them
  • Loading branch information
leejo committed Sep 12, 2017
1 parent ae9da8e commit 73457d5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Business-GoCardless

0.27 2017-09-12
- Update some perldoc relating to Webhooks and Events

0.26 2017-09-12
- Automatically handle legacy webhooks in the ::Pro ->webhook code

Expand Down
4 changes: 2 additions & 2 deletions lib/Business/GoCardless.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set of modules
=head1 VERSION
0.26
0.27
=head1 DESCRIPTION
Expand Down Expand Up @@ -53,7 +53,7 @@ use Carp qw/ confess /;
use Business::GoCardless::Client;
use Business::GoCardless::Webhook;

$Business::GoCardless::VERSION = '0.26';
$Business::GoCardless::VERSION = '0.27';

has api_version => (
is => 'ro',
Expand Down
2 changes: 1 addition & 1 deletion lib/Business/GoCardless/Upgrading.pod
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ logic to check this:
See the docs for L<Business::GoCardless::Webhook::V2> and
L<Business::GoCardless::Webhook>. Note that to support this you will also need to
make sure either you set the value of $ENV{'GOCARDLESS_APP_SECRET'} to your previous
Basic API app_secret or your new webhook_secret is the same as your old app_secret.
Basic API app_secret or your new webhook_secret is the same as your old app_secret otherwise signatures will not be valid.

=head1 AUTHOR

Expand Down
17 changes: 10 additions & 7 deletions lib/Business/GoCardless/Webhook/Event.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package Business::GoCardless::Webhook::Event;

=head1 NAME
Business::GoCardless::Webhook
Business::GoCardless::Webhook::Event
=head1 DESCRIPTION
Expand Down Expand Up @@ -58,12 +58,15 @@ has [ qw/
Returns an array of resource objects (Payment, Subscription, etc) that are present
in the event allowing you to do things with them or update your own data:
if ( $Webhook->is_payment ) {
foreach my $Payment ( $Webhook->resources ) {
...
}
} elsif ( $Webhook->is_subscription ) {
...
if ( $Event->is_payment ) {
foreach my $Payment ( $Event->resources ) {
if ( $Event->action eq 'paid_out' ) {
...
}
}
}
=cut

Expand Down
11 changes: 9 additions & 2 deletions lib/Business/GoCardless/Webhook/V2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use Business::GoCardless::Webhook::Event;
=head1 ATTRIBUTES
json
events
signature
has_legacy_data
Expand All @@ -49,11 +48,19 @@ has [ qw/

=head1 Operations on a webhook
=head2 events
Get a list of L<Business::GoCardless::Webhook::Event> objects for processing:
foreach my $Event ( @{ $Webhook->events // [] } ) {
...
}
=head2 json
Allows you to set the json data sent to you in the webhook:
$Webhook->json( $json_data )
$Webhook->json( $json_data )
Will throw a L<Business::GoCardless::Exception> exception if the json fails to
parse or if the signature does not match the payload data.
Expand Down

0 comments on commit 73457d5

Please sign in to comment.