Class: Liqpay::Request

Inherits:
BaseOperation show all
Defined in:
lib/liqpay/request.rb

Instance Attribute Summary collapse

Attributes inherited from BaseOperation

#private_key, #public_key

Instance Method Summary collapse

Methods inherited from BaseOperation

#signature

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/liqpay/request.rb', line 23

def initialize(options={})
  super(options)

  @amount = options[:amount]
  @currency = options[:currency]
  @description = options[:description]
  @order_id = options[:order_id]
  @result_url = options[:result_url]
  @server_url = options[:server_url]
  @type = options[:type]
  @language = options[:language]
  @kamikaze = options[:kamikaze]
end

Instance Attribute Details

#amountObject

REQUIRED Amount of payment (Float), in :currency



7
8
9
# File 'lib/liqpay/request.rb', line 7

def amount
  @amount
end

#currencyObject

REQUIRED Currency of payment - one of ‘Liqpay::SUPPORTED_CURRENCIES`



9
10
11
# File 'lib/liqpay/request.rb', line 9

def currency
  @currency
end

#descriptionObject

REQUIRED Description to be displayed to the user



11
12
13
# File 'lib/liqpay/request.rb', line 11

def description
  @description
end

#languageObject

OPTIONAL UI language - ‘ru` or `en`



21
22
23
# File 'lib/liqpay/request.rb', line 21

def language
  @language
end

#order_idObject

RECOMMENDED Arbitrary but unique ID (May be REQUIRED by LiqPay configuration)



13
14
15
# File 'lib/liqpay/request.rb', line 13

def order_id
  @order_id
end

#result_urlObject

RECOMMENDED URL that the user will be redirected to after payment



15
16
17
# File 'lib/liqpay/request.rb', line 15

def result_url
  @result_url
end

#server_urlObject

RECOMMENDED URL that’ll receive the order details in the background.



17
18
19
# File 'lib/liqpay/request.rb', line 17

def server_url
  @server_url
end

#typeObject

OPTIONAL type of payment = either ‘buy` (the default) or `donate`



19
20
21
# File 'lib/liqpay/request.rb', line 19

def type
  @type
end

Instance Method Details

#form_fieldsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/liqpay/request.rb', line 41

def form_fields
  validate! unless @kamikaze
  {
    public_key: public_key,
    amount: amount,
    currency: currency,
    description: description,
    order_id: order_id,
    result_url: result_url,
    server_url: server_url,
    type: type,
    signature: signature,
    language: language
  }.reject{|k,v| v.nil?}
end

#signature_fieldsObject



37
38
39
# File 'lib/liqpay/request.rb', line 37

def signature_fields
  [amount, currency, public_key, order_id, type, description, result_url, server_url]
end