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 |
|
|
<MNT_SIGNATURE><% $reply_md5 %></MNT_SIGNATURE> |
7 |
|
|
<%doc> |
8 |
|
|
<MNT_ATTRIBUTES> |
9 |
|
|
<ATTRIBUTE> |
10 |
|
|
<KEY></KEY> |
11 |
|
|
<VALUE></VALUE> |
12 |
|
|
</ATTRIBUTE> |
13 |
|
|
</MNT_ATTRIBUTES> |
14 |
|
|
</%doc> |
15 |
|
|
</MNT_RESPONSE> |
16 |
|
|
<%once> |
17 |
|
|
|
18 |
|
|
use Digest::MD5; |
19 |
|
|
|
20 |
|
|
</%once> |
21 |
|
|
<%args> |
22 |
|
|
|
23 |
|
|
$MNT_ID => undef |
24 |
|
|
$MNT_TRANSACTION_ID => undef |
25 |
|
|
$MNT_OPERATION_ID => undef |
26 |
|
|
$MNT_AMOUNT => '' |
27 |
|
|
$MNT_CURRENCY_CODE => undef |
28 |
|
|
$MNT_TEST_MODE => 0 |
29 |
|
|
$MNT_SIGNATURE => undef |
30 |
|
|
$MNT_USER => undef |
31 |
|
|
$MNT_CORRACCOUNT => undef |
32 |
|
|
$MNT_CUSTOM1 => undef |
33 |
|
|
$MNT_CUSTOM2 => undef |
34 |
|
|
$MNT_CUSTOM3 => undef |
35 |
|
|
|
36 |
|
|
</%args> |
37 |
|
|
<%init> |
38 |
|
|
|
39 |
|
|
warn Dumper \%ARGS if $DEBUG; |
40 |
|
|
unless ( $MNT_ID && $MNT_TRANSACTION_ID && $MNT_OPERATION_ID && $MNT_AMOUNT && $MNT_CURRENCY_CODE ) { |
41 |
|
|
$m->out('FAIL'); |
42 |
|
|
return; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
my $str = $MNT_ID . $MNT_TRANSACTION_ID . $MNT_OPERATION_ID . $MNT_AMOUNT . $MNT_CURRENCY_CODE . $MNT_TEST_MODE . $state->{monetaru}->{moneta_sig_code}; |
46 |
|
|
my $md5 = Digest::MD5::md5_hex ( $str ); |
47 |
|
|
unless ( $MNT_SIGNATURE eq $md5 ) { |
48 |
|
|
$m->out('FAIL'); |
49 |
|
|
return; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
my $reply_code; |
53 |
|
|
my $last = $keeper->{monetaru}->check( $MNT_TRANSACTION_ID ); |
54 |
|
|
if ( ref $last ) { |
55 |
|
|
my $sum = sprintf("%.2f", $last->sum); |
56 |
|
|
if ( $last->name eq 'cancel' ) { |
57 |
|
|
$reply_code = 500; |
58 |
|
|
} elsif ( $last->name eq 'suspend' ) { |
59 |
|
|
$reply_code = 500; |
60 |
|
|
} |
61 |
|
|
} else { |
62 |
|
|
$reply_code = 500; |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
unless ( $reply_code ) { |
66 |
|
|
my ($obj) = $keeper->get_documents( |
67 |
|
|
class => 'monetaru::Transaction', |
68 |
|
|
operation_id => $MNT_OPERATION_ID, |
69 |
|
|
order_id => $MNT_TRANSACTION_ID, |
70 |
|
|
limit => 1, |
71 |
|
|
); |
72 |
|
|
|
73 |
|
|
unless ( $obj ) { |
74 |
|
|
$obj = monetaru::Transaction->new( $keeper ); |
75 |
|
|
$obj->status( $MNT_TEST_MODE || 0 ); |
76 |
|
|
$obj->account_id( $MNT_ID ); |
77 |
|
|
$obj->order_id( $MNT_TRANSACTION_ID ); |
78 |
|
|
$obj->operation_id( $MNT_OPERATION_ID ); |
79 |
|
|
$obj->sum( $MNT_AMOUNT ); |
80 |
|
|
$obj->currency_code( $MNT_CURRENCY_CODE ); |
81 |
|
|
$obj->account_user( $MNT_USER ); |
82 |
|
|
$obj->account_corr( $MNT_CORRACCOUNT ); |
83 |
|
|
$obj->payment_system( $ARGS{'paymentSystem.unitId'} ); |
84 |
|
|
$obj->name( $MNT_CUSTOM1 ); |
85 |
|
|
$obj->custom1( $MNT_CUSTOM1 ); |
86 |
|
|
$obj->custom2( $MNT_CUSTOM2 ); |
87 |
|
|
$obj->custom3( $MNT_CUSTOM3 ); |
88 |
|
|
$obj->store; |
89 |
|
|
} |
90 |
|
|
if ( $obj->id ) { |
91 |
|
|
$reply_code = 200; |
92 |
|
|
} else { |
93 |
|
|
$reply_code = 100; |
94 |
|
|
} |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
$str = $reply_code . $MNT_ID . $MNT_TRANSACTION_ID . $state->{monetaru}->{moneta_sig_code}; |
98 |
|
|
my $reply_md5 = Digest::MD5::md5_hex ( $str ); |
99 |
|
|
|
100 |
|
|
</%init> |