Code Monkey home page Code Monkey logo

active_merchant_pay2go's Introduction

Gem Version Build Status Code Climate

ActiveMerchantPay2go

Join the chat at https://gitter.im/imgarylai/active_merchant_pay2go

這個 gem 的目的是要串接 智付通(原智付寶) 的金流,不過不是只有單純的 API 封裝,是透過 active_merchantoffsite_payments 包裝後可以快速的在 Rails 上使用。

另外非常感謝 active_merchant_allpay

安裝

Gemfile 中加入這一行

gem 'active_merchant_pay2go'

透過 bundle 安裝:

$ bundle

設定

  • 建議第一次使用的人可以先看一下官方的文件... Official API

  • 建立 config/initializers/pay2go.rb

rails g pay2go:install
  • 到智付寶上申請申請相關的 key 並放入 config/initializers/pay2go.rb 中。
# Example
OffsitePayments::Integrations::Pay2go.setup do |pay2go|
  # You have to apply credential below by yourself.
  pay2go.merchant_id = '123456'
  pay2go.hash_key    = 'xxx'
  pay2go.hash_iv     = 'yyy'
end
  • 環境設定:
# config/environments/development.rb
config.after_initialize do
  ActiveMerchant::Billing::Base.mode = :development
end
# config/environments/production.rb
config.after_initialize do
  ActiveMerchant::Billing::Base.mode = :production
end

範例

<% payment_service_for  @order,
                        @order.user.email,
                        service: :pay2go,
                        html: { :id => 'pay2go-form', :method => :post } do |service| %>
  <% service.time_stamp @order.created_at %>
  <% service.merchant_order_no @order.id %>
  <% service.amt @order.total_amount.to_i %>
  <% service.item_desc @order.description %>
  <% service.email @order.user.email %>
  <% service.login_type 0 %>
  <% service.encrypted_data %>
  <%= submit_tag '付款' %>
<% end %>

這段程式碼只有實做了很基本的功能。

如果有更多的設定,建議看一下官方文件有沒有支援。

範例 (很簡陋的範例).

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/imgarylai/active_merchant_pay2go. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

active_merchant_pay2go's People

Contributors

chenjenping avatar gitter-badger avatar imgarylai avatar linyiru avatar nickhsu avatar tomchentw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.