yp-ruby 0.1.2 → 0.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.
- checksums.yaml +4 -4
- data/lib/base.rb +4 -2
- data/lib/transaction_logger.rb +39 -0
- data/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0e8f0cb22b7a4f03a355e460984e1ac50da242b
|
4
|
+
data.tar.gz: fa63594396cabc343e2699290b1223c762c903fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e96e8bfbb983d3336d1b81798087b6d81c64b1631f748488fccaa8206210aa325d1b4c5341523192a141bdb5c80d61882247fad4767a8d1e548a2145c487eff
|
7
|
+
data.tar.gz: 01ec3ed018db1179656697a4ea112b493e04021d3453ff58519f45041abc6d9623b6bd348fe267bb4f1206ee501c32590912cc84fae86fd7af495694740a5ac2
|
data/lib/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'transaction_logger'
|
2
|
+
|
1
3
|
module Yp
|
2
4
|
class Base
|
3
5
|
TYPE = {
|
@@ -16,7 +18,7 @@ module Yp
|
|
16
18
|
def body
|
17
19
|
@params.clone.tap do |params|
|
18
20
|
params[:signature] = create_signing_hash
|
19
|
-
|
21
|
+
TransactionLogger.log_request(params)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -69,7 +71,7 @@ module Yp
|
|
69
71
|
|
70
72
|
def parse(response)
|
71
73
|
ruby_hash_from_response(CGI::parse(response)).tap do |parsed|
|
72
|
-
|
74
|
+
TransactionLogger.log_response(parsed)
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Yp
|
2
|
+
class TransactionLogger
|
3
|
+
class << self
|
4
|
+
|
5
|
+
FILTERED_KEYS = %w(cardNumber cardCVV cardExpiryMonth cardExpiryYear)
|
6
|
+
|
7
|
+
def log_request(params)
|
8
|
+
info 'Sending transaction', params
|
9
|
+
end
|
10
|
+
|
11
|
+
def log_response(params)
|
12
|
+
info 'Response received', params
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def info(str, params=nil)
|
18
|
+
Yp.logger.info("#{format_message(str)} #{format_params(params)}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def format_message(str)
|
22
|
+
"[YP] #{str}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def format_params(params)
|
26
|
+
" with params #{filter_card_params(params).to_s}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def filter_card_params(hash)
|
30
|
+
hash.reduce({}) { |memo, param| memo.merge(apply_filter(*param)) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def apply_filter(k, v)
|
34
|
+
{ k => FILTERED_KEYS.include?(k.to_s) ? '[FILTERED]' : v }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yp-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hall
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/nil_logger.rb
|
140
140
|
- lib/preauth.rb
|
141
141
|
- lib/sale.rb
|
142
|
+
- lib/transaction_logger.rb
|
142
143
|
- lib/verify.rb
|
143
144
|
- lib/version.rb
|
144
145
|
- lib/yp.rb
|