Class: Alertpay::Notification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/notification.rb', line 5

def params
  @params
end

#rawObject

Returns the value of attribute raw.



6
7
8
# File 'lib/notification.rb', line 6

def raw
  @raw
end

Instance Method Details

#amountObject

Amount of item purchased.



46
47
48
# File 'lib/notification.rb', line 46

def amount
  params['ap_amount'].to_f
end

#currencyObject

Currency that the payment was made in.



51
52
53
# File 'lib/notification.rb', line 51

def currency
  params['ap_currency']
end

#customObject

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?

Returns:

  • (Boolean)


36
37
38
# File 'lib/notification.rb', line 36

def is_subscription_payment?
  status == 'Subscription-Payment-Success'
end

#item_codeObject

The item code on the alertpay side



72
73
74
# File 'lib/notification.rb', line 72

def item_code
  params['ap_itemcode']
end

#item_nameObject

Name of the item that was purchased.



26
27
28
# File 'lib/notification.rb', line 26

def item_name
  params['ap_itemname']
end

#merchantObject

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_typeObject

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_numberObject

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_codeObject

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

#shippingObject

The shipping charges for this transaction.



41
42
43
# File 'lib/notification.rb', line 41

def shipping
  params['ap_shippingcharges'].to_f
end

#statusObject

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?

Returns:

  • (Boolean)


31
32
33
# File 'lib/notification.rb', line 31

def successful?
  status == 'Success'
end