Class: Platbamobilom::Redirect
- Inherits:
-
Object
- Object
- Platbamobilom::Redirect
- Defined in:
- lib/platbamobilom/redirect.rb
Constant Summary collapse
- PRODUCTION_URL =
'https://pay.platbamobilom.sk/pay/'.freeze
- TEST_URL =
'https://pay.platbamobilom.sk/test/'.freeze
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pid:, id:, desc:, price:, url:, email:) ⇒ Redirect
constructor
A new instance of Redirect.
- #sign(secret) ⇒ Object
- #signed_query_string(signature) ⇒ Object
- #signed_url(signature) ⇒ Object
Constructor Details
#initialize(pid:, id:, desc:, price:, url:, email:) ⇒ Redirect
Returns a new instance of Redirect.
17 18 19 20 21 22 23 24 |
# File 'lib/platbamobilom/redirect.rb', line 17 def initialize(pid:, id:, desc:, price:, url:, email:) @pid = pid @id = id @desc = desc @price = price @url = url @email = email end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
12 13 14 |
# File 'lib/platbamobilom/redirect.rb', line 12 def desc @desc end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
15 16 17 |
# File 'lib/platbamobilom/redirect.rb', line 15 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/platbamobilom/redirect.rb', line 11 def id @id end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
10 11 12 |
# File 'lib/platbamobilom/redirect.rb', line 10 def pid @pid end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
13 14 15 |
# File 'lib/platbamobilom/redirect.rb', line 13 def price @price end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
14 15 16 |
# File 'lib/platbamobilom/redirect.rb', line 14 def url @url end |
Class Method Details
.production_url ⇒ Object
6 |
# File 'lib/platbamobilom/redirect.rb', line 6 def self.production_url; PRODUCTION_URL end |
.test_url ⇒ Object
7 |
# File 'lib/platbamobilom/redirect.rb', line 7 def self.test_url; TEST_URL end |
.url ⇒ Object
8 |
# File 'lib/platbamobilom/redirect.rb', line 8 def self.url; (Platbamobilom.test_mode ? test_url : production_url) end |
Instance Method Details
#sign(secret) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/platbamobilom/redirect.rb', line 26 def sign(secret) signing_data = [pid, id, desc, price, url, email].join digest = OpenSSL::Digest.new('sha256') hmac = OpenSSL::HMAC.digest(digest, secret, signing_data) signature = hmac.unpack('H*').join.upcase end |
#signed_query_string(signature) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/platbamobilom/redirect.rb', line 33 def signed_query_string(signature) Rack::Utils.build_query({ PID: pid, ID: id, DESC: desc, PRICE: price, URL: url, EMAIL: email, SIGN: signature }) end |
#signed_url(signature) ⇒ Object
45 46 47 |
# File 'lib/platbamobilom/redirect.rb', line 45 def signed_url(signature) '%s?%s' % [self.class.url, signed_query_string(signature)] end |