More info: [ic] routes + payment provider

Mathias Picker mathiasp@venus.virtual-earth.de
Mon, 28 Aug 2000 17:27:47 +0200 (CEST)


As a followup to my own post, I now have some part of a solution, but it
does not work :-(

What I'm trying now is to do order routing in the [vipresponse ...] user
tag (which my payment provider wrote, so I don't understand it fully).
(see tag definition at eom)

I try to call Vend::Order::route_order, and get a blank order. Since I
do not yet understand the session saving/loading code employed in this
script, I'm stumped. 


My perl is more than rusty, and I'm far from understanding the minivend
order process, so I'm really looking for help (!!)


Thanks, Mathias

P.S.: A summary of the intended order process:

checkout.html --> vip_request.html
		  (encrypt data)
		  	
vip_request.html   -(order info)->     provider page
		   (via redirect)     (process payment)

vip_response.html <-(payment status)-  provider page 
(route order if ok)    (http GET)	      

vip_response.html -(routing status)->  provider page
 		  (html page content) (end transaction)




from minivend.cfg: 
(see end of file for part named 
#CHANGE BY MATHIASP TO ENABLE ORDER ROUTING)

# [vipresponse]
#
# This tag executes vipclient to decrypt the message from the vipserver
# It extracts OrderID and Status and opens the session that contains the
# users shopping cart.
#
UserTag vipresponse HasEndTag
UserTag vipresponse Interpolate
UserTag vipresponse Routine <<EOF
sub { 
  require Vend::Session;
  require Vend::Order;
  require Vend::Cart;

  my ($input) = @_;
  
  # Split input in rows
  my @rows = split /\n+/, $input;
  my ($left, $right, $path, $message);
  
  # Get path to vipclient and message to decrypt
  for(@rows) {
  	($left, $right) = split /\s*:\s*/, $_, 2;
      if ($left =~ /path/) {      
	     	$path = $right;
      }
      if ($left =~ /message/) {      
      	$message = "message=$right";
      }
  }
 
  # Execute vipclient
  my $vip = `$path command=response $message`;
   
  # Split returnvalue from vipclient 
  my @array = split(' ', $vip);
  my ($tempid, $tempstatus);
  my $len = $#array;
  
  # Get OrderID and Status 
  for (my $i = 0; $i <= $len; $i++) {
    if ($array[$i] =~ /orderID/) {
      my @array2 = split('=', $array[$i]);
      $tempid = $array2[1];
    }
    if ($array[$i] =~ /status/) {
      my @array2 = split('=', $array[$i]);
      $tempstatus = $array2[1];
    } 
  }

  # closing and unlocking of old session
  Vend::Session::open_session();
  Vend::Session::read_session();
  Vend::Session::unlock_session();
  Vend::Session::close_session();
  
  # open file to get complete SessionName
  open(SESSION, "etc/$tempid") or 
  	die "can´t open file etc/$tempid\n";
  my $test = <SESSION>;
  $Vend::SessionName = $test;
  close SESSION;
  
  # delete file
  unlink("etc/$tempid") or 
  	die "can´t unlink file etc/$tempid\n";
  
  
  # Open old Session
  Vend::Session::open_session();
  Vend::Session::read_session();  
  unless($Vend::Session::File_sessions) {
	Vend::Session::lock_session();
	Vend::Session::close_session();
  }

  #Set Scratch-Variables after opening old Session
  $Vend::Session->{'scratch'}->{'status'} = $tempstatus;
  $Vend::Session->{'scratch'}->{'sessionid'} = $Vend::SessionName;
  
  if ($tempstatus = "success") {
  	# You can specify a fully-configurable order report by setting the field ``mv_order_report'' 
  	# to a legal MiniVend page. This page will be interpolated with all MiniVend tags before 
	# sending by email. 
  	# The same page as in <INPUT TYPE="hidden" NAME="mv_order_report" VALUE="../etc/report">
  	# from checkout.html
  	$Vend::Session->{'values'}->{'mv_order_report'} = "../etc/report";

	#########################################################################################
	# CHANGE BY MATHIASP TO ENABLE ORDER ROUTING - NOT WORKING!

	# $Vend::Items gives me an empty order, so how is this?
	my $MyCart = Vend::Cart::get_cart('main');
	
        my ($ok, $order_no); #never used
        ($ok, $order_no) = Vend::Order::route_order(
	"main log copy_user",
	# $Vend::Items
	$MyCart
        );

	# END OF CHANGE FOR ORDER ROUTING
	###########################################################################################

  	# order_report, update_order_number, track_order, send_mail;
  	Vend::Order::mail_order();

  }
  
  # empty Shopping Cart
  @$Vend::Items = ();
  
  return "";
}
EOF
-- 
                            virtual earth
 Mathias Picker
 Geschäftsführer      Gesellschaft für Wissens re/prä sentation mbH

                            Mathias.Picker@virtual-earth.de 
			    Fon +49 89  / 540 7425-1
                            Fax +49 89  / 540 7425-9