# ==================================================================
# Gossamer Links - enhanced directory management system
#
#   Website  : http://gossamer-threads.com/
#   Support  : http://gossamer-threads.com/scripts/support/
#   CVS Info : 087,071,086,086,085      
#   Revision : $Id: Manual.pm,v 1.3 2005/03/05 01:46:06 brewt Exp $
# 
# Copyright (c) 2003 Gossamer Threads Inc.  All Rights Reserved.
# Redistribution in part or in whole strictly prohibited.  Please
# see LICENSE file for full details.
# ==================================================================
#
# Glue between Gossamer Links and Manual payment interface

package Links::Payment::Remote::Manual;
use strict;

# Make sure the payment module is available
use Links qw/:objects/;
use Links::Payment qw/:status :log/;
use Links::SiteHTML;
use vars qw/%INVALID %EMPTY/;

sub required {
# -----------------------------------------------------------------------------
# No required parameters available
    return;
}

sub optional {
# -----------------------------------------------------------------------------
# No optional parameters available.
    return;
}

sub payment_info {
# -----------------------------------------------------------------------------
# Returns a hashref of payment hints
#
    return;
}

sub insert_log {
# -----------------------------------------------------------------------------
# 
    my $unique = shift;
    my $pay = $DB->table('Payments');
    my $log = $DB->table('PaymentLogs');
    my $payment = $pay->select({ payments_id => $unique })->fetchrow_hashref or return; # return if the payment doesn't exist.
    return if $payment->{payments_status} == COMPLETED;
    my $cond = GT::SQL::Condition->new(
        paylogs_payments_id => '=' => $unique,
        paylogs_type => '=' => LOG_ACCEPTED
    );
    my $found = $log->count($cond);
    return if $found;
    $log->insert({
        paylogs_payments_id => $payment->{payments_id},
        paylogs_type => LOG_MANUAL,
        paylogs_time => time,
        paylogs_text => (
            "This payment will be manually approved by admin.\n" .
            "Amount: $payment->{payments_amount}\n"
        )
    });
    return;
}

1;
