active_merchant_allpay 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee196458cee31d52bbdeec5ef7b2f7df7ca3bc13
4
- data.tar.gz: 075db62c77d3e9d07f699cd8619f92367717a465
3
+ metadata.gz: 3b5b7316493c8408a42d6151b32918d5fa129318
4
+ data.tar.gz: dee01594819a8ca7fab9be0588b12afb2d12911e
5
5
  SHA512:
6
- metadata.gz: f23496aca65532d1787206ede00c9ea913ff6101ce606c97f8a38979794063a126548126404b1033d50508bb986c1069c624ff3ff15aadc6156b4bbc0c96b5c5
7
- data.tar.gz: 8904df32ebc5217b00e0776cbe581edc8ad697969ec7ef59badbda43d3171ca17eb9226977e6ae79206ca97c1e9072178349b6e135a13b6b69a21ea33123e88e
6
+ metadata.gz: 5fb1819769610b827a56ae20e0586e64055b666b004f564045900946689fc778ac222ed4a07c523df4e011025b30a8ea30640602202701caadcd4d37d13a7509
7
+ data.tar.gz: 18a66c88a215458591c3717b383a5f6912027c24649cec6dd305a288863c1f6766b02a8f56492d0150983d1525b3a1dab528eb39a1fc734a1a98a938cced087f
data/README.md CHANGED
@@ -8,7 +8,7 @@ Now it supports Credit card(信用卡), ATM(虛擬ATM) and CVS(超商繳費).
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  gem 'activemerchant'
11
- gem 'active_merchant_allpay'
11
+ gem 'active_merchant_allpay', '>=0.1.2'
12
12
 
13
13
  And then execute:
14
14
 
@@ -74,7 +74,6 @@ Once you’ve configured ActiveMerchantAllpay, you need a checkout form; it look
74
74
  @order.user.email,
75
75
  :service => :allpay,
76
76
  :html => { :id => 'allpay-atm-form', :method => :post } do |service| %>
77
-
78
77
  <% service.merchant_trade_no @order.payments.last.identifier %>
79
78
  <% service.merchant_trade_date @order.created_at %>
80
79
  <% service.total_amount @order.total.to_i %>
@@ -19,4 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'activemerchant', '>= 1.9.4'
22
+
23
+ spec.add_development_dependency('rake')
24
+ spec.add_development_dependency('mocha', '~> 0.13.0')
25
+ spec.add_development_dependency('rails', '>= 2.3.14')
26
+ spec.add_development_dependency('thor')
22
27
  end
@@ -57,22 +57,9 @@ module ActiveMerchant #:nodoc:
57
57
 
58
58
  def encrypted_data
59
59
 
60
- hash_data = {
61
- :ChoosePayment => @fields['ChoosePayment'],
62
- :ClientBackURL => @fields['ClientBackURL'],
63
- :ItemName => @fields['ItemName'],
64
- :MerchantID => @fields['MerchantID'],
65
- :MerchantTradeDate => @fields['MerchantTradeDate'],
66
- :MerchantTradeNo => @fields['MerchantTradeNo'],
67
- :PaymentType => @fields['PaymentType'],
68
- :ReturnURL => @fields['ReturnURL'],
69
- :TotalAmount => @fields['TotalAmount'],
70
- :TradeDesc => @fields['TradeDesc']
71
- }
72
-
73
- raw_data = hash_data.map do |x, y|
74
- "#{x}=#{y}"
75
- end.join('&')
60
+ raw_data = @fields.sort.map{|field, value|
61
+ "#{field}=#{value}"
62
+ }.join('&')
76
63
 
77
64
  hash_raw_data = "HashKey=#{ActiveMerchant::Billing::Integrations::Allpay.hash_key}&#{raw_data}&HashIV=#{ActiveMerchant::Billing::Integrations::Allpay.hash_iv}"
78
65
 
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchantAllpay
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class AllpayModuleTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def test_notification_method
7
+ assert_instance_of Allpay::Notification, Allpay.notification('name=cody')
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class AllpayHelperTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def setup
7
+ end
8
+
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class AllpayNotificationTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def setup
7
+ @allpay = Allpay::Notification.new(http_raw_data)
8
+ end
9
+
10
+
11
+ end
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ begin
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ Bundler.setup
8
+ rescue LoadError => e
9
+ puts "Error loading bundler (#{e.message}): \"gem install bundler\" for bundler support."
10
+ end
11
+
12
+ require 'test/unit'
13
+ require 'money'
14
+ require 'mocha/version'
15
+ if(Mocha::VERSION.split(".")[1].to_i < 12)
16
+ require 'mocha'
17
+ else
18
+ require 'mocha/setup'
19
+ end
20
+ require 'yaml'
21
+ require 'json'
22
+ require 'active_merchant'
23
+ require 'comm_stub'
24
+
25
+ require 'active_support/core_ext/integer/time'
26
+ require 'active_support/core_ext/numeric/time'
27
+
28
+ begin
29
+ require 'active_support/core_ext/time/acts_like'
30
+ rescue LoadError
31
+ end
32
+
33
+ begin
34
+ gem 'actionpack'
35
+ rescue LoadError
36
+ raise StandardError, "The view tests need ActionPack installed as gem to run"
37
+ end
38
+
39
+ require 'action_controller'
40
+ require "action_view/template"
41
+ begin
42
+ require 'active_support/core_ext/module/deprecation'
43
+ require 'action_dispatch/testing/test_process'
44
+ rescue LoadError
45
+ require 'action_controller/test_process'
46
+ end
47
+ require 'active_merchant/billing/integrations/action_view_helper'
48
+
49
+ ActiveMerchant::Billing::Base.mode = :test
50
+
51
+ if ENV['DEBUG_ACTIVE_MERCHANT'] == 'true'
52
+ require 'logger'
53
+ ActiveMerchant::Billing::Gateway.logger = Logger.new(STDOUT)
54
+ ActiveMerchant::Billing::Gateway.wiredump_device = STDOUT
55
+ end
56
+
57
+ # Test gateways
58
+ class SimpleTestGateway < ActiveMerchant::Billing::Gateway
59
+ end
60
+
61
+ class SubclassGateway < SimpleTestGateway
62
+ end
63
+
64
+
65
+ module ActiveMerchant
66
+ module Assertions
67
+ AssertionClass = RUBY_VERSION > '1.9' ? MiniTest::Assertion : Test::Unit::AssertionFailedError
68
+
69
+ def assert_field(field, value)
70
+ clean_backtrace do
71
+ assert_equal value, @helper.fields[field]
72
+ end
73
+ end
74
+
75
+ # Allows the testing of you to check for negative assertions:
76
+ #
77
+ # # Instead of
78
+ # assert !something_that_is_false
79
+ #
80
+ # # Do this
81
+ # assert_false something_that_should_be_false
82
+ #
83
+ # An optional +msg+ parameter is available to help you debug.
84
+ def assert_false(boolean, message = nil)
85
+ message = build_message message, '<?> is not false or nil.', boolean
86
+
87
+ clean_backtrace do
88
+ assert_block message do
89
+ not boolean
90
+ end
91
+ end
92
+ end
93
+
94
+ # A handy little assertion to check for a successful response:
95
+ #
96
+ # # Instead of
97
+ # assert response.success?
98
+ #
99
+ # # DRY that up with
100
+ # assert_success response
101
+ #
102
+ # A message will automatically show the inspection of the response
103
+ # object if things go afoul.
104
+ def assert_success(response, message=nil)
105
+ clean_backtrace do
106
+ assert response.success?, build_message(nil, "#{message + "\n" if message}Response expected to succeed: <?>", response)
107
+ end
108
+ end
109
+
110
+ # The negative of +assert_success+
111
+ def assert_failure(response, message=nil)
112
+ clean_backtrace do
113
+ assert !response.success?, build_message(nil, "#{message + "\n" if message}Response expected to fail: <?>", response)
114
+ end
115
+ end
116
+
117
+ def assert_valid(validateable)
118
+ clean_backtrace do
119
+ assert validateable.valid?, "Expected to be valid"
120
+ end
121
+ end
122
+
123
+ def assert_not_valid(validateable)
124
+ clean_backtrace do
125
+ assert_false validateable.valid?, "Expected to not be valid"
126
+ end
127
+ end
128
+
129
+ def assert_deprecation_warning(message, target)
130
+ target.expects(:deprecated).with(message)
131
+ yield
132
+ end
133
+
134
+ def assert_no_deprecation_warning(target)
135
+ target.expects(:deprecated).never
136
+ yield
137
+ end
138
+
139
+ private
140
+ def clean_backtrace(&block)
141
+ yield
142
+ rescue AssertionClass => e
143
+ path = File.expand_path(__FILE__)
144
+ raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
145
+ end
146
+ end
147
+
148
+ module Fixtures
149
+ HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
150
+ LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
151
+ DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
152
+
153
+ private
154
+ def credit_card(number = '4242424242424242', options = {})
155
+ defaults = {
156
+ :number => number,
157
+ :month => 9,
158
+ :year => Time.now.year + 1,
159
+ :first_name => 'Longbob',
160
+ :last_name => 'Longsen',
161
+ :verification_value => '123',
162
+ :brand => 'visa'
163
+ }.update(options)
164
+
165
+ Billing::CreditCard.new(defaults)
166
+ end
167
+
168
+ def check(options = {})
169
+ defaults = {
170
+ :name => 'Jim Smith',
171
+ :bank_name => 'Bank of Elbonia',
172
+ :routing_number => '244183602',
173
+ :account_number => '15378535',
174
+ :account_holder_type => 'personal',
175
+ :account_type => 'checking',
176
+ :number => '1'
177
+ }.update(options)
178
+
179
+ Billing::Check.new(defaults)
180
+ end
181
+
182
+ def address(options = {})
183
+ {
184
+ :name => 'Jim Smith',
185
+ :address1 => '1234 My Street',
186
+ :address2 => 'Apt 1',
187
+ :company => 'Widgets Inc',
188
+ :city => 'Ottawa',
189
+ :state => 'ON',
190
+ :zip => 'K1C2N6',
191
+ :country => 'CA',
192
+ :phone => '(555)555-5555',
193
+ :fax => '(555)555-6666'
194
+ }.update(options)
195
+ end
196
+
197
+ def all_fixtures
198
+ @@fixtures ||= load_fixtures
199
+ end
200
+
201
+ def fixtures(key)
202
+ data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
203
+
204
+ data.dup
205
+ end
206
+
207
+ def load_fixtures
208
+ [DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name|
209
+ if File.exists?(file_name)
210
+ yaml_data = YAML.load(File.read(file_name))
211
+ credentials.merge!(symbolize_keys(yaml_data))
212
+ end
213
+ credentials
214
+ end
215
+ end
216
+
217
+ def symbolize_keys(hash)
218
+ return unless hash.is_a?(Hash)
219
+
220
+ hash.symbolize_keys!
221
+ hash.each{|k,v| symbolize_keys(v)}
222
+ end
223
+ end
224
+ end
225
+
226
+ Test::Unit::TestCase.class_eval do
227
+ include ActiveMerchant::Billing
228
+ include ActiveMerchant::Assertions
229
+ include ActiveMerchant::Utils
230
+ include ActiveMerchant::Fixtures
231
+ end
232
+
233
+ module ActionViewHelperTestHelper
234
+
235
+ def self.included(base)
236
+ base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)
237
+ base.send(:include, ActionView::Helpers::FormHelper)
238
+ base.send(:include, ActionView::Helpers::FormTagHelper)
239
+ base.send(:include, ActionView::Helpers::UrlHelper)
240
+ base.send(:include, ActionView::Helpers::TagHelper)
241
+ base.send(:include, ActionView::Helpers::CaptureHelper)
242
+ base.send(:include, ActionView::Helpers::TextHelper)
243
+ base.send(:attr_accessor, :output_buffer)
244
+ end
245
+
246
+ def setup
247
+ @controller = Class.new do
248
+ attr_reader :url_for_options
249
+ def url_for(options, *parameters_for_method_reference)
250
+ @url_for_options = options
251
+ end
252
+ end
253
+ @controller = @controller.new
254
+ @output_buffer = ''
255
+ end
256
+
257
+ protected
258
+ def protect_against_forgery?
259
+ false
260
+ end
261
+ end
metadata CHANGED
@@ -1,29 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_merchant_allpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - xwaynec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.9.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.9.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: mocha
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.3.14
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.3.14
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
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'
27
83
  description: A rails plugin to add active_merchant patch for Taiwan payment
28
84
  email:
29
85
  - xwaynec@gmail.com
@@ -31,7 +87,7 @@ executables: []
31
87
  extensions: []
32
88
  extra_rdoc_files: []
33
89
  files:
34
- - .gitignore
90
+ - ".gitignore"
35
91
  - Gemfile
36
92
  - LICENSE.txt
37
93
  - README.md
@@ -42,6 +98,10 @@ files:
42
98
  - lib/active_merchant/billing/integrations/allpay/notification.rb
43
99
  - lib/active_merchant_allpay.rb
44
100
  - lib/active_merchant_allpay/version.rb
101
+ - test/unit/integrations/allpay_module_test.rb
102
+ - test/unit/integrations/helpers/allpay_helper_test.rb
103
+ - test/unit/integrations/notifications/allpay_notification_test.rb
104
+ - test/unit/test_helper.rb
45
105
  homepage: https://github.com/xwaynec/active_merchant_allpay
46
106
  licenses:
47
107
  - MIT
@@ -52,19 +112,22 @@ require_paths:
52
112
  - lib
53
113
  required_ruby_version: !ruby/object:Gem::Requirement
54
114
  requirements:
55
- - - '>='
115
+ - - ">="
56
116
  - !ruby/object:Gem::Version
57
117
  version: '0'
58
118
  required_rubygems_version: !ruby/object:Gem::Requirement
59
119
  requirements:
60
- - - '>='
120
+ - - ">="
61
121
  - !ruby/object:Gem::Version
62
122
  version: '0'
63
123
  requirements: []
64
124
  rubyforge_project:
65
- rubygems_version: 2.1.9
125
+ rubygems_version: 2.2.2
66
126
  signing_key:
67
127
  specification_version: 4
68
128
  summary: A rails plugin to add active_merchant patch for Taiwan payment
69
- test_files: []
70
- has_rdoc:
129
+ test_files:
130
+ - test/unit/integrations/allpay_module_test.rb
131
+ - test/unit/integrations/helpers/allpay_helper_test.rb
132
+ - test/unit/integrations/notifications/allpay_notification_test.rb
133
+ - test/unit/test_helper.rb