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.
-
#authorization_status ⇒ Object
Returns: status of authorization.
-
#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
39 40 41 |
# File 'lib/notification.rb', line 39 def action @json_body['action'] end |
#authorization_status ⇒ Object
Returns: status of authorization
24 25 26 |
# File 'lib/notification.rb', line 24 def @json_body['authorization_status'] end |
#order_id ⇒ Object
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 |
#sale ⇒ Object
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_action ⇒ Object
Returns: action of sale executed
74 75 76 |
# File 'lib/notification.rb', line 74 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
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_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
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 |
#type ⇒ Object
Returns: type of payment
29 30 31 |
# File 'lib/notification.rb', line 29 def type @json_body['type'] end |