line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::Payment; |
2
|
4
|
|
|
4
|
|
202582
|
use Moose; |
|
4
|
|
|
|
|
1268114
|
|
|
4
|
|
|
|
|
28
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01_01'; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
21648
|
use Business::Payment::Charge; |
|
4
|
|
|
|
|
36545
|
|
|
4
|
|
|
|
|
587
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has processor => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
does => 'Business::Payment::Processor', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub handle { |
15
|
3
|
|
|
3
|
0
|
112
|
my ($self, $charge) = @_; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
86
|
return $self->processor->handle($charge); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub charge { |
21
|
0
|
|
|
0
|
0
|
|
my ( $self, %fields ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $roles = $self->processor->charge_roles; |
24
|
0
|
|
|
|
|
|
return Business::Payment::Charge->new_with_traits( |
25
|
|
|
|
|
|
|
traits => $roles, |
26
|
|
|
|
|
|
|
%fields |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
4
|
|
35
|
no Moose; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
25
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Business::Payment - Payment Processing Library |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Business::Payment; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $bp = Business::Payment->new( |
42
|
|
|
|
|
|
|
processor => Business::Payment::Processor::Test::True->new |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $charge = Business::Payment::Charge->new( |
46
|
|
|
|
|
|
|
amount => 10.00 # Something Math::Currency can parse |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $result = $bp->handle($charge); |
50
|
|
|
|
|
|
|
if($result->success) { |
51
|
|
|
|
|
|
|
print "Success!\n"; |
52
|
|
|
|
|
|
|
} else { |
53
|
|
|
|
|
|
|
print "Failed: ".$result->error_code.": ".$result->error_message."\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NOTICE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This module is currently under development. The API is unstable! Contributions |
59
|
|
|
|
|
|
|
and suggestions are welcome. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Business::Payment is a payment abstraction library, primarily meant to be used |
64
|
|
|
|
|
|
|
in front of payment processor libraries. The expected use is for credit cards |
65
|
|
|
|
|
|
|
but care is taken to assume little and to allow the implementor to choose |
66
|
|
|
|
|
|
|
what functionality is needed, leaving the door open for other payment processing |
67
|
|
|
|
|
|
|
needs. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Cory G Watson, C<< <gphat@cpan.org> >> |
72
|
|
|
|
|
|
|
J. Shirley, C<< <jshirley+cpan@gmail.com> >> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Copyright 2009 Cold Hard Code, LLC, all rights reserved. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
79
|
|
|
|
|
|
|
under the same terms as Perl itself. |