Class: OffsitePayments::Integrations::EPaymentPlans::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::EPaymentPlans::Notification
show all
- Includes:
- ActiveUtils::PostsData
- Defined in:
- lib/offsite_payments/integrations/e_payment_plans.rb
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #gross_cents, #initialize, #iso_currency, #valid_sender?
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
Acknowledge the transaction to EPaymentPlans. This method has to be called after a new apc arrives. EPaymentPlans will verify that all the information we received are correct and will return ok or a fail.
Example:
def ipn
notify = EPaymentPlans.notification(request.raw_post)
if notify.acknowledge
... process order ... if notify.complete?
else
... log possible hacking attempt ...
end
123
124
125
126
127
128
129
130
131
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 123
def acknowledge(authcode = nil)
payload = raw
response = ssl_post(EPaymentPlans.notification_confirmation_url, payload)
raise StandardError.new("Faulty EPaymentPlans result: #{response}") unless ["AUTHORISED", "DECLINED"].include?(response)
response == "AUTHORISED"
end
|
#complete? ⇒ Boolean
71
72
73
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 71
def complete?
status == "Completed"
end
|
#currency ⇒ Object
92
93
94
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 92
def currency
params['currency']
end
|
#gross ⇒ Object
88
89
90
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 88
def gross
params['gross']
end
|
#item_id ⇒ Object
79
80
81
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 79
def item_id
params['item_id']
end
|
#received_at ⇒ Object
When was this payment received by the client.
84
85
86
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 84
def received_at
Time.parse(params['received_at'].to_s).utc
end
|
#security_key ⇒ Object
96
97
98
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 96
def security_key
params['security_key']
end
|
#status ⇒ Object
105
106
107
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 105
def status
params['status'].capitalize
end
|
#test? ⇒ Boolean
Was this a test transaction?
101
102
103
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 101
def test?
params['test'] == 'test'
end
|
#transaction_id ⇒ Object
75
76
77
|
# File 'lib/offsite_payments/integrations/e_payment_plans.rb', line 75
def transaction_id
params['transaction_id']
end
|