line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::CPI::Gateway::Test; |
2
|
|
|
|
|
|
|
# ABSTRACT: Fake gateway |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
7425
|
use Moo; |
|
6
|
|
|
|
|
50159
|
|
|
6
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.924'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Business::CPI::Gateway::Base'; |
9
|
|
|
|
|
|
|
with 'Business::CPI::Role::Gateway::FormCheckout'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_hidden_inputs { |
12
|
3
|
|
|
3
|
1
|
6
|
my ( $self, $info ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
6
|
my $buyer = $info->{buyer}; |
15
|
3
|
|
|
|
|
6
|
my $cart = $info->{cart}; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
82
|
my @hidden_inputs = ( |
18
|
|
|
|
|
|
|
receiver_email => $self->receiver_id, |
19
|
|
|
|
|
|
|
currency => $self->currency, |
20
|
|
|
|
|
|
|
encoding => $self->form_encoding, |
21
|
|
|
|
|
|
|
payment_id => $info->{payment_id}, |
22
|
|
|
|
|
|
|
buyer_name => $buyer->name, |
23
|
|
|
|
|
|
|
buyer_email => $buyer->email, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
21
|
my %buyer_extra = ( |
27
|
|
|
|
|
|
|
address_line1 => 'shipping_address', |
28
|
|
|
|
|
|
|
address_line2 => 'shipping_address2', |
29
|
|
|
|
|
|
|
address_city => 'shipping_city', |
30
|
|
|
|
|
|
|
address_state => 'shipping_state', |
31
|
|
|
|
|
|
|
address_country => 'shipping_country', |
32
|
|
|
|
|
|
|
address_zip_code => 'shipping_zip', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
15
|
for (keys %buyer_extra) { |
36
|
18
|
100
|
|
|
|
67
|
if (my $value = $buyer->$_) { |
37
|
11
|
|
|
|
|
29
|
push @hidden_inputs, ( $buyer_extra{$_} => $value ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
17
|
my %cart_extra = ( |
42
|
|
|
|
|
|
|
discount => 'discount_amount', |
43
|
|
|
|
|
|
|
handling => 'handling_amount', |
44
|
|
|
|
|
|
|
tax => 'tax_amount', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
12
|
for (keys %cart_extra) { |
48
|
9
|
50
|
|
|
|
43
|
if (my $value = $cart->$_) { |
49
|
9
|
|
|
|
|
4688
|
push @hidden_inputs, ( $cart_extra{$_} => $value ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
12
|
my $i = 1; |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
7
|
foreach my $item (@{ $info->{items} }) { |
|
3
|
|
|
|
|
13
|
|
56
|
6
|
|
|
|
|
103
|
push @hidden_inputs, |
57
|
|
|
|
|
|
|
( |
58
|
|
|
|
|
|
|
"item${i}_id" => $item->id, |
59
|
|
|
|
|
|
|
"item${i}_desc" => $item->description, |
60
|
|
|
|
|
|
|
"item${i}_price" => $item->price, |
61
|
|
|
|
|
|
|
"item${i}_qty" => $item->quantity, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
19
|
if (my $weight = $item->weight) { |
65
|
1
|
|
|
|
|
4
|
push @hidden_inputs, ( "item${i}_weight" => $weight * 1000 ); # show in grams |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
6
|
100
|
|
|
|
40
|
if (my $ship = $item->shipping) { |
69
|
1
|
|
|
|
|
2
|
push @hidden_inputs, ( "item${i}_shipping" => $ship ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
6
|
100
|
|
|
|
25
|
if (my $ship = $item->shipping_additional) { |
73
|
1
|
|
|
|
|
3
|
push @hidden_inputs, ( "item${i}_shipping2" => $ship ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
6
|
|
|
|
|
14
|
$i++; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
7
|
$i = 1; |
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
6
|
foreach my $receiver (@{ $cart->_receivers }) { |
|
3
|
|
|
|
|
14
|
|
82
|
2
|
|
|
|
|
25
|
push @hidden_inputs, |
83
|
|
|
|
|
|
|
( |
84
|
|
|
|
|
|
|
"receiver${i}_id" => $receiver->account->gateway_id, |
85
|
|
|
|
|
|
|
"receiver${i}_percent" => sprintf("%.2f", 0+$receiver->percent_amount), |
86
|
|
|
|
|
|
|
); |
87
|
2
|
|
|
|
|
477
|
$i++; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
186
|
return @hidden_inputs; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# TODO |
94
|
|
|
|
|
|
|
# use SQLite? |
95
|
|
|
|
|
|
|
# sub get_notification_details {} |
96
|
|
|
|
|
|
|
# sub query_transactions {} |
97
|
|
|
|
|
|
|
# sub get_transaction_details {} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |