Revision 358 (by ahitrov, 2013/06/11 08:56:08) |
Initial plugin import
|
<?xml version="1.0" encoding="UTF-8"?>
<MNT_RESPONSE>
<MNT_ID><% $MNT_ID %></MNT_ID>
<MNT_TRANSACTION_ID><% $MNT_TRANSACTION_ID %></MNT_TRANSACTION_ID>
<MNT_RESULT_CODE><% $reply_code %></MNT_RESULT_CODE>
% if ( ref $last ) {
<MNT_DESCRIPTION><% $last->name %></MNT_DESCRIPTION>
% }
<MNT_AMOUNT><% $MNT_AMOUNT %></MNT_AMOUNT>
<MNT_SIGNATURE><% $reply_md5 %></MNT_SIGNATURE>
<%doc>
<MNT_ATTRIBUTES>
<ATTRIBUTE>
<KEY></KEY>
<VALUE></VALUE>
</ATTRIBUTE>
</MNT_ATTRIBUTES>
</%doc>
</MNT_RESPONSE>
<%once>
use Digest::MD5;
</%once>
<%args>
$MNT_COMMAND => ''
$MNT_ID => undef
$MNT_TRANSACTION_ID => undef
$MNT_OPERATION_ID => ''
$MNT_AMOUNT => ''
$MNT_CURRENCY_CODE => undef
$MNT_TEST_MODE => 0
$MNT_SIGNATURE => undef
$MNT_USER => undef
$MNT_CORRACCOUNT => undef
$MNT_CUSTOM1 => undef
$MNT_CUSTOM2 => undef
$MNT_CUSTOM3 => undef
</%args>
<%init>
warn Dumper \%ARGS if $DEBUG;
unless ( $MNT_ID && $MNT_TRANSACTION_ID && $MNT_CURRENCY_CODE ) {
$m->out('FAIL');
return;
}
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};
my $md5 = Digest::MD5::md5_hex ( $str );
warn "MD5 Check: $md5\n" if $DEBUG;
unless ( $MNT_SIGNATURE eq $md5 ) {
$m->out('FAIL');
return;
}
my $reply_code;
my $last = $keeper->{monetaru}->check( $MNT_TRANSACTION_ID );
if ( ref $last ) {
my $sum = sprintf("%.2f", $last->sum);
if ( $last->name eq 'cancel' ) {
$reply_code = 500;
} elsif ( !$MNT_AMOUNT && $last->name =~ /(create|reform)/ ) {
$MNT_AMOUNT = $last->sum;
$reply_code = 100;
} elsif ( $last->name =~ /(create|reform)/ && $sum ne $MNT_AMOUNT ) {
$MNT_AMOUNT = $last->sum;
$reply_code = 100;
} elsif ( $last->name eq 'suspend' ) {
$reply_code = 302;
}
} else {
$reply_code = 500;
}
unless ( $reply_code ) {
my ($obj) = $keeper->get_documents(
class => 'monetaru::Transaction',
order_id => $MNT_TRANSACTION_ID,
limit => 1,
);
if ( ref $obj ) {
$reply_code = 200;
} else {
$reply_code = 402;
}
}
warn "CHECK_URL: Reply code = [$reply_code]\n" if $DEBUG;
$str = $reply_code . $MNT_ID . $MNT_TRANSACTION_ID . $state->{monetaru}->{moneta_sig_code};
my $reply_md5 = Digest::MD5::md5_hex ( $str );
warn "Reply MD5: $reply_md5\n" if $DEBUG;
</%init>