Passing arguments in Java

Hello, I’m in the process of implementing Verisign’s PayFlowPro. I got the PFProJava class directly from verisign and am trying to operate it into the Notes Agent environment. I am, however, having problems passing arguments.

My problem comes in the last line of code before the catch(Exception e) { line at the bottom where I am trying to do the following:

PFProJava pfProResult = new PFProJava(

			hostAddress,

			hostPort,

			parmList,

			timeOut,

			proxyAddress,

			proxyPort,

			proxyLogon,

			proxyPassword);

The compiler tells me that I do not have the correct number of arguments!

Help! I don’t understand. Here’s the entire listing of the code:

import lotus.domino.*;

import java.io.PrintWriter;

import com.Verisign.payment.PFProAPI;

import java.security.GeneralSecurityException;

import java.security.KeyPair;

import java.security.KeyPairGenerator;

import java.security.NoSuchAlgorithmException;

import java.security.PrivateKey;

import java.security.PublicKey;

import java.security.cert.X509Certificate;

import java.security.interfaces.RSAKey;

import java.util.Vector;

import java.io.*;

import java.security.*;

// I had to download these .java files from sun. However, they imported with absolutely no problems.

import javax.crypto.*;

import javax.crypto.spec.*;// Verisign, Inc.

// Verisign Payflow Pro Java Client

import com.Verisign.payment.PFProAPI;

public class JavaAgent extends AgentBase {

// http://www.verisign.com

// See contact.txt for additional contact information

class PFProJava {

// Set defaults

String HostAddress   = "test-payflow.verisign.com";

Integer HostPort = Integer.decode("443");

String ParmList      = "";

Integer Timeout = Integer.decode("30");

String ProxyAddress  = "";

Integer ProxyPort = Integer.decode("0");

String ProxyLogon    = "";

String ProxyPassword = "";



// Help system

void help()

{

	System.out.println( "Usage Error: \n" );



	System.out.println("pfpro <hostAddress> <hostPort> <parmList> <timeout> <proxyAddress> <proxyPort> <proxyLogon> <proxyPassword>");

	System.out.println("<hostAddress>   host name                   'test-payflow.verisign.com'");

	System.out.println("<hostPort>      host port number            '443'");

	System.out.println("<parmList>      parameter list              'ccNum=5105105105105105100&ccExpDate=1299&amount=1.23'");

	System.out.println("<timeOut>       timeout(sec) - optional     '30'");

	System.out.println("<proxyAddress>  proxy name - optional       'proxy'");

	System.out.println("<proxyPort>     proxy port - optional       '8080'");

	System.out.println("<proxyLogon>    proxy logon name - optional 'admin'");

	System.out.println("<proxyPassword> proxy password - optional   'password'");

}



public void main(String[] args)

{

	PFProAPI pn = new PFProAPI();



	// Check args, at least the first 3 must be there

	if (args.length < 3) {

		System.out.println( "\nPFPRO " + pn.Version() );



		try {

			if ( args[0].equalsIgnoreCase(new String("-version")) ) {

				System.out.println();

				return;

			}

		} catch (Exception e) { }



		help();

		return;

	}



	// Place the arguments in the correct variables

	// Once we get an OutOfBounds exception, parsing will stop and the rest will

	// retain their default values.

	try {

		HostAddress   = args[0];

		HostPort	  = Integer.decode(args[1]);

		ParmList      = args[2];

		Timeout		  = Integer.decode(args[3]);

		ProxyAddress  = args[4];

		ProxyPort	  = Integer.decode(args[5]);

		ProxyLogon    = args[6];

		ProxyPassword = args[7];

	} catch (Exception e) { }



    // Set the certificate path

    pn.SetCertPath("certs");



	// Call the client.

	pn.CreateContext(HostAddress,

                     HostPort.intValue(),

                     Timeout.intValue(),

                     ProxyAddress,

                     ProxyPort.intValue(),

                     ProxyLogon,

                     ProxyPassword);



	String rc = pn.SubmitTransaction(ParmList);



	System.out.println(rc);



	pn.DestroyContext();

}

}

public void NotesMain() {

	

	try {

		Session session = getSession();

		AgentContext agentContext = session.getAgentContext();

		Database db = agentContext.getCurrentDatabase();

		Document doc = agentContext.getDocumentContext();

		Document dbProfile = db.getProfileDocument("fmDbProfile", "");



		//First we get what we need from the dbProfile...

		String hostAddress = dbProfile.getItemValueString("HostAddress");

		String hostPort = dbProfile.getItemValueString("HostPort");

		String timeOut = dbProfile.getItemValueString("TimeOut");

		String proxyAddress = dbProfile.getItemValueString("ProxyAddress");

		String proxyPort = dbProfile.getItemValueString("ProxyPort");

		String proxyLogon = dbProfile.getItemValueString("ProxyLogon");

		String proxyPassword = dbProfile.getItemValueString("ProxyPassword");





		 // This comes from documentContext

		System.out.println("<parmList>      parameter list              'ccNum=5105105105105105100&ccExpDate=1299&amount=1.23'");

		String ccNum = doc.getItemValueString("ccNum");

		String ccExpDate = doc.getItemValueString("ccExpDate");

		String amount = doc.getItemValueString("amount");

		// Alright, let's build parmList

		String parmList = "'ccNum=" + ccNum + "&ccExpDate=" + ccExpDate + "&amount=" + amount + "'";

		//'ccNum=5105105105105105100&ccExpDate=1299&amount=1.23'

		





		PFProJava pfProResult = new PFProJava(

			hostAddress,

			hostPort,

			parmList,

			timeOut,

			proxyAddress,

			proxyPort,

			proxyLogon,

			proxyPassword);

		

		} 

	catch(Exception e) {

		e.printStackTrace();

	}

}

}