Tuesday, February 28, 2006

Interfacing the Camtech Server (part 2)

Interfacing the Camtech Server(part 2)
Next step is to use the camtech server from your application. We have now tested the existing Example code and know that it connects to the gateway using the generated private key and the imported certificate. Three steps to use this code from your application.

1. Copy the Example.java (see part 1) to your application.
2. Copy the needed jars (activation.jar, iaik_jce.jar, mail.jar, MerchantServer.jar) from .\MerchantServer\jars to your application. Set classpath if necessary and compile.
3. Copy the jars mentioned in step 2 to the J2EE container. In tomcat that is to the %CATALINA_HOME%\common\lib folder.
4. Set the system property "install.root" in the container. This can be done using command prompt:
SET JAVA_OPTS=-Dinstall.root=E:\Tools\MerchantServer
before running the startup script. More info found here and also check out A tomcat Service Manager for Windows

The tomcat service manager makes it easy to manage tomcat. I recommend to install this to avoid setting up temporarily properties and to get a good overview of the tomcat management.




5. Deploy your .war file to tomcat and test to run the Example code. Check the standard output, should have something like:

----------------------------------------------
The results of the transaction are as follows:
Summary Code: 0
Response Code: 00
Response Text: Approved
RRN: r9bTp96
Authorisation ID Response: DZ0
XID: 2187481
Settlement Date: 0301

--------------------------------------

Problems
If you get this exeption:
Exception: The merchant's private key could not be found"

Common reasons: the merchant id and password combination not being correct. If you are not sure of these values, then please delete and recreate this account, and request another certificate. This response is also generated if the keys or certificate have been corrupted. This scenario will also require you to delete and recreate this account, and request another certificate.

Please note that you will also receive this response if the -Dinstall.root property has not been set correctly when running your code. Please make sure that this property has been included within your Tomcat start up script. i.e. (step 4)

Thursday, February 23, 2006

Camtech Server Install and test (part1)

Just installed Camtech's Server which handles secure payments services via the Web. I knew that this will not be the only time installing and configuring the server so I wrote a quick manual to do the setup and test it in one go without going through the documentation (not that the documenation is bad in any way, it is very neat).

Installation

Downloaded the Version 6.2.0 of the Camtech Merchant Server

FTP site: 203.22.215.195
Login: channel
Password: CamtKeyCorp

http://www.camtech.com.au/Support/SoftwareandHardware.htm


Execute installer:

E:\Software\V6\620\Windows\MerchantServerInstaller620b2

And installed it under (for example):

E:\Tools\MerchantServer

Configure the MerchantServer….execute batch file

E:\Tools\MerchantServer\bin\ ConfigurationTool

IP Address: Whatever address you get when running “ipconfig” command. e.g.

SMTP mail host:

Outgoing mail server

Administrator Email Address

The email address where the certificate will be sent to.

Generate Keys will generate the keypair

Request Certificate will send the certificate to the Administrator mail address

Import Certificate is used to import the emailed certificate to the MerchantServer, don’t forget to Apply.

Don’t worry about the Gateways tab unless you bump into problems later on.

For testing

Set classpath so it can compile the Example.java file:


Update the Example.java

I had to do 3 things:

1. Change the path to the “merchantserver.config” file

2. Change the MERCANT_ID and the PASSWORD to the configured ones.

private static final String CONFIG_FILE =

"../merchantserver.config";

……

/*

* The Merchant's details, as configured in the Camtech E-Commerce Configuration

* Tool.

*/

private static final String MERCHANT_ID = "mytestID";

private static final String PASSWORD = "pass123";

Set the classpath, make sure to have the MerchantServer.jar, iaik_jce.jar, activation.jar as well as the Example java folder in the classpath.

Compile Example.java

Run a test (need to set System property “root.install” to the root directory where the Merchant is installed)


Voila...my server connected to the Payment Gateway and approved my creditcard :)

/Chris

Wednesday, February 22, 2006

Inaugural Sydney Spring User Group Meeting

I went to the first Spring User Group Meeting here in Sydney. It turned out to be very popular and it was full house.

Rod Johnson was there and talked about the goal of POJO development, Dependency Injection (a form of Inversion of Control), AOP (Aspect Oriented programming) and portable, lightweight abstractions for core services. He also talked about the new features in Spring 2.0 and beyond.

One thing that Rod emphazised was the fact that configuration was often made very differently, even in the same projects and how much easier it would be if configuration was done in one agreed way from start. He did also talked about testing and how Spring let you make push objects instead of pull objects and thereby make it much easier to test and showed some examples. It was all very interesting and I am looking forward to next meeting in April.

/Chris

MySQL user privileges

See this link for full description
http://mysqld.active-venture.com/Adding_users.html

Then you can add new users by issuing GRANT statements:

mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO admin@localhost;
mysql> GRANT USAGE ON *.* TO dummy@localhost;

Monday, February 20, 2006

Some MySQL stuff

Here is an overview of useful MySQL commands

Here is a full description of how to add a new MySQL user.

Delete a row from a table
Delete a row(s) from a table.
DELETE from [table name] where [field name] = 'whatever';

Add a MySQL user

mysql> use mysql;
Database changed

mysql> INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', 'chris', PASSWORD('password'), 'Y', 'Y', 'Y');
Query OK, 1 row affected (0.20 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0.01 sec)

Saturday, February 18, 2006

Hibernate mapping using xDoclet

Hibernate mapping using xDoclet

Matt Raible gives nice examples of how to do the many-to-many, one-to-many and many-to-one mappings using xDoclet.

Thomas Gaudin has written a tutorials for Hibernate mapping with xDoclet

I have not been practicing hibernate and ORM for a very long time, but it has definetly changed alot in terms of writing amount of code. I also recommend the book "Hibernate in Action" (read book review) written by Christian Bauer and Gaving King.

/Chris