Revision 358 (by ahitrov, 2013/06/11 08:56:08) Initial plugin import
SUCCESS
<%once>

    use Digest::MD5;

</%once>
<%args>

	$MNT_ID			=> undef
	$MNT_TRANSACTION_ID	=> undef
	$MNT_OPERATION_ID	=> undef
	$MNT_AMOUNT		=> 0
	$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_OPERATION_ID && $MNT_AMOUNT && $MNT_CURRENCY_CODE ) {
	$m->out('FAIL');
	return;
    }

    my ($obj) = $keeper->get_documents(
			class	=> 'monetaru::Transaction',
			operation_id	=> $MNT_OPERATION_ID,
			order_id	=> $MNT_TRANSACTION_ID,
			limit	=> 1,
		);
    my $str = $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 );
    unless ( $MNT_SIGNATURE eq $md5 ) {
	$m->out('FAIL');
	return;
    }

    unless ( $obj ) {
	$obj = monetaru::Transaction->new( $keeper );
	$obj->status( $MNT_TEST_MODE || 0 );
	$obj->account_id( $MNT_ID );
	$obj->order_id( $MNT_TRANSACTION_ID );
	$obj->operation_id( $MNT_OPERATION_ID );
	$obj->sum( $MNT_AMOUNT );
	$obj->currency_code( $MNT_CURRENCY_CODE );
	$obj->account_user( $MNT_USER );
	$obj->account_corr( $MNT_CORRACCOUNT );
	$obj->payment_system( $ARGS{'paymentSystem.unitId'} );
	$obj->name( $MNT_CUSTOM1 );
	$obj->custom1( $MNT_CUSTOM1 );
	$obj->custom2( $MNT_CUSTOM2 );
	$obj->custom3( $MNT_CUSTOM3 );
	$obj->store;
    }

</%init>