Recurly Grails API

  • Tags : api, recurly
  • Latest : 0.99
  • Last Updated: 19 October 2011
  • Grails version : 1.3.5 > *
  • Authors : null
3 votes
Dependency :
compile ":recurly:0.99"

Documentation Source

Summary

A Easy To Use Grails API to Communicate With Recurly servers. Its a grails-plugin implementation of the Recurly API. Feel Free to mail in case of any issues and enhancements.

This Plugin Is Built with these points in mind: 1) Ease Of Use 2) Robustness

Installation

grails install-plugin recurly

Description

Quick Start Guide

Here is a Comprehensive Quick Start Guide For Using The Plugin.

STEP-1: Installing the Plugin

To Install The Plugin Simply Do
grails install-plugin recurly

STEP-2: Implementing the WebHook Listener

Recurly Provides the Push Notifications for Events that happen at recurly End.(Ex. Subscription Complete, Failed Renewal etc..)

This Plugin Has Inbuilt Mechanism to Accept, Parse and Process the Notification and Call the desired Handler In The Application.

Implementing handler Is a VERY SIMPLE Process. All You have to do is:

  1. Make a Service, Lets say for an Example "RecurlyWebHookService"
  2. To that Service implement the interface "RecurlyWebHookListener", and Implement all Interface Methods(Your IDE Will Do that For you :) )
Hurray… Now this Service will be automatically registered as the handler for webHookEvents. And the Implemented Methods will Act as the handler to a particular event, The Name Of the Methods are Self Explanatory to tell what event they will handle.

Hurray! Was't that simple

EXAMPLE SERVICE: Just to show how your service will look like:

class RecurlyWebHookService implements RecurlyWebHookListener {

static transactional = false

void successfulPaymentNotificationHandler(RecurlySuccessfulPaymentWebHookNotification notification) { //Handler Code Here }

void failedRenewalPaymentNotificationHandler(RecurlyFailedRenewalWebHookNotification notification) { //Handler Code Here }

void cancelledSubscriptionNotificationHandler(RecurlyCanceledSubscriptionWebHookNotification notification) { //Handler Code Here }

void renewedSubscriptionNotificationHandler(RecurlyRenewedSubscriptionWebHookNotification notification) { //Handler Code Here }

void newSubscriptionNotificationHandler(RecurlyNewSubscriptionWebHookNotification notification) { //Handler Code Here }

void expiredSubscriptionNotificationHandler(RecurlyExpiredSubscriptionWebHookNotification notification) { //Handler Code Here }

void subscriptionUpdatedNotificationHandler(RecurlyChangedSubscriptionWebHookNotification notification) { //Handler Code Here } }

The Plugin automatically Parses the Notification Data. The Data Provided In the Notification Is Processed Into The Appropriate Bean. These Beans Are Passed In The Handler Methods (As Seen In Above Example)
If No WebHook Listener Is Implemented Then Plugin Will Function Normally, Only Difference Would be that All push notifications will be rejected by the plugin.

STEP-3 Configurations

Following Code Needs To Be Added To The Config.groovy

recurly {
    subDomain = "yourSubDomainHere"
    apiKey = "yourApiKeyHere"
    webhook {
        user = "user"
        pass = "pass"
    }
}

STEP-4 Setting Up Push Notification On The Recurly Server

Login to your recurly Admin Console, There go To Push Notifications then Click On the Configure Button

There In the URL Enter:

http://<YourAppBaseURL>/recurlyWebHook/acceptNotice?user=usernameAsSetInConfig&pass=passwordAsSetInConfig
Leave AuthUsername and AuthPassword, Blank For Basic Implementation.

The Plugin Currently Offers Basic Parameter Based Authentication

For Advanced Authentication(Optional), Use Spring Security Plugin And add a authenticated filter for (controller: recurlyWebHook, action: acceptNotice). And then fill in the AuthUsername and AuthPassword Fields in recurly Push Notification Settings.