Code Monkey home page Code Monkey logo

webhookr-recurly's Introduction

Webhookr::Recurly

Build Status Dependency Status Code Climate

This gem is a plugin for Webhookr that enables your application to accept webhooks from Recurly.

Installation

Add this line to your application's Gemfile:

gem 'webhookr-recurly'

Or install it yourself:

$ gem install webhookr-recurly

Usage

Once you have the gem installed, run the generator to add the engine route to your config/routes.rb:

rails g webhookr:add_route

or, add the routing information manually to config/routes.rb

mount Webhookr::Engine => "/webhookr", :as => "webhookr"

Then run the generator to add the code to your initializer. An initializer will be created if you do not have one.

rails g webhookr:recurly:init *initializer_name* -s

Run the generator to create an example file to handle Recurly webhooks.

rails g webhookr:recurly:example_hooks

Or create a Recurly handler class for any event that you want to handle. For example to handle unsubscribes you would create a class as follows:

class RecurlyHooks
  def canceled_subscription_notification(incoming)
    # Your custom logic goes here.
    User.sync_recurly_subscription(incoming.payload.account.account_code)
  end
end

For a complete list of events, and the payload format, see below.

Edit config/initializers/initializer_name and change the commented line to point to your custom Recurly event handling class. If your class was called RecurlyHooks the configuration line would look like this:

  Webhookr::Recurly::Adapter.config.callback = RecurlyHooks

To see the list of Recurly URLs for your application can use when you configure Recurly webhooks (https://[yoursite].recurly.com/configuration/notifications), run the provided webhookr rake task:

rake webhookr:services

Example output:

recurly:
  GET	/webhookr/events/recurly/19xl64emxvn
  POST	/webhookr/events/recurly/19xl64emxvn

Recurly Events & Payload

Events

All webhook events are supported. For further information on events, see the Recurly documentation.

Payload

The payload is the full payload data from as per the Recurly documentation, converted to an OpenStruct for ease of access. Examples for the subscription canceled webhook:

  incoming.payload.account.account_code
  incoming.payload.account.email
  incoming.payload.subscription.state
  incoming.payload.subscription.canceled_at
  incoming.payload.subscription.expires_at
  incoming.payload.subscription.plan.plan_code
  incoming.payload.subscription.plan.name

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, once this gem reaches a 1.0 release, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:

spec.add_dependency 'webhookr-recurly', '~> 1.0'

While this gem is currently a 0.x release, suggestion is to require the exact version that works for your code:

spec.add_dependency 'webhookr-recurly', '0.1'

License

webhookr-recurly is released under the MIT license.

Authors

webhookr-recurly's People

Contributors

tfe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

webhookr-recurly's Issues

Gem on RubyGems ?

Hello,

It seems that the gem is not available on Rubygems, have you planned to submit it to Rubygems ?

Thanks a lot !

Jeremy

A copy of RecurlyHooks has been removed from the module tree but is still active!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.