offsite_payments-integrations-smile_pay 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2200ba026a3aea76e2c64cffa92e942bf24efbb9
4
+ data.tar.gz: db1b411d3716480ffd929e5631088a9cd1fe03f2
5
+ SHA512:
6
+ metadata.gz: 13ab8e3fcb2a31fee72d40935f60f2c606d677b46be9cb30d24d8d882fc24393d3b09ed8e308645abeb0dbb6b95471688a7cd32497b16e00afa3d75a273cbf9f
7
+ data.tar.gz: d828bc4d19cc994a49eaef83aa96fdef33e2b5c392fc5ce56a04a7d98cc36903ad8685af6f2b143033706619a129221643cc1afb19a143cf614f8aaa36dcae21
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in .gemspec file
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 GoodLife
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ # OffsitePayments::SmilePay
2
+
3
+ 實作 OffsitePayments Integrations 介面串接 SmilePay 訊航科技的金流服務。這是非官方實作。
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'offsite_payments'
10
+ gem 'offsite_payments-integrations-smile_pay', github:'GoodLife/offsite_payments-integrations-smile_pay'
11
+
12
+ And then execute:
13
+
14
+ $ bundle install
15
+
16
+ ## Usage
17
+
18
+ 本實作 OffsitePayments 介面,使用者瀏覽器需在金流提供業者的網站下付款。
19
+
20
+ ## Contributing
21
+
22
+ 1. Fork it
23
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
24
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
25
+ 4. Push to the branch (`git push origin my-new-feature`)
26
+ 5. Create new Pull Request
@@ -0,0 +1,19 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ desc "Run the unit test suite"
6
+ task :default => 'test:units'
7
+
8
+ task :test => 'test:units'
9
+
10
+ namespace :test do
11
+
12
+ Rake::TestTask.new(:units) do |t|
13
+ t.pattern = 'test/unit/**/*_test.rb'
14
+ t.ruby_opts << '-rubygems'
15
+ t.libs << 'test'
16
+ t.verbose = true
17
+ end
18
+
19
+ end
@@ -0,0 +1,196 @@
1
+ require "offsite_payments"
2
+ require_relative "smile_pay/version"
3
+
4
+ module OffsitePayments #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module SmilePay
7
+
8
+ #mattr_accessor :service_url
9
+ mattr_accessor :production_url, :test_url
10
+
11
+ self.production_url = 'https://ssl.smse.com.tw/ezpos/mtmk_utf.asp'
12
+ self.test_url = 'https://ssl.smse.com.tw/ezpos_test/mtmk_utf.asp'
13
+
14
+ def self.service_url
15
+ case OffsitePayments.mode
16
+ when :production
17
+ self.production_url
18
+ when :test
19
+ self.test_url
20
+ else
21
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
22
+ end
23
+ end
24
+
25
+ def self.notification(post)
26
+ Notification.new(post)
27
+ end
28
+
29
+ def self.notification_confirmation_url
30
+ 'https://ssl.smse.com.tw/ezpos/roturl.asp'
31
+ end
32
+
33
+ class Helper < OffsitePayments::Helper
34
+ def initialize(order, account, options = {})
35
+ super
36
+
37
+ # 參數碼
38
+ add_field('Rvg2c', 1)
39
+ end
40
+
41
+ # 商家代號
42
+ mapping :account, 'Dcvc'
43
+ # 金額
44
+ mapping :amount, 'Amount'
45
+ # 訂單號碼
46
+ mapping :order, 'Data_id'
47
+ # 購買人(姓名改成單一欄位)
48
+ mapping :customer, :name => 'Pur_name',
49
+ :email => 'Email',
50
+ :phone => 'Tel_number',
51
+ :mobile_phone => 'Mobile_number' # Custom
52
+
53
+ # 地址(改成單一欄位)
54
+ mapping :shipping_address, 'Address'
55
+ # 備註
56
+ mapping :description, 'Remark'
57
+ # 交易完成後要回送的位置
58
+ mapping :notify_url, 'Roturl'
59
+ # 回送處理情形
60
+ mapping :notify_url_status, 'Roturl_status'
61
+
62
+
63
+ ### 以下為本服務特有欄位 Custom Fields
64
+
65
+ # 貨品名稱或貨品編號
66
+ mapping :sku, 'Od_sob'
67
+
68
+ # 收費模式
69
+ # 1. 線上刷卡
70
+ # 2. ATM / 轉帳匯款繳費
71
+ # 3. 超商代收
72
+ # 4. 7-11 ibon
73
+ # 5. 超商代收及 7-11 ibon
74
+ # 6. FamiPort
75
+ # 7. LifetET
76
+ # 8. 匯款、超商及 7-11 自訂繳款單模式
77
+ mapping :payment_method, 'Pay_zg'
78
+
79
+ # 繳款截止期限
80
+ mapping :deadline_date, 'Deadline_date'
81
+ mapping :deadline_time, 'Deadline_time'
82
+
83
+ # 語言模式
84
+ mapping :language, 'Pay_gdry'
85
+
86
+ #mapping :return_url, ''
87
+ #mapping :cancel_return_url, ''
88
+ #mapping :tax, ''
89
+ #mapping :shipping, ''
90
+
91
+ # 把 shipping address 轉成單一欄位
92
+ def shipping_address(params = {})
93
+ case params
94
+ when Hash
95
+ # TODO handle multi address input fields
96
+ address = params.values.join(',')
97
+ when String
98
+ address = params
99
+ end
100
+ add_field(mappings[:shipping_address], address)
101
+ end
102
+ end
103
+
104
+ class Notification < OffsitePayments::Notification
105
+ attr_accessor :custom_user_confirmation_param #商家認證參數
106
+
107
+ def complete?
108
+ if ['A','D'].include?(params['Classif'])
109
+ # Credit Card
110
+ return params['Response_id'] == '1'
111
+ else
112
+ # No status except for non credit card payments
113
+ true
114
+ end
115
+ end
116
+
117
+ def item_id
118
+ # 訂單號碼
119
+ params['Data_id']
120
+ end
121
+
122
+ def transaction_id
123
+ # Smile Pay 端訂單號碼
124
+ params['Smseid']
125
+ end
126
+
127
+ # When was this payment received by the client.
128
+ def received_at
129
+ params['Process_date'] + params['Process_time']
130
+ end
131
+
132
+ def payer_email
133
+ params['Email']
134
+ end
135
+
136
+ def receiver_email
137
+ nil
138
+ end
139
+
140
+ def security_key
141
+ # 驗證碼
142
+ params['Mid_smilepay']
143
+ end
144
+
145
+ # the money amount we received in X.2 decimal.
146
+ def gross
147
+ ::Money.new(params['Amount'].to_i * 100, currency)
148
+ end
149
+
150
+ # Was this a test transaction?
151
+ def test?
152
+ OffsitePayments.mode == :test
153
+ end
154
+
155
+ def status
156
+ params['Response_msg'] || 'Completed'
157
+ end
158
+
159
+ def currency
160
+ case params['Moneytype']
161
+ when 'TW'
162
+ 'TWD'
163
+ when 'CN'
164
+ 'CNY'
165
+ end
166
+ end
167
+
168
+ # SmilePay 沒有遠端驗證功能,
169
+ # 而以認證碼代替
170
+ def acknowledge
171
+ if test? # SmilePay 客服回答測試環境時認證碼只會傳0
172
+ true
173
+ else
174
+ # TODO 使用查詢功能實作 acknowledge
175
+ params['Mid_smilepay'].to_i == calculated_mid_smile_key
176
+ end
177
+ end
178
+
179
+ private
180
+
181
+ def calculated_mid_smile_key
182
+ b = "%08d" % (gross().dollars).to_i
183
+ c = params['Smseid'][-4..-1].gsub(/\D/,'9')
184
+ d = ( custom_user_confirmation_param() + b + c ).chars.to_a
185
+
186
+ # 偶數位數字(從左算起)
187
+ sum_even = d.values_at(* d.each_index.select(&:odd?)).compact.map(&:to_i).inject{|sum,x| sum + x }
188
+ # 奇數位數字(從左算起)
189
+ sum_odd = d.values_at(* d.each_index.select(&:even?)).compact.map(&:to_i).inject{|sum,x| sum + x }
190
+
191
+ sum_even * 3 + sum_odd * 9
192
+ end
193
+ end
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,7 @@
1
+ module OffsitePayments
2
+ module Integrations
3
+ module SmilePay
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -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 'offsite_payments/integrations/smile_pay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "offsite_payments-integrations-smile_pay"
8
+ spec.version = OffsitePayments::Integrations::SmilePay::VERSION
9
+ spec.authors = ["GoodLife", "lulalala"]
10
+ spec.email = ["mark@goodlife.tw"]
11
+ spec.description = %q{OffsitePayments for SmilePay 訊航科技, a Taiwan based payment gateway}
12
+ spec.summary = %q{OffsitePayments for SmilePay}
13
+ spec.homepage = "https://github.com/GoodLife/offsite_payments-integrations-smile_pay"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'offsite_payments', '~> 2.0', '>= 2.0.1'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency('test-unit', '~> 2.5.5')
26
+ spec.add_development_dependency('mocha', '~> 0.13.0')
27
+ spec.add_development_dependency('rails', '>= 3.2.14')
28
+ end
@@ -0,0 +1,203 @@
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
+
14
+ require 'money'
15
+ require 'mocha/version'
16
+ if(Mocha::VERSION.split(".")[1].to_i < 12)
17
+ require 'mocha'
18
+ else
19
+ require 'mocha/setup'
20
+ end
21
+ require 'yaml'
22
+ require 'json'
23
+
24
+ require 'active_support/core_ext/integer/time'
25
+ require 'active_support/core_ext/numeric/time'
26
+
27
+ begin
28
+ require 'active_support/core_ext/time/acts_like'
29
+ rescue LoadError
30
+ end
31
+
32
+ begin
33
+ gem 'actionpack'
34
+ rescue LoadError
35
+ raise StandardError, "The view tests need ActionPack installed as gem to run"
36
+ end
37
+
38
+ require 'action_controller'
39
+ #require "action_view/template"
40
+ begin
41
+ require 'active_support/core_ext/module/deprecation'
42
+ require 'action_dispatch/testing/test_process'
43
+ rescue LoadError
44
+ require 'action_controller/test_process'
45
+ end
46
+
47
+ require 'offsite_payments'
48
+ require 'offsite_payments/action_view_helper'
49
+ require 'offsite_payments/integrations/smile_pay'
50
+
51
+ OffsitePayments.mode = :test
52
+
53
+ module OffsitePayments
54
+ module Assertions
55
+ AssertionClass = Test::Unit::AssertionFailedError
56
+
57
+ def assert_field(field, value)
58
+ clean_backtrace do
59
+ assert_equal value, @helper.fields[field]
60
+ end
61
+ end
62
+
63
+ # Allows testing of negative assertions:
64
+ #
65
+ # # Instead of
66
+ # assert !something_that_is_false
67
+ #
68
+ # # Do this
69
+ # assert_false something_that_should_be_false
70
+ #
71
+ # An optional +msg+ parameter is available to help you debug.
72
+ def assert_false(boolean, message = nil)
73
+ message = build_message message, '<?> is not false or nil.', boolean
74
+
75
+ clean_backtrace do
76
+ assert_block message do
77
+ not boolean
78
+ end
79
+ end
80
+ end
81
+
82
+ # An assertion of a successful response:
83
+ #
84
+ # # Instead of
85
+ # assert response.success?
86
+ #
87
+ # # DRY that up with
88
+ # assert_success response
89
+ #
90
+ # A message will automatically show the inspection of the response
91
+ # object if things go afoul.
92
+ def assert_success(response, message=nil)
93
+ clean_backtrace do
94
+ assert response.success?, build_message(nil, "#{message + "\n" if message}Response expected to succeed: <?>", response)
95
+ end
96
+ end
97
+
98
+ # The negative of +assert_success+
99
+ def assert_failure(response, message=nil)
100
+ clean_backtrace do
101
+ assert !response.success?, build_message(nil, "#{message + "\n" if message}Response expected to fail: <?>", response)
102
+ end
103
+ end
104
+
105
+ def assert_valid(model)
106
+ errors = model.validate
107
+
108
+ clean_backtrace do
109
+ assert_equal({}, errors, "Expected to be valid")
110
+ end
111
+
112
+ errors
113
+ end
114
+
115
+ def assert_not_valid(model)
116
+ errors = model.validate
117
+
118
+ clean_backtrace do
119
+ assert_not_equal({}, errors, "Expected to not be valid")
120
+ end
121
+
122
+ errors
123
+ end
124
+
125
+ def assert_deprecation_warning(message)
126
+ OffsitePayments.expects(:deprecated).with(message)
127
+ yield
128
+ end
129
+
130
+ def silence_deprecation_warnings
131
+ OffsitePayments.stubs(:deprecated)
132
+ yield
133
+ end
134
+
135
+ def assert_no_deprecation_warning
136
+ OffsitePayments.expects(:deprecated).never
137
+ yield
138
+ end
139
+
140
+ private
141
+ def clean_backtrace(&block)
142
+ yield
143
+ rescue AssertionClass => e
144
+ path = File.expand_path(__FILE__)
145
+ raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
146
+ end
147
+ end
148
+
149
+ module Fixtures
150
+ HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
151
+ LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
152
+ DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
153
+
154
+ private
155
+
156
+ def address(options = {})
157
+ {
158
+ :name => 'Jim Smith',
159
+ :address1 => '1234 My Street',
160
+ :address2 => 'Apt 1',
161
+ :company => 'Widgets Inc',
162
+ :city => 'Ottawa',
163
+ :state => 'ON',
164
+ :zip => 'K1C2N6',
165
+ :country => 'CA',
166
+ :phone => '(555)555-5555',
167
+ :fax => '(555)555-6666'
168
+ }.update(options)
169
+ end
170
+
171
+ def generate_unique_id
172
+ SecureRandom.hex(16)
173
+ end
174
+
175
+ def all_fixtures
176
+ @@fixtures ||= load_fixtures
177
+ end
178
+
179
+ def fixtures(key)
180
+ data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
181
+
182
+ data.dup
183
+ end
184
+
185
+ def load_fixtures
186
+ [DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name|
187
+ if File.exists?(file_name)
188
+ yaml_data = YAML.load(File.read(file_name))
189
+ credentials.merge!(symbolize_keys(yaml_data))
190
+ end
191
+ credentials
192
+ end
193
+ end
194
+
195
+ def symbolize_keys(hash)
196
+ return unless hash.is_a?(Hash)
197
+
198
+ hash.symbolize_keys!
199
+ hash.each{|k,v| symbolize_keys(v)}
200
+ end
201
+ end
202
+ end
203
+
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ class SmilePayHelperTest < Test::Unit::TestCase
4
+ include OffsitePayments::Integrations
5
+ include OffsitePayments::Assertions
6
+
7
+ def setup
8
+ @helper = SmilePay::Helper.new('order-500','0000', :amount => 500, :currency => 'TWD')
9
+ end
10
+
11
+ def test_basic_helper_fields
12
+ assert_field 'Dcvc', '0000'
13
+
14
+ assert_field 'Amount', '500'
15
+ assert_field 'Data_id', 'order-500'
16
+ end
17
+
18
+ def test_customer_fields
19
+ @helper.customer :name => 'Cody Fauser', :email => 'cody@example.com'
20
+ assert_field 'Pur_name', 'Cody Fauser'
21
+ assert_field 'Email', 'cody@example.com'
22
+ end
23
+
24
+ def test_address_mapping
25
+ @helper.shipping_address 'address'
26
+ assert_field 'Address', 'address'
27
+ =begin
28
+ @helper.shipping_address :address1 => '1 My Street',
29
+ :address2 => '',
30
+ :city => 'Leeds',
31
+ :state => 'Yorkshire',
32
+ :zip => 'LS2 7EE',
33
+ :country => 'CA'
34
+
35
+ assert_field 'shipping_address', '1 My Street,,Yorkshire,LS2 7EE,CA'
36
+ =end
37
+ end
38
+
39
+ def test_unknown_mapping
40
+ assert_nothing_raised do
41
+ @helper.company_address :address => '500 Dwemthy Fox Road'
42
+ end
43
+ end
44
+
45
+ =begin
46
+ def test_setting_invalid_address_field
47
+ fields = @helper.fields.dup
48
+ @helper.billing_address :street => 'My Street'
49
+ assert_equal fields, @helper.fields
50
+ end
51
+ =end
52
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class SmilePayModuleTest < Test::Unit::TestCase
4
+ include OffsitePayments::Integrations
5
+
6
+ def test_notification_method
7
+ assert_instance_of SmilePay::Notification, SmilePay.notification('name=cody')
8
+ end
9
+ end
@@ -0,0 +1,77 @@
1
+ require 'test_helper'
2
+
3
+ class SmilePayNotificationTest < Test::Unit::TestCase
4
+ include OffsitePayments::Integrations
5
+
6
+ def setup
7
+ @smile_pay = SmilePay::Notification.new(http_raw_data)
8
+ @smile_pay.custom_user_confirmation_param = '1234'
9
+ end
10
+
11
+ def test_accessors
12
+ assert @smile_pay.complete?
13
+ assert_equal "Completed", @smile_pay.status
14
+ assert_equal "12_24_123", @smile_pay.transaction_id
15
+ assert_equal "888", @smile_pay.item_id
16
+ assert_equal Money.new(532 * 100,'TWD'), @smile_pay.gross
17
+ assert_equal "TWD", @smile_pay.currency
18
+ assert_equal "20130310140000", @smile_pay.received_at
19
+ assert @smile_pay.test?
20
+ end
21
+
22
+ def test_compositions
23
+ assert_equal Money.new(532 * 100, 'TWD'), @smile_pay.amount
24
+ end
25
+
26
+ # Replace with real successful acknowledgement code
27
+ def test_acknowledgement
28
+ OffsitePayments.mode = :production
29
+ assert @smile_pay.acknowledge
30
+ OffsitePayments.mode = :test
31
+ end
32
+
33
+ def test_send_acknowledgement
34
+ end
35
+
36
+ def test_respond_to_acknowledge
37
+ assert @smile_pay.respond_to?(:acknowledge)
38
+ end
39
+
40
+ def test_calculated_mid_smile_key
41
+ assert @smile_pay.send(:calculated_mid_smile_key), '213'
42
+ end
43
+
44
+ def test_credit_card_notification
45
+ raw_post = "Response_id=1&Moneytype=TW&Pur_name=&Classif=A&payment=3100&Od_sob=212515&customer_id=212515&billto=SmilePay&last_order=212515&customer_id=212515&Result=1&Purchamt=3100&Amount=3100&Data_id=212515&Process_date=2014%2F7%2F30&Process_time=15%3A02%3A7&Auth_code=123456&Tel_number=122141244&Mobile_number=122141244&Address=&Email=test%40example.com&Invoice_num=&Errdesc=&Smseid=7_30_1_1074870&Mid_smilepay=315&Remark=&Response_msg=%E5%B7%B2%E6%8E%88%E6%AC%8A"
46
+ @smile_pay = SmilePay::Notification.new(raw_post)
47
+ assert_equal true, @smile_pay.complete?
48
+ assert_equal '已授權', @smile_pay.status
49
+ end
50
+
51
+ def test_credit_card_notification_error
52
+ raw_post = "Response_id=0&Moneytype=TW&Pur_name=&Classif=A&payment=0&Od_sob=212512&customer_id=212512&billto=SmilePay&last_order=212512&customer_id=212512&Result=1&Purchamt=6200&Amount=0&Data_id=212512&Process_date=2014%2F7%2F30&Process_time=13%3A42%3A58&Auth_code=&Tel_number=122141244&Mobile_number=122141244&Address=&Email=test%40example.com&Invoice_num=&Errdesc=%288%3A57%29%E6%8B%92%E7%B5%95%E6%8C%81%E5%8D%A1%E8%80%85%E9%80%B2%E8%A1%8C%E8%A9%B2%E7%B6%B2%E8%B7%AF%E4%BA%A4%E6%98%93&Smseid=7_30_1_1074867&Mid_smilepay=357&Remark=&Response_msg=%E6%8E%88%E6%AC%8A%E5%A4%B1%E6%95%97"
53
+ @smile_pay = SmilePay::Notification.new(raw_post)
54
+ assert_equal false, @smile_pay.complete?
55
+ assert_equal '授權失敗', @smile_pay.status
56
+ end
57
+
58
+ def test_ibon
59
+ raw_post = "Classif=E&Od_sob=216&Data_id=216&Payment_no=21693575306&Process_date=2014/7/20&Process_time=08:19:45&Moneytype=TW&Purchamt=1570&Amount=1570&Response_id=1&Pur_name=&Tel_number=098800000&Mobile_number=098800000&Address=&Email=test@example.com&Invoice_num=&Smseid=7_19_1_0000000&LastPan=&Mid_smilepay=320&Auth_code=99999999999&Foreign=&Veirify_number=&Remark="
60
+ @smile_pay = SmilePay::Notification.new(raw_post)
61
+ assert_equal true, @smile_pay.complete?
62
+ assert_equal 'Completed', @smile_pay.status
63
+ end
64
+
65
+ private
66
+ def http_raw_data
67
+ %W{
68
+ Amount=532
69
+ Smseid=12_24_123
70
+ Data_id=888
71
+ Moneytype=TW
72
+ Process_date=20130310
73
+ Process_time=140000
74
+ Mid_smilepay=213
75
+ }.join('&')
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: offsite_payments-integrations-smile_pay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - GoodLife
8
+ - lulalala
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-08-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: offsite_payments
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.1
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '2.0'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: test-unit
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.5
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.5.5
76
+ - !ruby/object:Gem::Dependency
77
+ name: mocha
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.13.0
90
+ - !ruby/object:Gem::Dependency
91
+ name: rails
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.2.14
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.2.14
104
+ description: OffsitePayments for SmilePay 訊航科技, a Taiwan based payment gateway
105
+ email:
106
+ - mark@goodlife.tw
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - ".gitignore"
112
+ - Gemfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - lib/offsite_payments/integrations/smile_pay.rb
117
+ - lib/offsite_payments/integrations/smile_pay/version.rb
118
+ - offsite_payments-integrations-smile_pay.gemspec
119
+ - test/test_helper.rb
120
+ - test/unit/integrations/smile_pay/smile_pay_helper_test.rb
121
+ - test/unit/integrations/smile_pay/smile_pay_module_test.rb
122
+ - test/unit/integrations/smile_pay/smile_pay_notification_test.rb
123
+ homepage: https://github.com/GoodLife/offsite_payments-integrations-smile_pay
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.2.2
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: OffsitePayments for SmilePay
147
+ test_files:
148
+ - test/test_helper.rb
149
+ - test/unit/integrations/smile_pay/smile_pay_helper_test.rb
150
+ - test/unit/integrations/smile_pay/smile_pay_module_test.rb
151
+ - test/unit/integrations/smile_pay/smile_pay_notification_test.rb