class MC2P::NotificationData
Notification data - class to manage notification from MyChoice2Pay
Public Class Methods
new(json_body, mc2p)
click to toggle source
Initializes a notification data Params:
json_body
-
content of request from MyChoice2Pay
mc2p
# File lib/notification.rb, line 8 def initialize(json_body, mc2p) @json_body = json_body @mc2p = mc2p end
Public Instance Methods
action()
click to toggle source
Returns: action executed
# File lib/notification.rb, line 39 def action @json_body['action'] end
order_id()
click to toggle source
Returns: order_id
sent when payment was created
# File lib/notification.rb, line 34 def order_id @json_body['order_id'] end
sale()
click to toggle source
Returns: sale generated when payment was paid
# 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_action()
click to toggle source
Returns: action of sale executed
# File lib/notification.rb, line 74 def sale_action @json_body['sale_action'] end
status()
click to toggle source
Returns: status of payment
# File lib/notification.rb, line 14 def status @json_body['status'] end
subscription()
click to toggle source
Returns: subscription generated when payment was created
# 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_status()
click to toggle source
Returns: status of subscription
# File lib/notification.rb, line 19 def subscription_status @json_body['subscription_status'] end
transaction()
click to toggle source
Returns: transaction generated when payment was created
# 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
type()
click to toggle source
Returns: type of payment
# File lib/notification.rb, line 29 def type @json_body['type'] end