sepay_pg_ruby 0.0.1 → 0.0.2
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/sepay_pg_ruby/ipn.rb +11 -18
- data/lib/sepay_pg_ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 285ead0765edfb229619f9f5f8e848ed01f308211a4cc3269227c30002f3695d
|
|
4
|
+
data.tar.gz: be2e956b3f67fcf001978e5924ae3a6aaecd0e0dc29f3252a734a1023f95d7e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 399cf3b13d6aeae87f7e034d05ff0e4e18e6f3a1081158792e643d55ffe6b796355a91e5a0223032ecd79716448f0dff6523199ca7872c8e0ec742e5da24c2ee
|
|
7
|
+
data.tar.gz: ab82528fccc97b2ba63ee8617bac225a737dfe4e964dd0d65171fa7191512f7b7b63736227ecd1709602b1b1d5c881a7e3afab3be4c86b4b282c6fd1d5e66cec
|
data/lib/sepay_pg_ruby/ipn.rb
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
require 'openssl'
|
|
2
|
-
|
|
3
1
|
module SepayPgRuby
|
|
4
2
|
module IPN
|
|
5
3
|
module_function
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
sorted_keys = data_to_verify.keys.select { |k| !data_to_verify[k].nil? }.sort
|
|
14
|
-
query_string = sorted_keys.map { |key| "#{key}=#{data_to_verify[key]}" }.join('&')
|
|
5
|
+
# SePay authenticates inbound IPN calls via the `X-Secret-Key` request
|
|
6
|
+
# header, compared directly against the merchant's configured secret key.
|
|
7
|
+
# See https://developer.sepay.vn/en/cong-thanh-toan/IPN
|
|
8
|
+
def verify_secret_key(header_value, secret_key)
|
|
9
|
+
return false if header_value.nil? || header_value.to_s.empty?
|
|
10
|
+
return false if secret_key.nil? || secret_key.to_s.empty?
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
secure_compare(received_signature, calculated)
|
|
18
|
-
rescue StandardError
|
|
19
|
-
false
|
|
12
|
+
secure_compare(header_value.to_s, secret_key.to_s)
|
|
20
13
|
end
|
|
21
14
|
|
|
22
|
-
def secure_compare(
|
|
23
|
-
return false unless
|
|
24
|
-
return false unless
|
|
15
|
+
def secure_compare(header_value, secret_key)
|
|
16
|
+
return false unless header_value.is_a?(String) && secret_key.is_a?(String)
|
|
17
|
+
return false unless header_value.bytesize == secret_key.bytesize
|
|
25
18
|
|
|
26
19
|
result = 0
|
|
27
|
-
|
|
20
|
+
header_value.bytes.zip(secret_key.bytes) { |x, y| result |= x ^ y }
|
|
28
21
|
result.zero?
|
|
29
22
|
end
|
|
30
23
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sepay_pg_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiun
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Ruby SDK for SePay payment gateway with order and checkout support.
|
|
14
14
|
email:
|