Class: DPay::IpnEvent
- Inherits:
-
Object
- Object
- DPay::IpnEvent
- Defined in:
- lib/dpay/ipn/ipn_event.rb,
sig/dpay/ipn/ipn_event.rbs
Constant Summary collapse
- ACK =
"OK"
Instance Attribute Summary collapse
-
#raw ⇒ Hash[String, untyped]
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #amount ⇒ String
- #attempt ⇒ Integer
- #capture? ⇒ Boolean
- #capture_payment_id ⇒ String?
- #custom ⇒ String?
- #dcb? ⇒ Boolean
- #email ⇒ String?
- #id ⇒ String
-
#initialize(payload) ⇒ IpnEvent
constructor
A new instance of IpnEvent.
- #integer(key) ⇒ Integer
- #scalar(key) ⇒ String?
- #signature ⇒ String
- #transfer? ⇒ Boolean
- #type ⇒ String
- #version ⇒ Integer
Constructor Details
#initialize(payload) ⇒ IpnEvent
Returns a new instance of IpnEvent.
13 14 15 16 |
# File 'lib/dpay/ipn/ipn_event.rb', line 13 def initialize(payload) @raw = payload freeze end |
Instance Attribute Details
#raw ⇒ Hash[String, untyped] (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/dpay/ipn/ipn_event.rb', line 7 def raw @raw end |
Class Method Details
.from_verified_payload(payload) ⇒ IpnEvent
9 10 11 |
# File 'lib/dpay/ipn/ipn_event.rb', line 9 def self.from_verified_payload(payload) new(payload) end |
Instance Method Details
#amount ⇒ String
22 23 24 |
# File 'lib/dpay/ipn/ipn_event.rb', line 22 def amount scalar("amount") || "" end |
#attempt ⇒ Integer
46 47 48 |
# File 'lib/dpay/ipn/ipn_event.rb', line 46 def attempt integer("attempt") end |
#capture? ⇒ Boolean
58 59 60 |
# File 'lib/dpay/ipn/ipn_event.rb', line 58 def capture? type == IpnType::CAPTURE end |
#capture_payment_id ⇒ String?
42 43 44 |
# File 'lib/dpay/ipn/ipn_event.rb', line 42 def capture_payment_id scalar("capture_payment_id") end |
#custom ⇒ String?
38 39 40 |
# File 'lib/dpay/ipn/ipn_event.rb', line 38 def custom scalar("custom") end |
#dcb? ⇒ Boolean
62 63 64 |
# File 'lib/dpay/ipn/ipn_event.rb', line 62 def dcb? type == IpnType::DCB end |
#email ⇒ String?
34 35 36 |
# File 'lib/dpay/ipn/ipn_event.rb', line 34 def email scalar("email") end |
#id ⇒ String
18 19 20 |
# File 'lib/dpay/ipn/ipn_event.rb', line 18 def id scalar("id") || "" end |
#integer(key) ⇒ Integer
76 77 78 79 80 81 82 |
# File 'lib/dpay/ipn/ipn_event.rb', line 76 def integer(key) value = @raw[key] return value.to_i if value.is_a?(Integer) || value.is_a?(Float) return value.to_i if value.is_a?(String) && /\A[+-]?\d+\z/.match?(value) 0 end |
#scalar(key) ⇒ String?
68 69 70 71 72 73 74 |
# File 'lib/dpay/ipn/ipn_event.rb', line 68 def scalar(key) value = @raw[key] return nil unless value.is_a?(String) || value.is_a?(Numeric) || value.is_a?(TrueClass) || value.is_a?(FalseClass) Internal::PHP.strval(value) end |
#signature ⇒ String
30 31 32 |
# File 'lib/dpay/ipn/ipn_event.rb', line 30 def signature scalar("signature") || "" end |
#transfer? ⇒ Boolean
54 55 56 |
# File 'lib/dpay/ipn/ipn_event.rb', line 54 def transfer? type == IpnType::TRANSFER end |
#type ⇒ String
26 27 28 |
# File 'lib/dpay/ipn/ipn_event.rb', line 26 def type scalar("type") || "" end |
#version ⇒ Integer
50 51 52 |
# File 'lib/dpay/ipn/ipn_event.rb', line 50 def version integer("version") end |