fakesite-alipay 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9417cd9d34c4161a894206894c2fc0ea5aff54d8
4
+ data.tar.gz: 1421734a31ddea9347d8cbb4b54a2b4f18138979
5
+ SHA512:
6
+ metadata.gz: dd96e5f12a2b7a576ff7def73af308bbec251475c87f9ebc6d76a65dd13404c17cbc9241bde832c41870e0366821defac585459b86920b7eaa7c40eabbda4548
7
+ data.tar.gz: 0f806873ac178dc44cff139ce94e021b17777c89b35301a6f17b6a85fb72e694d4bf2624237cd33363baa8c9a5be5a3e4e2ba594f799534230adce4fab2bda4e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler
5
+ branches:
6
+ only:
7
+ - master
8
+ env:
9
+ - COVERALLS=1
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # v0.1.1 / 2015-10-12
2
+
3
+ Fixed timezone in +8.
4
+
5
+ # v0.1.0 / 2015-10-08
6
+
7
+ Create project
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fakesite-alipay.gemspec
4
+ gemspec
5
+
6
+ gem 'simplecov', :require => false
7
+ gem 'coveralls', :require => false
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Chen Yi-Cyuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # fakesite-alipay
2
+
3
+ [![Build Status](https://api.travis-ci.org/emn178/fakesite-alipay.png)](https://travis-ci.org/emn178/fakesite-alipay)
4
+ [![Coverage Status](https://coveralls.io/repos/emn178/fakesite-alipay/badge.svg?branch=master)](https://coveralls.io/r/emn178/fakesite-alipay?branch=master)
5
+
6
+ A [fakesite](https://github.com/emn178/fakesite) plugin that provides a stub method for alipay. It's useful to bypass payment flow in develpment environment.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'fakesite-alipay', group: :development
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ ### Route
21
+
22
+ Make sure that you have added fakesite route in your `config/route.rb`
23
+ ```Ruby
24
+ mount Fakesite::Engine => "/fakesite" if Rails.env.development?
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Add registration to `config/initializers/fakesite.rb`
30
+ ```Ruby
31
+ if Rails.env.development?
32
+ WebMock.allow_net_connect!
33
+ Fakesite.register Fakesite::Alipay::Base.new({:pid => 'PID', :key => 'KEY'})
34
+ end
35
+ ```
36
+ `PID` and `KEY` could be fake, but they have to be equal to the settings of library (eg. Gem `alipay`) that you use to request Alipay.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
42
+ ## Contact
43
+
44
+ The project's website is located at https://github.com/emn178/fakesite-alipay
45
+ Author: emn178@gmail.com
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fakesite/alipay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fakesite-alipay"
8
+ spec.version = Fakesite::Alipay::VERSION
9
+ spec.authors = ["Chen Yi-Cyuan"]
10
+ spec.email = ["emn178@gmail.com"]
11
+
12
+ spec.summary = %q{A fakesite plugin that provides a stub method for alipay.}
13
+ spec.description = %q{A fakesite plugin that provides a stub method for alipay.}
14
+ spec.homepage = "https://github.com/emn178/fakesite-alipay"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "fakesite"
21
+ spec.add_dependency "webmock"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec-its"
27
+ spec.add_development_dependency "alipay"
28
+ end
@@ -0,0 +1,10 @@
1
+ require "webmock"
2
+ require "fakesite"
3
+ require "fakesite/alipay/version"
4
+ require "fakesite/alipay/base"
5
+
6
+ module Fakesite
7
+ module Alipay
8
+ Host = 'mapi.alipay.com'
9
+ end
10
+ end
@@ -0,0 +1,46 @@
1
+ module Fakesite
2
+ module Alipay
3
+ class Base < Fakesite::Base
4
+ include WebMock::API
5
+
6
+ @@stubbed = false
7
+
8
+ def initialize(options = {})
9
+ unless @@stubbed
10
+ @@stubbed = true
11
+ stub_request(:get, 'https://' + Host + '/gateway.do')
12
+ .with(:query => hash_including({:service => 'notify_verify'}))
13
+ .to_return(:status => 200, :body => "true")
14
+ end
15
+ super(options)
16
+ end
17
+
18
+ def id
19
+ :alipay
20
+ end
21
+
22
+ def match(external_uri)
23
+ external_uri.host == Host
24
+ end
25
+
26
+ def parameters(external_uri)
27
+ {
28
+ "trade_status" => 'TRADE_SUCCESS',
29
+ "trade_no" => Time.now.to_i.to_s,
30
+ "notify_id" => Time.now.to_i.to_s,
31
+ "buyer_email" => "",
32
+ "buyer_id" => "",
33
+ "exterface" => "create_direct_pay_by_user",
34
+ "notify_time" => (Time.now.utc + 28800).strftime("%Y-%m-%d %H:%M:%S")
35
+ }
36
+ end
37
+
38
+ def return_parameters(params)
39
+ string = params.sort.map { |item| item.join('=') }.join('&')
40
+ params["sign"] = Digest::MD5.hexdigest("#{string}#{@options[:key]}")
41
+ params["sign_type"] = "MD5"
42
+ return params
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Fakesite
2
+ module Alipay
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fakesite-alipay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chen Yi-Cyuan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fakesite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-its
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: alipay
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A fakesite plugin that provides a stub method for alipay.
112
+ email:
113
+ - emn178@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CHANGELOG.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - fakesite-alipay.gemspec
127
+ - lib/fakesite/alipay.rb
128
+ - lib/fakesite/alipay/base.rb
129
+ - lib/fakesite/alipay/version.rb
130
+ homepage: https://github.com/emn178/fakesite-alipay
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: A fakesite plugin that provides a stub method for alipay.
154
+ test_files: []