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 =

Returns:

  • (String)
"OK"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ IpnEvent

Returns a new instance of IpnEvent.

Parameters:

  • payload (Hash[String, untyped])


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.

Returns:

  • (Hash[String, untyped])


7
8
9
# File 'lib/dpay/ipn/ipn_event.rb', line 7

def raw
  @raw
end

Class Method Details

.from_verified_payload(payload) ⇒ IpnEvent

Parameters:

  • payload (Hash[String, untyped])

Returns:



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

Returns:

  • (String)


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

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

#attemptInteger

Returns:

  • (Integer)


46
47
48
# File 'lib/dpay/ipn/ipn_event.rb', line 46

def attempt
  integer("attempt")
end

#capture?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/dpay/ipn/ipn_event.rb', line 58

def capture?
  type == IpnType::CAPTURE
end

#capture_payment_idString?

Returns:

  • (String, nil)


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

def capture_payment_id
  scalar("capture_payment_id")
end

#customString?

Returns:

  • (String, nil)


38
39
40
# File 'lib/dpay/ipn/ipn_event.rb', line 38

def custom
  scalar("custom")
end

#dcb?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/dpay/ipn/ipn_event.rb', line 62

def dcb?
  type == IpnType::DCB
end

#emailString?

Returns:

  • (String, nil)


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

def email
  scalar("email")
end

#idString

Returns:

  • (String)


18
19
20
# File 'lib/dpay/ipn/ipn_event.rb', line 18

def id
  scalar("id") || ""
end

#integer(key) ⇒ Integer

Parameters:

  • key (String)

Returns:

  • (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?

Parameters:

  • key (String)

Returns:

  • (String, nil)


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

Returns:

  • (String)


30
31
32
# File 'lib/dpay/ipn/ipn_event.rb', line 30

def signature
  scalar("signature") || ""
end

#transfer?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/dpay/ipn/ipn_event.rb', line 54

def transfer?
  type == IpnType::TRANSFER
end

#typeString

Returns:

  • (String)


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

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

#versionInteger

Returns:

  • (Integer)


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

def version
  integer("version")
end