active_merchant_pay2go 0.1.4 → 0.1.5
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 +4 -4
- data/lib/active_merchant_pay2go/version.rb +1 -1
- data/lib/active_merchant_pay2go.rb +0 -1
- data/lib/offsite_payments/integrations/pay2go/helper.rb +41 -0
- data/lib/offsite_payments/integrations/pay2go/notification.rb +46 -0
- data/lib/offsite_payments/integrations/pay2go.rb +2 -71
- metadata +3 -2
- data/lib/offsite_payments/integrations/pay2go_period.rb +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d0ec805a54b559acacc028454d76d5af1188c1a
|
4
|
+
data.tar.gz: fea441eaafed8b3bbb849f6385240b65f4af972a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d4501b11c1a90c316aaadd9b305a63920281c963be06420ab44bd4ff3ef02d05ba7c702af680bd40375eb476439d5745c34611bb447c2568db3b8b18345fc3
|
7
|
+
data.tar.gz: 766853f09055aba0ecb6ced5a22528db6b203640bceacd3cf8d0e4d979e30342eec15b74cff39a336854b84ef8f5b25f3705dfb871a3fb83004e8234a2070b8a
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
module OffsitePayments #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Pay2go
|
7
|
+
class Helper < OffsitePayments::Helper
|
8
|
+
FIELDS = %w(
|
9
|
+
MerchantID LangType MerchantOrderNo Amt ItemDesc TradeLimit ExpireDate ReturnURL NotifyURL CustomerURL ClientBackURL Email EmailModify LoginType OrderComment CREDIT CreditRed InstFlag UNIONPAY WEBATM VACC CVS BARCODE CUSTOM TokenTerm
|
10
|
+
)
|
11
|
+
|
12
|
+
FIELDS.each do |field|
|
13
|
+
mapping field.underscore.to_sym, field
|
14
|
+
end
|
15
|
+
mapping :account, 'MerchantID' # AM common
|
16
|
+
mapping :amount, 'Amt' # AM common
|
17
|
+
|
18
|
+
def initialize(order, account, options = {})
|
19
|
+
super
|
20
|
+
add_field 'Version', OffsitePayments::Integrations::Pay2go::VERSION
|
21
|
+
add_field 'RespondType', OffsitePayments::Integrations::Pay2go::RESPOND_TYPE
|
22
|
+
OffsitePayments::Integrations::Pay2go::CONFIG.each do |field|
|
23
|
+
add_field field, OffsitePayments::Integrations::Pay2go.send(field.underscore.to_sym)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def time_stamp(date)
|
27
|
+
add_field 'TimeStamp', date.to_time.to_i
|
28
|
+
end
|
29
|
+
def encrypted_data
|
30
|
+
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2go::CHECK_VALUE_FIELDS.sort.map { |field|
|
31
|
+
[field, @fields[field]]
|
32
|
+
}
|
33
|
+
|
34
|
+
hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}"
|
35
|
+
add_field 'CheckValue', Digest::SHA256.hexdigest(hash_raw_data).upcase
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
module OffsitePayments #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Pay2go
|
7
|
+
class Notification < OffsitePayments::Notification
|
8
|
+
PARAMS_FIELDS = %w(
|
9
|
+
Status Message MerchantID Amt TradeNo MerchantOrderNo PaymentType RespondType CheckCode PayTime IP
|
10
|
+
EscrowBank TokenUseStatus RespondCode Auth Card6No Card4No Inst InstFirst InstEach ECI PayBankCode
|
11
|
+
PayerAccount5Code CodeNo BankCode Barcode_1 Barcode_2 Barcode_3 ExpireDate CheckCode
|
12
|
+
)
|
13
|
+
|
14
|
+
PARAMS_FIELDS.each do |field|
|
15
|
+
define_method field.underscore do
|
16
|
+
@params[field]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def success?
|
21
|
+
status == 'SUCCESS'
|
22
|
+
end
|
23
|
+
|
24
|
+
# TODO 使用查詢功能實作 acknowledge
|
25
|
+
# Pay2go 沒有遠端驗證功能,
|
26
|
+
# 而以 checksum_ok? 代替
|
27
|
+
def acknowledge
|
28
|
+
checksum_ok?
|
29
|
+
end
|
30
|
+
|
31
|
+
def complete?
|
32
|
+
%w(SUCCESS CUSTOM).include? status
|
33
|
+
end
|
34
|
+
|
35
|
+
def checksum_ok?
|
36
|
+
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2go::CHECK_CODE_FIELDS.sort.map { |field|
|
37
|
+
[field, @params[field]]
|
38
|
+
}
|
39
|
+
|
40
|
+
hash_raw_data = "HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}"
|
41
|
+
Digest::SHA256.hexdigest(hash_raw_data).upcase == check_code
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'digest'
|
3
|
+
require File.dirname(__FILE__) + '/pay2go/helper.rb'
|
4
|
+
require File.dirname(__FILE__) + '/pay2go/notification.rb'
|
3
5
|
|
4
6
|
module OffsitePayments #:nodoc:
|
5
7
|
module Integrations #:nodoc:
|
@@ -45,77 +47,6 @@ module OffsitePayments #:nodoc:
|
|
45
47
|
yield(self)
|
46
48
|
end
|
47
49
|
|
48
|
-
class Helper < OffsitePayments::Helper
|
49
|
-
FIELDS = %w(
|
50
|
-
MerchantID LangType MerchantOrderNo Amt ItemDesc TradeLimit ExpireDate ReturnURL NotifyURL CustomerURL ClientBackURL Email EmailModify LoginType OrderComment CREDIT CreditRed InstFlag UNIONPAY WEBATM VACC CVS BARCODE CUSTOM TokenTerm
|
51
|
-
)
|
52
|
-
|
53
|
-
FIELDS.each do |field|
|
54
|
-
mapping field.underscore.to_sym, field
|
55
|
-
end
|
56
|
-
mapping :account, 'MerchantID' # AM common
|
57
|
-
mapping :amount, 'Amt' # AM common
|
58
|
-
|
59
|
-
def initialize(order, account, options = {})
|
60
|
-
super
|
61
|
-
add_field 'Version', OffsitePayments::Integrations::Pay2go::VERSION
|
62
|
-
add_field 'RespondType', OffsitePayments::Integrations::Pay2go::RESPOND_TYPE
|
63
|
-
OffsitePayments::Integrations::Pay2go::CONFIG.each do |field|
|
64
|
-
add_field field, OffsitePayments::Integrations::Pay2go.send(field.underscore.to_sym)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def time_stamp(date)
|
69
|
-
add_field 'TimeStamp', date.to_time.to_i
|
70
|
-
end
|
71
|
-
|
72
|
-
def encrypted_data
|
73
|
-
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2go::CHECK_VALUE_FIELDS.sort.map { |field|
|
74
|
-
[field, @fields[field]]
|
75
|
-
}
|
76
|
-
|
77
|
-
hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}"
|
78
|
-
add_field 'CheckValue', Digest::SHA256.hexdigest(hash_raw_data).upcase
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Notification < OffsitePayments::Notification
|
83
|
-
PARAMS_FIELDS = %w(
|
84
|
-
Status Message MerchantID Amt TradeNo MerchantOrderNo PaymentType RespondType CheckCode PayTime IP
|
85
|
-
EscrowBank TokenUseStatus RespondCode Auth Card6No Card4No Inst InstFirst InstEach ECI PayBankCode
|
86
|
-
PayerAccount5Code CodeNo BankCode Barcode_1 Barcode_2 Barcode_3 ExpireDate CheckCode
|
87
|
-
)
|
88
|
-
|
89
|
-
PARAMS_FIELDS.each do |field|
|
90
|
-
define_method field.underscore do
|
91
|
-
@params[field]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def success?
|
96
|
-
status == 'SUCCESS'
|
97
|
-
end
|
98
|
-
|
99
|
-
# TODO 使用查詢功能實作 acknowledge
|
100
|
-
# Pay2go 沒有遠端驗證功能,
|
101
|
-
# 而以 checksum_ok? 代替
|
102
|
-
def acknowledge
|
103
|
-
checksum_ok?
|
104
|
-
end
|
105
|
-
|
106
|
-
def complete?
|
107
|
-
%w(SUCCESS CUSTOM).include? status
|
108
|
-
end
|
109
|
-
|
110
|
-
def checksum_ok?
|
111
|
-
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2go::CHECK_CODE_FIELDS.sort.map { |field|
|
112
|
-
[field, @params[field]]
|
113
|
-
}
|
114
|
-
|
115
|
-
hash_raw_data = "HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}"
|
116
|
-
Digest::SHA256.hexdigest(hash_raw_data).upcase == check_code
|
117
|
-
end
|
118
|
-
end
|
119
50
|
end
|
120
51
|
end
|
121
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_merchant_pay2go
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary
|
@@ -109,7 +109,8 @@ files:
|
|
109
109
|
- lib/generators/pay2go/templates/README
|
110
110
|
- lib/generators/pay2go/templates/pay2go.rb
|
111
111
|
- lib/offsite_payments/integrations/pay2go.rb
|
112
|
-
- lib/offsite_payments/integrations/
|
112
|
+
- lib/offsite_payments/integrations/pay2go/helper.rb
|
113
|
+
- lib/offsite_payments/integrations/pay2go/notification.rb
|
113
114
|
homepage: https://github.com/imgarylai/active_merchant_pay2go
|
114
115
|
licenses:
|
115
116
|
- MIT
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'digest'
|
3
|
-
|
4
|
-
module OffsitePayments #:nodoc:
|
5
|
-
module Integrations #:nodoc:
|
6
|
-
module Pay2goPeriod
|
7
|
-
|
8
|
-
VERSION = '1.0'
|
9
|
-
RESPOND_TYPE = 'String'
|
10
|
-
CHECK_VALUE_FIELDS = %w(PeriodAmt MerchantID MerchantOrderNo TimeStamp PeriodType)
|
11
|
-
CHECK_CODE_FIELDS = %w(PeriodType MerchantID MerchantOrderNo)
|
12
|
-
|
13
|
-
mattr_accessor :service_url
|
14
|
-
mattr_accessor :merchant_id
|
15
|
-
mattr_accessor :hash_key
|
16
|
-
mattr_accessor :hash_iv
|
17
|
-
mattr_accessor :debug
|
18
|
-
|
19
|
-
def self.service_url
|
20
|
-
mode = ActiveMerchant::Billing::Base.mode
|
21
|
-
case mode
|
22
|
-
when :production
|
23
|
-
'https://api.pay2go.com/API/PeriodAPI'
|
24
|
-
when :development
|
25
|
-
'https://capi.pay2go.com/API/PeriodAPI'
|
26
|
-
when :test
|
27
|
-
'https://capi.pay2go.com/API/PeriodAPI'
|
28
|
-
else
|
29
|
-
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.notification(post)
|
34
|
-
Notification.new(post)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.setup
|
38
|
-
yield(self)
|
39
|
-
end
|
40
|
-
|
41
|
-
class Helper < OffsitePayments::Helper
|
42
|
-
FIELDS = %w(
|
43
|
-
MerchantID MerchantOrderNo PeriodAmt ProdDesc PeriodAmtMode PeriodType PeriodPoint PeriodStartType
|
44
|
-
PeriodTimes ReturnURL ProDetail PeriodMemo PaymentInfo OrderInfo InvoiceInfo NotifyURL
|
45
|
-
)
|
46
|
-
|
47
|
-
FIELDS.each do |field|
|
48
|
-
mapping field.underscore.to_sym, field
|
49
|
-
end
|
50
|
-
mapping :account, 'MerchantID' # AM common
|
51
|
-
|
52
|
-
def initialize(order, account, options = {})
|
53
|
-
super
|
54
|
-
add_field 'MerchantID', OffsitePayments::Integrations::Pay2go.merchant_id
|
55
|
-
add_field 'Version', OffsitePayments::Integrations::Pay2goPeriod::VERSION
|
56
|
-
add_field 'RespondType', OffsitePayments::Integrations::Pay2goPeriod::RESPOND_TYPE
|
57
|
-
end
|
58
|
-
|
59
|
-
def time_stamp(date)
|
60
|
-
add_field 'TimeStamp', date.to_time.to_i
|
61
|
-
end
|
62
|
-
|
63
|
-
def encrypted_data
|
64
|
-
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2goPeriod::CHECK_VALUE_FIELDS.sort.map { |field|
|
65
|
-
[field, @fields[field]]
|
66
|
-
}
|
67
|
-
|
68
|
-
hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}"
|
69
|
-
add_field 'CheckValue', Digest::SHA256.hexdigest(hash_raw_data).upcase
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
class Notification < OffsitePayments::Notification
|
75
|
-
PARAMS_FIELDS = %w(
|
76
|
-
Status Message MerchantID MerchantOrderNo PeriodType authDate authTime dateArray PeriodTotalAmt
|
77
|
-
PeriodFirstAmt PeriodAmt CheckCode
|
78
|
-
)
|
79
|
-
|
80
|
-
PARAMS_FIELDS.each do |field|
|
81
|
-
define_method field.underscore do
|
82
|
-
@params[field]
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def success?
|
87
|
-
status == 'SUCCESS'
|
88
|
-
end
|
89
|
-
|
90
|
-
# TODO 使用查詢功能實作 acknowledge
|
91
|
-
# Pay2go 沒有遠端驗證功能,
|
92
|
-
# 而以 checksum_ok? 代替
|
93
|
-
def acknowledge
|
94
|
-
checksum_ok?
|
95
|
-
end
|
96
|
-
|
97
|
-
def complete?
|
98
|
-
%w(SUCCESS CUSTOM).include? status
|
99
|
-
end
|
100
|
-
|
101
|
-
def checksum_ok?
|
102
|
-
raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2goPeriod::CHECK_CODE_FIELDS.sort.map { |field|
|
103
|
-
[field, @params[field]]
|
104
|
-
}
|
105
|
-
|
106
|
-
hash_raw_data = "HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}&#{raw_data}&HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}"
|
107
|
-
Digest::SHA256.hexdigest(hash_raw_data).upcase == check_code
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|