Topics
This appendix provides an overview of the Amazon Flexible Payments Service development libraries provided by Amazon. The sample code shows you how to implement most of the basic Amazon FPS functions. Packaged in four programming languages (C#, Java, Perl, and PHP), the development libraries are available from the Amazon Web Services developer community, under the Amazon Flexible Payments Service category. Refer to the following table for specific sample packages.
Each package is updated for signature version 2, and contains both a development library and a collection of sample implementations of the Amazon FPS APIs. The development libraries enable you to
Use the Co-Branded User Interface to create CBUI pipeline URLs
Invoke any of the Amazon FPS APIs documented in this quick start
Generating signatures compliant with signature version 2
Validate the content of return URL responses and IPN notifications
The following sections describe the code libraries in more detail, with an eye towards enabling you to build your applications quickly. If you want help building your first sample application using the development libraries, see "Making a Pay Request" in the Amazon Flexible Payments Service Getting Started Guide
Amazon provides five samples in four programming languages (C#, Java, Perl, and PHP) which show you how to build Co-Branded User Interface request URLs.
When you download a sample file, such as amazon-fps-2008-09-17-java-library, the folder contains sample classes showing how to generate pipeline-specific CBUI URLs from your code ([package root]/src/com/amazonaws/cbui/samples is the location you extracted your sample package).[package root]
Each sample describes its requirements in its Readme.html file, located at the package root. Typically, the entire library structure must be available to the compiler. For example, the amazon-fps-2008-09-17-php-library.zip file contains the src/Amazon/CBUI and folders which the files in src/Amazon/CBUI/Samples require.
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 folder, which must also be in your classpath in order to compile the sample.[package-root]/third-party
For each sample, you must set your security credentials and Amazon FPS sandbox endpoints in a library-dependant way. For example, to use the C# library, you set your security credentials in the file, while for the perl library you set them in the individual [package-root]/src/Amazon.FPS.Samples/Amazon.FPS.Samples/AmazonFPSSamples.cs file you are working with. [package-root]/src/Amazon/CBUI/Samples/*.pl
The following samples are provided with each sample library:
|
Class |
Description |
|---|---|
|
|
Requests authorization for a one-time payment. |
CBUIMulitUsePipeline Sample
| Requests authorization for multiple payments. |
CBUIRecipientPipeline Sample
| Requests authorization for a recipient token pipeline, such as that needed for marketplace fixed and variable fees. |
CBUIRecurringTokenPipeline Sample
| Requests authorization for a recurring token pipeline, such as that needed for periodic charges. |
|
|
Requests authorization for an edit-token pipeline. |
In the following section, we show how to work with the CBUISingleUsePipeline sample using the Java library. This sample enables you to set up a single-use token for a one-time payment. You will find that the basic process you use for the CBUISingleUsePipeline sample is the same for all the other samples in the CBUI/Samples (or, in the case of Amazon.CBUI.Samples) folder. (The process for the FPS and Return URL/IPN Validations samples are different. For more information, see Understanding the Amazon FPS Samples.)
This section describes the Java version of the CBUISingleUsePipeline. The files for the C#, Perl, and PHP CBUISingleUsePipeline samples are listed in Locations of the CBUISingleUsePipeline Files in Other Libraries
The CBUISingleUsePipeline sample centers on the following files:
|
File |
Description |
|---|---|
|
|
Set your AWS access key ID, AWS secret key, and sandbox endpoint in this file. |
CBUISingleUsePipelineSample.java | In the main method, you create an AmazonFPSSingleUsePipeline object and use it to add parameters specific to your application. |
AmazonFPSSingleUsePipeline.java | Invoked from CBUISingleUsePipelineSample.java, this class contains the setMandatoryParameters and validateParameters functions which you can customize for your application. |
Co-Branded service request with Java SDK Sample
|
1 |
Open the file |
|
2 |
In the same file, set the |
|
3 |
In the same file, set the |
|
4 |
Open the file AmazonFPSSingleUsePipeline pipeline= new AmazonFPSSingleUsePipeline(accessKey, secretKey); Change the //pipeline name, your return URL, and the amount
pipeline.setMandatoryParameters("callerReferenceSingleUse",
"
Save the file. |
|
5 |
Ensure that all the jar files in the |
|
6 |
Compile and run the sample. The Co-branded authorization page is printed to standard out. |
|
7 |
Using a web browser, navigate to the URL produced by the sample. You must use an account different from your AWS developer or business accounts. |
|
8 |
When complete, the page you specified as |
You can customize the sample by modifying the file . The [package-root]/src/com/amazonaws/cbui/AmazonFPSSingleUsePipeline.javasetMandatoryParameters only requires callerReference, returnUrl, and transactionAmount. If you want to make more parameters mandatory, modify this method.
In the same file, the validateParameters function ensures that the transactionAmount parameter is present. You can add custom validation checks to this method.
The development libraries for C#, Perl, and PHP also enable you to create CBUI pipeline urls. The following tables indicate the locations of the files referenced in Understanding the Amazon CBUI Samples.
C# File Locations for the Amazon.FPS CBUI Sample
|
File |
Location | |||
|---|---|---|---|---|
|
|
| |||
AmazonFPSSingleUsePipeline.cs | | |||
Amazon.CBUI.proj
(Visual Studio.NET solution for the development library) | | |||
|
(Visual Studio.NET solution for the Amazon FPS API samples) | | |||
Amazon.FPS.sln
Visual Studio.NET solution for the library package
| |
Perl File Locations for the Amazon.FPS VerifySignature Sample
|
Class |
Location |
|---|---|
|
|
|
AmazonFPSSingleUsePipeline.pm | |
ReadMe.html (readme for perl fps library) | |
PHP File Locations for the Amazon.FPS VerifySignature Sample
|
Class |
Location |
|---|---|
|
|
|
CBUISingleUsePipeline.php | |
ReadMe.html (readme for php fps library) | |