Skip to content


Repository files navigation

Grails Payment plugin

Author: Vahid Hedayati

Date: 18th June 2021

Grails Payment Plugin written in Grails 4

Installation for a grails 4 application

Add dependency to build.gradle:

dependencies {
  compile "io.github.vahidhedayati:payment:1.0.2"

  //You will only need this if you are looking to use square payment
  compile 'org.jetbrains.kotlin:kotlin-stdlib:1.3.70'


Supports 3 payment systems: PayPal, Stripe & Square

A web interface is provided to allow configuration changes of the following aspects:

Enable / Disable any / all providers as you like

Change from SANDBOX to LIVE on any or all give providers

Change sandbox / live secret / public keys for any / all providers.

All underlying providers use a concurrent hashmap which load are referred to by plugin as real configuration settings.

Getting plugin to work on a sample site:

Copy SampleApplication.groovy from conf folder of this
plugin to your app as /grails-app/conf/application.groovy & update according to your provider key / configuration.

Step 2: Update init/{package}/BootStrap.groovy

This will trigger all above configuration defined values to load from config onto Database and from Database to a concurrent hashmap containing all configuration values, allowing dynamic configuration change by product owner from a web interface:

class BootStrap {

    def paymentService
    def init = { servletContext ->

    def destroy = {

Start up your test site, there will now be an additional 2 controllers available:

http://localhost:8080/payment you will be working with:



Full walk through video

You-Tube Video showing plugin in use

How to use plugin locally

By installing the plugin you get the working steps to make payments work and all of the code to execute run it. If what you see in video is sufficient then all you need is the buttons

Where you would pass instance which contains what the sample checkout as part of the instance variable this would be all relevant input, all providers paypal, stripe & square have been fully implemented to create a customer on their systems which takes all of your users input by this I mean their address etc is also passed to the third party and is also returned in their final response back to you.

To figure out what variables / parameters are required refer to CartBean

Paypal steps:

Step 1 paypalcheckout

Step 2 uploadCart

Step 3 execute

step 4 cancel/thanks

Square steps:

Step 1 squarecheckout

step 2 thanks

Stripe steps:

Step 1 stripecheckout

Step 2 thanks