HncbEAtm

A simple Hncb Eatm ruby gem, without unnecessary magic or wraper, it's directly facing how Hncb Eatm api works.

Installation

Add this line to your application's Gemfile:

gem 'hncb_e_atm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hncb_e_atm

And then execute:

$ rails g hncb_e_atm:install

Usage

Generate payment url

you have two selections

  1. generator url directly

      options = {
        StoreID: "008757080070001ABCD1310",
        StoreAcnt: "100200000025",
        StoreTxDate: "2005-11-10",
        OrderNumber: "00001",
        Amount: "10",
        StoreName: "博客來網絡書店",
        StoreURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_01.jsp",
        SuccessURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_03OK.jsp",
        FailURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_03NOK.jsp"
      }
        HncbEAtm::Service.create_trade(@options)
       # => "https://www.smartatm.com.tw/eatm/servlet/TrxDispatcher?trx=com.eatm.wibc.trx.web.EAtmWShopping&state=prompt&val=...&mac=..."
    

    You can redirect user to this payment url, and user will see a payment page for his/her order. NOTICE: use HTTP POST method

  2. generate a form

      options = {
        StoreID: "008757080070001ABCD1310",
        StoreAcnt: "100200000025",
        StoreTxDate: "2005-11-10",
        OrderNumber: "00001",
        Amount: "10",
        StoreName: "博客來網絡書店",
        StoreURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_01.jsp",
        SuccessURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_03OK.jsp",
        FailURL: "http://10.8.61.71:8080/mctmk/eatm/Shopping_03NOK.jsp"
      }
        HncbEAtm::Service.create_trade(@options)
        hncb_e_atm_form_for(@options) do
        "<input>Other</input>" #option
        end
       # => "<form action=..."
    

callback

in the callback controller

HncbEAtm::Notify.parse params
# => {
        'StoreID' => "...",
        'StoreAcnt' => "...",
        'StoreTxDate' => "...",
        'OrderNumber' => "...",
        'Amount' => "...",
        'StoreName' => "...",
        'StoreURL' => "...",
        'SuccessURL' => "...",
        'FailURL' => "..."
      }
 #     or  => nil

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