#!/usr/local/bin/perl use strict; use ICS qw( ics_send ics_print ); $ENV{ICSPATH} = '/usr/local/cybersource_keys'; my %inpairs = (); $inpairs{currency} = "USD"; my $indata = ''; while (<>) { $indata .= $_; chomp; my ($key,$value) = split('=',$_,2); $inpairs{$key} = $value; } my @errors; my @required_fields = qw/customer_firstname customer_lastname customer_email customer_phone bill_address1 bill_city bill_state bill_zip bill_country customer_cc_number customer_cc_expmo customer_cc_expyr merchant_ref_number currency amount/; foreach my $field (@required_fields) { if ( ! $inpairs{$field} ) { push( @errors, $field . ' cannot be null'); } } my $merchant_id = $inpairs{'merchant_id'}; if (not defined $merchant_id) { print "errormsg=merchant_id cannot be null\n"; print "\nerrormsg=$indata\n"; exit(1); } elsif ( @errors ) { foreach my $error (@errors) { print "errormsg=" . $error . "\n"; } exit(1); } my %ics_req; # optional HTTP proxy support # $ics_req{http_proxy} = "http://myproxy:8000/"; # set these to use basic http proxy authentication # $ics_req{http_proxy_username} = "proxyusername"; # $ics_req{http_proxy_password} = "proxypassword"; # ICS Server fields $ics_req{server_host} = "ics2.ic3.com"; #$ics_req{server_host} = "ics2test.ic3.com"; $ics_req{server_port} = "80"; # generic ics fields #$ics_req{ics_applications} = "ics_score,ics_auth,ics_bill"; $ics_req{ics_applications} = "ics_auth,ics_bill"; $ics_req{merchant_id} = $merchant_id; # required ics_score fields $ics_req{customer_firstname} = $inpairs{customer_firstname}; $ics_req{customer_lastname} = $inpairs{customer_lastname}; $ics_req{customer_email} = $inpairs{customer_email}; $ics_req{customer_phone} = $inpairs{customer_phone}; $ics_req{bill_address1} = $inpairs{bill_address1}; $ics_req{bill_address2} = $inpairs{bill_address2}; $ics_req{bill_city} = $inpairs{bill_city}; $ics_req{bill_state} = $inpairs{bill_state}; $ics_req{bill_zip} = $inpairs{bill_zip}; $ics_req{bill_country} = $inpairs{bill_country}; $ics_req{customer_cc_number} = $inpairs{customer_cc_number}; $ics_req{customer_cc_expmo} = $inpairs{customer_cc_expmo}; $ics_req{customer_cc_expyr} = $inpairs{customer_cc_expyr}; $ics_req{merchant_ref_number} = $inpairs{merchant_ref_number}; $ics_req{currency} = $inpairs{currency}; # required offer fields #$ics_req{"offer0"} = #"offerid:0^product_name:widgets^merchant_product_sku:billco2000^product_code:electronic_software^amount:1.00^quantity:1"; $ics_req{"offer0"} = "offerid:0^amount:" . $inpairs{'amount'} . "^quantity:1"; #print "---- test request --------------------------\n"; #&ics_print(%ics_req); #print "--------------------------------------------\n"; # send request print "sending request...\n"; my %ics_res = ics_send(%ics_req); print "---- test result ---------------------------\n"; &ics_print(%ics_res); print "--------------------------------------------\n"; if ( $ics_res{ics_rcode} == -1 ) { exit(-1); } else { exit(0); }