Skip to content

jhaesus/bank_link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BankLink Gem Version Build Status Dependency Status Code Climate

Helper gem to simplify bank link usage in Rails projects

Installation

Add this line to your application's Gemfile:

gem 'bank_link'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bank_link

Usage

Set Up Initializer

BankLink.configuration do |config|
BankLink do |config|

Override mac fields if you so wish

Defaults can be found in mac_fields.yml

  config.mac_fields do |mac_fields|
    mac_fields.SOLOPMT_VERSION[:request]["0003"] = [
      :VERSION,
      :STAMP,
      :RCV_ID,
      :AMOUNT,
      :REF,
      :DATE,
      :CUR
    ]
  end

Add banks

  config.banks :name_of_bank do |bank|
Change bank settings
    bank.settings do |settings|
Encoding
      settings.encoding_key = "VK_CHARSET"
      settings.encoding = "UTF-8"
Private/Public keys and passphrases
      settings.private_key = File.read("my/private_key.pem")
      settings.private_key_passphrase = File.read("my_password")
      settings.public_key = File.read("bank/certificate")
Mac calculation settings
      settings.mac_class = BankLink::Mac::VK
      settings.digest = OpenSSL::Digest::SHA1

      settings.mac_class = BankLink::Mac::Solo
      settings.digest = OpenSSL::Digest::MD5

      settings.mac_class = BankLink::Mac::Custom #Or roll your own
    end
Add link(s)

All the correct form fields can be found in various bank documentations, listed below. "Have fun"

    bank.payment_link "https://url.of.link" do |form|
      form[:VK_SERVICE] = "1001"
      form[:VK_VERSION] = "008"
      form[:VK_AMOUNT] = Proc.new { |link, object| object.price }
      form[:VK_CURR] = "EUR"
    end
    bank.authorization_link "https://url.of.link/auth" do |form|
      form[:VK_SERVICE] = "1001"
      form[:VK_VERSION] = "008"
    end

View Helper

= payment_links @object do |link|
  = submit_tag(link.bank.name)
- BankLink.payment_links do |link|
  = bank_link_tag link, @object do
    = submit_tag(link.bank.name)

Override/Set Form Values

- payment_links @object, { :values => { :VK_AMOUNT => Proc.new { |link, object| object.price * 2 } }} do |link|
  = submit_tag
- BankLink.payment_links do |link|
  = bank_link_tag link, @object, { :values => {:VK_AMOUNT => @object.price }} do
    = submit_tag

Override/Set Form Attributes

- payment_links @object, { :form => { :data => { :something => "other" } } } do |link|
  = submit_tag
- BankLink.payment_links do |link|
  = bank_link_tag link, @object, { :form => {:method => :get }} do
    = submit_tag

Verifying Responses

  link = BankLink.configuration.banks.name_of_link
  link.verify params

Additional Info

Pangalink.net

Documentations

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

GA