Plugins You can find out about all the publicly available Grails plugins.

Amazon Flexible Payments

  • Tags: ecommerce, amazon
  • Latest: 0.2.4
  • Last Updated: 31 May 2009
  • Grails version: 1.1 > *
  • Authors: null
0 vote
compile "org.grails.plugins:amazonfps:0.2.4"




grails install-plugin amazonfps


Amazon FPS Plugin

This plugins allows developers to accept payments using Amazon FPS.


With Amazon FPS, developers can accept payments on their website for selling goods or services, raise donations, execute recurring payments, and send payments.

Amazon FPS offers developers unmatched flexibility in how they can structure payment instructions, including standing instructions that can remain in place for multiple transactions. These instructions impose conditions and constraints on money movements and can be set by both senders and receivers of funds. For example, a sender might set a spending limit per week for a particular named recipient. Only that named recipient would be able to withdraw funds and only up to an amount per week equal to the spending limit.

For More Information

The most favorite features are MicroTransactions, Refunds,Cancellations, MultiUse Payments all from your website.">

Grails plugin is built on top of Amazon FPS Java library based on API Version 2008-09-17. The Amazon FPS Advanced Quick Start Guide is an excellent document


To use AmazonFPS Plugin, there is a sign up needed with, which is very simple, and you need to obtain the AccessKey and SecretKey

SandBox Testing

Amazon has excellent support for SandBox Testing. Configuration settings below has the Url settings set for the Sandbox. Just remember, In Sandbox mode, the monthly limit is $24K, so for all your testings, use micro transactions in the mound of $0.10 cents, and you will never run out of Quota.

Domain Design

This plugin is based on two domain classes AznOrders and AznTransactions. Every time a users registers for a payment may be SingleUse Payment or MultiUse payment he creates an Order. An Order has all the description of the order common for all transactions, and all the attributes are specific to what amazon wants.

An Order can have many Transactions. For e.g When users pays for the service a Pay transaction is Created. When the user is refunded for the amount, one more transaction is created. For Multiuse, when everytime a user is charged, a transaction is created. Amount is always associated with the transaction

Two main fields to remember are

  • callerReference this is the unique reference passed to the Amazon to identify the particular transaction/order. Amazon returns this reference back to locate the order/transaction in the database
  • TransactionId : represents the unique transaction Id for each transaction

How A Simple Payment Works

The plugin introduces a Sample AznOrdersController and AznTransactions Controller to demonstrate all type of activties that can be done.

E.g To accept a OneTime payment from User

  1. User enters the information on the input form where user inputs the Amount,Order Id,Description
  2. The AznOrdersController creates a AznOrder Object and a AznTransaction Object (Transaction instance is needed Since we are also going to charge the user right away).
  3. AznOrdersController creates CoBranded Url and redirects user to Amazon Website to enter and approve the payment
  4. Amazon gives a callback to CallBack action specified
  5. CallBack response is processed and a payrequest is initiated
  6. Keep checking the status, still the Transaction status is Success/Failure. Once the status is obtained, user is passed to the Success/Failure Page


Following are the Changes needed in config.groovy
//AWS Pay
    //Mandatory values
    fps_accessKey=’YOUR FPS ACCESS KEY
    fps_secretKey=’YOUR FPS SECRET KEY’
    //Allows you to specify a co-branding URL dynamically. It specifies the URL of your company's logo.Constraint: This URL should point to a co-branding imagethat is not larger than 215 (w) x 40 (h) pixels in a secure HTTP server.
//  cobrandingUrl=
    //website description to appear on website
    websiteDescription = "SAMPLE WEBSITE DESCRIPTION"


The following artefacts will be added:
  • Groovy Source
    • AmazonPaymentsException : This class handles all the Exceptions received from Amazon FPS
  • Controllers
    • AznOrdersController : Test Controller to demonstrated SingleUse and MultiUse Payments.
    • AznFpsTransactionsController : Test Controller to demonstrate the operations on a Transactions like, Refund, Recharge, Resync
  • Domain: Check the #Domain Design Section for more details.
    • AznOrders : Represents the Order
    • AznFpsTransactions : Represents a transaction within a Order(PAY, REFUND, CANCEL).
  • Services
    • AmazonPaymentsService
  • Taglib
    • None
  • Integration Tests
    • TBD


If you already have a Order Domain, where you are processing Orders, either you can extend the AznOrder class or define a reference to it.

Further Examples

For further examples please have a look at the source code in
  • $PLUGIN_DIR/amazonfps-$VERSION/grails-app/controllers/com/harvest/plugins/amazonfps/AznOrdersController.groovy
  • PLUGIN_DIR/amazonfpst-$VERSION/grails-app/views/AznOrders/list
  • Source Code is also available on github at

Revision History

  • June 01 2009 : 0.2.4 : Initial Version