>>>>> "RA" == Ryan Adams <[EMAIL PROTECTED]> writes:

RA> I'm trying to integrate CyberCash with a shopping system that we've
RA> developed in-house using mod_perl almost exclusively.  I haven't been
RA> particularly impressed with the way it installs.  We're on a Linux machine
RA> and it has a very NT-centric design, in my opinion.

I never felt that way.  It consists entirely of installing 3 *.pm
files and a config file if I recall correctly.

RA> I have been able to get test scripts to run from the command-line
RA> and through basic mod_cgi execution, but I can't get consistent
RA> results when executing them via mod_perl ContentHandlers.  In

I used CyberCash from registry scripts without ever having any
problems.  We used the "authcapture" method.  It took a long time to
refine the error checking, but once done it was quite reliable.  We
only ever had failures when the credit card was bad or typed
incorrectly by the user.

RA> looking through their library files, they are doing some
RA> IPC::Open2 calls to executables and some other pretty ugly stuff
RA> that may or may not be causing the problems.

I don't recall them calling external routines, but it has been a
little while since I last checked.


RA> Does anyone have experience doing this?  What approach did you
RA> take?  Any good documentation?  I've read all the CyberCash stuff,
RA> but it hasn't given me the kind of answers I wanted.

No good documentation.  I can send you the snippet of my program that
did the CyberCash call(s) and checked return status.  Heck, I'll just
post it here.  Obviously, you'll have to fill in the details and
change the data structure that holds your order info to be what you
use, not what we use.



# CyberCash config file
my $cychConfigFile = '/path/to/merchant/mck-cgi/conf/merchant_conf';

use CCMckDirectLib3_2 qw(SendCC2_1Server);
use CCMckLib3_2 qw(InitConfig);


    if (&InitConfig($cychConfigFile)) {
      return "Failed to initialize CyberCash config.  Contact administrator!";
    }

    # fix up some values for CyberCash program

    $orderInfo->{card_exp} =~ s|(\d{1,2})/(\d\d)(\d\d)|$1/$3|; # remove century
    $orderInfo->{card_number} =~ s/\D//g; # remove non-digits (blanks)
    
    # now charge credit card
    my %result = &SendCC2_1Server('mauthcapture', 
                                  'Order-ID', "${oidprefix}${orderid}",
                                  'Amount', "usd $orderInfo->{total}",
                                  'Card-Number', $orderInfo->{card_number},
                                  'Card-Name', $orderInfo->{bill_name},
                                  'Card-Address', $orderInfo->{bill_addr1},
                                  'Card-City', $orderInfo->{bill_city},
                                  'Card-State', $orderInfo->{bill_state},
                                  'Card-Zip', $orderInfo->{bill_zip},
                                  'Card-Country', $orderInfo->{bill_country},
                                  'Card-Exp', $orderInfo->{card_exp});
    
    if ($result{"MStatus"} =~ m/^failure/i) {
      # mark order as "failed"  -- ignore error
      $statush->execute('failed',$orderInfo->{card_number},
                        "$result{MErrMsg} ($result{MErrLoc})",$orderid);
      
      if ($result{"MErrLoc"} =~ m/BANK|CCSP/i) {
        return "OID $orderid: Card Declined.";
      } else { # if ($result{"MErrLoc"} =~ /CLIENT|MPMT|CCSRVR|SMPS/i)
        return "OID $orderid ERROR: $result{MErrMsg} ($result{MErrLoc})";
      }
    }
    
    # catch non-successful, non failure-hard errors whatever they may be.
    if ($result{'MStatus'} ne "success") {
      # do not mark as failed, since this is usually transient error
      return "OID $orderid TRY AGAIN: $result{MErrMsg} ($result{MErrLoc})";
    }
    
    # mangle CC number so we don't use it again
    $orderInfo->{card_number} =~ s/^(\d{2})(\d+)(\d{4})$/$1\*$3/;

    $ccstatus = "Auth Code: $result{'auth-code'}";

# if you get this far, you have the money.

Reply via email to