Git Product home page Git Product logo

bank_link's Introduction

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

bank_link's People

Contributors

jhaesus avatar tomukas avatar msokk avatar tambet avatar

Watchers

 avatar

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.