Module: OpenReceive::Settlement
- Defined in:
- lib/openreceive/core.rb
Class Method Summary collapse
- .settled?(transaction) ⇒ Boolean
-
.state?(data, expected) ⇒ Boolean
Raw wallet states compare case-insensitively, like the JS isTransactionState rule.
- .status(transaction) ⇒ Object
Class Method Details
.settled?(transaction) ⇒ Boolean
90 91 92 93 |
# File 'lib/openreceive/core.rb', line 90 def settled?(transaction) data = OpenReceive.stringify(transaction) data["settled_at"].to_i.positive? || state?(data, "settled") end |
.state?(data, expected) ⇒ Boolean
Raw wallet states compare case-insensitively, like the JS isTransactionState rule.
105 106 107 108 109 |
# File 'lib/openreceive/core.rb', line 105 def state?(data, expected) [data["state"], data["transaction_state"]].any? do |value| value.is_a?(String) && value.downcase == expected end end |
.status(transaction) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/openreceive/core.rb', line 95 def status(transaction) data = OpenReceive.stringify(transaction) return "settled" if settled?(data) return "expired" if state?(data, "expired") return "failed" if state?(data, "failed") "pending" end |