Class: WechatPayment::InvokeResult
- Inherits:
-
Hash
- Object
- Hash
- WechatPayment::InvokeResult
- Defined in:
- lib/wechat_payment/invoke_result.rb
Constant Summary collapse
- SUCCESS_FLAG =
'SUCCESS'.freeze
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(result) ⇒ InvokeResult
constructor
A new instance of InvokeResult.
- #payment_success? ⇒ Boolean
- #refund_success? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(result) ⇒ InvokeResult
Returns a new instance of InvokeResult.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wechat_payment/invoke_result.rb', line 5 def initialize(result) super nil # Or it will call `super result` if result['xml'].class == Hash result['xml'].each_pair do |k, v| self[k] = v end else result.each_pair do |k, v| self[k] = v end end end |
Instance Method Details
#failure? ⇒ Boolean
31 32 33 |
# File 'lib/wechat_payment/invoke_result.rb', line 31 def failure? !success? end |
#payment_success? ⇒ Boolean
23 24 25 |
# File 'lib/wechat_payment/invoke_result.rb', line 23 def payment_success? self['return_code'] == SUCCESS_FLAG && self['result_code'] == SUCCESS_FLAG end |
#refund_success? ⇒ Boolean
27 28 29 |
# File 'lib/wechat_payment/invoke_result.rb', line 27 def refund_success? self['refund_status'] == SUCCESS_FLAG end |
#success? ⇒ Boolean
19 20 21 |
# File 'lib/wechat_payment/invoke_result.rb', line 19 def success? payment_success? || refund_success? end |