On Mon, 12 Aug 2002 21:25:18 +0300, [EMAIL PROTECTED] (Octavian Rasnita) wrote: > >Thank you but I want to learn that. >I want to learn how to work with a commerce partner, how should I write the >shopping cart to be able to communicate with them, etc. >
Most of these online verification systems accept form posts with all the data in form fields defined by them, then they return some post form data to a url you specify. They vary on the field names, required fields, and some idenification stuff, but are generally similar. So the best thing to do is go to the website of the verifier that you want to use, and get their "help guide". It will detail the names of the fields they expect, and most of them have a test server so you can test verification routines. First do it manually, making a html form with the fields, and send it. When you can get good results, and learn how to capture the return results; then try converting it to do the posts with LWP::UserAgent. Below is an example of one for Bank of America. I'm sending the form data to an script on my own machine, respgen.pl which simulates the BOA response, this is for testing offline. It's listing is below. I give a $url to return the results to, called boacc.pl. Now this will work with the BOA test server, just change respgen.pl to the BOA test server address. I would encourage you to make your own offline test setup, that way you will really see what is happening from both the bank's end as well as yours. Go here to get their developer docs, and test a sample transaction. The url may be wordwrapped. http://www.bankofamerica.com/merchantservices/index.cfm?template=merch_ic_estores_settle.cfm By the way, if you want to see this in action, go to http://zentara.net/store and make a phony purchase. You can download the sources for this store if they interest you. ############################################################## print qq( <body text="#000000" bgcolor="9999cc" link="#000000" vlink="#000000" alink="#FF0000"> <p><b><font color="CC3333">The Bank Of America Credit Card Verification results:</font></b $card_no= &z($card_no); my $ua = LWP::UserAgent->new(timeout=>45); my $req = POST 'https://zentara.zentara.net/~zentara/cgi-bin/store/respgen.pl', [IOC_merchant_id => '4301330018817403', IOC_order_total_amount => "$grand_total", IOC_merchant_shopper_id => 'susehost', # IOC_merchant_order_id => "$order_id", IOC_merchant_order_id => "$unique_id", ecom_billto_postal_street_line1 => "$street1", ecom_billto_postal_postalcode => "$zip", ecom_billto_postal_countrycode => "$country", ecom_billto_online_email => "$email", ecom_payment_card_name => "$first $last", ecom_payment_card_number => "$card_no", ecom_payment_card_expdate_month => "$exp_mon", ecom_payment_card_expdate_year => "$exp_yr", url => 'https://192.168.0.1/~zentara/cgi-bin/shop/boacc.pl', ]; my $content = $ua->request($req)->as_string; print 'Please wait while your credit card is verified <br>'; &verifycc(); } ################################################################### respgen.pl ################################################# #!/usr/bin/perl use warnings; use CGI 'cgi'; use LWP::UserAgent; our ($secure_server_address,$cgi_directory); require './store_cfg'; #my $test= 'FALSE'; #set this to simulate a reject my $test= 'TRUE'; # set this for a good acceptance my $relay; my $cgi = new CGI; my %input= $cgi->Vars(); foreach $name (keys %input){ $value = $input{$name}; $relay .= "$name=$value&"; } $relay .= "Ecom_transaction_complete=$test&"; $relay .= "IOC_response_code=0&"; open (RT,">respgen.test"); print RT $relay; close RT; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new (POST => "$secure_server_address$cgi_directory/boacc.pl"); $req->content_type('application/x-www-form-urlencoded'); $req->content("$relay"); my $res = $ua->request($req); print $res->as_string; ############################################################## boacc.pl ----- what I do with the returned data ####################################################3 #!/usr/bin/perl use CGI 'cgi'; use Crypt::RC4; our $ccpassword; require './store_cfg'; $ret = new CGI; %boaresp = $ret -> Vars(); my $data = ''; open(BT,">>boaresp.test"); foreach $name (keys %boaresp){ $value = $boaresp{$name}; print BT "$name = $value\n"; if ($name eq 'ecom_payment_card_number'){$value= &z($value)} $data .= "$name=$value|"; } foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; print BT "${var}=\"${val}\"\n"; } print BT "\n--------------------------------------------------\n"; close BT; open(VERIFY,"+>customers/$boaresp{IOC_merchant_order_id}.v") or die "Can't open RETURN: $!\n"; flock VERIFY, LOCK_EX or warn "Unable to lock for verify: $!"; if (($boaresp{Ecom_transaction_complete} eq 'TRUE')&&($boaresp{IOC_response_code} eq 0)) { print VERIFY "VeRiFiEdByZ$boaresp{IOC_merchant_order_id}|"; }else{ print VERIFY "REJECTED$boaresp{IOC_merchant_order_id}|"; } print VERIFY $data; close VERIFY; exit; sub z{ $in = $_[0]; #$p = pack('C*', (0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef)); $p = $ccpassword; $out = RC4($p,$in); return ($out); } ############################################################# -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]