line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::BancaSella::Encode::Gestpay; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
push @ISA,'Business::BancaSella::Gestpay'; |
4
|
2
|
|
|
2
|
|
2115
|
use Business::BancaSella::Gestpay; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
5
|
2
|
|
|
2
|
|
1868
|
use URI::Escape; |
|
2
|
|
|
|
|
4153
|
|
|
2
|
|
|
|
|
148
|
|
6
|
2
|
|
|
2
|
|
2041
|
use HTML::Entities; |
|
2
|
|
|
|
|
1317112
|
|
|
2
|
|
|
|
|
234
|
|
7
|
2
|
|
|
2
|
|
22
|
use Carp; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
259
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = "0.13"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $bKeys = { |
13
|
|
|
|
|
|
|
currency => 'PAY1_UICCODE', |
14
|
|
|
|
|
|
|
amount => 'PAY1_AMOUNT', |
15
|
|
|
|
|
|
|
id => 'PAY1_SHOPTRANSACTIONID', |
16
|
|
|
|
|
|
|
otp => 'PAY1_OTP', |
17
|
|
|
|
|
|
|
cardnumber => 'PAY1_CARDNUMBER', |
18
|
|
|
|
|
|
|
expmonth => 'PAY1_EXPMONTH', |
19
|
|
|
|
|
|
|
expyear => 'PAY1_EXPYEAR', |
20
|
|
|
|
|
|
|
name => 'PAY1_CHNAME', |
21
|
|
|
|
|
|
|
mail => 'PAY1_CHMAIL', |
22
|
|
|
|
|
|
|
language => 'PAY1_IDLANGUAGE', |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
0
|
sub Version { $VERSION; } |
27
|
|
|
|
|
|
|
require 5.004; |
28
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11964
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %fields = |
31
|
|
|
|
|
|
|
( |
32
|
|
|
|
|
|
|
base_url => 'https://ecomm.sella.it/gestpay/pagam.asp', |
33
|
|
|
|
|
|
|
currency => 'eur', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @fields_req = qw/shopping amount id otp/; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new |
39
|
|
|
|
|
|
|
{ |
40
|
1
|
|
|
1
|
1
|
20
|
my $proto = shift; |
41
|
1
|
|
33
|
|
|
8
|
my $class = ref($proto) || $proto; |
42
|
1
|
|
|
|
|
2
|
my $self = {}; |
43
|
1
|
|
|
|
|
4
|
bless $self,$class; |
44
|
1
|
|
|
|
|
6
|
$self->init(@_); |
45
|
1
|
|
|
|
|
3
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub init { |
49
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
50
|
2
|
|
|
|
|
21
|
my (%options) = @_; |
51
|
2
|
|
|
|
|
24
|
$self->SUPER::init(@_); |
52
|
|
|
|
|
|
|
# Assign default options |
53
|
2
|
|
|
|
|
13
|
while (my ($key,$value) = each(%fields)) { |
54
|
4
|
|
66
|
|
|
29
|
$self->{$key} = $self->{$key} || $value; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
# Assign options |
57
|
2
|
|
|
|
|
12
|
while (my ($key,$value) = each(%options)) { |
58
|
17
|
|
|
|
|
46
|
$self->{$key} = $value |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
# Check required params |
61
|
2
|
|
|
|
|
7
|
foreach (@fields_req) { |
62
|
8
|
50
|
|
|
|
33
|
croak "You must declare '$_' in " . ref($self) . "::new" |
63
|
|
|
|
|
|
|
if (!defined $self->{$_}); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub uri { |
68
|
2
|
|
|
2
|
1
|
28
|
my $self = shift; |
69
|
2
|
|
|
|
|
15
|
my $uri = 'a=' . $self->shopping . '&b=' . $self->getB; |
70
|
|
|
|
|
|
|
#$uri = uri_escape($uri); |
71
|
2
|
|
|
|
|
247
|
return $self->base_url . '?' . $uri; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub form { |
75
|
2
|
|
|
2
|
1
|
14
|
my $self = shift; |
76
|
2
|
|
50
|
|
|
12
|
my $frmName = shift || ''; |
77
|
2
|
|
|
|
|
11
|
my $ret = ' |
|
|
|
|
|
|
$self->base_url . '">' . "\n"; |
79
|
2
|
|
|
|
|
19
|
$ret .= '
80
|
|
|
|
|
|
|
'">' . "\n"; |
81
|
2
|
|
|
|
|
13
|
$ret .= '
82
|
|
|
|
|
|
|
encode_entities($self->getB) . '">' . "\n"; |
83
|
2
|
|
|
|
|
227
|
$ret .= "\n"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub getB { |
87
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
88
|
4
|
|
|
|
|
28
|
my @b; |
89
|
4
|
|
|
|
|
6
|
foreach (keys(%{$bKeys})) { |
|
4
|
|
|
|
|
26
|
|
90
|
40
|
|
|
|
|
43
|
my $addValue; |
91
|
40
|
100
|
66
|
|
|
176
|
if (exists($self->{$_}) && defined($self->{$_}) ) { |
92
|
28
|
|
|
|
|
152
|
$addValue = $self->$_; |
93
|
28
|
100
|
|
|
|
75
|
$addValue = valuta_encode($addValue) if ($_ eq 'currency'); |
94
|
28
|
100
|
|
|
|
57
|
$addValue = lingua_encode($addValue) if ($_ eq 'language'); |
95
|
28
|
|
|
|
|
123
|
push @b,$bKeys->{$_} . '=' . $addValue; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
# add user personal parameters |
99
|
4
|
|
|
|
|
11
|
while (my ($key,$val) = each %{$self->{user_params}}) { |
|
8
|
|
|
|
|
32
|
|
100
|
4
|
|
|
|
|
20
|
push @b, "$key=$val"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
#return join('*P1*',@b); |
103
|
4
|
|
|
|
|
28
|
return uri_escape(join('*P1*',@b)); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub valuta_encode { |
107
|
4
|
|
|
4
|
0
|
11
|
my $valuta = lc(shift); |
108
|
4
|
|
|
|
|
37
|
my %vd = ( |
109
|
|
|
|
|
|
|
'eur' => 242, |
110
|
|
|
|
|
|
|
'itl' => 18, |
111
|
|
|
|
|
|
|
'usd' => 1, |
112
|
|
|
|
|
|
|
'uk' => 2, |
113
|
|
|
|
|
|
|
'yen' => 71, |
114
|
|
|
|
|
|
|
'hkd' => 103, |
115
|
|
|
|
|
|
|
'real' => 234 |
116
|
|
|
|
|
|
|
); |
117
|
4
|
50
|
|
|
|
13
|
die "Unable to encode you currency '$valuta'" if (!exists $vd{$valuta}); |
118
|
4
|
|
|
|
|
15
|
return $vd{$valuta}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub lingua_encode { |
122
|
2
|
|
|
2
|
0
|
5
|
my $lingua = lc(shift); |
123
|
2
|
|
|
|
|
9
|
my %ld = ( |
124
|
|
|
|
|
|
|
'italian' => 1, |
125
|
|
|
|
|
|
|
'english' => 2, |
126
|
|
|
|
|
|
|
'spanish' => 3, |
127
|
|
|
|
|
|
|
'french' => 4 |
128
|
|
|
|
|
|
|
); |
129
|
2
|
50
|
|
|
|
7
|
return $ld{'english'} if (!exists $ld{$lingua}); |
130
|
2
|
|
|
|
|
6
|
return $ld{$lingua}; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
4
|
50
|
|
4
|
0
|
7
|
sub base_url { my $s=shift; return @_ ? ($s->{base_url}=shift) : $s->{base_url} } |
|
4
|
|
|
|
|
80
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |