webpay.client
Class Webpay

java.lang.Object
  |
  +--webpay.client.Webpay

public class Webpay
extends java.lang.Object

This object provides methods to perform transactions with the Webpay gateway array, or a specified gateway array. Transactions are implemented securely using SSL and a supplied digital certificate.


Constructor Summary
Webpay(java.lang.String clientID, java.lang.String certificatePath, java.lang.String certificatePassphrase)
          Constructor for the Webpay object.
Webpay(java.lang.String clientID, java.lang.String certificatePath, java.lang.String storeFormat, java.lang.String certificatePassphrase)
           
 
Method Summary
 void completeTransaction()
          This method is used to complete a transaction request that is currently in progress and has been initialised using the initTransaction method.
 void execute()
          This method has the same effect as calls to initTransaction() and completeTransaction.
 java.lang.String get(java.lang.String name)
          Returns a value from the response bundle.
 webpay.net.TransactionBundle getBundle()
          Returns the TransactionBundle from the Webpay client object
 java.lang.String[] getResponseNames()
          Returns a String array of the names for values in the response bundle.
 java.lang.String initTransaction()
          Initialises a transaction against the Webpay Transaction Servers.
 void put(java.lang.String name, java.lang.String value)
          Put a value the internal data bundle for transmission.
 void setDebugLevel(int level)
          Sets tho amount of logging to enable within the webpay object.
 void setPort(int port)
          Sets and overrides the default Webpay server port.
 void setPort(java.lang.String port)
          Sets and overrides the default Webpay server port.
 void setServers(java.lang.String[] servers)
          Sets and overrides the default Webpay server array.
 java.lang.String toString()
          Outputs the Transaction Bundle in the form of value pairs separated by a newline (crlf).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Webpay

public Webpay(java.lang.String clientID,
              java.lang.String certificatePath,
              java.lang.String certificatePassphrase)
       throws java.lang.Exception
Constructor for the Webpay object. Throws one of many exceptions relating to the SSL certificate or file system.
Parameters:
clientID - The client identification number.
certificatePath - The location on disk of the clients digital certificate.
certificatePassphrase - The passphrase for the digital certificate.
Throws:
java.lang.Exception - Throws an Exception if the object could not be set up correctly.

Webpay

public Webpay(java.lang.String clientID,
              java.lang.String certificatePath,
              java.lang.String storeFormat,
              java.lang.String certificatePassphrase)
       throws java.lang.Exception
Method Detail

execute

public void execute()
             throws java.io.IOException
                    java.net.ConnectException
This method has the same effect as calls to initTransaction() and completeTransaction. The get() method must be used to obtain the results of the transaction after this method returns. Protocol Flow is as follows:

		|              			|
 1 	| ------------------>	|
  	|              			|
 2 	| <------------------	|
  	|             			|
 3 	| ------------------>	|
  	|              			|
 4 	| <------------------	|
  	|              			|

 
1. Send FULL request. 2. Recieve Transaction Reference. 3. Send Transaction Reference back to server. 4. Receive FULL response. If you do not receive a response(4) then you can do a status transaction against the server, to get the transaction status.
Throws:
java.io.IOException - if a communications error occurs
java.net.ConnectException - if a connection exception occurs

initTransaction

public java.lang.String initTransaction()
                                 throws java.io.IOException
                                        java.net.ConnectException
Initialises a transaction against the Webpay Transaction Servers. This method must be used in conjunction with completeTransaction. These methods are useful for logging transaction status mid way through the transaction.
Returns:
String containing the transaction reference.
Throws:
java.io.IOException - when a communications error occurs with the engine. It is safe to assume that the transaction has not been processed.
java.io.ConnectException - when a communications error occurs with the engine. It is safe to assume that the transaction has not been processed.

completeTransaction

public void completeTransaction()
                         throws java.io.IOException
This method is used to complete a transaction request that is currently in progress and has been initialised using the initTransaction method. If this method fails or throws an exception, it must be logged, and a status transaction should be performed to check the outcome. It must be assumed that the transaction was processed until it is confirmed otherwise.
Throws:
java.io.IOException - on a communications error

toString

public java.lang.String toString()
Outputs the Transaction Bundle in the form of value pairs separated by a newline (crlf).
Overrides:
toString in class java.lang.Object
Returns:
String containing the contents of the TransactionBundle

getBundle

public webpay.net.TransactionBundle getBundle()
Returns the TransactionBundle from the Webpay client object
Returns:
TransactionBundle

put

public void put(java.lang.String name,
                java.lang.String value)
Put a value the internal data bundle for transmission. This bundle will be sent on a call to doTransaction(). This method can be used to replace the parametized transaction implementations. Transactions can be implemented with Name / Value combinations published by Webpay. Matching sets of values also exist for the response data. see get().
Parameters:
name - The name of the value to be set
value - The transaction value to be set e.g. Credit card number

get

public java.lang.String get(java.lang.String name)
Returns a value from the response bundle.
Parameters:
name - The name of the value to be extracted from the response bundle
Returns:
The requested string value. May return null if the value has not been set

getResponseNames

public java.lang.String[] getResponseNames()
Returns a String array of the names for values in the response bundle. This allows you to determine all the values which have been returned by the gateway for the last transaction. If no values are available or no transaction has occured, a String array of length zero is returned.
Returns:
An String array containing the names of the values that are available within the object.

setServers

public void setServers(java.lang.String[] servers)
Sets and overrides the default Webpay server array. This method should only be used if transactions are to be passed through a gateway other than the standard Webpay server array. This method should be called before any transaction attempts are made and should not be reset once transactions have begun through this instance of a Webpay object.
Parameters:
servers - A String array of domain names and/ or IP addresses.

setPort

public void setPort(java.lang.String port)
Sets and overrides the default Webpay server port. This method should be called before any transaction attempts are made and should not be reset once transactions have begun through this instance of a Webpay object.
Parameters:
port - port - the TCP port number to connect to

setPort

public void setPort(int port)
Sets and overrides the default Webpay server port. This method should be called before any transaction attempts are made and should not be reset once transactions have begun through this instance of a Webpay object.
Parameters:
port - the IP port number of the webpay servers to connect to.

setDebugLevel

public void setDebugLevel(int level)
Sets tho amount of logging to enable within the webpay object.
Parameters:
level - int specifiying the amount of debugging. 0 = off, 1 = lowest, 3 = highest.