veritrans 1.1.0 → 1.1.3
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.
- data/config/veritrans.yml +8 -2
- data/lib/veritrans/config.rb +12 -0
- data/lib/veritrans/v_t_direct.rb +45 -5
- data/lib/veritrans/version.rb +1 -1
- metadata +2 -2
data/config/veritrans.yml
CHANGED
@@ -4,8 +4,11 @@ development:
|
|
4
4
|
finish_payment_return_url: "http://localhost/finish"
|
5
5
|
unfinish_payment_return_url: "http://localhost/cancel"
|
6
6
|
error_payment_return_url: "http://localhost/error"
|
7
|
-
server_key: "
|
7
|
+
server_key: "c0b44171-d7fe-4cf5-8b15-06049fc9980c"
|
8
|
+
# server_key: "2a8f3674-71cf-42af-aa56-b872b8924f72"
|
8
9
|
server_host: "http://veritrans.dev"
|
10
|
+
charges_url: "/charges"
|
11
|
+
token_url: "/tokens"
|
9
12
|
|
10
13
|
production:
|
11
14
|
merchant_id: "production_id"
|
@@ -13,6 +16,9 @@ production:
|
|
13
16
|
finish_payment_return_url: "http://mydomain/finish"
|
14
17
|
unfinish_payment_return_url: "http://mydomain/cancel"
|
15
18
|
error_payment_return_url: "http://mydomain/error"
|
16
|
-
server_key: "
|
19
|
+
server_key: "c0b44171-d7fe-4cf5-8b15-06049fc9980c"
|
20
|
+
# server_key: "2a8f3674-71cf-42af-aa56-b872b8924f72"
|
17
21
|
server_host: "http://veritrans.dev"
|
22
|
+
charges_url: "/charges"
|
23
|
+
token_url: "/tokens"
|
18
24
|
# server_host: "http://192.168.10.250:80"
|
data/lib/veritrans/config.rb
CHANGED
@@ -12,8 +12,20 @@ module Veritrans
|
|
12
12
|
# Request Key Url - use in #get_keys - defined in gem - no change!
|
13
13
|
REQUEST_KEY_URL = "/web1/commodityRegist.action"
|
14
14
|
|
15
|
+
# Request Key Url - use in #get_keys - defined in gem - no change!
|
16
|
+
TOKENS_URL = "/vtdirect-rest/v1/tokens"
|
17
|
+
|
18
|
+
# Charges Url - use in #get_keys - defined in gem - no change!
|
19
|
+
CHARGES_URL = "/vtdirect-rest/v1/charges"
|
20
|
+
|
21
|
+
# Void Url - use in #get_keys - defined in gem - no change!
|
22
|
+
VOID_URL = "/vtdirect-rest/v1/void"
|
23
|
+
|
15
24
|
# Payment Redirect Url - defined in gem - no change!
|
16
25
|
PAYMENT_REDIRECT_URL = "/web1/deviceCheck.action"
|
26
|
+
|
27
|
+
# CA_PATH
|
28
|
+
# CA_PATH = "/usr/lib/ssl/certs"
|
17
29
|
|
18
30
|
# :nodoc:
|
19
31
|
CUSTOMER_SPECIFICATION_FLAG = '0' #Billing same as shipping address '1' Different, manually input in Veritrans-web
|
data/lib/veritrans/v_t_direct.rb
CHANGED
@@ -63,12 +63,13 @@ module Veritrans
|
|
63
63
|
# vt_direct.charges
|
64
64
|
#
|
65
65
|
def charges
|
66
|
-
|
67
|
-
parms = prepare_params([:server_key]+@@attr).to_json
|
66
|
+
parms = prepare_params(@@attr).to_json
|
68
67
|
basic = Base64.encode64("#{server_key}:")
|
69
|
-
|
68
|
+
copt = {:url => server_host}
|
69
|
+
copt[:ssl] = { :ca_path => VTDirect.config["ca_path"] } if VTDirect.config["ca_path"] #"/usr/lib/ssl/certs"
|
70
|
+
conn = Faraday.new( copt )
|
70
71
|
@resp = conn.post do |req|
|
71
|
-
req.url(
|
72
|
+
req.url(charges_url)
|
72
73
|
req.headers['Content-Type'] = 'application/json'
|
73
74
|
req.headers['Authorization'] = "Basic #{basic}"
|
74
75
|
req.body = parms
|
@@ -76,11 +77,35 @@ module Veritrans
|
|
76
77
|
@data = @resp[:body]
|
77
78
|
end
|
78
79
|
|
80
|
+
def void
|
81
|
+
api_call(void_url)
|
82
|
+
end
|
83
|
+
|
84
|
+
# :nodoc:
|
85
|
+
# def ca_path
|
86
|
+
# return VTDirect.config["ca_path"] ? VTDirect.config["ca_path"] : Config::CA_PATH
|
87
|
+
# end
|
88
|
+
|
79
89
|
# :nodoc:
|
80
90
|
def server_host
|
81
91
|
return VTDirect.config["server_host"] ? VTDirect.config["server_host"] : Config::SERVER_HOST
|
82
92
|
end
|
83
93
|
|
94
|
+
# :nodoc:
|
95
|
+
def tokens_url
|
96
|
+
return Client.config["tokens_url"] ? Client.config["tokens_url"] : Config::TOKENS_URL
|
97
|
+
end
|
98
|
+
|
99
|
+
# :nodoc:
|
100
|
+
def charges_url
|
101
|
+
return Client.config["charges_url"] ? Client.config["charges_url"] : Config::CHARGES_URL
|
102
|
+
end
|
103
|
+
|
104
|
+
# :nodoc:
|
105
|
+
def void_url
|
106
|
+
return Client.config["void_url"] ? Client.config["void_url"] : Config::VOID_URL
|
107
|
+
end
|
108
|
+
|
84
109
|
# :nodoc:
|
85
110
|
def server_key
|
86
111
|
return VTDirect.config["server_key"]
|
@@ -93,11 +118,26 @@ module Veritrans
|
|
93
118
|
|
94
119
|
private
|
95
120
|
|
121
|
+
def api_call(url)
|
122
|
+
parms = prepare_params(@@attr).to_json
|
123
|
+
basic = Base64.encode64("#{server_key}:")
|
124
|
+
copt = {:url => server_host}
|
125
|
+
copt[:ssl] = { :ca_path => VTDirect.config["ca_path"] } if VTDirect.config["ca_path"] #"/usr/lib/ssl/certs"
|
126
|
+
conn = Faraday.new( copt )
|
127
|
+
@resp = conn.post do |req|
|
128
|
+
req.url(url)
|
129
|
+
req.headers['Content-Type'] = 'application/json'
|
130
|
+
req.headers['Authorization'] = "Basic #{basic}"
|
131
|
+
req.body = parms
|
132
|
+
end.env
|
133
|
+
@data = @resp[:body]
|
134
|
+
end
|
135
|
+
|
96
136
|
def prepare_params(*arg)
|
97
137
|
params = {}
|
98
138
|
arg.flatten.each do |key|
|
99
139
|
value = self.send(key)
|
100
|
-
params[key.downcase] = value if value
|
140
|
+
params[key.to_s.downcase] = value if value
|
101
141
|
end
|
102
142
|
return params
|
103
143
|
end
|
data/lib/veritrans/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veritrans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|