Amazon Simple Pay
Advanced User Guide (API Version 2010-08-28)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Understanding the VerifySignature Sample

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

CancelSample.java

This class contains the program entry point for invoking a Cancel request.

GetTransactionStatusSample.javaThis class contains the program entry point for invoking a GetTransactionStatus request.
RefundSample.javaThis class contains the program entry point for invoking a Refund request.
SettleSample.javaThis class contains the program entry point for invoking a Settle request.
VerifySignatureSample.javaThis 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: .;..\model; ..\mock; ..\..\utils; ..\..\fps; ..\..\..\..\..\src; ..\..\..\..\..\third-party\commons-codec-1.3\commons-codec-1.3.jar; ..\..\..\..\..\third-party\commons-httpclient-3.0.1\commons-httpclient-3.0.1.jar; ..\..\..\..\..\third-party\commons-logging-1.1\commons-logging-1.1.jar; .

2

In the FPSApis/src/config.properties file, set the values for AwsAccessKey and AwsSecretKey using your security credentials. To get your credentials, see Using Access Identifiers.

In the same file, if you want to target the sandbox, change the AwsServiceEndPoint property to https://payments-sandbox.amazon.com.

3

In the FPSApis/src/com/amazonaws/fps/samples/VerifySignature.java file, find the section containing the lines:

VerifySignatureRequest fpsRequest = new VerifySignatureRequest();
                     // @TODO: set request parameters here
                     // invokeVerifySignature(service, fpsRequest);
                  

(The VerifySignatureRequest, VerifySignatureResult, and VerifySignatureResponse classes are located in FPSApis/src/com/amazonaws/fps/model folder.)

4

Remove the comment on invokeVerifySignature, and add the VerifySignature parameter assignments. For example:

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 VerifySignature, see VerifySignature.

5

Compile the sample. For example, from the linux command line, you would type

$javac VerifySignatureSample.java

On Windows, you would type

$javac VerifySignatureSample.java
6

Run the sample. Continuing the previous example, on linux, you would type

$javac VerifySignatureSample

On Windows, you would type

$javac VerifySignatureSample

The program copies to standard out a representation of the VerifySigatureResponse XML fragment similar to the following:

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