File Coverage

blib/lib/Catalyst/Model/Net/Stripe.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Catalyst::Model::Net::Stripe;
2 1     1   123526 use strict;
  1         3  
  1         45  
3              
4 1     1   7 use Carp qw( croak );
  1         2  
  1         71  
5 1     1   602 use Net::Stripe;
  0            
  0            
6             use Moose;
7             extends 'Catalyst::Model';
8             no Moose;
9              
10             =head1 NAME
11              
12             Catalyst::Model::Net::Stripe - Stripe Model for Catalyst
13              
14             =head1 VERSION
15              
16             Version 0.05
17              
18             =cut
19              
20             our $VERSION = '0.05';
21              
22             =head1 SYNOPSIS
23              
24             # Use the helper to add a Stripe model to your application
25             script/myapp_create.pl model Stripe Net::Stripe
26              
27             package YourApp::Model::Stripe;
28             use parent 'Catalyst::Model::Net::Stripe';
29             __PACKAGE->config(
30             api_key => 'API_KEY_HERE',
31             );
32             1;
33            
34             package YourApp::Controller::Foo;
35              
36             sub index : Path('/') {
37             my ($self, $c) = @_;
38            
39             my $card = Net::Stripe::Card->new(
40             number => '4242424242424242',
41             cvc => '499',
42             name => 'Bob Jones',
43             address_line1 => '2222 Palm Street',
44             address_line2 => 'Apt. 603',
45             address_zip => '78705',
46             address_state => 'TX',
47             exp_month => '02',
48             exp_year=> '15',
49             );
50              
51             my $customer = $c->model('Net::Stripe')->post_customer(
52             card => $card,
53             email => 'stripe@example.com',
54             description => 'Test for Net::Stripe',
55             );
56              
57             $c->res->body($customer->id);
58             }
59            
60             1;
61              
62             =head1 SUBROUTINES/METHODS
63              
64             =cut
65              
66             =head2 new
67              
68             L<Catalyst> calls this method.
69              
70             =cut
71              
72             sub new {
73             my $self = shift->next::method(@_);
74             my $class = ref($self);
75              
76             # Ensure that the required configuration is available...
77             croak "->config->{api_key} must be set for $class\n" unless $self->{api_key};
78            
79             # Instantiate a new Net::Stripe object...
80             $self->{stripe} = Net::Stripe->new(
81             api_key => $self->{api_key},
82             );
83            
84             return $self;
85             }
86              
87             sub stripe { shift->{stripe} }
88              
89             sub AUTOLOAD {
90             my $self = shift;
91             my %args = @_;
92            
93             our $AUTOLOAD;
94            
95             my $program = $AUTOLOAD;
96             $program =~ s/.*:://;
97            
98             # pass straight through to our paypal object
99             return $self->{stripe}->$program(%args);
100             }
101              
102             =head1 AUTHOR
103              
104             Adam Hopkins, C<< <srchulo at cpan.org> >>
105              
106             =head1 BUGS
107              
108             Please report any bugs or feature requests to C<bug-catalyst-model-net-stripe at rt.cpan.org>, or through
109             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-Net-Stripe>. I will be notified, and then you'll
110             automatically be notified of progress on your bug as I make changes.
111              
112              
113              
114              
115             =head1 SUPPORT
116              
117             You can find documentation for this module with the perldoc command.
118              
119             perldoc Catalyst::Model::Net::Stripe
120              
121              
122             You can also look for information at:
123              
124             =over 4
125              
126             =item * RT: CPAN's request tracker (report bugs here)
127              
128             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Model-Net-Stripe>
129              
130             =item * AnnoCPAN: Annotated CPAN documentation
131              
132             L<http://annocpan.org/dist/Catalyst-Model-Net-Stripe>
133              
134             =item * CPAN Ratings
135              
136             L<http://cpanratings.perl.org/d/Catalyst-Model-Net-Stripe>
137              
138             =item * Search CPAN
139              
140             L<http://search.cpan.org/dist/Catalyst-Model-Net-Stripe/>
141              
142             =back
143              
144              
145             =head1 ACKNOWLEDGEMENTS
146              
147              
148             =head1 LICENSE AND COPYRIGHT
149              
150             Copyright 2014 Adam Hopkins.
151              
152             This program is free software; you can redistribute it and/or modify it
153             under the terms of the the Artistic License (2.0). You may obtain a
154             copy of the full license at:
155              
156             L<http://www.perlfoundation.org/artistic_license_2_0>
157              
158             Any use, modification, and distribution of the Standard or Modified
159             Versions is governed by this Artistic License. By using, modifying or
160             distributing the Package, you accept this license. Do not use, modify,
161             or distribute the Package, if you do not accept this license.
162              
163             If your Modified Version has been derived from a Modified Version made
164             by someone other than you, you are nevertheless required to ensure that
165             your Modified Version complies with the requirements of this license.
166              
167             This license does not grant you the right to use any trademark, service
168             mark, tradename, or logo of the Copyright Holder.
169              
170             This license includes the non-exclusive, worldwide, free-of-charge
171             patent license to make, have made, use, offer to sell, sell, import and
172             otherwise transfer the Package with respect to any patent claims
173             licensable by the Copyright Holder that are necessarily infringed by the
174             Package. If you institute patent litigation (including a cross-claim or
175             counterclaim) against any party alleging that the Package constitutes
176             direct or contributory patent infringement, then this Artistic License
177             to you shall terminate on the date that such litigation is filed.
178              
179             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
180             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
181             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
182             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
183             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
184             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
185             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
186             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
187              
188              
189             =cut
190              
191             1; # End of Catalyst::Model::Net::Stripe