Class: GatewayNotification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- GatewayNotification
show all
- Defined in:
- app/models/gateway_notification.rb
Defined Under Namespace
Classes: EmptyChargeIdError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
12
13
14
|
# File 'app/models/gateway_notification.rb', line 12
def logger
@logger
end
|
#raw_post ⇒ Object
Returns the value of attribute raw_post.
12
13
14
|
# File 'app/models/gateway_notification.rb', line 12
def raw_post
@raw_post
end
|
Instance Method Details
#acknowledge ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/models/gateway_notification.rb', line 14
def acknowledge
res = adapter.acknowledge
if charge_id.nil? && adapter.item_id
update_column(:charge_id, adapter.item_id)
end
res
end
|
#approve ⇒ Object
36
37
38
39
40
41
|
# File 'app/models/gateway_notification.rb', line 36
def approve
raise EmptyChargeIdError unless charge_id
logger.info "real amount = #{real_amount}"
charge.approve(real_amount) unless charge.ok?
end
|
#complete? ⇒ Boolean
24
25
26
|
# File 'app/models/gateway_notification.rb', line 24
def complete?
adapter.complete?
end
|
#need_response? ⇒ Boolean
28
29
30
|
# File 'app/models/gateway_notification.rb', line 28
def need_response?
adapter.respond_to?(:success_response)
end
|
#real_amount ⇒ Object
43
44
45
|
# File 'app/models/gateway_notification.rb', line 43
def real_amount
adapter.gross
end
|
#success_response ⇒ Object
32
33
34
|
# File 'app/models/gateway_notification.rb', line 32
def success_response
adapter.respond_to?(:success_response) ? adapter.success_response : "OK"
end
|