Class: MC2P::NotificationData
- Inherits:
-
Object
- Object
- MC2P::NotificationData
- Defined in:
- lib/notification.rb
Overview
Notification data - class to manage notification from MyChoice2Pay
Instance Method Summary collapse
-
#action ⇒ Object
Returns: action executed.
-
#initialize(json_body, mc2p) ⇒ NotificationData
constructor
- Initializes a notification data Params:
json_body - content of request from MyChoice2Pay
mc2p -
MC2PClient.
- content of request from MyChoice2Pay
- Initializes a notification data Params:
-
#order_id ⇒ Object
Returns: order_id sent when payment was created.
-
#sale ⇒ Object
Returns: sale generated when payment was paid.
-
#sale_action ⇒ Object
Returns: action of sale executed.
-
#status ⇒ Object
Returns: status of payment.
-
#subscription ⇒ Object
Returns: subscription generated when payment was created.
-
#subscription_status ⇒ Object
Returns: status of subscription.
-
#transaction ⇒ Object
Returns: transaction generated when payment was created.
-
#type ⇒ Object
Returns: type of payment.
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
#action ⇒ Object
Returns: action executed
34 35 36 |
# File 'lib/notification.rb', line 34 def action @json_body['action'] end |
#order_id ⇒ Object
Returns: order_id sent when payment was created
29 30 31 |
# File 'lib/notification.rb', line 29 def order_id @json_body['order_id'] end |
#sale ⇒ Object
Returns: sale generated when payment was paid
59 60 61 62 63 64 65 66 |
# File 'lib/notification.rb', line 59 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 ⇒ Object
Returns: action of sale executed
69 70 71 |
# File 'lib/notification.rb', line 69 def sale_action @json_body['sale_action'] end |
#status ⇒ Object
Returns: status of payment
14 15 16 |
# File 'lib/notification.rb', line 14 def status @json_body['status'] end |
#subscription ⇒ Object
Returns: subscription generated when payment was created
49 50 51 52 53 54 55 56 |
# File 'lib/notification.rb', line 49 def subscription ret = nil if type == 'S' ret = @mc2p.subscription('id' => @json_body['id']) ret.retrieve end ret end |
#subscription_status ⇒ Object
Returns: status of subscription
19 20 21 |
# File 'lib/notification.rb', line 19 def subscription_status @json_body['subscription_status'] end |
#transaction ⇒ Object
Returns: transaction generated when payment was created
39 40 41 42 43 44 45 46 |
# File 'lib/notification.rb', line 39 def transaction ret = nil if type == 'P' ret = @mc2p.transaction('id' => @json_body['id']) ret.retrieve end ret end |
#type ⇒ Object
Returns: type of payment
24 25 26 |
# File 'lib/notification.rb', line 24 def type @json_body['type'] end |