suning_pay 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/suning_pay.rb ADDED
@@ -0,0 +1,96 @@
1
+ #encoding: utf-8
2
+ require 'uri'
3
+ require 'openssl'
4
+ require 'digest/md5'
5
+ require 'base64'
6
+
7
+ require "suning_pay/version"
8
+ require "suning_pay/rsa"
9
+ require "suning_pay/util"
10
+ require "suning_pay/service"
11
+ require "suning_pay/ent_service"
12
+ require "suning_pay/railtie" if defined?(Rails)
13
+
14
+ module SuningPay
15
+ @client_options = {}
16
+ @ent_options = {}
17
+ @debug_mode = true
18
+ @public_key_index = '0001'
19
+ @version = '1.0'
20
+ @input_charset = 'UTF-8'
21
+
22
+ API_CODE_PAY = 'PAY'
23
+ API_CODE_TRANSFER = 'TRAN'
24
+ API_CODE_Q_PAY = 'Q_PAY'
25
+ API_CODE_TRANSFER_CARD = 'TRAN_C'
26
+
27
+ class<< self
28
+ attr_accessor :merchant_no, :signature, :sign_algorithm, :submit_time, :debug_mode
29
+ attr_reader :api_base_url, :api_query_base_url, :api_tranfer_url, :api_card_tranfer_url
30
+ attr_reader :api_suning_cert, :api_suning_public_key, :api_client_public_key, :api_client_private_key
31
+
32
+ def api_base_url=(url)
33
+ @api_base_url = url
34
+ end
35
+
36
+ def api_query_base_url=(url)
37
+ @api_query_base_url = url
38
+ end
39
+
40
+ def api_tranfer_url=(url)
41
+ @api_tranfer_url = url
42
+ end
43
+
44
+ def api_card_tranfer_url=(url)
45
+ @api_card_tranfer_url = url
46
+ end
47
+
48
+ def api_suning_cert=(cert_path)
49
+ unless cert_path.blank?
50
+ cert = File.read cert_path
51
+ @api_suning_cert = OpenSSL::X509::Certificate.new(cert)
52
+ @api_suning_public_key = @api_suning_cert.public_key
53
+ end
54
+ end
55
+
56
+ def api_client_public_key=(key_path)
57
+ unless key_path.blank?
58
+ key = File.read key_path
59
+ @api_client_public_key = OpenSSL::PKey::RSA.new(key)
60
+ end
61
+ end
62
+
63
+ def api_client_private_key=(key_path)
64
+ unless key_path.blank?
65
+ key = File.read key_path
66
+ @api_client_private_key = OpenSSL::PKey::RSA.new(key)
67
+ end
68
+ end
69
+
70
+ def debug_mode?
71
+ @debug_mode
72
+ end
73
+
74
+ def client_options
75
+ options = {:merchantNo => @merchant_no,
76
+ :publicKeyIndex => @public_key_index,
77
+ :version => @version,
78
+ :inputCharset => @input_charset,
79
+ :submitTime => Time.now.strftime("%Y%m%d%H%M%S")
80
+ }
81
+
82
+ @client_options = options
83
+ @client_options
84
+ end
85
+
86
+ def ent_options
87
+ options = {:merchantNo => @merchant_no,
88
+ :publicKeyIndex => @public_key_index,
89
+ :inputCharset => @input_charset
90
+ }
91
+
92
+ @ent_options = options
93
+ @ent_options
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "suning_pay/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "suning_pay"
8
+ spec.version = SuningPay::VERSION
9
+ spec.authors = ["Terry.Tu"]
10
+ spec.email = ["tuminfei1981@gmail.com"]
11
+
12
+ spec.summary = %q{Suning Pay 1.1.2 doc.}
13
+ spec.description = %q{Suning Pay 1.1.2 doc.}
14
+ spec.homepage = "https://gitee.com/tarzansos"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.15"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "minitest", "~> 5.0"
36
+ spec.add_development_dependency "faraday", "~> 0.9.0"
37
+ end
data/suning_pay.rb ADDED
@@ -0,0 +1,28 @@
1
+ ##################TEST##################
2
+ #接口地址-委托代收
3
+ SuningPay.api_base_url = 'https://ebanksandbox.suning.com/epps-ebpg/api/contract/'
4
+ SuningPay.api_query_base_url = 'https://paymentsandbox.suning.com/epps-pag/apiGateway/merchantOrder/'
5
+ #接口地址-批量付款
6
+ SuningPay.api_tranfer_url = 'https://wagtestpre.suning.com/epps-twg/'
7
+ SuningPay.api_card_tranfer_url ='https://wagtestpre.suning.com/epps-wag/'
8
+ #客户号
9
+ SuningPay.merchant_no = '70057278'
10
+ #Suning证书存放路径
11
+ SuningPay.api_suning_cert = '/Users/terry/Documents/RUBY/hex/yifubao-pre.cer'
12
+ #客户端RSA 公钥,1024, pem文件路径
13
+ SuningPay.api_client_public_key = '/Users/terry/Documents/RUBY/hex/rsa_public_key.pem'
14
+ #客户端RSA 私钥,1024, pem文件路径
15
+ SuningPay.api_client_private_key = '/Users/terry/Documents/RUBY/hex/rsa_private_key.pem'
16
+
17
+ ##################PROD##################
18
+ #SuningPay.api_base_url = 'https://ebankpay.suning.com/epps-ebpg/api/contract/'
19
+ #SuningPay.api_query_base_url = 'https://payment.suning.com/epps-pag/apiGateway/merchantOrder/'
20
+ #SuningPay.api_tranfer_url = 'https://tag.yifubao.com/epps-twg/'
21
+ #SuningPay.api_card_tranfer_url ='https://wag.yifubao.com/epps-wag/'
22
+
23
+ #SuningPay.merchant_no = ''
24
+ #SuningPay.api_suning_cert = ''
25
+ #SuningPay.api_client_public_key = ''
26
+ #SuningPay.api_client_private_key = ''
27
+
28
+ #SuningPay.debug_mode = false
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: suning_pay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Terry.Tu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.0
69
+ description: Suning Pay 1.1.2 doc.
70
+ email:
71
+ - tuminfei1981@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".idea/inspectionProfiles/Project_Default.xml"
78
+ - ".idea/misc.xml"
79
+ - ".idea/modules.xml"
80
+ - ".idea/suning_pay.iml"
81
+ - ".idea/vcs.xml"
82
+ - ".idea/workspace.xml"
83
+ - ".travis.yml"
84
+ - CODE_OF_CONDUCT.md
85
+ - Gemfile
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - bin/console
90
+ - bin/setup
91
+ - bin/suning_pay
92
+ - lib/rake/suning_pay.rake
93
+ - lib/suning_pay.rb
94
+ - lib/suning_pay/ent_service.rb
95
+ - lib/suning_pay/railtie.rb
96
+ - lib/suning_pay/rsa.rb
97
+ - lib/suning_pay/service.rb
98
+ - lib/suning_pay/util.rb
99
+ - lib/suning_pay/version.rb
100
+ - suning_pay.gemspec
101
+ - suning_pay.rb
102
+ homepage: https://gitee.com/tarzansos
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.6
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Suning Pay 1.1.2 doc.
126
+ test_files: []