In a recent project, I got a requirement to integrate a Payment gateway. I choose Stripe as it is PCI Level 1 complaint which is the most stringent level of all 4.

Following are the steps to integrate stripe in Grails.

  1. Create an Account on Stripe.
  2. Goto Account settings and click “Api Keys” tab.
  3. Stripe provides a publishable key and a private key. Publishable key is used by the java-script code to
    generate tokens and secret key is used for API calls on the server-side.
  4. Configure the two keys in Config.groovy file.
  5. Include stripe.js file.
  6. Add the following dependency in BuildConfig.groovy. Make sure to use the latest version as the API keeps changing from version to version.
  7. Add html form and javascript code in your gsp page with proper field names provided by stripe. Sample code can be downloaded from stripe’s website. The Javascript will first generate a token that represents the credit card information. If a token is generated successfully, a hidden input is appended with stripe token as its value.
  8. Now the form should be submitted to our server(not to be confused with stripe server).
  9. We can now use the token to charge a customer.

That was all! Hope it helped 🙂