Class: Alertpay::Notification
- Inherits:
-
Object
- Object
- Alertpay::Notification
- Defined in:
- lib/notification.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
-
#amount ⇒ Object
Amount of item purchased.
-
#currency ⇒ Object
Currency that the payment was made in.
-
#custom ⇒ Object
An array containing the 6 custom elements.
-
#initialize(post) ⇒ Notification
constructor
A new instance of Notification.
-
#is_subscription_payment? ⇒ Boolean
Was this a subscription payment?.
-
#item_code ⇒ Object
The item code on the alertpay side.
-
#item_name ⇒ Object
Name of the item that was purchased.
-
#merchant ⇒ Object
The email address associated with the merchant that recieved the monies.
-
#purchase_type ⇒ Object
The type of purchase.
-
#reference_number ⇒ Object
The reference number or transaction ID you can use to refer to this transaction.
-
#security_code ⇒ Object
Security code sent through from alertpay.
-
#shipping ⇒ Object
The shipping charges for this transaction.
-
#status ⇒ Object
Status of the payment.
-
#successful? ⇒ Boolean
Was the payment successful?.
Constructor Details
#initialize(post) ⇒ Notification
Returns a new instance of Notification.
8 9 10 11 |
# File 'lib/notification.rb', line 8 def initialize(post) @params = {} parse(post) end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/notification.rb', line 5 def params @params end |
#raw ⇒ Object
Returns the value of attribute raw.
6 7 8 |
# File 'lib/notification.rb', line 6 def raw @raw end |
Instance Method Details
#amount ⇒ Object
Amount of item purchased.
46 47 48 |
# File 'lib/notification.rb', line 46 def amount params['ap_amount'].to_f end |
#currency ⇒ Object
Currency that the payment was made in.
51 52 53 |
# File 'lib/notification.rb', line 51 def currency params['ap_currency'] end |
#custom ⇒ Object
An array containing the 6 custom elements
77 78 79 |
# File 'lib/notification.rb', line 77 def custom params.values_at('apc_1', 'apc_2', 'apc_3', 'apc_4', 'apc_5', 'apc_6') end |
#is_subscription_payment? ⇒ Boolean
Was this a subscription payment?
36 37 38 |
# File 'lib/notification.rb', line 36 def is_subscription_payment? status == 'Subscription-Payment-Success' end |
#item_code ⇒ Object
The item code on the alertpay side
72 73 74 |
# File 'lib/notification.rb', line 72 def item_code params['ap_itemcode'] end |
#item_name ⇒ Object
Name of the item that was purchased.
26 27 28 |
# File 'lib/notification.rb', line 26 def item_name params['ap_itemname'] end |
#merchant ⇒ Object
The email address associated with the merchant that recieved the monies.
67 68 69 |
# File 'lib/notification.rb', line 67 def merchant params['ap_merchant'] end |
#purchase_type ⇒ Object
The type of purchase. E.g. ‘item’ or ‘subscription’.
14 15 16 |
# File 'lib/notification.rb', line 14 def purchase_type params['ap_purchasetype'] end |
#reference_number ⇒ Object
The reference number or transaction ID you can use to refer to this transaction.
62 63 64 |
# File 'lib/notification.rb', line 62 def reference_number params['ap_referencenumber'] end |
#security_code ⇒ Object
Security code sent through from alertpay. You are to compare this with a hard coded value that you get from your alertpay profile, which only you should know.
21 22 23 |
# File 'lib/notification.rb', line 21 def security_code params['ap_securitycode'] end |
#shipping ⇒ Object
The shipping charges for this transaction.
41 42 43 |
# File 'lib/notification.rb', line 41 def shipping params['ap_shippingcharges'].to_f end |
#status ⇒ Object
Status of the payment. E.g. ‘Succes’
56 57 58 |
# File 'lib/notification.rb', line 56 def status params['ap_status'] end |
#successful? ⇒ Boolean
Was the payment successful?
31 32 33 |
# File 'lib/notification.rb', line 31 def successful? status == 'Success' end |