Low commit activity in last 3 years
No release in over a year
This gem integrate Rails with spgateway (智付通).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
>= 3.2.6, < 5
~> 10.0

Runtime

 Project Readme

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.