| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::Payment::Processor; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1928
|
use Moose::Role; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
31
|
|
|
4
|
4
|
|
|
4
|
|
8182
|
use Carp; |
|
|
4
|
|
|
|
|
22
|
|
|
|
4
|
|
|
|
|
1273
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
requires 'prepare_data'; |
|
7
|
|
|
|
|
|
|
requires 'request'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'charge_roles' => ( |
|
10
|
|
|
|
|
|
|
is => 'rw', |
|
11
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
12
|
|
|
|
|
|
|
default => sub { [] } |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub prepare_charge { |
|
16
|
3
|
|
|
3
|
0
|
5
|
my ( $self, $charge ) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO: This doesn't necessarily have to be here, there are roles that |
|
19
|
|
|
|
|
|
|
# are always required and roles that are sometimes required (for capture vs |
|
20
|
|
|
|
|
|
|
# a refund) per type. A refund or void doesn't need all the roles |
|
21
|
3
|
50
|
|
|
|
85
|
if ( defined ( my $roles = $self->charge_roles ) ) { |
|
22
|
3
|
|
|
|
|
9
|
foreach my $role ( @$roles ) { |
|
23
|
0
|
0
|
|
|
|
0
|
unless ( $charge->meta->does_role( $role ) ) { |
|
24
|
0
|
|
|
|
|
0
|
my $ns = "Business::Payment::Charge"; |
|
25
|
0
|
0
|
|
|
|
0
|
unless ( $role =~ /^$ns/ ) { |
|
26
|
0
|
|
|
|
|
0
|
$role = join('::', $ns, $role); |
|
27
|
0
|
0
|
|
|
|
0
|
if ( $charge->meta->does_role( $role ) ) { |
|
28
|
0
|
|
|
|
|
0
|
next; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
0
|
|
|
|
|
0
|
croak "Charge must have the role '$role' applied"; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub handle { |
|
39
|
3
|
|
|
3
|
0
|
6
|
my ( $self, $charge ) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
12
|
$self->prepare_charge( $charge ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
13
|
my $data = $self->prepare_data( $charge ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
14
|
$self->prepare_result( $self->request( { }, $data ) ); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub prepare_result { |
|
49
|
1
|
|
|
1
|
0
|
2
|
my ( $self, $response ) = @_; |
|
50
|
1
|
|
|
|
|
28
|
return Business::Payment::Result->new( |
|
51
|
|
|
|
|
|
|
success => 0, |
|
52
|
|
|
|
|
|
|
error_code => -1, |
|
53
|
|
|
|
|
|
|
error_message => 'No prepare_result method defined in processor' |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Business::Payment::Processor - Role for all Processors |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package My::Processor; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use Moose; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
with 'Business::Payment::Processor'; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub handle { |
|
73
|
|
|
|
|
|
|
die "Ain't got no money"; |
|
74
|
|
|
|
|
|
|
return 1; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
no Moose; |
|
78
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Business::Payment::Processor is the base class from which all Processors |
|
83
|
|
|
|
|
|
|
should inherit. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Cory G Watson, C<< <gphat@cpan.org> >> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright 2009 Cold Hard Code, LLC, all rights reserved. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
94
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|