activemerchant_patch_for_china 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 [nouse]
1
+ Copyright (c) 2009 - 2010 [Richard Huang]
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.textile CHANGED
@@ -1,8 +1,8 @@
1
1
  h1. activemerchant_patch_for_china
2
2
 
3
- *Please note! This active_merchant patch is written by nouse.*
3
+ This plugin is an active_merchant patch for china online payment platform, now it supports alipay (支付宝), 99bill (快钱), tenpay (财付通), 19pay(捷迅支付) and yeepay(易宝).
4
4
 
5
- This plugin is an active_merchant patch for china online payment platform, now it supports alipay (支付宝), 99bill (快钱) and tenpay (财付通).
5
+ <a href='http://www.pledgie.com/campaigns/14062'><img alt='Click here to lend your support to: activemerchant patch for china and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/14062.png?skin_name=chrome' border='0' /></a>
6
6
 
7
7
  **************************************************************************
8
8
 
@@ -22,8 +22,6 @@ sudo gem install activemerchant
22
22
  sudo gem install activemerchant_patch_for_china
23
23
  </code></pre>
24
24
 
25
-
26
-
27
25
  **************************************************************************
28
26
 
29
27
  h2. Configuration
@@ -51,9 +49,15 @@ ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionVie
51
49
 
52
50
  h2. Usage
53
51
 
54
- "Alipay (支付宝)":http://wiki.github.com/flyerhzm/activemerchant_patch_for_china/alipay
52
+ "Alipay (支付宝)":http://github.com/flyerhzm/activemerchant_patch_for_china/wiki/Alipay-(%E6%94%AF%E4%BB%98%E5%AE%9D)
53
+
54
+ **************************************************************************
55
+
56
+ h2. About
57
+
58
+ <code>activemerchant_patch_for_china</code> is inspired by "masterwujiang's patch":https://jadedpixel.lighthouseapp.com/projects/11599-active-merchant/tickets/8-patch-additon-integrations-support-alipay-99bill-and-tenpay-all-in-china
55
59
 
56
60
  **************************************************************************
57
61
 
58
62
 
59
- Copyright (c) 2009 [nouse], released under the MIT license
63
+ Copyright (c) 2009 - 2010 [Richard Huang], released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -1,59 +1,69 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{activemerchant_patch_for_china}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Huang"]
12
- s.date = %q{2009-12-16}
12
+ s.date = %q{2011-02-24}
13
13
  s.description = %q{A rails plugin to add an active_merchant patch for china online payment platform}
14
14
  s.email = %q{flyerhzm@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.textile"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.textile",
22
- "Rakefile",
23
- "VERSION",
24
- "activemerchant_patch_for_china.gemspec",
25
- "lib/active_merchant/billing/integrations/alipay.rb",
26
- "lib/active_merchant/billing/integrations/alipay/helper.rb",
27
- "lib/active_merchant/billing/integrations/alipay/notification.rb",
28
- "lib/active_merchant/billing/integrations/alipay/return.rb",
29
- "lib/active_merchant/billing/integrations/alipay/sign.rb",
30
- "lib/active_merchant/billing/integrations/bill99.rb",
31
- "lib/active_merchant/billing/integrations/bill99/helper.rb",
32
- "lib/active_merchant/billing/integrations/bill99/return.rb",
33
- "lib/active_merchant/billing/integrations/tenpay.rb",
34
- "lib/active_merchant/billing/integrations/tenpay/helper.rb",
35
- "lib/active_merchant/billing/integrations/tenpay/return.rb",
36
- "lib/activemerchant_patch_for_china.rb",
37
- "lib/integrations_helper.rb",
38
- "rails/init.rb",
39
- "test/activemerchant_patch_for_china_test.rb",
40
- "test/test_helper.rb"
19
+ "MIT-LICENSE",
20
+ "README.textile",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "activemerchant_patch_for_china.gemspec",
24
+ "init.rb",
25
+ "lib/active_merchant/billing/integrations/alipay.rb",
26
+ "lib/active_merchant/billing/integrations/alipay/helper.rb",
27
+ "lib/active_merchant/billing/integrations/alipay/notification.rb",
28
+ "lib/active_merchant/billing/integrations/alipay/return.rb",
29
+ "lib/active_merchant/billing/integrations/alipay/sign.rb",
30
+ "lib/active_merchant/billing/integrations/bill99.rb",
31
+ "lib/active_merchant/billing/integrations/bill99/helper.rb",
32
+ "lib/active_merchant/billing/integrations/bill99/notification.rb",
33
+ "lib/active_merchant/billing/integrations/bill99/return.rb",
34
+ "lib/active_merchant/billing/integrations/bill99_card.rb",
35
+ "lib/active_merchant/billing/integrations/bill99_card/helper.rb",
36
+ "lib/active_merchant/billing/integrations/bill99_card/notification.rb",
37
+ "lib/active_merchant/billing/integrations/bill99_card/return.rb",
38
+ "lib/active_merchant/billing/integrations/pay19.rb",
39
+ "lib/active_merchant/billing/integrations/pay19/helper.rb",
40
+ "lib/active_merchant/billing/integrations/pay19/notification.rb",
41
+ "lib/active_merchant/billing/integrations/pay19/return.rb",
42
+ "lib/active_merchant/billing/integrations/tenpay.rb",
43
+ "lib/active_merchant/billing/integrations/tenpay/helper.rb",
44
+ "lib/active_merchant/billing/integrations/tenpay/return.rb",
45
+ "lib/active_merchant/billing/integrations/yeepay.rb",
46
+ "lib/active_merchant/billing/integrations/yeepay/helper.rb",
47
+ "lib/active_merchant/billing/integrations/yeepay/notification.rb",
48
+ "lib/active_merchant/billing/integrations/yeepay/return.rb",
49
+ "lib/activemerchant_patch_for_china.rb",
50
+ "lib/integrations_helper.rb",
51
+ "test/activemerchant_patch_for_china_test.rb",
52
+ "test/test_helper.rb"
41
53
  ]
42
54
  s.homepage = %q{http://github.com/flyerhzm/activemerchant_patch_for_china}
43
- s.rdoc_options = ["--charset=UTF-8"]
44
55
  s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.3.5}
56
+ s.rubygems_version = %q{1.5.2}
46
57
  s.summary = %q{A rails plugin to add an active_merchant patch for china online payment platform}
47
58
  s.test_files = [
48
59
  "test/activemerchant_patch_for_china_test.rb",
49
- "test/test_helper.rb"
60
+ "test/test_helper.rb"
50
61
  ]
51
62
 
52
63
  if s.respond_to? :specification_version then
53
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
64
  s.specification_version = 3
55
65
 
56
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
66
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
67
  s.add_runtime_dependency(%q<activemerchant>, [">= 1.4.2"])
58
68
  else
59
69
  s.add_dependency(%q<activemerchant>, [">= 1.4.2"])
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require 'activemerchant_patch_for_china'
@@ -9,7 +9,7 @@ module ActiveMerchant #:nodoc:
9
9
  CREATE_DIRECT_PAY_BY_USER = 'create_direct_pay_by_user'
10
10
  CREATE_PARTNER_TRADE_BY_BUYER = 'create_partner_trade_by_buyer'
11
11
  TRADE_CREATE_BY_BUYER = 'trade_create_by_buyer'
12
-
12
+
13
13
  ###################################################
14
14
  # common
15
15
  ###################################################
@@ -27,7 +27,8 @@ module ActiveMerchant #:nodoc:
27
27
  mapping :charset, '_input_charset'
28
28
  mapping :service, 'service'
29
29
  mapping :payment_type, 'payment_type'
30
-
30
+ mapping :extra_common_param, 'extra_common_param'
31
+
31
32
  #################################################
32
33
  # create direct pay by user
33
34
  #################################################
@@ -37,7 +38,7 @@ module ActiveMerchant #:nodoc:
37
38
  mapping :royalty, :type => 'royalty_type',
38
39
  :parameters => 'royalty_parameters'
39
40
  mapping :it_b_pay, 'it_b_pay'
40
-
41
+
41
42
  #################################################
42
43
  # create partner trade by buyer and trade create by user
43
44
  #################################################
@@ -59,7 +60,7 @@ module ActiveMerchant #:nodoc:
59
60
  mapping :t_b_pay, 't_b_pay'
60
61
  mapping :t_s_send_1, 't_s_send_1'
61
62
  mapping :t_s_send_2, 't_s_send_2'
62
-
63
+
63
64
  #################################################
64
65
  # create partner trade by buyer
65
66
  #################################################
@@ -75,6 +76,7 @@ module ActiveMerchant #:nodoc:
75
76
  Digest::MD5.hexdigest((@fields.sort.collect{|s|s[0]+"="+CGI.unescape(s[1])}).join("&")+KEY)
76
77
  )
77
78
  add_field('sign_type', 'MD5')
79
+ nil
78
80
  end
79
81
 
80
82
  end
@@ -11,11 +11,11 @@ module ActiveMerchant #:nodoc:
11
11
  def complete?
12
12
  trade_status == "TRADE_FINISHED"
13
13
  end
14
-
14
+
15
15
  def pending?
16
16
  trade_status == 'WAIT_BUYER_PAY'
17
17
  end
18
-
18
+
19
19
  def status
20
20
  trade_status
21
21
  end
@@ -25,7 +25,7 @@ module ActiveMerchant #:nodoc:
25
25
  true
26
26
  end
27
27
 
28
- ['notify_type', 'notify_id', 'out_trade_no', 'trade_no', 'payment_type', 'subject', 'body',
28
+ ['extra_common_param', 'notify_type', 'notify_id', 'out_trade_no', 'trade_no', 'payment_type', 'subject', 'body',
29
29
  'seller_email', 'seller_id', 'buyer_email', 'buyer_id', 'logistics_type', 'logistics_payment',
30
30
  'receive_name', 'receive_address', 'receive_zip', 'receive_phone', 'receive_mobile'].each do |param|
31
31
  self.class_eval <<-EOF
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  end
35
35
  EOF
36
36
  end
37
-
37
+
38
38
  ['price', 'discount', 'quantity', 'total_fee', 'coupon_discount', 'logistics_fee'].each do |param|
39
39
  self.class_eval <<-EOF
40
40
  def #{param}
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  end
43
43
  EOF
44
44
  end
45
-
45
+
46
46
  ['trade_status', 'refund_status', 'logistics_status'].each do |param|
47
47
  self.class_eval <<-EOF
48
48
  def #{param}
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  end
67
67
  EOF
68
68
  end
69
-
69
+
70
70
  private
71
71
 
72
72
  # Take the posted data and move the relevant data into a hash
@@ -25,6 +25,7 @@ module ActiveMerchant #:nodoc:
25
25
  Digest::MD5.hexdigest("merchant_id=#{ACCOUNT}&orderid=#{order}&amount=#{amount}&merchant_url=#{return_url}" +
26
26
  "&merchant_key=#{KEY}").upcase
27
27
  )
28
+ nil
28
29
  end
29
30
 
30
31
  end
@@ -0,0 +1,74 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Bill99
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ "10" == params["payResult"]
10
+ end
11
+
12
+ def received_at
13
+ Time.parse params['dealTime']
14
+ end
15
+
16
+ def status
17
+
18
+ end
19
+
20
+ def transaction_id
21
+ params['dealId']
22
+ end
23
+
24
+ def type
25
+ end
26
+
27
+ def gross
28
+ params['payAmount']
29
+ end
30
+
31
+ def fee
32
+ params['fee']
33
+ end
34
+
35
+ def currency
36
+ end
37
+
38
+ def item_id
39
+ params['orderId']
40
+ end
41
+
42
+ def invoice
43
+
44
+ end
45
+
46
+ def test?
47
+
48
+ end
49
+
50
+ def account
51
+ params['merchantAccId']
52
+ end
53
+
54
+ def acknowledge
55
+ verify_payment == params['signMsg']
56
+ end
57
+
58
+ def acknowledge_response
59
+ "<result>1</result><redirecturl>#{REDIRECT_URL}</redirecturl>"
60
+ end
61
+
62
+ private
63
+ def verify_payment
64
+ Digest::MD5.hexdigest(%w(merchantAcctId version language signType
65
+ payType bankId orderId orderTime orderAmount dealId bankDealId
66
+ dealTime payAmount fee ext1 ext2 payResult errCode).collect{
67
+ |name| "#{name}=#{params[name]}" unless params[name].blank?
68
+ }.compact.join('&') + "&key=#{KEY}").upcase
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/bill99_card/helper.rb'
2
+ require File.dirname(__FILE__) + '/bill99_card/return.rb'
3
+ require File.dirname(__FILE__) + '/bill99_card/notification.rb'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ module Integrations #:nodoc:
8
+ module Bill99Card
9
+
10
+ mattr_accessor :service_url
11
+ self.service_url = 'https://www.99bill.com/szxgateway/recvMerchantInfoAction.htm'
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,42 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Bill99Card
7
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
8
+ mapping :account, 'merchantAcctId'
9
+ mapping :amount, 'orderAmount'
10
+ mapping :order, 'orderId'
11
+ mapping :return_url, 'pageUrl'
12
+ mapping :notify_url, 'bgUrl'
13
+ mapping :description, 'productName'
14
+ mapping :channel, 'bossType'
15
+
16
+ def initialize(order, account, options = {})
17
+ options[:amount] = (options[:amount] * 100).to_i
18
+ super(order, account, options)
19
+ add_field('version', 'v2.0')
20
+ add_field('language', '1')
21
+ add_field('signType', '1')
22
+ add_field('payType', '42')
23
+ add_field('fullAmountFlag', '0')
24
+ add_field('orderTime', DateTime.now.strftime("%Y%m%d%H%M%S"))
25
+ end
26
+
27
+ def form_fields
28
+ @fields.merge('signMsg' => sign)
29
+ end
30
+
31
+ def sign
32
+ Digest::MD5.hexdigest(%w(inputCharset bgUrl pageUrl version language signType merchantAcctId payerName payerContactType payerContact
33
+ orderId orderAmount payType fullAmountFlag orderTime productName productNum productId productDesc ext1 ext2 bossType).collect{
34
+ |name| @fields[name].blank? ? "" : "#{name}=#{@fields[name]}"
35
+ }.select{|s| !s.blank? }.join('&') + "&key=#{KEY[@fields['bossType']]}").upcase
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,72 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Bill99Card
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ "10" == params["payResult"]
10
+ end
11
+
12
+ def received_at
13
+ Time.parse params['dealTime']
14
+ end
15
+
16
+ def status
17
+
18
+ end
19
+
20
+ def transaction_id
21
+ params['dealId']
22
+ end
23
+
24
+ def type
25
+ end
26
+
27
+ def gross
28
+ params['payAmount']
29
+ end
30
+
31
+ def fee
32
+ params['fee']
33
+ end
34
+
35
+ def currency
36
+ end
37
+
38
+ def item_id
39
+ params['orderId']
40
+ end
41
+
42
+ def invoice
43
+
44
+ end
45
+
46
+ def test?
47
+
48
+ end
49
+
50
+ def account
51
+ params['merchantAccId']
52
+ end
53
+
54
+ def acknowledge
55
+ verify_payment == params['signMsg']
56
+ end
57
+
58
+ def acknowledge_response
59
+ "<result>1</result><redirecturl>#{REDIRECT_URL}</redirecturl>"
60
+ end
61
+
62
+ private
63
+ def verify_payment
64
+ Digest::MD5.hexdigest(%w(merchantAcctId version language payType cardNumber cardPwd orderId orderAmount dealId orderTime ext1 ext2 payAmount billOrderTime payResult signType bossType receiveBossType receiverAcctId).collect{
65
+ |name| "#{name}=#{params[name]}" unless params[name].blank?
66
+ }.select{|s| !s.blank? }.join('&') + "&key=#{KEY[params['bossType']]}").upcase
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,52 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Bill99Card
7
+ class Return < ActiveMerchant::Billing::Integrations::Return
8
+
9
+ def account
10
+ params["merchantAcctId"]
11
+ end
12
+
13
+ def order
14
+ params["orderid"]
15
+ end
16
+
17
+ def amount
18
+ params['payAmount']
19
+ end
20
+
21
+ def sign
22
+ params['signMsg']
23
+ end
24
+
25
+ def success?
26
+ unless params['payResult'] == "10"
27
+ @message = "Bill99 Error: FALSE_RETURN"
28
+ return false
29
+ end
30
+ # unless verify_sign == sign.upcase
31
+ # @message = "Bill99 Error: ILLEGAL_SIGN"
32
+ # return false
33
+ # end
34
+
35
+ return true
36
+ end
37
+
38
+ def message
39
+ @message
40
+ end
41
+
42
+ private
43
+ def verify_sign
44
+ Digest::MD5.hexdigest(%w(merchantAcctId version language payType cardNumber cardPwd orderId orderAmount dealId orderTime ext1 ext2 payAmount billOrderTime payResult signType bossType receiveBossType receiverAcctId).collect{
45
+ |name| "#{name}=#{params[name]}" unless params[name].blank?
46
+ }.select{|s| !s.blank? }.join('&') + "&key=#{KEY[params['bossType']]}").upcase
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/pay19/helper.rb'
2
+ require File.dirname(__FILE__) + '/pay19/return.rb'
3
+ require File.dirname(__FILE__) + '/pay19/notification.rb'
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ module Integrations #:nodoc:
7
+ module Pay19
8
+ mattr_accessor :service_url
9
+ self.service_url = 'https://pay.19pay.com/page/bussOrder.do'
10
+
11
+ def self.notification(post)
12
+ Notification.new(post)
13
+ end
14
+
15
+ def self.return(query_string)
16
+ Return.new(query_string)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Pay19
7
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
8
+ mapping :account, 'merchant_id'
9
+ mapping :amount, 'amount'
10
+ mapping :currency, 'currency'
11
+ mapping :order, 'order_id'
12
+ mapping :return_url, 'returl'
13
+ mapping :notify_url, 'notify_url'
14
+ mapping :description, 'order_pname'
15
+ mapping :channel, 'pm_id'
16
+
17
+ def initialize(order, account, options = {})
18
+ super(order, ACCOUNT, options)
19
+ add_field('version_id', '2.00')
20
+ add_field('order_date', DateTime.now.strftime("%Y%m%d"))
21
+ add_field('pc_id', '') # Keep empty if pm_id is empty
22
+ end
23
+
24
+ def form_fields
25
+ @fields.merge('verifystring' => sign)
26
+ end
27
+
28
+ def sign
29
+ Digest::MD5.hexdigest(%w(version_id merchant_id order_date order_id
30
+ amount currency returl pm_id pc_id).collect{
31
+ |name| "#{name}=#{@fields[name]}"
32
+ }.join('&') + "&merchant_key=#{KEY}")
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,74 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Pay19
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ "Y" == params["result"]
10
+ end
11
+
12
+ def received_at
13
+ Time.parse params['pay_date']
14
+ end
15
+
16
+ def status
17
+
18
+ end
19
+
20
+ def transaction_id
21
+ params['pay_sq']
22
+ end
23
+
24
+ def type
25
+ params['pm_id']
26
+ end
27
+
28
+ def gross
29
+ params['amount']
30
+ end
31
+
32
+ def fee
33
+ end
34
+
35
+ def currency
36
+ params['currency']
37
+ end
38
+
39
+ def item_id
40
+ params['order_id']
41
+ end
42
+
43
+ def invoice
44
+
45
+ end
46
+
47
+ def test?
48
+
49
+ end
50
+
51
+ def account
52
+ params['merchant_id']
53
+ end
54
+
55
+ def acknowledge
56
+ verify_payment == params['verifystring']
57
+ end
58
+
59
+ def acknowledge_response
60
+ "Y"
61
+ end
62
+
63
+ private
64
+ def verify_payment
65
+ Digest::MD5.hexdigest(%w(version_id merchant_id order_id result
66
+ order_date amount currency pay_sq pay_date pc_id).collect{
67
+ |name| "#{name}=#{params[name]}"
68
+ }.join('&') + "&merchant_key=#{KEY}")
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,65 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Pay19
7
+ class Return < ActiveMerchant::Billing::Integrations::Return
8
+
9
+ def account
10
+ @params["merchant_id"]
11
+ end
12
+
13
+ def order
14
+ @params["order_id"]
15
+ end
16
+
17
+ def amount
18
+ @params['amount']
19
+ end
20
+
21
+ def sign
22
+ @params['verifystring']
23
+ end
24
+
25
+ def item_id
26
+ @params['order_id']
27
+ end
28
+
29
+ def gross
30
+ @params['amount']
31
+ end
32
+
33
+ def success?
34
+
35
+ if @params['result'] == "N"
36
+ @message = "19Pay Error: PAYMENT_FAILED"
37
+ return false
38
+ end
39
+
40
+ unless @params['result'] == "Y"
41
+ @message = "19Pay message: transaction is processing.. code:#{@params['result']}"
42
+ return false
43
+ end
44
+
45
+ hash_keys = %w(version_id merchant_id order_date order_id amount
46
+ currency pay_sq pay_date pc_id result)
47
+
48
+ md5_string = hash_keys.inject([]){|array, key| array << "#{key}=#{@params[key]}"}.join("&")
49
+ unless Digest::MD5.hexdigest(md5_string+"&merchant_key=#{KEY}") == sign.downcase
50
+ @message = "19Pay Error: ILLEGAL_SIGN"
51
+ return false
52
+ end
53
+
54
+ return true
55
+ end
56
+
57
+ def message
58
+ @message
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -29,6 +29,7 @@ module ActiveMerchant #:nodoc:
29
29
  Digest::MD5.hexdigest("cmdno=#{cmdno}&date=#{date}&bargainor_id=#{account}" +
30
30
  "&transaction_id=#{transaction_id}&sp_billno=#{order}&total_fee=#{amount}" +
31
31
  "&fee_type=#{currency}&return_url=#{return_url}&attach=#{attach}&key=#{KEY}"))
32
+ nil
32
33
  end
33
34
 
34
35
  end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/yeepay/helper.rb'
2
+ require File.dirname(__FILE__) + '/yeepay/notification.rb'
3
+ require File.dirname(__FILE__) + '/yeepay/return.rb'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ module Integrations #:nodoc:
8
+ module Yeepay
9
+
10
+ mattr_accessor :test_url
11
+ self.test_url = 'http://tech.yeepay.com:8080/robot/debug.action'
12
+
13
+ mattr_accessor :production_url
14
+ self.production_url = 'https://www.yeepay.com/app-merchant-proxy/node'
15
+
16
+ def self.service_url
17
+ mode = ActiveMerchant::Billing::Base.integration_mode
18
+ case mode
19
+ when :production
20
+ self.production_url
21
+ when :test
22
+ self.test_url
23
+ else
24
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ require 'hmac-md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Yeepay
7
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
8
+ mapping :account, 'p1_MerId'
9
+ mapping :order, 'p2_Order'
10
+ mapping :amount, 'p3_Amt'
11
+ mapping :currency, 'p4_Cur'
12
+
13
+ mapping :description, 'p5_Pid'
14
+ mapping :return_url, 'p8_Url'
15
+ mapping :channel, 'pd_FrpId'
16
+
17
+ def initialize(order, account, options = {})
18
+ super(order, ACCOUNT, options)
19
+ add_field('p0_Cmd', 'Buy')
20
+ end
21
+
22
+ def form_fields
23
+ @fields.merge('hmac' => hmac_md5_hexdigest)
24
+ end
25
+
26
+ def hmac_md5_hexdigest
27
+ HMAC::MD5.hexdigest(KEY, @fields.sort.collect{|s| s[1]}.join)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,70 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Yeepay
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+ def complete?
7
+ "1" == params["r1_Code"]
8
+ end
9
+
10
+ def received_at
11
+ Time.parse params['ru_Trxtime']
12
+ end
13
+
14
+ def status
15
+
16
+ end
17
+
18
+ def transaction_id
19
+ params['r2_TrxId']
20
+ end
21
+
22
+ def type
23
+ params['r0_Cmd']
24
+ end
25
+
26
+ def gross
27
+ params['r3_Amt']
28
+ end
29
+
30
+ def fee
31
+
32
+ end
33
+
34
+ def currency
35
+ params['r4_Cur']
36
+ end
37
+
38
+ def item_id
39
+ params['r6_Order']
40
+ end
41
+
42
+ def invoice
43
+
44
+ end
45
+
46
+ def test?
47
+
48
+ end
49
+
50
+ def account
51
+ params['p1_MerId']
52
+ end
53
+
54
+ def acknowledge
55
+ hmac_md5_hexdigest == params['hmac']
56
+ end
57
+
58
+ def acknowledge_response
59
+ "success"
60
+ end
61
+
62
+ private
63
+ def hmac_md5_hexdigest
64
+ HMAC::MD5.hexdigest(KEY, %w(p1_MerId r0_Cmd r1_Code r2_TrxId r3_Amt r4_Cur r5_Pid r6_Order r7_Uid r8_MP r9_BType).collect{|name| params[name]}.join)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,18 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Yeepay
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ def success?
7
+ hmac_md5_hexdigest == params['hmac']
8
+ end
9
+
10
+ private
11
+ def hmac_md5_hexdigest
12
+ HMAC::MD5.hexdigest(KEY, %w(p1_MerId r0_Cmd r1_Code r2_TrxId r3_Amt r4_Cur r5_Pid r6_Order r7_Uid r8_MP r9_BType).collect{|name| params[name]}.join)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant_patch_for_china
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 6
10
+ version: 0.1.6
5
11
  platform: ruby
6
12
  authors:
7
13
  - Richard Huang
@@ -9,19 +15,25 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-16 00:00:00 +08:00
18
+ date: 2011-02-24 00:00:00 +08:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: activemerchant
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 2
23
34
  version: 1.4.2
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  description: A rails plugin to add an active_merchant patch for china online payment platform
26
38
  email: flyerhzm@gmail.com
27
39
  executables: []
@@ -31,12 +43,12 @@ extensions: []
31
43
  extra_rdoc_files:
32
44
  - README.textile
33
45
  files:
34
- - .gitignore
35
46
  - MIT-LICENSE
36
47
  - README.textile
37
48
  - Rakefile
38
49
  - VERSION
39
50
  - activemerchant_patch_for_china.gemspec
51
+ - init.rb
40
52
  - lib/active_merchant/billing/integrations/alipay.rb
41
53
  - lib/active_merchant/billing/integrations/alipay/helper.rb
42
54
  - lib/active_merchant/billing/integrations/alipay/notification.rb
@@ -44,13 +56,25 @@ files:
44
56
  - lib/active_merchant/billing/integrations/alipay/sign.rb
45
57
  - lib/active_merchant/billing/integrations/bill99.rb
46
58
  - lib/active_merchant/billing/integrations/bill99/helper.rb
59
+ - lib/active_merchant/billing/integrations/bill99/notification.rb
47
60
  - lib/active_merchant/billing/integrations/bill99/return.rb
61
+ - lib/active_merchant/billing/integrations/bill99_card.rb
62
+ - lib/active_merchant/billing/integrations/bill99_card/helper.rb
63
+ - lib/active_merchant/billing/integrations/bill99_card/notification.rb
64
+ - lib/active_merchant/billing/integrations/bill99_card/return.rb
65
+ - lib/active_merchant/billing/integrations/pay19.rb
66
+ - lib/active_merchant/billing/integrations/pay19/helper.rb
67
+ - lib/active_merchant/billing/integrations/pay19/notification.rb
68
+ - lib/active_merchant/billing/integrations/pay19/return.rb
48
69
  - lib/active_merchant/billing/integrations/tenpay.rb
49
70
  - lib/active_merchant/billing/integrations/tenpay/helper.rb
50
71
  - lib/active_merchant/billing/integrations/tenpay/return.rb
72
+ - lib/active_merchant/billing/integrations/yeepay.rb
73
+ - lib/active_merchant/billing/integrations/yeepay/helper.rb
74
+ - lib/active_merchant/billing/integrations/yeepay/notification.rb
75
+ - lib/active_merchant/billing/integrations/yeepay/return.rb
51
76
  - lib/activemerchant_patch_for_china.rb
52
77
  - lib/integrations_helper.rb
53
- - rails/init.rb
54
78
  - test/activemerchant_patch_for_china_test.rb
55
79
  - test/test_helper.rb
56
80
  has_rdoc: true
@@ -58,26 +82,32 @@ homepage: http://github.com/flyerhzm/activemerchant_patch_for_china
58
82
  licenses: []
59
83
 
60
84
  post_install_message:
61
- rdoc_options:
62
- - --charset=UTF-8
85
+ rdoc_options: []
86
+
63
87
  require_paths:
64
88
  - lib
65
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
66
91
  requirements:
67
92
  - - ">="
68
93
  - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
69
97
  version: "0"
70
- version:
71
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
72
100
  requirements:
73
101
  - - ">="
74
102
  - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
75
106
  version: "0"
76
- version:
77
107
  requirements: []
78
108
 
79
109
  rubyforge_project:
80
- rubygems_version: 1.3.5
110
+ rubygems_version: 1.5.2
81
111
  signing_key:
82
112
  specification_version: 3
83
113
  summary: A rails plugin to add an active_merchant patch for china online payment platform
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- pkg/*
data/rails/init.rb DELETED
@@ -1,2 +0,0 @@
1
- # Include hook code here
2
- require 'activemerchant_patch_for_china'