| 1 | package Business::GoCardless::PreAuthorization; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Business::GoCardless::PreAuthorization | ||||||||||
| 6 | |||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||
| 8 | |||||||||||
| 9 | A class for a gocardless pre_authorization, extends L<Business::GoCardless::Resource> | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 55 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 55 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 55 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 55 | extends 'Business::GoCardless::Resource'; | |||||||||
| 18 | |||||||||||
| 19 | 55 | ▶ | use Business::GoCardless::Bill; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | =head1 ATTRIBUTES | ||||||||||
| 22 | |||||||||||
| 23 | created_at | ||||||||||
| 24 | currency | ||||||||||
| 25 | description | ||||||||||
| 26 | expires_at | ||||||||||
| 27 | id | ||||||||||
| 28 | interval_length | ||||||||||
| 29 | interval_unit | ||||||||||
| 30 | max_amount | ||||||||||
| 31 | merchant_id | ||||||||||
| 32 | name | ||||||||||
| 33 | next_interval_start | ||||||||||
| 34 | remaining_amount | ||||||||||
| 35 | setup_fee | ||||||||||
| 36 | status | ||||||||||
| 37 | sub_resource_uris | ||||||||||
| 38 | uri | ||||||||||
| 39 | user_id | ||||||||||
| 40 | |||||||||||
| 41 | =cut | ||||||||||
| 42 | |||||||||||
| 43 | 55 | has [ qw/ | |||||||||
| 44 | created_at | ||||||||||
| 45 | currency | ||||||||||
| 46 | description | ||||||||||
| 47 | expires_at | ||||||||||
| 48 | id | ||||||||||
| 49 | interval_length | ||||||||||
| 50 | interval_unit | ||||||||||
| 51 | max_amount | ||||||||||
| 52 | merchant_id | ||||||||||
| 53 | name | ||||||||||
| 54 | next_interval_start | ||||||||||
| 55 | remaining_amount | ||||||||||
| 56 | setup_fee | ||||||||||
| 57 | status | ||||||||||
| 58 | sub_resource_uris | ||||||||||
| 59 | uri | ||||||||||
| 60 | user_id | ||||||||||
| 61 | / ] => ( | ||||||||||
| 62 | is => 'rw', | ||||||||||
| 63 | ); | ||||||||||
| 64 | |||||||||||
| 65 | =head1 Operations on a pre_authorization | ||||||||||
| 66 | |||||||||||
| 67 | bill | ||||||||||
| 68 | |||||||||||
| 69 | my $Bill = $PreAuthorization->bill; | ||||||||||
| 70 | |||||||||||
| 71 | Creates a new bill, returning a L<Business::GoCardless::Bill> object. | ||||||||||
| 72 | |||||||||||
| 73 | cancel | ||||||||||
| 74 | |||||||||||
| 75 | $PreAuthorization->cancel; | ||||||||||
| 76 | |||||||||||
| 77 | Cancels a pre_authorization. | ||||||||||
| 78 | |||||||||||
| 79 | =cut | ||||||||||
| 80 | |||||||||||
| 81 | 2 | ▶ | sub bill { | ||||||||
|
Subroutine
bill: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 82 | 2 | my ( $self,%params ) = @_; | |||||||||
| 83 | |||||||||||
| 84 | 2 | ▶ | if ( $self->client->api_version > 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | |||||||||||
| 86 | my $post_data = { | ||||||||||
| 87 | payments => { | ||||||||||
| 88 | %params, | ||||||||||
| 89 | links => { | ||||||||||
| 90 | # $self here will be a RedirectFlow | ||||||||||
| 91 | mandate => $self->links->{mandate}, | ||||||||||
| 92 | }, | ||||||||||
| 93 | }, | ||||||||||
| 94 | 1 | }; | |||||||||
| 95 | |||||||||||
| 96 | 1 | my $data = $self->client->api_post( "/payments",$post_data ); | |||||||||
| 97 | |||||||||||
| 98 | return Business::GoCardless::Payment->new( | ||||||||||
| 99 | client => $self->client, | ||||||||||
| 100 | 1 | %{ $data->{payments} }, | |||||||||
| 101 | ); | ||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 1 | my $data = $self->client->api_post( | |||||||||
| 105 | "/bills", | ||||||||||
| 106 | { | ||||||||||
| 107 | bill => { | ||||||||||
| 108 | pre_authorization_id => $self->id, | ||||||||||
| 109 | %params, | ||||||||||
| 110 | } | ||||||||||
| 111 | } | ||||||||||
| 112 | ); | ||||||||||
| 113 | |||||||||||
| 114 | return Business::GoCardless::Bill->new( | ||||||||||
| 115 | client => $self->client, | ||||||||||
| 116 | 1 | %{ $data } | |||||||||
| 117 | ); | ||||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 1 | ▶ | sub cancel { shift->_operation( 'cancel','api_put' ); } | ||||||||
|
Subroutine
cancel: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 121 | |||||||||||
| 122 | =head1 Status checks on a pre_authorization | ||||||||||
| 123 | |||||||||||
| 124 | inactive | ||||||||||
| 125 | active | ||||||||||
| 126 | cancelled | ||||||||||
| 127 | expired | ||||||||||
| 128 | |||||||||||
| 129 | if ( $PreAuthorization->active ) { | ||||||||||
| 130 | ... | ||||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | 2 | ▶ | sub inactive { return shift->status eq 'inactive' } | ||||||||
|
Subroutine
inactive: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 136 | 2 | ▶ | sub active { return shift->status eq 'active' } | ||||||||
|
Subroutine
active: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 137 | 3 | ▶ | sub cancelled { return shift->status eq 'cancelled' } | ||||||||
|
Subroutine
cancelled: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 138 | 2 | ▶ | sub expired { return shift->status eq 'expired' } | ||||||||
|
Subroutine
expired: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 139 | |||||||||||
| 140 | =head1 AUTHOR | ||||||||||
| 141 | |||||||||||
| 142 | Lee Johnson - C<lee@payprop.com> | ||||||||||
| 143 | |||||||||||
| 144 | This library is free software; you can redistribute it and/or modify it under | ||||||||||
| 145 | the same terms as Perl itself. If you would like to contribute documentation, | ||||||||||
| 146 | features, bug fixes, or anything else then please raise an issue / pull request: | ||||||||||
| 147 | |||||||||||
| 148 | https://github.com/payprop/business-gocardless | ||||||||||
| 149 | |||||||||||
| 150 | =cut | ||||||||||
| 151 | |||||||||||
| 152 | 55 | 1; | |||||||||
| 153 | |||||||||||
| 154 | # vim: ts=4:sw=4:et | ||||||||||