Class: DPay::IpnEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/ipn/ipn_event.rb,
sig/dpay/ipn/ipn_event.rbs

Constant Summary collapse

ACK =
"OK"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ IpnEvent



13
14
15
16
# File 'lib/dpay/ipn/ipn_event.rb', line 13

def initialize(payload)
  @raw = payload
  freeze
end

Instance Attribute Details

#rawHash[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

#amountString



22
23
24
# File 'lib/dpay/ipn/ipn_event.rb', line 22

def amount
  scalar("amount") || ""
end

#attemptInteger



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_idString?



42
43
44
# File 'lib/dpay/ipn/ipn_event.rb', line 42

def capture_payment_id
  scalar("capture_payment_id")
end

#customString?



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

#emailString?



34
35
36
# File 'lib/dpay/ipn/ipn_event.rb', line 34

def email
  scalar("email")
end

#idString



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

#signatureString



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

#typeString



26
27
28
# File 'lib/dpay/ipn/ipn_event.rb', line 26

def type
  scalar("type") || ""
end

#versionInteger



50
51
52
# File 'lib/dpay/ipn/ipn_event.rb', line 50

def version
  integer("version")
end