| Did this page help you? Yes No Tell us about it... |
Amazon provides four sample-specific buttons in five programming languages which show you how to create a specific button programmatically. In this section, we will briefly go over the essential details for the standard button, Java version only. The other samples differ only in the parameters that comprise them, and the programming language used for rendering them. For specific comprehensive information on a particular sample, see its ButtonGenerationWithSignature/README.html file.
For information on which parameters are specific to which buttons, please see Amazon Simple Pay Button Input Reference.
When you download a sample file, such as ASPStandard-JAVA-2.0, it contains three separate samples. This section describes the sample contained in the ButtonGenerationWithSignature folder.
Each button generator sample contains three primary components in the ASPStandard-JAVA-2.0/ButtonGenerationWithSignature/src folder. For the standard button, these are:
|
Class |
Description |
|---|---|
|
|
This class contains the program entry point. It sets up initial parameter values for the standard button, and then calls the static method |
ButtonGenerator.java | Invoked from StandardButton.java, this class generates the HTML form, by assembling the parameter values provided to the GenerateForm method. It adds other parameters required by the form, such as signatureMethod and signingVersion. In addition, it obtains a well-formed signature version 2 signature from the SignatureUtils.java class. |
SignatureUtils.java | Invoked from ButtonGenerator.java, this class uses the signature version 2 process to create the string to sign and calculate the button-specific signature. It contains static methods to compile the string to sign, URL encode the string, and sign it. |
In addition to these primary components, a sample may include other required resources. For example, the Java samples all include the lib/commons-codec/jars/commons-codec-1.3.jar file, which must be in your classpath in order to compile the sample.
To use the sample, do the following
Using the Standard Button Generator Sample
| 1 |
Set up your programming environment so that the program compiles without warnings or errors. For the Java sample, this includes ensuring that the | |||
| 2 |
The Set the
| |||
| 3 | Compile the sample. For example, if you are including the $javac -cp .:lib/commons-codec/jars/commons-codec-1.3.jar StandardButtonSample.java SignatureUtils.java StandardButtonSample.javaOn Windows, you would type $javac -cp .;lib/commons-codec/jars/commons-codec-1.3.jar StandardButtonSample.java SignatureUtils.java StandardButtonSample.java | |||
| 4 | Run the sample. Continuing the previous example, on linux, you would type $javac -cp .:lib/commons-codec/jars/commons-codec-1.3.jar StandardButtonSampleOn Windows, you would type $javac -cp .;lib/commons-codec/jars/commons-codec-1.3.jar StandardButtonSample
The complete signed button is printed to standard out. | |||
| 5 |
When you are satisfied with the way the button works, you can change the |