Class: MC2P::NotificationData

Inherits:
Object
  • Object
show all
Defined in:
lib/notification.rb

Overview

Notification data - class to manage notification from MyChoice2Pay

Instance Method Summary collapse

Constructor Details

#initialize(json_body, mc2p) ⇒ NotificationData

Initializes a notification data Params:

json_body

content of request from MyChoice2Pay

mc2p

MC2PClient



8
9
10
11
# File 'lib/notification.rb', line 8

def initialize(json_body, mc2p)
  @json_body = json_body
  @mc2p = mc2p
end

Instance Method Details

#actionObject

Returns: action executed



39
40
41
# File 'lib/notification.rb', line 39

def action
  @json_body['action']
end

#authorization_statusObject

Returns: status of authorization



24
25
26
# File 'lib/notification.rb', line 24

def authorization_status
  @json_body['authorization_status']
end

#order_idObject

Returns: order_id sent when payment was created



34
35
36
# File 'lib/notification.rb', line 34

def order_id
  @json_body['order_id']
end

#saleObject

Returns: sale generated when payment was paid



64
65
66
67
68
69
70
71
# File 'lib/notification.rb', line 64

def sale
  ret = nil
  if @json_body.include?('sale_id')
    ret = @mc2p.sale('id' => @json_body['sale_id'])
    ret.retrieve
  end
  ret
end

#sale_actionObject

Returns: action of sale executed



74
75
76
# File 'lib/notification.rb', line 74

def sale_action
  @json_body['sale_action']
end

#statusObject

Returns: status of payment



14
15
16
# File 'lib/notification.rb', line 14

def status
  @json_body['status']
end

#subscriptionObject

Returns: subscription generated when payment was created



54
55
56
57
58
59
60
61
# File 'lib/notification.rb', line 54

def subscription
  ret = nil
  if type == 'S'
    ret = @mc2p.subscription('id' => @json_body['id'])
    ret.retrieve
  end
  ret
end

#subscription_statusObject

Returns: status of subscription



19
20
21
# File 'lib/notification.rb', line 19

def subscription_status
  @json_body['subscription_status']
end

#transactionObject

Returns: transaction generated when payment was created



44
45
46
47
48
49
50
51
# File 'lib/notification.rb', line 44

def transaction
  ret = nil
  if type == 'P'
    ret = @mc2p.transaction('id' => @json_body['id'])
    ret.retrieve
  end
  ret
end

#typeObject

Returns: type of payment



29
30
31
# File 'lib/notification.rb', line 29

def type
  @json_body['type']
end