Sending a Purchase to Web-Merchant/WM using Select Pro

This is done as described in Sending a Purchase to Web-Merchant/WM, except that certain parameters are encapsulated in a "purchase token". This is a signed and encrypted string that is submitted to Web-Merchant/WM as the value of the "purchase" parameter. If you use Select Pro then you can be sure that the information received by Web-Merchant/WM has not been tampered with in transit. Similarly Web-Merchant/WM can be sure that the information came from your installation. If your installation is set up to accept Select protocol then any attempt to submit the purchase token parameters in plain text will be rejected by the Web-Merchant/WM server.

Generating a Purchase Token String

You must create an instance of the PurchaseToken class, using the following constructor:

public PurchaseToken(
             long installationID,
             CurrencyAmount amt,
             String cartID) throws ArgumentException, SelectException
"CurrencyAmount" is a class that encapsulates the amount along with its currency. See Handling Currencies . One of the reasons exceptions would be thrown during creation of the purchase token is if the installationID is incorrect or the installation has not yet been initialised. Your installation must be initialised by Web-Merchant/WM before you can work with currencies or the purchase token.

Once you have an instance of the purchase token you call the method "produce". This returns a string representing the contents of the purchase token. It can only be reconstructed into a purchase token by Web-Merchant/WM. This string is used as the value of the "purchase" URL parameter.

You are supplied with an example servlet class called "BuyThis" which demonstrates how to create and use the purchase token. It is supplied in source form with the distribution in the directory java/examples. The source is also included below.

BuyThis Example Servlet

This example uses the Web-Merchant/WMServlet and HTTP protocol libraries to simplify the handling of the request. These Java classes are provided in the select.jar archive. Form input fields are named using the constants provided in the class com.WM.select.SelectDefs.
 

$Revision: 1.6 $