| Did this page help you? Yes No Tell us about it... |
Amazon provides five samples in five programming languages in the Amazon Simple Pay SDK which show you how to invoke the Amazon FPS actions available with Amazon Simple Pay.
When you download a language-specific SDK, such as ASP-JAVA-2.0, it contains the following five separate samples (in the
FPSApis\src\com\amazonaws\fps\samples folder) showing how to invoke an FPS
API.
|
Class |
Description |
|---|---|
|
|
This class contains the program entry point for invoking a Cancel request. |
GetTransactionStatusSample.java | This class contains the program entry point for invoking a GetTransactionStatus request. |
RefundSample.java | This class contains the program entry point for invoking a Refund request. |
SettleSample.java | This class contains the program entry point for invoking a Settle request. |
VerifySignatureSample.java | This class contains the program entry point for invoking a VerifySignature request. |
These samples depend on the classes in com.amazonaws.fps.model,
com.amazonaws.fps.mock, and com.amazonaws.utils which are
provided in the FPSApis/src folder. These must be in your project
classpath.
In addition to these primary components, a sample may include other required resources. For
example, the Java samples all include numerous jar files in the
FPSApis/src/third-party folder, which must be in your classpath in order to
compile the sample.
This section explains how to use the VerifySignature API only. For
specific comprehensive information on a particular language-specific sample, see its
FPSApis/README.html file.
To use the sample, do the following
Using the VerifySignature Action Sample
| 1 |
Set up your programming environment so that the program will compile without
warnings or errors. For the Java sample, this includes ensuring that the
required folders and .jar files are in the in the java CLASSPATH environment
variable. If you plan to invoke javac from within the com\amazonaws\fps\samples
folder, you will need to include the following as the -cp argument:
|
| 2 |
In the In the same file, if you want to target the sandbox, change the |
| 3 |
In the
VerifySignatureRequest fpsRequest = new VerifySignatureRequest();
// @TODO: set request parameters here
// invokeVerifySignature(service, fpsRequest);
(The |
| 4 |
Remove the comment on
fpsRequest.setUrlEndpoint("http://myApplication/my-ipn-response.pgp");
fpsRequest.setHttpParameters(
"Name1=Value1&" +
"Name2=Value2&" +
"signatureVersion=2&" +
"signatureMethod=HMACSHA256&" +
"certificateUrl=https://fps.amazonaws.com/cert/key.pem&" +
"signature=aoeuAOE123eAUdhf]");
invokeVerifySignature(service, fpsRequest);
For information on the parameters to |
| 5 | Compile the sample. For example, from the linux command line, you would type $javac VerifySignatureSample.javaOn Windows, you would type $javac VerifySignatureSample.java |
| 6 | Run the sample. Continuing the previous example, on linux, you would type $javac VerifySignatureSampleOn Windows, you would type $javac VerifySignatureSample
The program copies to standard out a representation of the VerifySignature Action Response ======================================= VerifySignatureResponse VerifySignatureResult True VerificationStatus Success ResponseMetadata RequestId bda6-4f5f-b37b-1a146b9a-b9e45c3012a5:0 |
In addition to simple invocation, the samples provide you the following advanced options:
The ability to simulate a mock Amazon FPS service, to get responses without a live connection.
Specifying a proxy host and port, through config.properties.
Setting the endpoint, through config.properties
Logging, through log4j.properties