[ic] Request for more info and a partial solution: custom payments, GlobalSub

Larry Morley lmorley@cslimits.net
Fri, 09 Mar 2001 05:38:25 -0500

The other day I posted a request r.e. GlobalSub / custom payment
etc.  I need to communicate with several systems via TCP/IP and other
systems to process transactions from Interchange.

Thanks all for the info I received.  First a few questions -

1) does anyone know of any place I can find some comprehensive info on
   how Interchange interacts with validation and processing systems?

2) has anyone written GlobalSub type modules in C (presumably with
   a Perl wrapper) that do anything they would be willing to share -
   even an example?

3) any info on life with Interchange (other than the supplied docs
   which read kind of like stereo instructions) would be really,
   really appreciated.

Now for what I found - I made the following changes to the files
below, and wrote the GlobalSub contained herein (with bits and pieces
I gleaned from code I received, found, etc.) - works like a charm.
It communicates with a TCP server I wrote that accepts connections on
port 1234 - doesn't do anything at this point but gather and dump info
passed to it by the Perl routine.

Please bear in mind that I'm using the RPM install; your files may not
be in the exact same locations as mine ...

Assuming the name of the catalog-in-question is "mycatalog":

In /usr/lib/interchange/eg/globalsub/testsub:

   GlobalSub <<EOS

   use strict;
   use Vend::Util;

   sub test {

      ::logDebug("Entering test GlobalSub...");

      my %ic_result;
      $ic_result{'order-id'}=1; # must be !null

      ::logDebug("Exiting test GlobalSub.");
      return (%ic_result);

To communicate with a remote, I added

   use Socket;

at the head of the file; then:

   # ---------------
   # Spill our guts via TCP ...

   my @S;
   my $addr = sockaddr_in(1234,inet_aton('some.remote.host'));

   print S "<SOT>\n",
           "CCNUM ",$actual{mv_credit_card_number},"\n",
           "FNAME ",$actual{b_fname},"\n",
           "LNAME ",$actual{b_lname},"\n",
           "ADDR  ",$actual{address},"\n",
           "CITY  ",$actual{b_city},"\n",
           "STATE ",$actual{b_state},"\n",
           "ZIPPC ",$actual{zip},"\n",
           "PMTMD ",$actual{mv_payment_mode},"\n",
           "AMT   ",$amount,"\n",
           "EXPDT ",$exp,"\n",
           "ORDNM ",$actual{mv_order_number},"\n",
           "PSKEY ",$secret,"\n",
           "USRID ",$user,"\n",


The "\007" char is the end-of-message indicator.  Like I
said earlier, it's crude, but it seems to show that what
I need to do can be done ...

In /var/lib/interchange/mycatalog/etc/profiles.order
(the ... and line are here so it should be easy to
 figure out where in the file I added this)


   &set = mv_payment Incomplete

   # call /usr/lib/interchange/eg/globalsub/testsub
   #          function == test
   &charge=custom test

   [if value fax_order == 1]
   &set = mv_payment Check or Money Order (will call)


In /etc/interchange.cfg:

   #Uncomment to log to debug file /tmp/icdebug
   # CHANGE make it so...
   Variable   DEBUG     1
   # /CHANGE

and, at the end of the file (after everything else has
been set, included, etc.):

   AllowGlobal mycatalog
   #include /usr/lib/interchange/eg/globalsub/testsub