paymob_accept 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/paymob_accept/api/pay.rb +2 -2
- data/lib/paymob_accept/hmac.rb +17 -3
- data/lib/paymob_accept/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: beebd510c172fc729ba4dbbd07646a2d1863364581a505e1b46db855cb4e243e
|
4
|
+
data.tar.gz: 958f6cc877b89a37fa367369b1856e33807c0deae2fed33f61ddfc0e5fd7deb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc4667a2a84e21a8bd461543fc5a2decf3a61fb517a69aaf50f4230ce5aaad4d201c12751a27da7cd0760c03f9aceb9e85cf0b5c741d44681cd5eefc26a906e9
|
7
|
+
data.tar.gz: 216f96de1a00cfbe165f8d9b08015676eb6a12f3075ecd334a0bb9ecd3fcc9eb95dc5e0fee5ee91dd40f37542429cb8eddcfbb34254e4103d44e3c0773a6edc2
|
data/Gemfile.lock
CHANGED
@@ -30,9 +30,9 @@ module PaymobAccept
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def pay_auth(customer:, address:, amount_cents:, amount_currency:)
|
33
|
+
def pay_auth(customer:, address:, amount_cents:, amount_currency:, iframe_id: nil, cc_token: nil)
|
34
34
|
generate_payment_intent(customer: customer, address: address, amount_cents: amount_cents, amount_currency: amount_currency,
|
35
|
-
integration_id: auth_integration_id)
|
35
|
+
integration_id: auth_integration_id, iframe_id: iframe_id, cc_token: cc_token)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Return an iFrame URL if an iframe_id is provided. Otherwise, returns a payment token
|
data/lib/paymob_accept/hmac.rb
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
module PaymobAccept
|
2
2
|
module Hmac
|
3
|
-
|
3
|
+
FILTERED_TRANSACTION_KEYS = %w[amount_cents created_at currency error_occured has_parent_transaction id
|
4
4
|
integration_id is_3d_secure is_auth is_capture is_refunded is_standalone_payment
|
5
5
|
is_voided order.id owner
|
6
6
|
pending source_data.pan source_data.sub_type source_data.type success].freeze
|
7
7
|
|
8
|
+
FILTERED_TOKEN_KEYS = %w[card_subtype created_at email id masked_pan merchant_id order_id token].freeze
|
9
|
+
|
8
10
|
class << self
|
11
|
+
|
9
12
|
def validate(paymob_response:, hmac_key: PaymobAccept.configuration.hmac_key)
|
10
|
-
|
13
|
+
validate_transaction?(paymob_response: paymob_response, hmac_key: hmac_key) || validate_token?(paymob_response: paymob_response, hmac_key: hmac_key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate_transaction?(paymob_response:, hmac_key: PaymobAccept.configuration.hmac_key)
|
17
|
+
digest = OpenSSL::Digest.new('sha512')
|
18
|
+
concatenated_str = FILTERED_TRANSACTION_KEYS.map do |element|
|
19
|
+
paymob_response.dig('obj', *element.split('.'))
|
20
|
+
end.join
|
21
|
+
secure_hash = OpenSSL::HMAC.hexdigest(digest, hmac_key, concatenated_str)
|
22
|
+
secure_hash == paymob_response['hmac']
|
23
|
+
end
|
11
24
|
|
25
|
+
def validate_token?(paymob_response:, hmac_key: PaymobAccept.configuration.hmac_key)
|
12
26
|
digest = OpenSSL::Digest.new('sha512')
|
13
|
-
concatenated_str =
|
27
|
+
concatenated_str = FILTERED_TOKEN_KEYS.map do |element|
|
14
28
|
paymob_response.dig('obj', *element.split('.'))
|
15
29
|
end.join
|
16
30
|
secure_hash = OpenSSL::HMAC.hexdigest(digest, hmac_key, concatenated_str)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paymob_accept
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OneOrder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|