activemerchant_patch_for_china 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +63 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/lib/active_merchant/billing/integrations/alipay/helper.rb +41 -0
- data/lib/active_merchant/billing/integrations/alipay/notification.rb +88 -0
- data/lib/active_merchant/billing/integrations/alipay/return.rb +39 -0
- data/lib/active_merchant/billing/integrations/alipay/sign.rb +26 -0
- data/lib/active_merchant/billing/integrations/alipay.rb +23 -0
- data/lib/active_merchant/billing/integrations/bill99/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/bill99/return.rb +55 -0
- data/lib/active_merchant/billing/integrations/bill99.rb +22 -0
- data/lib/active_merchant/billing/integrations/tenpay/helper.rb +38 -0
- data/lib/active_merchant/billing/integrations/tenpay/return.rb +48 -0
- data/lib/active_merchant/billing/integrations/tenpay.rb +18 -0
- data/lib/activemerchant_patch_for_china.rb +5 -0
- data/lib/integrations_helper.rb +11 -0
- data/rails/init.rb +2 -0
- data/test/activemerchant_patch_for_china_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +84 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [nouse]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
h1. activemerchant_patch_for_china
|
2
|
+
|
3
|
+
*Please note! This active_merchant patch is written by nouse.*
|
4
|
+
|
5
|
+
This plugin is an active_merchant patch for china online payment platform, now it supports alipay (支付宝), 99bill (快钱) and tenpay (财付通).
|
6
|
+
|
7
|
+
**************************************************************************
|
8
|
+
|
9
|
+
h2. Install
|
10
|
+
|
11
|
+
install active_merchant plugin first:
|
12
|
+
<pre><code>
|
13
|
+
script/plugin install git://github.com/Shopify/active_merchant.git
|
14
|
+
</code></pre>
|
15
|
+
|
16
|
+
then, install activemerchant_patch_for_china plugin:
|
17
|
+
<pre><code>
|
18
|
+
script/plugin install git://github.com/flyerhzm/activemerchant_patch_for_china.git
|
19
|
+
</code></pre>
|
20
|
+
|
21
|
+
**************************************************************************
|
22
|
+
|
23
|
+
h2. Configuration
|
24
|
+
|
25
|
+
if you install active_merchant and activemerchant_patch_for_china as rails plugins, then define plugin load order in <code>config/environment.rb</code> to promise activemerchant_patch_for_china is loaded after active_merchant.
|
26
|
+
<pre><code>
|
27
|
+
config.plugins = [:all, :active_merchant, :activemerchant_patch_for_china]
|
28
|
+
</code></pre>
|
29
|
+
|
30
|
+
define your api key, account and email in development
|
31
|
+
<pre><code>
|
32
|
+
ActiveMerchant::Billing::Integrations::Alipay::KEY
|
33
|
+
ActiveMerchant::Billing::Integrations::Alipay::ACCOUNT
|
34
|
+
ActiveMerchant::Billing::Integrations::Alipay::EMAIL
|
35
|
+
</code></pre>
|
36
|
+
|
37
|
+
**************************************************************************
|
38
|
+
|
39
|
+
h2. Usage
|
40
|
+
|
41
|
+
<pre><code>
|
42
|
+
<% payment_service_for 'payment order', ActiveMerchant::Billing::Integrations::Alipay::ACCOUNT,
|
43
|
+
:service => :alipay,
|
44
|
+
:html => { :id => 'payment-form', :method => :get } do |service| %>
|
45
|
+
<% service.amount '0.01' %>
|
46
|
+
<% service.seller :email => ActiveMerchant::Billing::Integrations::Alipay::EMAIL %>
|
47
|
+
<% service.notify_url url_for(:only_path => false, :action => 'notify') %>
|
48
|
+
<% service.return_url url_for(:only_path => false, :action => 'done') %>
|
49
|
+
<% service.show_url url_for(:only_path => false, :action => 'show') %>
|
50
|
+
<% service.description 'payment description' %>
|
51
|
+
<% service.charset "utf-8" %>
|
52
|
+
<% service.service "create_direct_pay_by_user" %>
|
53
|
+
<% service.payment_type 1 %>
|
54
|
+
<% service.subject 'payment subject' %>
|
55
|
+
<% service.sign %>
|
56
|
+
<% end %>
|
57
|
+
<%= button_to_function "Submit", "document.getElementById('payment-form').submit();" %>
|
58
|
+
</code></pre>
|
59
|
+
|
60
|
+
**************************************************************************
|
61
|
+
|
62
|
+
|
63
|
+
Copyright (c) 2009 [nouse], released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'jeweler'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc 'Test the activemerchant_patch_for_china plugin.'
|
10
|
+
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.libs << 'test'
|
13
|
+
t.pattern = 'test/**/*_test.rb'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generate documentation for the activemerchant_patch_for_china plugin.'
|
18
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
19
|
+
rdoc.rdoc_dir = 'rdoc'
|
20
|
+
rdoc.title = 'ActivemerchantPatchForChina'
|
21
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
22
|
+
rdoc.rdoc_files.include('README')
|
23
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
+
end
|
25
|
+
|
26
|
+
Jeweler::Tasks.new do |gemspec|
|
27
|
+
gemspec.name = "activemerchant_patch_for_china"
|
28
|
+
gemspec.summary = "A rails plugin to add an active_merchant patch for china online payment platform"
|
29
|
+
gemspec.description = "A rails plugin to add an active_merchant patch for china online payment platform"
|
30
|
+
gemspec.email = "flyerhzm@gmail.com"
|
31
|
+
gemspec.homepage = "http://github.com/flyerhzm/activemerchant_patch_for_china"
|
32
|
+
gemspec.authors = ["Richard Huang"]
|
33
|
+
gemspec.add_dependency 'activemerchant', '>= 1.4.2'
|
34
|
+
end
|
35
|
+
Jeweler::GemcutterTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'digest/md5'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Alipay
|
8
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
9
|
+
mapping :account, 'partner'
|
10
|
+
mapping :amount, 'total_fee'
|
11
|
+
|
12
|
+
mapping :order, 'out_trade_no'
|
13
|
+
|
14
|
+
mapping :seller, :email => 'seller_email'
|
15
|
+
|
16
|
+
mapping :notify_url, 'notify_url'
|
17
|
+
mapping :return_url, 'return_url'
|
18
|
+
mapping :show_url, 'show_url'
|
19
|
+
mapping :description, 'body'
|
20
|
+
|
21
|
+
mapping :charset, '_input_charset'
|
22
|
+
mapping :service, 'service'
|
23
|
+
mapping :payment_type, 'payment_type'
|
24
|
+
mapping :subject, 'subject'
|
25
|
+
|
26
|
+
def initialize(order, account, options = {})
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign
|
31
|
+
add_field('sign',
|
32
|
+
Digest::MD5.hexdigest((@fields.sort.collect{|s|s[0]+"="+CGI.unescape(s[1])}).join("&")+KEY)
|
33
|
+
)
|
34
|
+
add_field('sign_type', 'MD5')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'active_merchant/billing/integrations/alipay/sign'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Alipay
|
8
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
9
|
+
include Sign
|
10
|
+
|
11
|
+
def complete?
|
12
|
+
if status != "TRADE_FINISHED"
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
|
16
|
+
unless verify_sign
|
17
|
+
@message = "Alipay Error: ILLEGAL_SIGN"
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def order
|
25
|
+
@params["out_trade_no"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def amount
|
29
|
+
@params["total_fee"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def message
|
33
|
+
@message
|
34
|
+
end
|
35
|
+
|
36
|
+
def item_id
|
37
|
+
params['']
|
38
|
+
end
|
39
|
+
|
40
|
+
def transaction_id
|
41
|
+
params['']
|
42
|
+
end
|
43
|
+
|
44
|
+
# When was this payment received by the client.
|
45
|
+
def received_at
|
46
|
+
params['']
|
47
|
+
end
|
48
|
+
|
49
|
+
def payer_email
|
50
|
+
params['']
|
51
|
+
end
|
52
|
+
|
53
|
+
def receiver_email
|
54
|
+
params['']
|
55
|
+
end
|
56
|
+
|
57
|
+
def security_key
|
58
|
+
params['']
|
59
|
+
end
|
60
|
+
|
61
|
+
# the money amount we received in X.2 decimal.
|
62
|
+
def gross
|
63
|
+
params['']
|
64
|
+
end
|
65
|
+
|
66
|
+
# Was this a test transaction?
|
67
|
+
def test?
|
68
|
+
params[''] == 'test'
|
69
|
+
end
|
70
|
+
|
71
|
+
def status
|
72
|
+
params['trade_status']
|
73
|
+
end
|
74
|
+
private
|
75
|
+
|
76
|
+
# Take the posted data and move the relevant data into a hash
|
77
|
+
def parse(post)
|
78
|
+
@raw = post
|
79
|
+
for line in post.split('&')
|
80
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
81
|
+
params[key] = value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_merchant/billing/integrations/alipay/sign.rb'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Alipay
|
7
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
8
|
+
include Sign
|
9
|
+
|
10
|
+
def order
|
11
|
+
@params["out_trade_no"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def amount
|
15
|
+
@params["total_fee"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(query_string)
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def success?
|
23
|
+
unless verify_sign
|
24
|
+
@message = "Alipay Error: ILLEGAL_SIGN"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def message
|
32
|
+
@message
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Alipay
|
8
|
+
module Sign
|
9
|
+
def verify_sign
|
10
|
+
sign_type = @params.delete("sign_type")
|
11
|
+
sign = @params.delete("sign")
|
12
|
+
|
13
|
+
md5_string = @params.sort.collect do |s|
|
14
|
+
unless s[0] == "notify_id"
|
15
|
+
s[0]+"="+CGI.unescape(s[1])
|
16
|
+
else
|
17
|
+
s[0]+"="+s[1]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
Digest::MD5.hexdigest(md5_string.join("&")+KEY) == sign.downcase
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/alipay/helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/alipay/notification.rb'
|
3
|
+
require File.dirname(__FILE__) + '/alipay/return.rb'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
module Integrations #:nodoc:
|
8
|
+
module Alipay
|
9
|
+
|
10
|
+
mattr_accessor :service_url
|
11
|
+
self.service_url = 'https://www.alipay.com/cooperate/gateway.do'
|
12
|
+
|
13
|
+
def self.notification(post)
|
14
|
+
Notification.new(post)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.return(query_string)
|
18
|
+
Return.new(query_string)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Bill99
|
7
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
8
|
+
mapping :account, 'merchant_id'
|
9
|
+
mapping :amount, 'amount'
|
10
|
+
mapping :currency, 'currency'
|
11
|
+
|
12
|
+
mapping :order, 'orderid'
|
13
|
+
|
14
|
+
mapping :customer, :name => 'pname',
|
15
|
+
:email => 'pemail'
|
16
|
+
mapping :pid, 'pid'
|
17
|
+
|
18
|
+
mapping :return_url, 'merchant_url'
|
19
|
+
mapping :description, 'commodity_info'
|
20
|
+
mapping :support_des, 'isSupportDES'
|
21
|
+
mapping :attach, 'merchant_param'
|
22
|
+
|
23
|
+
def sign
|
24
|
+
add_field('mac',
|
25
|
+
Digest::MD5.hexdigest("merchant_id=#{ACCOUNT}&orderid=#{order}&amount=#{amount}&merchant_url=#{return_url}" +
|
26
|
+
"&merchant_key=#{KEY}").upcase
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Bill99
|
7
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
8
|
+
|
9
|
+
def account
|
10
|
+
@params["merchant_id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def order
|
14
|
+
@params["orderid"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def amount
|
18
|
+
@params['amount']
|
19
|
+
end
|
20
|
+
|
21
|
+
def sign
|
22
|
+
@params['mac']
|
23
|
+
end
|
24
|
+
|
25
|
+
def success?
|
26
|
+
unless @params['succeed'] == "Y"
|
27
|
+
@message = "Bill99 Error: FALSE_RETURN"
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
unless account == ACCOUNT
|
31
|
+
@message = "Bill99 Error: INCORRECT_ACCOUNT"
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
hash_keys = %w(merchant_id orderid amount date succeed)
|
36
|
+
|
37
|
+
md5_string = hash_keys.inject([]){|array, key| array << "#{key}=#{@params[key]}"}.join("&")
|
38
|
+
|
39
|
+
unless Digest::MD5.hexdigest(md5_string+"&merchant_key=#{KEY}") == sign.downcase
|
40
|
+
@message = "Bill99 Error: ILLEGAL_SIGN"
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
|
47
|
+
def message
|
48
|
+
@message
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/bill99/helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/bill99/return.rb'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Bill99
|
8
|
+
|
9
|
+
mattr_accessor :service_url
|
10
|
+
self.service_url = 'https://www.99bill.com/gateway/receiveMerchantInfoAction.do'
|
11
|
+
|
12
|
+
def self.notification(post)
|
13
|
+
Notification.new(post)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.return(query_string)
|
17
|
+
Return.new(query_string)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Tenpay
|
7
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
8
|
+
# Replace with the real mapping
|
9
|
+
mapping :account, 'bargainor_id'
|
10
|
+
mapping :amount, 'total_fee'
|
11
|
+
|
12
|
+
mapping :order, 'sp_billno'
|
13
|
+
|
14
|
+
mapping :cmdno, 'cmdno'
|
15
|
+
mapping :return_url, 'return_url'
|
16
|
+
mapping :description, 'desc'
|
17
|
+
mapping :attach, 'attach'
|
18
|
+
mapping :date, 'date'
|
19
|
+
mapping :currency, 'fee_type'
|
20
|
+
mapping :transaction_id, 'transaction_id'
|
21
|
+
|
22
|
+
def initialize(order, account, options = {})
|
23
|
+
super
|
24
|
+
add_field('bank_type', 0)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sign
|
28
|
+
add_field('sign',
|
29
|
+
Digest::MD5.hexdigest("cmdno=#{cmdno}&date=#{date}&bargainor_id=#{account}" +
|
30
|
+
"&transaction_id=#{transaction_id}&sp_billno=#{order}&total_fee=#{amount}" +
|
31
|
+
"&fee_type=#{currency}&return_url=#{return_url}&attach=#{attach}&key=#{KEY}"))
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Tenpay
|
7
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
8
|
+
|
9
|
+
def account
|
10
|
+
@params["bargainor_id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def order
|
14
|
+
@params["sp_billno"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def amount
|
18
|
+
@params["total_fee"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def success?
|
22
|
+
return false unless @params["pay_info"] == "OK" && @params["pay_result"] == "0"
|
23
|
+
unless account == ACCOUNT
|
24
|
+
@message = "Tenpay Error: INCORRECT_ACCOUNT"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
hash_keys = %w(cmdno pay_result date transaction_id sp_billno total_fee fee_type attach)
|
29
|
+
|
30
|
+
md5_string = hash_keys.inject([]){|array, key| array << "#{key}=#{@params[key]}"}.join("&")
|
31
|
+
|
32
|
+
unless Digest::MD5.hexdigest(md5_string+"&key=#{KEY}") == @params["sign"].downcase
|
33
|
+
@message = "Tenpay Error: ILLEGAL_SIGN"
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
|
40
|
+
def message
|
41
|
+
@message || @params['pay_info']
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/tenpay/helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/tenpay/return.rb'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Tenpay
|
8
|
+
|
9
|
+
mattr_accessor :service_url
|
10
|
+
self.service_url = 'https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi'
|
11
|
+
|
12
|
+
def self.return(query_string)
|
13
|
+
Return.new(query_string)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ActiveMerchant::Billing::Integrations::Helper.class_eval do
|
2
|
+
alias_method :origin_add_field, :add_field
|
3
|
+
|
4
|
+
def add_field(name, value)
|
5
|
+
if ![Array, Hash].include?(name.class) and value.nil?
|
6
|
+
@fields[name.to_s]
|
7
|
+
else
|
8
|
+
origin_add_field(name, value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/rails/init.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activemerchant_patch_for_china
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Huang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-24 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activemerchant
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.4.2
|
24
|
+
version:
|
25
|
+
description: A rails plugin to add an active_merchant patch for china online payment platform
|
26
|
+
email: flyerhzm@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.textile
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.textile
|
36
|
+
- Rakefile
|
37
|
+
- VERSION
|
38
|
+
- lib/active_merchant/billing/integrations/alipay.rb
|
39
|
+
- lib/active_merchant/billing/integrations/alipay/helper.rb
|
40
|
+
- lib/active_merchant/billing/integrations/alipay/notification.rb
|
41
|
+
- lib/active_merchant/billing/integrations/alipay/return.rb
|
42
|
+
- lib/active_merchant/billing/integrations/alipay/sign.rb
|
43
|
+
- lib/active_merchant/billing/integrations/bill99.rb
|
44
|
+
- lib/active_merchant/billing/integrations/bill99/helper.rb
|
45
|
+
- lib/active_merchant/billing/integrations/bill99/return.rb
|
46
|
+
- lib/active_merchant/billing/integrations/tenpay.rb
|
47
|
+
- lib/active_merchant/billing/integrations/tenpay/helper.rb
|
48
|
+
- lib/active_merchant/billing/integrations/tenpay/return.rb
|
49
|
+
- lib/activemerchant_patch_for_china.rb
|
50
|
+
- lib/integrations_helper.rb
|
51
|
+
- rails/init.rb
|
52
|
+
- test/activemerchant_patch_for_china_test.rb
|
53
|
+
- test/test_helper.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/flyerhzm/activemerchant_patch_for_china
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: A rails plugin to add an active_merchant patch for china online payment platform
|
82
|
+
test_files:
|
83
|
+
- test/activemerchant_patch_for_china_test.rb
|
84
|
+
- test/test_helper.rb
|