Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A gem to interact with versapay
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.rvmrc
.travis.yml
Gemfile
README.md
Rakefile
versapay.gemspec

README.md

A gem to help with using VersaPay's API Build Status

Usage

Include it in your app's 'Gemfile':

gem 'versapay'

In the controller you can make sure that all the actions are called with a valid Web Hook signature:

class VersapayController < ApplicationController
  check_versapay_signatures "MyKey"

There are some Rails view helpers to set up a debit agreement:

# The first you hear of a new debit agreement is when VersaPay sends a callback. So the reference should be
# something you can use to identify your user. For example,
# key = MyApp::Application.config.secret_token
# verifier = ActiveSupport::MessageVerifier.new(key)
# @reference = verifier.generate(@user.id)
= link_to "Setup VersaPay", debit_agreement_link("Set up an agreement", { :reference => @reference, :pref => "ba" })

And of course, you can sent transactions:

 Versapay::Transactions.new do |v|
    begin
      result = v.create(:amount_in_cents => 12345,
                        :debit_agreement_token => "RWOCDPSM",
                        :transaction_type => "pre_authorized_debit",
                        :email => "foo@example.com",
                        :message => "A crate of widgets",
                        :transaction_reference => "my reference",
                        :fund_token => "VersaPayBalanceFundingSource"
                       )
    rescue Versapay::VersapayError => e
      logger.error "Transaction failed"
      return false
    end
  end

Pretty much all the parameters to the functions match the way the VersaPay developers API works.

See the VersaPay developers API: http://developers.versapay.com

Something went wrong with that request. Please try again.