Ever since the first time I heard about the new Amazon FPS service I have been anxious to integrate it into a web application. When I was tasked with creating a few use cases for Bungee Connect Amazon FPS was at the top of my list of services to use.
The tricky part about using FPS is signing each of the requests to the service. Amazon has made it easy for a few languages by providing a library to sign the requests. I decided to do the same for Bungee Connect. I cheated a little and just opened the Java and PHP libraries provided by Amazon and re-created the functionality in Bungee Logic.
For this use case I am using REST, so I made a wrapper around the api. I made a function for each REST call that has an input with all the params you might want and the response returned by the service. Because Bungee is object-based, for each response we take the XML and convert it to a Bungee object. To make handling both the requests and responses easier I imported the WSDL for FPS to automatically create all the types for both the responses and requests. Even though this library uses REST, all the types created during the WSDL import made it much easier to build this library. Normally I would have used SOAP, but Amazon uses WSSE and Bungee doesn’t have a predictable way for me to use the body in signing the request. However, the feature has been added to the roadmap and will be available in future releases.
While the WSDL had most of the types I needed, I had to add a couple to work with the Co-Branded UI Pipeline. To authenticate users, the app must send them to Amazon.com to sign in and authorize the app to charge them. Amazon calls this process the FPS Co-Branded UI Pipeline. Depending on the type of financial arrangement (prepaid, postpaid, etc.) you have to construct the request differently, so I added a type for the prepaid and postpaid requests and the subsequent responses. I also added a function for each to construct the URL to redirect customers to for the prepaid and postpaid pipelines. Note: I’ll be adding functions to create urls for multi-use and single-use pipelines in future versions.
Now that I have the library done, my use case will be much easier to build. I plan to release an early version very soon.
Hopefully this will make it easier for you to use FPS as well. If you want to use this library just import it from the “Example code” area on the home tab. Read the notes on the fpsApi class for a few steps to set it up. Let me know if you have any comments or questions.
If you would like to try this library, but don’t have a Bungee Connect account sign up here.