Class: ParichkiBg::Request::Transaction
- Inherits:
-
Base
- Object
- Base
- ParichkiBg::Request::Transaction
show all
- Defined in:
- lib/parichki_bg/request/transaction.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#amount, #pin, #user_id
Instance Method Summary
collapse
Methods inherited from Base
#checksum, #encoded_checksum, #encoded_data, #https, #result, #send, #signed_request
Constructor Details
#initialize(attributes = {}) ⇒ Transaction
Returns a new instance of Transaction.
8
9
10
11
|
# File 'lib/parichki_bg/request/transaction.rb', line 8
def initialize(attributes = {})
super
@request_id = attributes.fetch :request_id
end
|
Instance Attribute Details
#request_id ⇒ Object
Returns the value of attribute request_id.
5
6
7
|
# File 'lib/parichki_bg/request/transaction.rb', line 5
def request_id
@request_id
end
|
#type ⇒ Object
Returns the value of attribute type.
6
7
8
|
# File 'lib/parichki_bg/request/transaction.rb', line 6
def type
@type
end
|
Instance Method Details
#paid? ⇒ Boolean
40
41
42
|
# File 'lib/parichki_bg/request/transaction.rb', line 40
def paid?
result["error"].nil?
end
|
#pay_with_cash ⇒ Object
26
27
28
29
|
# File 'lib/parichki_bg/request/transaction.rb', line 26
def pay_with_cash
@type = "cash"
send
end
|
#pay_with_points ⇒ Object
31
32
33
34
|
# File 'lib/parichki_bg/request/transaction.rb', line 31
def pay_with_points
@type = "points"
send
end
|
#success? ⇒ Boolean
36
37
38
|
# File 'lib/parichki_bg/request/transaction.rb', line 36
def success?
@response.code == "200" && !@response.body.match(/error/)
end
|
#to_json ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/parichki_bg/request/transaction.rb', line 17
def to_json
{
amount: amount.to_s,
request_id: request_id.to_s,
type: type,
pin: pin
}.to_json
end
|