Class: WebpayBy::Request
- Inherits:
-
Object
- Object
- WebpayBy::Request
- Defined in:
- lib/webpay_by/request.rb
Constant Summary collapse
- CURRENCIES =
%w( BYN USD EUR RUB )
Instance Attribute Summary collapse
-
#back_url ⇒ Object
readonly
Returns the value of attribute back_url.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#currency_id ⇒ Object
readonly
Returns the value of attribute currency_id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#notify_url ⇒ Object
readonly
Returns the value of attribute notify_url.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
- #form(options = {}) ⇒ Object
-
#initialize(client:, seed:, order_id:, back_url:, notify_url:, items:, currency_id: nil) ⇒ Request
constructor
A new instance of Request.
-
#signature ⇒ Object
Электронная подпись формируется для предотвращения изменений в форме платежа и должна присутствовать в каждой форме заказа.
- #test_mode ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(client:, seed:, order_id:, back_url:, notify_url:, items:, currency_id: nil) ⇒ Request
Returns a new instance of Request.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/webpay_by/request.rb', line 30 def initialize(client:, seed:, order_id:, back_url:, notify_url:, items:, currency_id: nil) @client = client @order_id = order_id @seed = seed @currency_id ||= CURRENCIES.first @back_url = back_url @notify_url = notify_url @items = items.map { |item| item.is_a?(WebpayBy::Item) ? item : WebpayBy::Item.new(item) } raise "Unsupported currency, must be one of #{CURRENCIES.join ', '}" unless CURRENCIES.include? @currency_id end |
Instance Attribute Details
#back_url ⇒ Object (readonly)
Returns the value of attribute back_url.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def back_url @back_url end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def client @client end |
#currency_id ⇒ Object (readonly)
Returns the value of attribute currency_id.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def currency_id @currency_id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def items @items end |
#notify_url ⇒ Object (readonly)
Returns the value of attribute notify_url.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def notify_url @notify_url end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def order_id @order_id end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
28 29 30 |
# File 'lib/webpay_by/request.rb', line 28 def seed @seed end |
Instance Method Details
#form(options = {}) ⇒ Object
58 59 60 |
# File 'lib/webpay_by/request.rb', line 58 def form( = {}) WebpayBy::Form.new .merge request: self end |
#signature ⇒ Object
Электронная подпись формируется для предотвращения изменений в форме платежа и должна присутствовать в каждой форме заказа. Все заказы без электронной подписи не будут рассматриваться системой WebPay
52 53 54 55 56 |
# File 'lib/webpay_by/request.rb', line 52 def signature signed_attrs = [@seed, @client.billing_id, @order_id, test_mode, @currency_id, total, @client.secret_key].join Digest::SHA1.hexdigest signed_attrs end |
#test_mode ⇒ Object
46 47 48 |
# File 'lib/webpay_by/request.rb', line 46 def test_mode @client.debug_mode? ? 1 : 0 end |
#total ⇒ Object
42 43 44 |
# File 'lib/webpay_by/request.rb', line 42 def total @items.map(&:total).sum end |