offsite_payments_pay2go 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +134 -0
- data/LICENSE.txt +21 -0
- data/README.md +28 -0
- data/Rakefile +17 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/offsite_payments/integrations/pay2go.rb +297 -0
- data/lib/offsite_payments_pay2go.rb +8 -0
- data/lib/offsite_payments_pay2go/version.rb +3 -0
- data/offsite_payments_pay2go.gemspec +42 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17bc7be70ded1c3fd6045587e7813a9a9c9b4f0c
|
4
|
+
data.tar.gz: 69c2f763aebd5dacb6e209bfee4b3fa8d348e6fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6d0f95efe41dcd1c4658d15205efb5fec833ccdd0f259c1e3c7d5615a907aa6058e8fad8d2ee4fdddd8e5bffe18291b9c1ba75e8be2fbd350c175f2ba2df53f
|
7
|
+
data.tar.gz: 787dc54e0b52f904da74a85edb47f81d3151a7da448c255d930a5e5bc0b9a87c3743f5c3bf0a522f0838409bd78671b07f75bcbb97c98be4e5f6b91a602df2a3
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at solve153@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
offsite_payments_pay2go (0.1.0)
|
5
|
+
money (>= 6)
|
6
|
+
offsite_payments (>= 2.7)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.2.11.1)
|
12
|
+
actionpack (= 4.2.11.1)
|
13
|
+
actionview (= 4.2.11.1)
|
14
|
+
activejob (= 4.2.11.1)
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
16
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
+
actionpack (4.2.11.1)
|
18
|
+
actionview (= 4.2.11.1)
|
19
|
+
activesupport (= 4.2.11.1)
|
20
|
+
rack (~> 1.6)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
+
actionview (4.2.11.1)
|
25
|
+
activesupport (= 4.2.11.1)
|
26
|
+
builder (~> 3.1)
|
27
|
+
erubis (~> 2.7.0)
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
30
|
+
active_utils (3.3.16)
|
31
|
+
activesupport (>= 4.2)
|
32
|
+
i18n
|
33
|
+
activejob (4.2.11.1)
|
34
|
+
activesupport (= 4.2.11.1)
|
35
|
+
globalid (>= 0.3.0)
|
36
|
+
activemodel (4.2.11.1)
|
37
|
+
activesupport (= 4.2.11.1)
|
38
|
+
builder (~> 3.1)
|
39
|
+
activerecord (4.2.11.1)
|
40
|
+
activemodel (= 4.2.11.1)
|
41
|
+
activesupport (= 4.2.11.1)
|
42
|
+
arel (~> 6.0)
|
43
|
+
activesupport (4.2.11.1)
|
44
|
+
i18n (~> 0.7)
|
45
|
+
minitest (~> 5.1)
|
46
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
47
|
+
tzinfo (~> 1.1)
|
48
|
+
arel (6.0.4)
|
49
|
+
builder (3.2.3)
|
50
|
+
concurrent-ruby (1.1.5)
|
51
|
+
crass (1.0.4)
|
52
|
+
erubis (2.7.0)
|
53
|
+
globalid (0.4.2)
|
54
|
+
activesupport (>= 4.2.0)
|
55
|
+
i18n (0.9.5)
|
56
|
+
concurrent-ruby (~> 1.0)
|
57
|
+
loofah (2.2.3)
|
58
|
+
crass (~> 1.0.2)
|
59
|
+
nokogiri (>= 1.5.9)
|
60
|
+
mail (2.7.1)
|
61
|
+
mini_mime (>= 0.1.1)
|
62
|
+
metaclass (0.0.4)
|
63
|
+
mini_mime (1.0.1)
|
64
|
+
mini_portile2 (2.4.0)
|
65
|
+
minitest (5.11.3)
|
66
|
+
mocha (1.8.0)
|
67
|
+
metaclass (~> 0.0.1)
|
68
|
+
money (6.13.3)
|
69
|
+
i18n (>= 0.6.4, <= 2)
|
70
|
+
nokogiri (1.9.1)
|
71
|
+
mini_portile2 (~> 2.4.0)
|
72
|
+
offsite_payments (2.7.11)
|
73
|
+
actionpack (>= 3.2.20, < 6.0)
|
74
|
+
active_utils (~> 3.3.0)
|
75
|
+
activesupport (>= 3.2.14)
|
76
|
+
builder (>= 2.1.2, < 4.0.0)
|
77
|
+
i18n (>= 0.6.6)
|
78
|
+
nokogiri (~> 1.6)
|
79
|
+
power_assert (1.1.4)
|
80
|
+
rack (1.6.11)
|
81
|
+
rack-test (0.6.3)
|
82
|
+
rack (>= 1.0)
|
83
|
+
rails (4.2.11.1)
|
84
|
+
actionmailer (= 4.2.11.1)
|
85
|
+
actionpack (= 4.2.11.1)
|
86
|
+
actionview (= 4.2.11.1)
|
87
|
+
activejob (= 4.2.11.1)
|
88
|
+
activemodel (= 4.2.11.1)
|
89
|
+
activerecord (= 4.2.11.1)
|
90
|
+
activesupport (= 4.2.11.1)
|
91
|
+
bundler (>= 1.3.0, < 2.0)
|
92
|
+
railties (= 4.2.11.1)
|
93
|
+
sprockets-rails
|
94
|
+
rails-deprecated_sanitizer (1.0.3)
|
95
|
+
activesupport (>= 4.2.0.alpha)
|
96
|
+
rails-dom-testing (1.0.9)
|
97
|
+
activesupport (>= 4.2.0, < 5.0)
|
98
|
+
nokogiri (~> 1.6)
|
99
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
100
|
+
rails-html-sanitizer (1.0.4)
|
101
|
+
loofah (~> 2.2, >= 2.2.2)
|
102
|
+
railties (4.2.11.1)
|
103
|
+
actionpack (= 4.2.11.1)
|
104
|
+
activesupport (= 4.2.11.1)
|
105
|
+
rake (>= 0.8.7)
|
106
|
+
thor (>= 0.18.1, < 2.0)
|
107
|
+
rake (12.3.2)
|
108
|
+
sprockets (3.7.2)
|
109
|
+
concurrent-ruby (~> 1.0)
|
110
|
+
rack (> 1, < 3)
|
111
|
+
sprockets-rails (3.2.1)
|
112
|
+
actionpack (>= 4.0)
|
113
|
+
activesupport (>= 4.0)
|
114
|
+
sprockets (>= 3.0.0)
|
115
|
+
test-unit (3.3.3)
|
116
|
+
power_assert
|
117
|
+
thor (0.20.3)
|
118
|
+
thread_safe (0.3.6)
|
119
|
+
tzinfo (1.2.5)
|
120
|
+
thread_safe (~> 0.1)
|
121
|
+
|
122
|
+
PLATFORMS
|
123
|
+
ruby
|
124
|
+
|
125
|
+
DEPENDENCIES
|
126
|
+
bundler
|
127
|
+
mocha (~> 1.0)
|
128
|
+
offsite_payments_pay2go!
|
129
|
+
rails (>= 3.2.14)
|
130
|
+
rake
|
131
|
+
test-unit (~> 3.0)
|
132
|
+
|
133
|
+
BUNDLED WITH
|
134
|
+
1.14.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 stan
|
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,28 @@
|
|
1
|
+
# OffsitePaymentsPay2go
|
2
|
+
|
3
|
+
OffsitePayments Integrations 介面串接 pay2go 的金流服務。這是非官方實作。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
|
10
|
+
gem 'offsite_payments'
|
11
|
+
gem 'offsite_payments_pay2go', github: 'GoodLife/offsite_payments_pay2go.git'
|
12
|
+
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
實作 OffsitePayments 介面,使用者瀏覽器需在金流提供業者的網站下付款。
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
+
Rake::TestTask.new(:units) do |t|
|
12
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "offsite_payments_pay2go"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
require "offsite_payments"
|
2
|
+
|
3
|
+
module OffsitePayments #:nodoc:
|
4
|
+
module Integrations #:nodoc:
|
5
|
+
module Pay2go
|
6
|
+
mattr_accessor :service_url
|
7
|
+
mattr_accessor :merchant_id
|
8
|
+
mattr_accessor :hash_key
|
9
|
+
mattr_accessor :hash_iv
|
10
|
+
mattr_accessor :debug
|
11
|
+
|
12
|
+
def self.service_url
|
13
|
+
mode = OffsitePayments.mode
|
14
|
+
case mode
|
15
|
+
when :production
|
16
|
+
'https://core.spgateway.com/MPG/mpg_gateway'
|
17
|
+
when :development
|
18
|
+
'https://ccore.spgateway.com/MPG/mpg_gateway'
|
19
|
+
when :test
|
20
|
+
'https://ccore.spgateway.com/MPG/mpg_gateway'
|
21
|
+
else
|
22
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.notification(post)
|
27
|
+
Notification.new(post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.setup
|
31
|
+
yield(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.fetch_url_encode_data(fields)
|
35
|
+
check_fields = [:"Amt", :"MerchantID", :"MerchantOrderNo", :"TimeStamp", :"Version"]
|
36
|
+
raw_data = fields.sort.map{|field, value|
|
37
|
+
"#{field}=#{value}" if check_fields.include?(field.to_sym)
|
38
|
+
}.compact.join('&')
|
39
|
+
|
40
|
+
hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}"
|
41
|
+
|
42
|
+
sha256 = Digest::SHA256.new
|
43
|
+
sha256.update hash_raw_data.force_encoding("utf-8")
|
44
|
+
sha256.hexdigest.upcase
|
45
|
+
end
|
46
|
+
|
47
|
+
class Helper < OffsitePayments::Helper
|
48
|
+
def initialize(order, account, options = {})
|
49
|
+
super
|
50
|
+
add_field 'MerchantID', merchant_id
|
51
|
+
end
|
52
|
+
|
53
|
+
### 常見介面
|
54
|
+
# 廠商編號
|
55
|
+
mapping :merchant_id, 'MerchantID'
|
56
|
+
mapping :account, 'MerchantID' # AM common
|
57
|
+
# 回傳格式
|
58
|
+
mapping :respond_type, 'RespondType'
|
59
|
+
# 時間戳記
|
60
|
+
mapping :time_stamp, 'TimeStamp'
|
61
|
+
# 串接程式版本
|
62
|
+
mapping :version, 'Version'
|
63
|
+
# 語系 (no required)
|
64
|
+
mapping :lang_type, 'LangType'
|
65
|
+
# 廠商交易編號
|
66
|
+
mapping :merchant_order_no, 'MerchantOrderNo'
|
67
|
+
mapping :order, 'MerchantOrderNo' # AM common
|
68
|
+
# 交易金額(幣別:新台幣)
|
69
|
+
mapping :amt, 'Amt'
|
70
|
+
mapping :amount, 'Amt' # AM common
|
71
|
+
# 商品資訊(限制長度50字)
|
72
|
+
mapping :item_desc, 'ItemDesc'
|
73
|
+
# 交易限制秒數,下限是 60 秒,上限 900 秒 (no required)
|
74
|
+
mapping :trade_limit, 'TradeLimit'
|
75
|
+
# 繳費有限期限,格式範例:20140620
|
76
|
+
mapping :expire_date, 'ExpireDate'
|
77
|
+
# 支付完成返回商店網址(沒給會留在智付寶畫面)
|
78
|
+
mapping :return_url, 'ReturnURL'
|
79
|
+
# 支付通知網址
|
80
|
+
mapping :notify_url, 'NotifyURL'
|
81
|
+
# 商店取號網址(沒給的話取號後會留在智付寶畫面)
|
82
|
+
mapping :customer_url, 'CustomerURL'
|
83
|
+
# 支付取消返回商店網址(交易取消後平台會出現返回鈕)
|
84
|
+
mapping :client_back_url, 'ClientBackURL'
|
85
|
+
# 付款人電子信箱
|
86
|
+
mapping :email, 'Email'
|
87
|
+
# 付款人電子信箱是否開放修改(預設為可修改,給0, 1)
|
88
|
+
mapping :email_odify, 'EmailModify'
|
89
|
+
# 智付寶會員(預設1則需要登入智付寶)
|
90
|
+
mapping :login_type, 'LoginType'
|
91
|
+
# 商店備註
|
92
|
+
mapping :order_comment, 'OrderComment'
|
93
|
+
# 信用卡一次付清啟用(1為啟用)
|
94
|
+
mapping :credit, 'CREDIT'
|
95
|
+
# 信用卡紅利啟用(1為啟用)
|
96
|
+
mapping :credit_red, 'CreditRed'
|
97
|
+
# 信用卡分期付款啟用
|
98
|
+
mapping :inst_flag, 'InstFlag'
|
99
|
+
# 信用卡銀聯卡啟用
|
100
|
+
mapping :union_pay, 'UNIONPAY'
|
101
|
+
# WebATM 啟用
|
102
|
+
mapping :web_atm, 'WEBATM'
|
103
|
+
# ATM 轉帳啟用
|
104
|
+
mapping :vacc, 'VACC'
|
105
|
+
# 超商代碼繳費啟用
|
106
|
+
mapping :cvs, 'CVS'
|
107
|
+
# 條碼繳費啟用
|
108
|
+
mapping :barcode, 'BARCODE'
|
109
|
+
# 自訂支付啟用
|
110
|
+
mapping :custom, 'CUSTOM'
|
111
|
+
# 付款人綁定資料(快速結帳參數)
|
112
|
+
mapping :token_term, 'TokenTerm'
|
113
|
+
|
114
|
+
def encrypted_data
|
115
|
+
url_encrypted_data = OffsitePayments::Integrations::Pay2go.fetch_url_encode_data(@fields)
|
116
|
+
|
117
|
+
add_field 'CheckValue', url_encrypted_data
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
class Notification < OffsitePayments::Notification
|
123
|
+
attr_accessor :_params
|
124
|
+
|
125
|
+
def _params
|
126
|
+
if @_params.nil?
|
127
|
+
if @params.key?("JSONData") # json response type
|
128
|
+
# puts params['JSONData'].to_s
|
129
|
+
@_params = JSON.parse(@params['JSONData'].to_s)
|
130
|
+
# puts JSON.parse(@_params['Result'])['Amt']
|
131
|
+
@_params = @_params.merge(JSON.parse(@_params['Result']))
|
132
|
+
else # string response type
|
133
|
+
@_params = @params
|
134
|
+
end
|
135
|
+
end
|
136
|
+
@_params
|
137
|
+
end
|
138
|
+
|
139
|
+
# TODO 使用查詢功能實作 acknowledge
|
140
|
+
# 而以 checksum_ok? 代替
|
141
|
+
def acknowledge
|
142
|
+
checksum_ok?
|
143
|
+
end
|
144
|
+
|
145
|
+
def complete?
|
146
|
+
case status
|
147
|
+
when 'SUCCESS' # 付款/取號成功
|
148
|
+
true
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def checksum_ok?
|
153
|
+
params_copy = _params.clone
|
154
|
+
|
155
|
+
check_fields = [:"Amt", :"MerchantID", :"MerchantOrderNo", :"TradeNo"]
|
156
|
+
raw_data = params_copy.sort.map{|field, value|
|
157
|
+
"#{field}=#{value}" if check_fields.include?(field.to_sym)
|
158
|
+
}.compact.join('&')
|
159
|
+
|
160
|
+
hash_raw_data = "HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}"
|
161
|
+
|
162
|
+
sha256 = Digest::SHA256.new
|
163
|
+
sha256.update hash_raw_data.force_encoding("utf-8")
|
164
|
+
(sha256.hexdigest.upcase == check_code.to_s)
|
165
|
+
end
|
166
|
+
|
167
|
+
def status
|
168
|
+
_params['Status']
|
169
|
+
end
|
170
|
+
|
171
|
+
def message
|
172
|
+
URI.decode(_params['Message'])
|
173
|
+
end
|
174
|
+
|
175
|
+
def merchant_id
|
176
|
+
_params['MerchantID']
|
177
|
+
end
|
178
|
+
|
179
|
+
def amt
|
180
|
+
_params['Amt'].to_s
|
181
|
+
end
|
182
|
+
|
183
|
+
# 訂單號碼
|
184
|
+
def item_id
|
185
|
+
merchant_order_no
|
186
|
+
end
|
187
|
+
|
188
|
+
# Pay2go 端訂單號碼
|
189
|
+
def transaction_id
|
190
|
+
trade_no
|
191
|
+
end
|
192
|
+
|
193
|
+
def trade_no
|
194
|
+
_params['TradeNo']
|
195
|
+
end
|
196
|
+
|
197
|
+
def merchant_order_no
|
198
|
+
_params['MerchantOrderNo']
|
199
|
+
end
|
200
|
+
|
201
|
+
def payment_type
|
202
|
+
_params['PaymentType']
|
203
|
+
end
|
204
|
+
|
205
|
+
def respond_type
|
206
|
+
_params['RespondType']
|
207
|
+
end
|
208
|
+
|
209
|
+
def check_code
|
210
|
+
_params['CheckCode']
|
211
|
+
end
|
212
|
+
|
213
|
+
def pay_time
|
214
|
+
URI.decode(_params['PayTime']).gsub("+", " ")
|
215
|
+
end
|
216
|
+
|
217
|
+
def ip
|
218
|
+
_params['IP']
|
219
|
+
end
|
220
|
+
|
221
|
+
def escrow_bank
|
222
|
+
_params['EscrowBank']
|
223
|
+
end
|
224
|
+
|
225
|
+
# credit card
|
226
|
+
def respond_code
|
227
|
+
_params['RespondCode']
|
228
|
+
end
|
229
|
+
|
230
|
+
def auth
|
231
|
+
_params['Auth']
|
232
|
+
end
|
233
|
+
|
234
|
+
def card_6no
|
235
|
+
_params['Card6No']
|
236
|
+
end
|
237
|
+
|
238
|
+
def card_4no
|
239
|
+
_params['Card4No']
|
240
|
+
end
|
241
|
+
|
242
|
+
def inst
|
243
|
+
_params['Inst']
|
244
|
+
end
|
245
|
+
|
246
|
+
def inst_first
|
247
|
+
_params['InstFirst']
|
248
|
+
end
|
249
|
+
|
250
|
+
def inst_each
|
251
|
+
_params['InstEach']
|
252
|
+
end
|
253
|
+
|
254
|
+
def eci
|
255
|
+
_params['ECI']
|
256
|
+
end
|
257
|
+
|
258
|
+
def token_use_status
|
259
|
+
_params['TokenUseStatus']
|
260
|
+
end
|
261
|
+
|
262
|
+
# web atm, atm
|
263
|
+
def pay_bank_code
|
264
|
+
_params['PayBankCode']
|
265
|
+
end
|
266
|
+
|
267
|
+
def payer_account_5code
|
268
|
+
_params['PayerAccount5Code']
|
269
|
+
end
|
270
|
+
|
271
|
+
# cvs
|
272
|
+
def code_no
|
273
|
+
_params['CodeNo']
|
274
|
+
end
|
275
|
+
|
276
|
+
# barcode
|
277
|
+
def barcode_1
|
278
|
+
_params['Barcode_1']
|
279
|
+
end
|
280
|
+
|
281
|
+
def barcode_2
|
282
|
+
_params['Barcode_2']
|
283
|
+
end
|
284
|
+
|
285
|
+
def barcode_3
|
286
|
+
_params['Barcode_3']
|
287
|
+
end
|
288
|
+
|
289
|
+
# other about serials
|
290
|
+
def expire_date
|
291
|
+
_params['ExpireDate']
|
292
|
+
end
|
293
|
+
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "offsite_payments_pay2go/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "offsite_payments_pay2go"
|
7
|
+
spec.version = OffsitePaymentsPay2go::VERSION
|
8
|
+
spec.authors = ["hothero", "hrs", "stan"]
|
9
|
+
spec.email = ["hothero0705@gmail.com", "hrs113355@gmail.com", "solve153@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{OffsitePayments for Pay2go, a Taiwan based payment gateway}
|
12
|
+
spec.description = %q{OffsitePayments for Pay2go}
|
13
|
+
spec.homepage = "https://github.com/GoodLife/offsite_payments_pay2go"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
else
|
23
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
|
+
"public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_runtime_dependency 'money', '>= 6'
|
35
|
+
spec.add_runtime_dependency 'offsite_payments', '>= 2.7'
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "rake"
|
39
|
+
spec.add_development_dependency "test-unit", "~> 3.0"
|
40
|
+
spec.add_development_dependency "mocha", "~> 1.0"
|
41
|
+
spec.add_development_dependency "rails", ">= 3.2.14"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: offsite_payments_pay2go
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hothero
|
8
|
+
- hrs
|
9
|
+
- stan
|
10
|
+
autorequire:
|
11
|
+
bindir: exe
|
12
|
+
cert_chain: []
|
13
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: money
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '6'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: offsite_payments
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '2.7'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.7'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: test-unit
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: mocha
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rails
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 3.2.14
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.2.14
|
113
|
+
description: OffsitePayments for Pay2go
|
114
|
+
email:
|
115
|
+
- hothero0705@gmail.com
|
116
|
+
- hrs113355@gmail.com
|
117
|
+
- solve153@gmail.com
|
118
|
+
executables: []
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".gitignore"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/console
|
130
|
+
- bin/setup
|
131
|
+
- lib/offsite_payments/integrations/pay2go.rb
|
132
|
+
- lib/offsite_payments_pay2go.rb
|
133
|
+
- lib/offsite_payments_pay2go/version.rb
|
134
|
+
- offsite_payments_pay2go.gemspec
|
135
|
+
homepage: https://github.com/GoodLife/offsite_payments_pay2go
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata:
|
139
|
+
allowed_push_host: https://rubygems.org
|
140
|
+
homepage_uri: https://github.com/GoodLife/offsite_payments_pay2go
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.2.5
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: OffsitePayments for Pay2go, a Taiwan based payment gateway
|
161
|
+
test_files: []
|