1 |
358 |
ahitrov |
<?xml version="1.0" encoding="UTF-8"?> |
2 |
|
|
<MNT_RESPONSE> |
3 |
|
|
<MNT_ID><% $MNT_ID %></MNT_ID> |
4 |
|
|
<MNT_TRANSACTION_ID><% $MNT_TRANSACTION_ID %></MNT_TRANSACTION_ID> |
5 |
|
|
<MNT_RESULT_CODE><% $reply_code %></MNT_RESULT_CODE> |
6 |
|
|
% if ( ref $last ) { |
7 |
|
|
<MNT_DESCRIPTION><% $last->name %></MNT_DESCRIPTION> |
8 |
|
|
% } |
9 |
|
|
<MNT_AMOUNT><% $MNT_AMOUNT %></MNT_AMOUNT> |
10 |
|
|
<MNT_SIGNATURE><% $reply_md5 %></MNT_SIGNATURE> |
11 |
|
|
<%doc> |
12 |
|
|
<MNT_ATTRIBUTES> |
13 |
|
|
<ATTRIBUTE> |
14 |
|
|
<KEY></KEY> |
15 |
|
|
<VALUE></VALUE> |
16 |
|
|
</ATTRIBUTE> |
17 |
|
|
</MNT_ATTRIBUTES> |
18 |
|
|
</%doc> |
19 |
|
|
</MNT_RESPONSE> |
20 |
|
|
<%once> |
21 |
|
|
|
22 |
|
|
use Digest::MD5; |
23 |
|
|
|
24 |
|
|
</%once> |
25 |
|
|
<%args> |
26 |
|
|
|
27 |
|
|
$MNT_COMMAND => '' |
28 |
|
|
$MNT_ID => undef |
29 |
|
|
$MNT_TRANSACTION_ID => undef |
30 |
|
|
$MNT_OPERATION_ID => '' |
31 |
|
|
$MNT_AMOUNT => '' |
32 |
|
|
$MNT_CURRENCY_CODE => undef |
33 |
|
|
$MNT_TEST_MODE => 0 |
34 |
|
|
$MNT_SIGNATURE => undef |
35 |
|
|
$MNT_USER => undef |
36 |
|
|
$MNT_CORRACCOUNT => undef |
37 |
|
|
$MNT_CUSTOM1 => undef |
38 |
|
|
$MNT_CUSTOM2 => undef |
39 |
|
|
$MNT_CUSTOM3 => undef |
40 |
|
|
|
41 |
|
|
</%args> |
42 |
|
|
<%init> |
43 |
|
|
|
44 |
|
|
warn Dumper \%ARGS if $DEBUG; |
45 |
|
|
unless ( $MNT_ID && $MNT_TRANSACTION_ID && $MNT_CURRENCY_CODE ) { |
46 |
|
|
$m->out('FAIL'); |
47 |
|
|
return; |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
my $str = $MNT_COMMAND . $MNT_ID . $MNT_TRANSACTION_ID . $MNT_OPERATION_ID . $MNT_AMOUNT . $MNT_CURRENCY_CODE . $MNT_TEST_MODE . $state->{monetaru}->{moneta_sig_code}; |
51 |
|
|
my $md5 = Digest::MD5::md5_hex ( $str ); |
52 |
|
|
warn "MD5 Check: $md5\n" if $DEBUG; |
53 |
|
|
unless ( $MNT_SIGNATURE eq $md5 ) { |
54 |
|
|
$m->out('FAIL'); |
55 |
|
|
return; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
my $reply_code; |
59 |
|
|
my $last = $keeper->{monetaru}->check( $MNT_TRANSACTION_ID ); |
60 |
|
|
if ( ref $last ) { |
61 |
|
|
my $sum = sprintf("%.2f", $last->sum); |
62 |
|
|
if ( $last->name eq 'cancel' ) { |
63 |
|
|
$reply_code = 500; |
64 |
|
|
} elsif ( !$MNT_AMOUNT && $last->name =~ /(create|reform)/ ) { |
65 |
|
|
$MNT_AMOUNT = $last->sum; |
66 |
|
|
$reply_code = 100; |
67 |
|
|
} elsif ( $last->name =~ /(create|reform)/ && $sum ne $MNT_AMOUNT ) { |
68 |
|
|
$MNT_AMOUNT = $last->sum; |
69 |
|
|
$reply_code = 100; |
70 |
|
|
} elsif ( $last->name eq 'suspend' ) { |
71 |
|
|
$reply_code = 302; |
72 |
|
|
} |
73 |
|
|
} else { |
74 |
|
|
$reply_code = 500; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
unless ( $reply_code ) { |
78 |
|
|
my ($obj) = $keeper->get_documents( |
79 |
|
|
class => 'monetaru::Transaction', |
80 |
|
|
order_id => $MNT_TRANSACTION_ID, |
81 |
|
|
limit => 1, |
82 |
|
|
); |
83 |
|
|
if ( ref $obj ) { |
84 |
|
|
$reply_code = 200; |
85 |
|
|
} else { |
86 |
|
|
$reply_code = 402; |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
warn "CHECK_URL: Reply code = [$reply_code]\n" if $DEBUG; |
90 |
|
|
|
91 |
|
|
$str = $reply_code . $MNT_ID . $MNT_TRANSACTION_ID . $state->{monetaru}->{moneta_sig_code}; |
92 |
|
|
my $reply_md5 = Digest::MD5::md5_hex ( $str ); |
93 |
|
|
warn "Reply MD5: $reply_md5\n" if $DEBUG; |
94 |
|
|
|
95 |
|
|
</%init> |