csob_payment_gateway 0.0.6 → 0.0.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea96e4d46b6839e5e205077cc4352872285c63c1
|
4
|
+
data.tar.gz: 1274cd423da2d02c103f3b1427a31cdd69a5fee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449d92efc5d3860a825ed2d7df4045b09ed81d8a74775a63659e2ee086ac0abac509506a4c03adcd39289b849c46930d58754ce36d0f69582ce4209de0a84719
|
7
|
+
data.tar.gz: 80d961e87befeef2238ff097ed349bcccbae2d86a09f40b30ba163436bf9dd3c2bca62de44c420be5ae18f070d74f161fa6091eefa11e55bba91914c91620a07
|
@@ -31,6 +31,10 @@ module CsobPaymentGateway
|
|
31
31
|
::Rails.root.join(CsobPaymentGateway.configuration.keys_directory.to_s, CsobPaymentGateway.configuration.private_key.to_s)
|
32
32
|
end
|
33
33
|
|
34
|
+
def public_key_url
|
35
|
+
::Rails.root.join(CsobPaymentGateway.configuration.keys_directory.to_s, CsobPaymentGateway.configuration.public_key.to_s)
|
36
|
+
end
|
37
|
+
|
34
38
|
def sign(data, method)
|
35
39
|
data_to_sign = prepare_data_to_sign(data, method)
|
36
40
|
key = OpenSSL::PKey::RSA.new(File.read(private_key_url))
|
@@ -40,5 +44,16 @@ module CsobPaymentGateway
|
|
40
44
|
|
41
45
|
Base64.encode64(signature).gsub("\n","")
|
42
46
|
end
|
47
|
+
|
48
|
+
def verify(data, signature_64)
|
49
|
+
key = OpenSSL::PKey::RSA.new(File.read(public_key_url))
|
50
|
+
signature = Base64.decode64(signature_64)
|
51
|
+
digest = OpenSSL::Digest::SHA1.new
|
52
|
+
if key.verify digest, signature, data
|
53
|
+
"Valid"
|
54
|
+
else
|
55
|
+
"Invalid"
|
56
|
+
end
|
57
|
+
end
|
43
58
|
end
|
44
59
|
end
|
@@ -64,6 +64,23 @@ module CsobPaymentGateway
|
|
64
64
|
JSON.parse(refund_response)
|
65
65
|
end
|
66
66
|
|
67
|
+
def verify_response
|
68
|
+
text = [
|
69
|
+
response["payId"],
|
70
|
+
response["dttm"],
|
71
|
+
response["resultCode"],
|
72
|
+
response["resultMessage"]
|
73
|
+
].map { |param| param.is_a?(Hash) ? "" : param.to_s }.join("|")
|
74
|
+
|
75
|
+
text = text + "|" + response["paymentStatus"].to_s if !response["paymentStatus"].nil?
|
76
|
+
|
77
|
+
text = text + "|" + response["authCode"].to_s if response["authCode"] and !response["authCode"].nil?
|
78
|
+
|
79
|
+
text = text + "|" + response["merchantData"].to_s if response["merchantData"] and !response["merchantData"].nil?
|
80
|
+
|
81
|
+
CsobPaymentGateway::Crypt.verify(text, response["signature"])
|
82
|
+
end
|
83
|
+
|
67
84
|
def get_data
|
68
85
|
text = [
|
69
86
|
merchant_id,
|