Revision 563 (by ahitrov, 2016/04/12 12:53:34) Payment plugin contenido interface. Order finder and order actions

<%once>

    my %NAMES = (
		'MerchantBlock'		=> 'Authorized',
		'MerchantPay'		=> 'Charged',
		'MerchantRefund'	=> 'Refunded',
	);

</%once>
<%args>

	$SessionId	=> undef
	$OrderId	=> undef
	$Notification	=> undef
	$Success	=> undef
	$Amount		=> undef
	$CardNumber	=> undef
	$MerchantContract	=> undef

</%args>
<%init>

    warn Dumper \%ARGS;

    my $provider = payments::Provider::PayTure->new;
    my (@operations, $transaction);
    if ( $OrderId ) {
	@operations = $keeper->get_documents(
			class	=> 'payments::Operation',
			order_id	=> $OrderId,
			order_by	=> 'ctime',
		);
	($transaction) = $keeper->get_documents (
			class	=> 'payments::Transaction',
			provider	=> $provider->payment_system,
			order_id	=> $OrderId,
			order_by	=> 'ctime desc',
			limit	=> 1,
		);
    }
    if ( ref $transaction ) {
	$transaction->name( $NAMES{$Notification} );
	$transaction->success( $Success eq 'True' ? 1 : 0 );
	$transaction->store;

	if ( $transaction->success && $keeper->can('_payture_handler') ) {
		$keeper->_payture_handler( $transaction );
	}
    }

</%init>