Class: Paymaster::UrlGenerator
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- Paymaster::UrlGenerator
- Defined in:
- lib/paymaster/url_generator.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#description ⇒ Object
Returns the value of attribute description.
-
#email ⇒ Object
Returns the value of attribute email.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#fail_url ⇒ Object
Returns the value of attribute fail_url.
-
#fail_url_method ⇒ Object
Returns the value of attribute fail_url_method.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#number ⇒ Object
Returns the value of attribute number.
-
#payment_system ⇒ Object
Returns the value of attribute payment_system.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#sim_mode ⇒ Object
Returns the value of attribute sim_mode.
-
#success_url ⇒ Object
Returns the value of attribute success_url.
-
#success_url_method ⇒ Object
Returns the value of attribute success_url_method.
Attributes inherited from BaseRequest
Instance Method Summary collapse
- #datetime(value) ⇒ Object
- #endpoint ⇒ Object
- #generate ⇒ Object
- #methods(method) ⇒ Object
- #params ⇒ Object
- #params_as_string ⇒ Object
- #signature ⇒ Object
Methods inherited from BaseRequest
Constructor Details
This class inherits a constructor from Paymaster::BaseRequest
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/paymaster/url_generator.rb', line 4 def amount @amount end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/paymaster/url_generator.rb', line 6 def description @description end |
#email ⇒ Object
Returns the value of attribute email.
9 10 11 |
# File 'lib/paymaster/url_generator.rb', line 9 def email @email end |
#expires ⇒ Object
Returns the value of attribute expires.
7 8 9 |
# File 'lib/paymaster/url_generator.rb', line 7 def expires @expires end |
#fail_url ⇒ Object
Returns the value of attribute fail_url.
12 13 14 |
# File 'lib/paymaster/url_generator.rb', line 12 def fail_url @fail_url end |
#fail_url_method ⇒ Object
Returns the value of attribute fail_url_method.
13 14 15 |
# File 'lib/paymaster/url_generator.rb', line 13 def fail_url_method @fail_url_method end |
#locale ⇒ Object
Returns the value of attribute locale.
3 4 5 |
# File 'lib/paymaster/url_generator.rb', line 3 def locale @locale end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/paymaster/url_generator.rb', line 5 def number @number end |
#payment_system ⇒ Object
Returns the value of attribute payment_system.
14 15 16 |
# File 'lib/paymaster/url_generator.rb', line 14 def payment_system @payment_system end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
8 9 10 |
# File 'lib/paymaster/url_generator.rb', line 8 def phone_number @phone_number end |
#sim_mode ⇒ Object
Returns the value of attribute sim_mode.
15 16 17 |
# File 'lib/paymaster/url_generator.rb', line 15 def sim_mode @sim_mode end |
#success_url ⇒ Object
Returns the value of attribute success_url.
10 11 12 |
# File 'lib/paymaster/url_generator.rb', line 10 def success_url @success_url end |
#success_url_method ⇒ Object
Returns the value of attribute success_url_method.
11 12 13 |
# File 'lib/paymaster/url_generator.rb', line 11 def success_url_method @success_url_method end |
Instance Method Details
#datetime(value) ⇒ Object
49 50 51 52 |
# File 'lib/paymaster/url_generator.rb', line 49 def datetime(value) return unless value value.strftime("%Y-%m-%d %H:%M:%S") end |
#endpoint ⇒ Object
17 18 19 |
# File 'lib/paymaster/url_generator.rb', line 17 def endpoint "https://lmi.paymaster.ua/#{fetch_locale}/index/get" end |
#generate ⇒ Object
40 41 42 |
# File 'lib/paymaster/url_generator.rb', line 40 def generate "#{endpoint}?#{params_as_string}" end |
#methods(method) ⇒ Object
44 45 46 47 |
# File 'lib/paymaster/url_generator.rb', line 44 def methods(method) return unless method method.to_s == "post" ? 1 : 0 end |
#params ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/paymaster/url_generator.rb', line 21 def params { LMI_MERCHANT_ID: client.merchant_id, LMI_PAYMENT_AMOUNT: amount, LMI_PAYMENT_NO: number, LMI_PAYMENT_DESC: description, LMI_EXPIRES: datetime(expires), LMI_PAYER_PHONE_NUMBER: phone_number, LMI_PAYER_EMAIL: email, LMI_SUCCESS_URL: success_url, LMI_SUCCESS_METHOD: methods(success_url_method), LMI_FAIL_URL: fail_url, LMI_FAIL_METHOD: methods(fail_url_method), LMI_PAYMENT_SYSTEM: payment_system, LMI_SIM_MODE: sim_mode, LMI_HASH: signature, }.compact end |
#params_as_string ⇒ Object
60 61 62 |
# File 'lib/paymaster/url_generator.rb', line 60 def params_as_string params.map { |k, v| "#{k}=#{v}" }.join("&") end |
#signature ⇒ Object
54 55 56 57 58 |
# File 'lib/paymaster/url_generator.rb', line 54 def signature return unless client.secret_key string = "#{client.merchant_id}#{number}#{amount}#{client.secret_key}" Digest::SHA256.hexdigest(string).upcase end |