GithubHelp home page GithubHelp logo

active_merchant_spgateway's Introduction

ActiveMerchantSpgateway

This gem integrate Rails with spgateway(智付通).

Installation

Add this line to your application's Gemfile:

gem 'active_merchant_spgateway', github: 'afunction/active_merchant_spgateway'

And then execute:

$ bundle

Setup

  • Create file config/initializers/spgateway.rb
rails g spgateway:install
  • Go to spgateway and get your credential information. Then fill in config/initializers/spgateway.rb
OffsitePayments::Integrations::Spgateway.setup do |spgateway|
  # You have to apply credential below by yourself.
  spgateway.merchant_id = '123456'
  spgateway.hash_key    = 'xxx'
  spgateway.hash_iv     = 'yyy'
end
  • Environment configuration:
# 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

Example

  • Standard
<% payment_service_for  @order,
                        @order.user.email,
                        service: :spgateway,
                        html: { :id => 'spgateway-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 %>
  • Credit card agreement
<% payment_service_for  @order,
                        @order.user.email,
                        service: :spgateway,
                        html: { :id => 'spgateway-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.creditagreement 1 %>
  <% service.token_term billing.merchant_id %>
  <% service.encrypted_data %>
  <%= submit_tag '付款' %>
<% end %>

License

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

active_merchant_spgateway's People

Contributors

adz624 avatar sdlong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

active_merchant_spgateway's Issues

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.