| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::Giropay::Role::Request; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::Giropay::Role::Request - Moo::Role consumed by all Request classes |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
|
8
|
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
30645
|
use Business::Giropay::Types qw/Bool Enum HashRef Int Str/; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
26
|
|
|
10
|
5
|
|
|
5
|
|
2900
|
use Carp; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
224
|
|
|
11
|
5
|
|
|
5
|
|
1741
|
use Digest::HMAC_MD5 'hmac_md5_hex'; |
|
|
5
|
|
|
|
|
4856
|
|
|
|
5
|
|
|
|
|
196
|
|
|
12
|
5
|
|
|
5
|
|
2713
|
use HTTP::Tiny; |
|
|
5
|
|
|
|
|
160775
|
|
|
|
5
|
|
|
|
|
146
|
|
|
13
|
5
|
|
|
5
|
|
23
|
use Module::Runtime 'use_module'; |
|
|
5
|
|
|
|
|
4
|
|
|
|
5
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
212
|
use Moo::Role; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
|
|
with 'Business::Giropay::Role::Core', 'Business::Giropay::Role::Network'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
requires qw(parameters uri); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
See also L and |
|
23
|
|
|
|
|
|
|
L. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 base_uri |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
The base URI used for all requests. Defaults to: |
|
28
|
|
|
|
|
|
|
C |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has base_uri => ( |
|
33
|
|
|
|
|
|
|
is => 'ro', |
|
34
|
|
|
|
|
|
|
isa => Str, |
|
35
|
|
|
|
|
|
|
default => 'https://payment.girosolution.de/girocheckout/api/v2', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 data |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The constructed hash reference of parameters to be used in the POST request |
|
41
|
|
|
|
|
|
|
to Giropay. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has data => ( |
|
46
|
|
|
|
|
|
|
is => 'lazy', |
|
47
|
|
|
|
|
|
|
isa => HashRef, |
|
48
|
|
|
|
|
|
|
init_arg => undef, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_data { |
|
52
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# we might need to cleanup some data if we are sandboxed |
|
55
|
0
|
0
|
|
|
|
0
|
$self->sandbox_data if $self->sandbox; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
my $data = { |
|
58
|
|
|
|
|
|
|
merchantId => $self->merchantId, |
|
59
|
|
|
|
|
|
|
projectId => $self->projectId, |
|
60
|
|
|
|
|
|
|
secret => $self->secret, |
|
61
|
|
|
|
|
|
|
hash => $self->hash, |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
0
|
|
|
|
|
0
|
foreach my $parameter ( @{ $self->parameters } ) { |
|
|
0
|
|
|
|
|
0
|
|
|
64
|
0
|
0
|
|
|
|
0
|
$data->{$parameter} = $self->$parameter if $self->$parameter; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
0
|
return $data; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 hash |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The constructed HMAC hash of the constructed parameter values sent in the |
|
72
|
|
|
|
|
|
|
request. This is built automatically. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has hash => ( |
|
77
|
|
|
|
|
|
|
is => 'lazy', |
|
78
|
|
|
|
|
|
|
isa => Str, # Varchar[32] |
|
79
|
|
|
|
|
|
|
init_arg => undef, |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _build_hash { |
|
83
|
9
|
|
|
9
|
|
21198
|
my $self = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
9
|
|
|
|
|
12
|
my @parameters; |
|
86
|
9
|
|
|
|
|
7
|
foreach my $parameter ( @{ $self->parameters } ) { |
|
|
9
|
|
|
|
|
28
|
|
|
87
|
59
|
100
|
|
|
|
117
|
push @parameters, $self->$parameter if $self->$parameter; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
9
|
|
|
|
|
65
|
return hmac_md5_hex( |
|
90
|
|
|
|
|
|
|
join( '', $self->merchantId, $self->projectId, @parameters ), |
|
91
|
|
|
|
|
|
|
$self->secret ); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 url |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The full URL for the request. This is built from L along with |
|
97
|
|
|
|
|
|
|
the C attribute of the specific request class. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has url => ( |
|
102
|
|
|
|
|
|
|
is => 'lazy', |
|
103
|
|
|
|
|
|
|
isa => Str, |
|
104
|
|
|
|
|
|
|
init_arg => undef, |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _build_url { |
|
108
|
9
|
|
|
9
|
|
5379
|
my $self = shift; |
|
109
|
9
|
|
|
|
|
36
|
return join( '/', $self->base_uri, $self->uri ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 submit |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Submits the request to Giropay and returns an appropriate response object. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub submit { |
|
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
122
|
0
|
|
|
|
|
|
my $http = HTTP::Tiny->new( verify_SSL => 1 ); |
|
123
|
0
|
|
|
|
|
|
my $response = $http->post_form( $self->url, $self->data ); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return use_module( $self->response_class )->new( |
|
126
|
|
|
|
|
|
|
network => $self->network, |
|
127
|
|
|
|
|
|
|
hash => $response->{headers}->{hash}, |
|
128
|
|
|
|
|
|
|
json => $response->{content}, |
|
129
|
0
|
|
|
|
|
|
secret => $self->secret, |
|
130
|
|
|
|
|
|
|
); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 sandbox_data |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Individual Request class can override this method to massage data when |
|
136
|
|
|
|
|
|
|
L is true. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
0
|
1
|
|
sub sandbox_data {} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |