line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::iDEAL::Mollie; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
57047
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
95
|
|
6
|
1
|
|
|
1
|
|
838379
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
1471283
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
513
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my ($class, $args) = @_; |
13
|
|
|
|
|
|
|
$args ||= {}; |
14
|
|
|
|
|
|
|
$class->_croak("Options must be a hash reference") |
15
|
|
|
|
|
|
|
if ref($args) ne 'HASH'; |
16
|
|
|
|
|
|
|
my $self = {}; |
17
|
|
|
|
|
|
|
bless $self, $class; |
18
|
|
|
|
|
|
|
$self->_init($args) or return undef; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _init { |
24
|
|
|
|
|
|
|
my ($self, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new( |
27
|
|
|
|
|
|
|
agent => __PACKAGE__." v. $VERSION", |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
my %options = ( |
30
|
|
|
|
|
|
|
baseurl => 'http://www.mollie.nl/xml/ideal', |
31
|
|
|
|
|
|
|
ua => $ua, |
32
|
|
|
|
|
|
|
%{ $args }, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
$self->{"_$_"} = $options{$_} foreach (%options); |
35
|
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub banklist { |
39
|
|
|
|
|
|
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $res = $self->{'_ua'}->get($self->{'_baseurl'}.'?a=banklist'); |
42
|
|
|
|
|
|
|
if ($res->is_success) { |
43
|
|
|
|
|
|
|
return _parse_output($res->decoded_content)->{'bank'}; |
44
|
|
|
|
|
|
|
} else { |
45
|
|
|
|
|
|
|
$self->{'_error'} = $res->status_line; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub fetch { |
50
|
|
|
|
|
|
|
my ($self, $parms) = @_; |
51
|
|
|
|
|
|
|
$parms ||= {}; |
52
|
|
|
|
|
|
|
$self->_croak("Parameters must be in a hash reference") |
53
|
|
|
|
|
|
|
if ref($parms) ne 'HASH'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Check for mandatory input |
56
|
|
|
|
|
|
|
foreach(qw/partnerid amount bank_id description reporturl returnurl/) { |
57
|
|
|
|
|
|
|
$self->_croak("Mandatory parameter $_ not found!") unless($parms->{$_}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Make sure amount is in cents |
61
|
|
|
|
|
|
|
$parms->{'amount'} =~ s/[\.,]//g; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Put the action value in $parms |
64
|
|
|
|
|
|
|
$parms->{'a'} = 'fetch'; |
65
|
|
|
|
|
|
|
my $res = $self->{'_ua'}->post($self->{'_baseurl'}, $parms); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ($res->is_success) { |
68
|
|
|
|
|
|
|
return _parse_output($res->decoded_content)->{'order'}; |
69
|
|
|
|
|
|
|
} else { |
70
|
|
|
|
|
|
|
$self->{'_error'} = $res->status_line; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub check { |
75
|
|
|
|
|
|
|
my ($self, $parms) = @_; |
76
|
|
|
|
|
|
|
$parms ||= {}; |
77
|
|
|
|
|
|
|
$self->_croak("Parameters must be in a hash reference") |
78
|
|
|
|
|
|
|
if ref($parms) ne 'HASH'; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Check for mandatory input |
81
|
|
|
|
|
|
|
foreach(qw/partnerid transaction_id/) { |
82
|
|
|
|
|
|
|
$self->_croak("Mandatory parameter $_ not found!") unless($parms->{$_}); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Put the action value in $parms |
86
|
|
|
|
|
|
|
$parms->{'a'} = 'check'; |
87
|
|
|
|
|
|
|
my $res = $self->{'_ua'}->post($self->{'_baseurl'}, $parms); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
if ($res->is_success) { |
90
|
|
|
|
|
|
|
return _parse_output($res->decoded_content)->{'order'}; |
91
|
|
|
|
|
|
|
} else { |
92
|
|
|
|
|
|
|
$self->{'_error'} = $res->status_line; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub is_payed { |
97
|
|
|
|
|
|
|
my ($self, $parms) = @_; |
98
|
|
|
|
|
|
|
my $resp = $self->check($parms); |
99
|
|
|
|
|
|
|
return ($resp->{'payed'} eq 'true') ? 1 : 0; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub error { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
return $self->{'_error'}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _parse_output { |
109
|
|
|
|
|
|
|
my $input = shift; |
110
|
|
|
|
|
|
|
return unless($input); |
111
|
|
|
|
|
|
|
my $xso = new XML::Simple(); |
112
|
|
|
|
|
|
|
return $xso->XMLin($input); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _croak { |
116
|
|
|
|
|
|
|
my ($self, @error) = @_; |
117
|
|
|
|
|
|
|
Carp::croak(@error); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
__END__ |