finish huanan

This commit is contained in:
chiu 2020-05-28 22:04:48 +08:00
commit 384765316a
79 changed files with 2222 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache

14
Gemfile Normal file
View File

@ -0,0 +1,14 @@
source "https://rubygems.org"
# Declare your gem's dependencies in payment_settup.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'debugger'

20
MIT-LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright 2020 Harry Bomrah
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= PaymentSettup
This project rocks and uses MIT-LICENSE.

34
Rakefile Normal file
View File

@ -0,0 +1,34 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'PaymentSettup'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test

286
app/assets/javascripts/jspdf.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,18 @@
.all_key{
padding: 1em;
}
label{
display: inline-block;
padding: 0.5em;
margin: 0;
}
input.payment_setup, select.payment_setup{
margin: 0;
background: #a2c3df;
color: #9100ff;
border-radius: 0.7em;
}
.all_key_div{
padding-left: 1em;
margin-bottom: 0.3em;
}

View File

@ -0,0 +1,87 @@
class Admin::PaymentsController < Admin::SitesController
protect_from_forgery with: :exception
layout "structure"
def pay
user = User.find(session[:user_id]) if session[:user_id] rescue nil
payment_pay = PaymentPay.all.select{|v| check_exist(v,user)}
if payment_pay.blank?
payment_pay = PaymentPay.create({amount: 1,user: user})
else
payment_pay = payment_pay[0]
end
@html = Admin::PaymentSetupHelper.render_pay_html(payment_pay)
end
def payment
bank_list = Admin::PaymentSetupHelper.get_bank_list
@payment_options = bank_list.map{|v| [t("payment_settup.#{v}"),v]}
end
def payment_log
@logs = PaymentLog.where(:is_hidden.ne => true).desc(:created_at)
end
def delete_log
if params[:ids]
PaymentLog.any_in(:_id => params[:ids]).each{|v| v.set_hidden}
end
render :nothing => true
end
def payment_detail
select_option = params[:select_option]
option_id = params[:option_id]
render partial: 'payment_detail', locals: {select_option: select_option,option_id: option_id,key_index: 0}
end
def form
data = params['data']
payment_type = params['payment_type']
if params['id'].nil?
if data != nil
PaymentSetupList.create(data:data,payment_type:payment_type)
end
else
payment_setup =
PaymentSetupList.where(id:params['id']).first.nil? ? PaymentSetupList.create() : PaymentSetupList.where(id:params['id']).first
payment_setup.update_attributes({data:data,payment_type:payment_type})
end
redirect_to action:'payment'
end
def test
payment_id = params['payment_id']
@payment_setup = PaymentSetupList.where(id:payment_id).first
if !@payment_setup.nil?
@helper1 = @payment_setup.helper_method
@select_option = @payment_setup.payment_type
end
@AuthResURL = 'https://demo45.dev.rulingcom.com/admin/sites/BoYa-38037656/payment/5e32440f841a8e14c9000014/recieve_result'
end
def get_checkValue
payment_id = params['payment_id']
@payment_setup = PaymentSetupList.where(id:payment_id).first
if !@payment_setup.nil?
@helper1 = @payment_setup.helper_method
@select_option = @payment_setup.payment_type
a = params['data'].merge({'setup'=>@payment_setup}).to_h
checkValue = @helper1.get_checkValue(a)
render text: checkValue
else
render texy: 'error'
end
end
def delete
payment_id = params['payment_id']
payment_setup = PaymentSetupList.where(id:payment_id).first
if !payment_setup.nil?
payment_setup.destroy
end
redirect_to action:'payment'
end
private
def check_exist(pay_data,user)
if user.nil? && pay_data.user.nil?
true
elsif !user.nil? && !pay_data.user.nil?
user.id==pay_data.user.id
else
false
end
end
end

View File

@ -0,0 +1,47 @@
class PaymentsController < ActionController::Base
protect_from_forgery with: :exception,:except => [:recieve_result,:pay]
layout :dynamic
before_action :allow_cross_domain_access,:only => :recieve_result
def dynamic
if action_name != 'recieve_result'
"structure"
else
false
end
end
def allow_cross_domain_access
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
headers['Access-Control-Allow-Headers'] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(',')
headers['Access-Control-Max-Age'] = '1728000'
end
def recieve_result
setup = PaymentSetupList.find(params['payment_id']) rescue nil
if !setup.nil?
helper1 = setup.helper_method
result = helper1.valid_check_value(setup,params)
@html = result
else
@html = 'something went wrong'
end
end
def pay
setup = PaymentSetupList.find(params['payment_id']) rescue nil
if !setup.nil?
payment_pay = PaymentPay.find(params['pay_id']) rescue nil
if !payment_pay.nil?
user = User.find(session[:user_id]) if session[:user_id] rescue nil
member_id = (user.member_profile.id if !user.nil? rescue nil)
order_num = Admin::PaymentSetupHelper.new_ordernum(setup.payment_type)
amount = payment_pay.amount
helper1 = setup.helper_method
hash_data = helper1.pay(params,setup,params['recieve_url'].to_s+payment_recieve_result_path(I18n.locale,setup.id,member_id,payment_pay.id),order_num,amount)
redirect_post(hash_data['form_url'], params: hash_data['data'])
else
render :text => 'something went wrong'
end
else
render :text => 'something went wrong'
end
end
end

View File

@ -0,0 +1,161 @@
module Admin::PaymentSetup::HuaNanHelper
def self.get_setup_form(option_id)
form_array =
[['form_url','text',nil],['MerchantID','text',nil],
['TerminalID','text',nil],['MerchantName','text',nil],
['merID','text',nil],['store_id','text',nil],['PageVer','text',nil],
['txType_mask','select',[[I18n.t('payment_settup.yes'),'yes'],[I18n.t('payment_settup.no'),'no']],nil],
['NumberOfPayOption','number',[nil]],['encode','select',['UTF-8','BIG5'],nil],
['AutoCap','select',[[I18n.t('payment_settup.no'),'0'],[I18n.t('payment_settup.yes'),'1']],nil]]
if !option_id.nil?
value = PaymentSetupList.where(id:option_id).first
form_array = form_array.collect do |v1|
v1[-1] = value['data'][v1[0]]
v1
end
end
form_array
end
def self.pay(params,setup,recieve_url,order_num=nil,amount=nil)
data = setup.data.clone
['NumberOfPayOption','txType_mask','form_url','store_id'].each do |d_value|
data.delete(d_value)
end
checkValue = get_checkValue({'lidm'=>order_num.to_s,'purchAmt'=>amount.to_s,'setup'=>setup})
data = data.merge({'lidm'=>order_num,'purchAmt'=>amount,
'checkValue'=>checkValue,'AuthResURL'=>recieve_url})
if params['txType']=='1' && setup.data['txType_mask']=='yes'
data = data.merge({'txType'=>'1','NumberOfPay'=>params['NumberOfPay']})
else
data = data.merge({'txType'=>'0'})
end
{'form_url'=>setup.data['form_url'],'data'=>data}
end
def self.name(obj=nil)
if !obj.nil?
obj.data['MerchantName']
end
end
def self.get_txType_and_num_pay(setup)
mask = setup.data['txType_mask']
if mask=='yes'
v1 = [[I18n.t('payment_settup.yes'),'1'],[I18n.t('payment_settup.no'),'0']]
v2 = setup.data['NumberOfPayOption']
else
v1 = [[I18n.t('payment_settup.no'),'0']]
v2 = nil
end
[v1,v2]
end
def self.valid_general(id,lidm,status,errcode,authCode,authAmt,xid)
hv1 = Digest::MD5.hexdigest (id+'|'+lidm.to_s)
hv2 =
Digest::MD5.hexdigest (hv1+'|'+status.to_s+'|'+errcode.to_s +
'|' + authCode.to_s + '|' + authAmt.to_s + '|' + xid.to_s)
checkValue = hv2[-16..-1]
end
def self.valid_union(id,orderNumber,status,errcode,orderAmount,xid)
hv1 = Digest::MD5.hexdigest (id+'|'+orderNumber.to_s)
hv2 =
Digest::MD5.hexdigest (hv1+'|'+status.to_s+'|'+errcode.to_s+
'|'+orderAmount.to_s+'|'+xid.to_s)
checkValue = hv2[-16..-1]
end
def self.valid_check_value(setup,param,log_obj=nil)
return_checkValue = param['checkValue']
id = setup.data['store_id']
blank_flag = false
if !param['lidm'].nil?
pay_type = 'general_card'
card_type = I18n.t('payment_settup.general_card')
checkValue = valid_general(id,param['lidm'],param['status'],
param['errcode'],param['authCode'],param['authAmt'],param['xid'])
orderNumber = param['lidm']
amount = param['authAmt']
elsif !param['orderNumber'].nil?
pay_type = 'union_card'
card_type = I18n.t('payment_settup.union_card')
checkValue = valid_general(id,param['orderNumber'],param['status'],
param['errcode'],param['orderAmount'],param['xid'])
orderNumber = param['lidm']
amount = param['orderAmount']
else
blank_flag = true
end
result = param['status']=='0'
if checkValue != return_checkValue
result = false
end
if log_obj.nil?
if blank_flag
'something went wrong'
else
payment_log = PaymentLog.all.select{|v| v.orderNumber == orderNumber}
if !(!payment_log.blank? && payment_log.length == 1 && payment_log[0].params == param.permit!)
payment_log = []
else
payment_log = payment_log[0]
end
if payment_log.blank?
payment_log = PaymentLog.create(params: param.permit!,
result: result,
payment_setup_id: param['pament_id'],
orderNumber: orderNumber,
amount: amount,
member: param['member_id'],
account: '***' + param['Last4digitPAN'],
pay_type: pay_type,
pay_id: param['pay_id'])
end
member_name = payment_log.get_member.name rescue nil
{ 'orderNumber' => orderNumber,
'card_type' => card_type,
'user' => member_name,
'amount' => amount,
'account' => '***' + param['Last4digitPAN'].to_s,
'trading_result' => I18n.t("payment_settup.#{result}")}
end
else
log_obj.update_attributes(params: param,
result: param['status']=='0',
payment_setup_id: param['pament_id'],
orderNumber: orderNumber,
amount: amount,
member: param['member_id'],
account: '***' + param['Last4digitPAN'].to_s,
pay_type: pay_type,
pay_id: param['pay_id'])
end
end
def self.regenerate(setup,param,log_obj)
valid_check_value(setup,param,log_obj)
end
def self.get_pay_array(setup)
txType_opt,num_pay_opt = self.get_txType_and_num_pay(setup)
[['txType','select',txType_opt,nil,'pay_mask'],['NumberOfPay','select',num_pay_opt,nil,'numofpay']]
end
def self.get_checkValue(param)
if param.class == Hash
lidm = param['lidm']
purchAmt = param['purchAmt']
setup = param['setup']
hv1 = Digest::MD5.hexdigest (setup.data['store_id']+'|'+lidm)
hv2 =
Digest::MD5.hexdigest (hv1+'|'+setup.data['MerchantID']+'|'+setup.data['TerminalID']+'|'+purchAmt)
checkValue = hv2[-16..-1]
else
'error'
end
end
def self.get_test_form(setup)
data = setup.data.clone
['NumberOfPayOption','txType_mask','form_url','store_id'].each do |d_value|
data.delete(d_value)
end
txType_opt,num_pay_opt = self.get_txType_and_num_pay(setup)
{'form_url'=>setup.data['form_url'],
'readonly_data'=>data,
'data'=>[['lidm','text',nil,'param'],['txType','select',txType_opt,nil,'pay_mask'],['NumberOfPay','select',num_pay_opt,nil,'numofpay'],
['purchAmt','number',1,'param'],['checkValue','check',nil],['AuthResURL','recieve_url',nil]]}
end
end

View File

@ -0,0 +1,23 @@
module Admin::PaymentSetupHelper
def self.get_bank_list
Dir["#{File.expand_path(__dir__)}/payment_setup/*.rb"].map{|v| v.split('/')[-1].split('_helper')[0]}
end
def self.new_ordernum(bank_name)
if bank_name=='hua_nan'
order_num = (('a'..'z').to_a + (0..9).to_a + ('A'..'Z').to_a ).shuffle[0,19].join
end
if !PaymentLog.all.select {|v| v.orderNumber == order_num }.blank?
order_num = new_ordernum(bank_name)
end
order_num
end
def self.render_pay_html(payment_pay=nil)
url_helpers = Rails.application.routes.url_helpers
ac = ActionController::Base.new()
html_render =
ac.render_to_string :template => 'payment/_pay_html',
:locals=> {url_helpers: url_helpers,payment_pay: payment_pay}
end
end

43
app/models/payment_log.rb Normal file
View File

@ -0,0 +1,43 @@
class PaymentLog
include Mongoid::Document
include Mongoid::Timestamps
field :params, type: Hash,default: {}
field :result
field :payment_setup_id
field :pay_id
field :module_name
field :module_item_id
field :is_hidden, default: false
field :orderNumber
field :amount
field :member
field :account
field :pay_type
def get_member
pay = PaymentPay.find(self.pay_id) rescue nil
if !pay.nil?
mem = pay.member_profile
else
mem = nil
end
if mem.nil?
mem = MemberProfile.find(self['member']) rescue nil
end
mem
end
def set_hidden
self.is_hidden = true
self.save!
end
def set_show
self.is_hidden = false
self.save!
end
def regenerate
setup = PaymentSetupList.find(self.payment_setup_id || self.params['payment_id']) rescue nil
if !setup.nil?
helper1 = setup.helper_method
helper1.regenerate(setup,self.params,self)
end
end
end

20
app/models/payment_pay.rb Normal file
View File

@ -0,0 +1,20 @@
class PaymentPay
include Mongoid::Document
include Mongoid::Timestamps
field :amount
field :module_name
field :module_item_id
field :member_profile
attr_accessor :user
before_create do
if self.member_profile.nil?
self.member_profile = self.user.member_profile
end
end
def member_profile
MemberProfile.find(self['member_profile']) rescue nil
end
def member_profile= (member)
self['member_profile'] = member.id
end
end

View File

@ -0,0 +1,18 @@
class PaymentSetupList
include Mongoid::Document
include Mongoid::Timestamps
field :data, type: Hash,default: {}
field :payment_type, type: String,default: ''
def name
helper1 = helper_method
helper1.name(self)
end
def get_pay_array
helper1 = helper_method
helper1.get_pay_array(self)
end
def helper_method
select_option = self.payment_type
Admin::PaymentSetup.module_eval "#{select_option.split('_').map{|v| v.capitalize}.join('')}Helper"
end
end

View File

@ -0,0 +1,55 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "payment/payment" %>
<% end %>
<style type="text/css">
.other_settings_<%= key_index %>{
border: 0.1em solid #10bf97;
margin-bottom: 1em;
padding-top: 1em;
}
#add_key_<%= key_index %>{
margin: 1em;
}
</style>
<div class="other_settings_<%= key_index %>">
<% helper1 = Admin::PaymentSetup.module_eval "#{select_option.split('_').map{|v| v.capitalize}.join('')}Helper" %>
<% helper1.get_setup_form(option_id).each do |child| %>
<label><%= t("#{select_option}.#{child[0]}") %>:</label>
<% if child[1]=='text' %>
<input class="payment_setup" type="text" name="data[<%= child[0] %>]" value="<%= child[2] %>">
<% elsif child[1]=='select' %>
<%= select_tag("data[#{child[0]}]",options_for_select(child[2],:selected => child[3]),{:class => 'payment_setup'}) %>
<% elsif child[1]=='number' %>
<br>
<% Array(child[2]).each_with_index do |number,index1| %>
<div class="all_key_div">
<span class="all_key"><span><%= index1+1 %></span>.</span><input class="payment_setup all_key_input" type="number" name="data[<%= child[0] %>][]" value='<%= number %>' min="3" step="3">
<%= "<button type='button' class='delete_key'>#{t('payment_settup.delete_key')}</button>".html_safe if index1!=0 %>
<br>
</div>
<% end %>
<button type="button" id="add_key_<%= key_index %>"><%= t('payment_settup.add_key') %></button>
<% end %>
<br>
<% end %>
<%= "<input type='hidden' name='payment_type' value='#{select_option}'>".html_safe %>
<%= "<input type='hidden' name='id' value='#{option_id}'>".html_safe if !option_id.nil? %>
</div>
<script type="text/javascript">
function delete_key_<%= key_index %>(){
$('.other_settings_<%= key_index %> .all_key_div').eq($(this).index('.delete_key')+1).remove()
$('.other_settings_<%= key_index %> .all_key').children('span').each(function(){
$(this).text($(this).parent().index('.all_key')+1)
})
}
$('.other_settings_<%= key_index %>').ready(
function(){
$('#add_key_<%= key_index %>').click(function(){
$('.other_settings_<%= key_index %> .all_key_div').eq(-1).after('<div class="all_key_div"><span class="all_key"><span>'+($('.other_settings_<%= key_index %> input.all_key_input').length+1)+'</span>.</span><input class="payment_setup all_key_input" type="number" name="'+$('input.all_key_input').attr('name')+'" min="3" step="3"> <button type="button" class="delete_key"><%= t('payment_settup.delete_key') %></button><br></div>')
$('.other_settings_<%= key_index %> .delete_key').off('click').on('click',delete_key_<%= key_index %>)
})
$('.other_settings_<%= key_index %> .delete_key').click(delete_key_<%= key_index %>)
}
)
</script>

View File

@ -0,0 +1 @@
<%= @html %>

View File

@ -0,0 +1,108 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "payment/payment" %>
<% end %>
<script type="text/javascript">
$('.payment-page').ready(function (){
$('.wrap-inner a').click(function(){
var ele = $(this)
$('.wrap-inner a').each(function(i,v){
if (ele.index('.wrap-inner a')!=i){
$(v).removeClass('active_in')
}
})
ele.addClass('active_in')
})
$('.payment-selector').change(function(){
console.log($(this).val())
var value = $(this).val()
$.ajax({
type : "post",
url : "/admin/sites/<%= @current_site.to_param %>/payment_detail",
dataType : "text",
data:{select_option: value},
async: false,
global:false,
success: function(data)
{
$('#payment-detail').html(data)
},
error : function(data){
alert('init upload process failed, please try again later.')
}
});
})
}
)
</script>
<style type="text/css">
.fade-in{
display: none;
}
.fade-in.active{
display: block;
}
a:focus{
outline: 0;
}
a.active_in{
color: #9431f8;
}
input[type="button"],button,input[type="submit"] {
outline: 0;
border-radius: 1.3em;
background: #d9e4f7;
font-weight: bold;
outline: 0;
}
input[type="button"]:hover,button:hover,input[type="submit"]:hover {
background: #be8a8a;
}
select{
background: linear-gradient(0deg, #515fff, #ff3e3e);
color: white;
box-shadow: none;
border-radius: 1.3em;
}
select:focus{
outline: 0;
}
option, option:checked, option:hover {
color: #515fff;
font-weight: bold;
}
</style>
<form target="_blank" action="<%= form_admin_site_payment_path(@current_site)%>" class='payment-page' method="get">
<%= csrf_meta_tags %>
<%= t('payment') %>
<br>
<div style="padding-bottom: 2em;border-bottom: 0.1em solid #002bff;">
<% prompt = '------Select a payment-----' %>
bank: <%= select_tag "payment_type", options_for_select(@payment_options.unshift(prompt),selected: prompt,disabled: prompt), :class => "payment-selector" %>
<div id="payment-detail">
<%#  用js新增 %>
</div>
<input type="submit" value="<%= t('payment_settup.add') %>">
<button type="button" onclick="window.location='<%= pay_admin_site_payment_path(@current_site) %>'"><%= t('payment_settup.test_all') %></button>
</div>
</form>
<% index1 = 0 %>
<% PaymentSetupList.all.asc(:created_at).each do |payment_setup_list| %>
<% if !payment_setup_list.payment_type.nil? %>
<% index1+=1 %>
<%= '|' if index1 != 1 %>
<% name1 = payment_setup_list.name.to_s %>
<a href="#<%= payment_setup_list.id.to_s %>" data-toggle="tab" class="<%= 'active_in' if index1== 1 %>"><%= t("payment_settup.#{payment_setup_list.payment_type}")+ (name1.blank? ? '' : "-#{name1}" ) %></a>
<% end %>
<% end %>
<% PaymentSetupList.all.asc(:created_at).each_with_index do |payment_setup_list,index1| %>
<% if !payment_setup_list.payment_type.nil? %>
<form action="<%= form_admin_site_payment_path(@current_site)%>" method="get" id='<%= payment_setup_list.id.to_s %>' class="fade-in <%= 'active' if index1==0 %>">
<%= render partial: 'payment_detail', locals: {select_option: payment_setup_list.payment_type,option_id: payment_setup_list.id,key_index: index1+1} %>
<input type="submit" value="<%= t('payment_settup.modify') %>">
<button type="button" onclick="window.location='<%= admin_site_payment_delete_path(@current_site,payment_setup_list.id) %>'"><%= t('payment_settup.delete') %></button>
<button type="button" onclick="window.location='<%= admin_site_payment_test_path(@current_site,payment_setup_list.id) %>'"><%= t('payment_settup.test') %></button>
</form>
<% end %>
<% end %>

View File

@ -0,0 +1,90 @@
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/list-check.css" %>
<%= stylesheet_link_tag "lib/togglebox.css" %>
<%= javascript_include_tag "lib/list-check" %>
<%= javascript_include_tag "lib/site_set" %>
<style type="text/css">
.main-list tr:hover:nth-child(n) > td {
background-color: #c8e1ed;
}
</style>
<div class="tab-pane fade in active list-check">
<p class="">
<%= link_to(content_tag(:i, nil, :class => "icons-trash"), '#', :class => "btn list-active-btn disabled", :rel => admin_site_delete_payment_log_path) %>
</p>
<form class="form-horizontal main-forms">
<fieldset>
<table class="table main-list table-striped">
<thead>
<tr>
<th class="listCheckHead">
<input type="checkbox" name="to_delete[]" value="b">
</th>
<th><%= t('payment_settup.trading_module') %></th>
<th><%= t('payment_settup.orderNumber') %></th>
<th><%= t('payment_settup.user') %></th>
<th><%= t('payment_settup.amount') %></th>
<th><%= t('payment_settup.pay_type') %></th>
<th><%= t('payment_settup.account') %></th>
<th><%= t('payment_settup.trading_time') %></th>
<th><%= t('payment_settup.trading_result') %></th>
</tr>
</thead>
<tbody id="payment_logs">
<%= @logs.collect do |log|
module_name = log.module_name.blank? ? 'payment' : log.module_name
result = 'payment_settup.' + log.result.inspect
member = log.get_member
member_name = member.name if !member.nil?
pay_type = t("payment_settup.#{log.pay_type}")
if is_manager?
td1 = check_box_tag 'to_delete[]', log.id, false,:id => '', :class => "list-check"
end
"<tr id='#{log.id}'>
<td>
#{td1}
</td>
<td>
#{t(module_name)}
</td>
<td>
#{log.orderNumber}
</td>
<td>
#{member_name}
</td>
<td>
#{log.amount}
</td>
<td>
#{pay_type}
</td>
<td>
#{log.account}
</td>
<td>
#{log.created_at.strftime('%Y/%m/%d %H:%M')}
</td>
<td>
#{t(result)}
</td>
</tr>"
end.join('').html_safe %>
</tbody>
</table>
</fieldset>
</form>
</div>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-body">
<span class="text-warning text-center"><%= t(:this_action_can_not_be_restore) %></span>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:delete_) %></button>
</div>
</div>

View File

@ -0,0 +1,102 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "payment/payment" %>
<% end %>
<% if !@helper1.nil? %>
<% user = User.find(session[:user_id]) if session[:user_id] rescue nil
member = user.member_profile.id if !user.nil?
%>
<% get_data = @helper1.get_test_form(@payment_setup) %>
<form target="_blank" action="<%= get_data['form_url'] %>" method="POST">
<% get_data['readonly_data'].each do |k,v| %>
<input type='hidden' name='<%= k %>' value='<%= v %>'>
<% end %>
<table>
<tbody>
<% get_data['data'].each do |child| %>
<tr>
<% if child[1]!= 'recieve_url' %>
<% if (!child[2].blank? && child[1]=='select') || child[1]!='select'%>
<td>
<label><%= t("#{@select_option}.#{child[0]}") %>:</label>
</td>
<% end %>
<% end %>
<% if child[1]=='text' %>
<td>
<input class="payment_setup<%= " #{child[3]}" if !child[3].nil? %>" type="text" name="<%= child[0] %>" value="<%= child[2] %>">
</td>
<% elsif child[1]=='select' %>
<% if !child[2].blank? %>
<td>
<% class_par = " #{child[4]}" if !child[4].nil? %>
<%= select_tag("#{child[0]}",options_for_select(child[2],:selected => [child[3]]),:class => "payment_setup#{class_par}") %>
</td>
<% end %>
<% elsif child[1]=='number' %>
<td>
<input class="payment_setup<%= " #{child[3]}" if !child[3].nil? %>" type="number" name="<%= child[0] %>" value="<%= child[2] %>">
</td>
<% elsif child[1]=='recieve_url' %>
<input type="hidden" id="recieve_url" name="<%= child[0] %>" value="<%= payment_recieve_result_path(@payment_setup.id,member) %>">
<% elsif child[1]=='check' %>
<td>
<input class="payment_setup" type="text" readonly id="check" name="<%= child[0] %>" value="<%= child[2] %>">
<button type="button" id="get_check"><%= t('payment_settup.get_check') %></button>
</td>
<% end %>
</tr>
<% end %>
<tr><td></td>
<td style="padding-top: 1em;">
<input type="submit" value="<%= t('payment_settup.submit') %>">
</td>
</tr>
</tbody>
</table>
</form>
<script type="text/javascript">
$('form').ready(function(){
href = $('input#recieve_url').val()
root_url = window.location.href.split('/').slice(0,3).join('/')
$('input#recieve_url').val(root_url+href)
$.fn.get_dic = function(){
dic = {}
console.log(this)
this.each(function(){
console.log(this)
dic[$(this).attr('name')] = $(this).val()
})
return dic
}
$('form').submit(function() {
$("tr:hidden").remove()
})
$('.pay_mask').change(function(){
if ($(this)[0].selectedIndex==0){
$('.numofpay').parents('tr').show();
}else{
$('.numofpay').parents('tr').hide();
}
})
$('#get_check').click(function(){
$.ajax({
type : "post",
url : "<%= admin_site_payment_get_checkValue_path(@current_site.to_param,@payment_setup.id) %>",
data:{data: $('.param').get_dic()},
dataType : "text",
async: false,
global:false,
success: function(data)
{
$('#check').val(data)
},
error : function(data){
alert('init upload process failed, please try again later.')
}
});
})
})
</script>
<% else %>
no content to test
<% end %>

View File

@ -0,0 +1 @@
<%= payment_pay_path %>

View File

@ -0,0 +1,91 @@
<style type="text/css">
div[class^="pay-"]{
display: none;
}
div[class^="pay-"].active{
display: block;
margin-top: 0.5em;
}
.pay_opt{
font-size: 1.3em;
}
.pay_opt select{
font-size: 1em;
height: auto;
width: auto;
}
.pay_opt label{
display: inline-block;
font-weight: bold;
font-size: 1em;
}
.pay_opt input[type="submit"] {
border-radius: 1.1em 1.1em;
background: #d9e4f7;
font-weight: bold;
outline: 0;
}
.pay_opt input[type="submit"]:hover{
background: #be8a8a;
}
</style>
<div class="pay_opt">
<% lists = PaymentSetupList.all.asc(:created_at).map{|v| v} %>
<noscript>
<p><%= t('payment_settup.need_script') %></p>
</noscript>
<label style="margin-right: 2.5em;"><%= t('payment_settup.pay_options') %>&nbsp;:</label>
<%= select_tag "pay_options", options_for_select(lists.map{|v| t("payment_settup.#{v.payment_type}")}), :class => "pay_options" %>
<br>
<% lists.each_with_index do |list,index1| %>
<div class="pay-<%= index1.to_s + (index1 == 0 ? ' active' : '' )%>">
<form target = "_blank" action="<%= url_helpers.payment_pay_path(I18n.locale,list.id,payment_pay) %>" method="post">
<table>
<tbody>
<tr>
<td><label><%= t('payment_settup.amount') %>&nbsp;:</label></td>
<td style="text-align: center;"><label><%= payment_pay.amount %></label></td>
</tr>
<% list.get_pay_array.each do |child| %>
<tr>
<% if (!child[2].blank? && child[1]=='select') || child[1]!='select'%>
<td>
<label><%= t("#{list.payment_type}.#{child[0]}") %>&nbsp;:</label>
</td>
<% end %>
<% if child[1]=='select' %>
<% if !child[2].blank? %>
<td>
<% class_par = " #{child[4]}" if !child[4].nil? %>
<%= select_tag("#{child[0]}",options_for_select(child[2],:selected => [child[3]]),:class => "payment_setup#{class_par}") %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<input type="hidden" name="recieve_url" value="">
<input type="submit" value="<%= t('payment_settup.pay') %>">
</form>
</div>
<% end %>
<script type="text/javascript">
$('.pay').ready(function(){
root_url = window.location.href.split('/').slice(0,3).join('/')
$('input[name=recieve_url]').val(root_url)
$('.pay_options').change(function(){
var index1 = this.selectedIndex
$('div[class^="pay-"]').removeClass('active')
$('.pay-'+index1).addClass('active')
})
$('.pay_mask').change(function(){
if ($(this)[0].selectedIndex==0){
$(this).parents('table').find('.numofpay').parents('tr').show();
}else{
$(this).parents('table').find('.numofpay').parents('tr').hide();
}
})
})
</script>
</div>

View File

View File

@ -0,0 +1,114 @@
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js">
</script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<%= javascript_include_tag "jspdf.min" %>
<style type="text/css">
.recieve_result table{
margin-bottom: 1em;
color: white;
}
.recieve_result tr td:nth-child(1){
padding-right: 1em;
}
.recieve_result span{
color: #ff642b;
}
body, div.recieve_result{
background: #014b86;
}
div.recieve_result {
padding: 2em;
display: inline-block;
}
input[type="button"],button,input[type="submit"] {
outline: 0;
border-radius: 1.3em;
background: #d9e4f7;
font-weight: bold;
outline: 0;
}
input[type="button"]:hover,button:hover,input[type="submit"]:hover {
background: #be8a8a;
}
</style>
<script type="text/javascript">
function close_window(){
if (confirm("<%= I18n.t('payment_settup.confirm_close_window') %>")){
closeWP()
}
}
function closeWP() {
var Browser = navigator.appName;
var indexB = Browser.indexOf('Explorer');
if (indexB > 0) {
var indexV = navigator.userAgent.indexOf('MSIE') + 5;
var Version = navigator.userAgent.substring(indexV, indexV + 1);
if (Version >= 7) {
window.open('', '_self', '');
window.close();
}
else if (Version == 6) {
window.opener = null;
window.close();
}
else {
window.opener = '';
window.close();
}
}
else {
window.close();
}
alert("<%= t('payment_settup.not_support_auto_close')%>")
}
function save_data(){
var filename = 'result_<%= @html['orderNumber'] rescue nil %>.pdf';
$('div.recieve_result').find('input[type=button]').hide()
html2canvas($('div.recieve_result')[0]).then(canvas => {
var pdf = new jsPDF('p', 'mm', 'a4');
var width = pdf.internal.pageSize.getWidth();
var height = pdf.internal.pageSize.getHeight();
var h = width / $('div.recieve_result').width() * $('div.recieve_result').height()
pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0,width ,h );
pdf.save(filename);
});
$('div.recieve_result').find('input[type=button]').show()
}
</script>
<div class="recieve_result">
<% if @html.class == String %>
<%= @html %>
<% elsif @html.class == Hash %>
<table>
<thead>
</thead>
<tbody>
<% @html.each do |key,value| %>
<tr>
<td>
<label>
<%= (I18n.t("payment_settup.#{key}") + '&#160;:').html_safe %>
</label>
</td>
<td>
<label>
<%= value %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<span>
<%= I18n.t('payment_settup.note') %>
</span>
<br>
<br>
<br>
<% if @html.class == Hash %>
<input onclick="save_data()" value="<%= I18n.t('payment_settup.save_data') %>" type="button">
<% end %>
<input onclick="close_window()" value="<%= I18n.t('payment_settup.close_window') %>" type="button">
</div>

12
bin/rails Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/payment_settup/engine', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require 'rails/all'
require 'rails/engine/commands'

55
config/locales/en.yml Normal file
View File

@ -0,0 +1,55 @@
en:
payment: Payment Setting
payment-log: Payment log
payment_settup:
pay_type: Payment type
account: Payment account
not_support_auto_close: Your browser dosn't support auto close window, please close by yourself.
save_data: Save the information as pdf
confirm_close_window: Are you sure to close window?
close_window: Close window
note: Please reserve the information on this pageif the transaction have problem, you can provide these information to us to deal with this Order faster
card_type: Card Type
general_card: 'General Card Transactions (VISA, MASTER, JCB)'
union_card: 'UnionPay card transaction (Union Pay)'
pay: Go to pay money
pay_options: Payment term
need_script: It need javascript to show content properly.
'true': success
'false': failed
trading_module: Trading module
orderNumber: Order Number
amount: Amount
user: Payment User
trading_time: Trading time
trading_result: Trading result
hua_nan: Hua Nan Commercial Bank
'yes': Yes
'no': No
add: Add
modify: Modify
add_key: Add Option
delete: Delete
test: Test
test_all: Test all
submit: Submit
delete_key: delete Option
get_check: Get check code
hua_nan:
form_url: Form's URL
MerchantID: MerchantID(Number of length = 15)
TerminalID: TerminalID(Number of length = 8)
MerchantName: Name to show for member
lidm: lidm
merID: merID
customize: customize
PageVer: PageVer
purchAmt: Total Amount
txType_mask: Whether to let member can use installment
txType: Whether to use installment
NumberOfPay: Number of pay
NumberOfPayOption: Number of pay Option
encode: encode
AutoCap: AutoCap
store_id: Store Pass code
checkValue: Check value

55
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,55 @@
zh_tw:
payment: 付款設定
payment-log: 付款紀錄
payment_settup:
pay_type: 付款方式
account: 付款帳戶
not_support_auto_close: 您的瀏覽器不支援自動關閉視窗的功能,請您自行點擊關閉視窗
save_data: 儲存本頁資訊為pdf
confirm_close_window: 請問您確定要關閉視窗嗎?
close_window: 關閉視窗
note: 請保留此頁資訊,若交易有疑慮時,可提供此頁訊息,方便快速處理
card_type: 卡片類型
general_card: '一般卡交易 (VISA、MASTER、JCB)'
union_card: '銀聯卡交易 (Union Pay)'
pay: 前往付款
pay_options: 付款方式
need_script: 需要啟動javascript才能正常顯示頁面
'true': 成功
'false': 失敗
trading_module: 交易模組
orderNumber: 訂單編號
amount: 總金額
user: 付費使用者
trading_time: 交易時間
trading_result: 交易結果
hua_nan: 華南銀行
'yes':
'no':
add: 新增
modify: 修改
add_key: 新增選項
delete: 刪除
test: 測試
test_all: 測試全部
submit: 送出
delete_key: 刪除選項
get_check: 取得驗證碼
hua_nan:
form_url: 表單發送網址
MerchantID: 特店代號(MerchantID)(長度為15位數字)
TerminalID: 端末代號(TerminalID)(長度為8位數字)
MerchantName: 顯示給消費者的名稱
lidm: 訂單編號
merID: 特店網站之代碼(merID)
customize: 客製化授權頁的語系版本(customize)
PageVer: 客製化授權頁版本號碼(PageVer)
purchAmt: 訂單總金額
txType_mask: 是否開放分期付款
txType: 是否使用分期付款
NumberOfPay: 分期期數
NumberOfPayOption: 開放分期期數
encode: 特約商店名稱編碼方式(encode)
AutoCap: 是否由系統繼續執行轉入請款檔作業(AutoCap)
store_id: 特店識別碼
checkValue: 驗證碼

30
config/routes.rb Normal file
View File

@ -0,0 +1,30 @@
Rails.application.routes.draw do
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
resources :sites do
post 'payment_detail' => 'payments#payment_detail'
resource :payment do
get '/' => 'payments#payment'
get 'form' => 'payments#form'
get 'pay' => 'payments#pay'
end
get 'delete_payment_log' => 'payments#delete_log'
resource :payment_log,only: [] do
get '/' => 'payments#payment_log'
end
resources :payment,only: [:delete,:test,:get_checkValue] do
get 'delete' => 'payments#delete'
get 'test' => 'payments#test'
post 'get_checkValue' => 'payments#get_checkValue'
end
end
end
resources :payment,only: [:recieve_result] do
post 'recieve_result(/:member_id)(/:pay_id)' => 'payments#recieve_result', as: 'recieve_result'
resources :pay,only: [:pay] do
post '/' => 'payments#pay'
end
end
end
end

4
lib/payment_settup.rb Normal file
View File

@ -0,0 +1,4 @@
require "payment_settup/engine"
module PaymentSettup
end

View File

@ -0,0 +1,5 @@
module PaymentSettup
class Engine < ::Rails::Engine
isolate_namespace PaymentSettup
end
end

View File

@ -0,0 +1,3 @@
module PaymentSettup
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :payment_settup do
# # Task goes here
# end

6
payment_li.erb Normal file
View File

@ -0,0 +1,6 @@
<style>
.icons-payment:before{ content: "\f09d"; font-family: FontAwesome;}
.icons-payment-log:before{ content: "\f00b"; font-family: FontAwesome;}
</style>
<li title="<%= t('payment') %>"><%= link_to admin_site_payment_path(current_site), :class => active_for_action('sites', 'payment') do %><span><i class="icons-payment"></i></span><%end%></li>
<li title="<%= t('payment-log') %>"><%= link_to admin_site_payment_log_path(current_site), :class => active_for_action('sites', 'payment_log') do %><span><i class="icons-payment-log"></i></span><%end%></li>

34
payment_settup.gemspec Normal file
View File

@ -0,0 +1,34 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "payment_settup/version"
app_path = File.expand_path(__dir__)
#Add payment to Admin area
@payment_li = File.read(app_path+"/payment_li.erb")
@file_text = File.read(ENV['PWD']+'/app/views/shared/_side_bar.html.erb')
if !@file_text.include?('payment')
@insert_index = @file_text.index('<li title="<%= t(\'update_manager\') %>">')
@file_text.insert(@insert_index , @payment_li)
end
f = File.open(ENV['PWD']+'/app/views/shared/_side_bar.html.erb','w')
f.write(@file_text)
f.close
puts "finish change payment setup in #{ENV['PWD']}/app/views/shared"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "payment_settup"
s.version = PaymentSettup::VERSION
s.authors = ["chiu"]
s.email = ["naruto0426@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "PaymentSettup module"
s.description = "PaymentSettup"
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 4.1.16"
s.add_development_dependency "sqlite3"
end

28
test/dummy/README.rdoc Normal file
View File

@ -0,0 +1,28 @@
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.

6
test/dummy/Rakefile Normal file
View File

@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks

View File

View File

@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .

View File

@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/

View File

@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end

View File

@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

View File

View File

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

3
test/dummy/bin/bundle Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
test/dummy/bin/rails Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
test/dummy/bin/rake Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

4
test/dummy/config.ru Normal file
View File

@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@ -0,0 +1,23 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "payment_settup"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end

View File

@ -0,0 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

View File

@ -0,0 +1,25 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3

View File

@ -0,0 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!

View File

@ -0,0 +1,37 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,78 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@ -0,0 +1,39 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_dummy_session'

View File

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View File

@ -0,0 +1,23 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@ -0,0 +1,4 @@
Rails.application.routes.draw do
mount PaymentSettup::Engine => "/payment_settup"
end

View File

@ -0,0 +1,22 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: da3b9e40e2233f3ee018931fc5ad6c3bdae8443e599abcc2d3a9da4965ca30e2f8b24ad9c847c99403ba20b93ed9c417694c75643bb3b6049913cf6847f86355
test:
secret_key_base: b3f5d354c47494e32a81d7243b5ddff4c39f4284ad873562f91455ecdb0bf9ccc95675baad1267b2980646f301869a24ca646d80721a983a35212580ad5d464b
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

View File

0
test/dummy/log/.keep Normal file
View File

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<div>
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

View File

@ -0,0 +1,10 @@
require 'test_helper'
class NavigationTest < ActionDispatch::IntegrationTest
fixtures :all
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class PaymentSettupTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, PaymentSettup
end
end

19
test/test_helper.rb Normal file
View File

@ -0,0 +1,19 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end