Module: ActiveMerchant::Billing::Integrations::Banklink::Notification
- Included in:
- DnbNordLtu::Notification, SampoEst::Notification, SebEst::Notification, SebLtu::Notification, SwedbankEst::Notification, SwedbankLtu::Notification
- Defined in:
- lib/active_merchant/billing/integrations/banklink/notification.rb
Instance Method Summary collapse
-
#acknowledge ⇒ Object
We don’t actually acknowledge the notification by making another request ourself, instead, we check the notification by checking the signature that came with the notification.
-
#automatic? ⇒ Boolean
If our request was sent automatically by the bank (true) or manually by the user triggering the callback by pressing a “return” button (false).
-
#bank_signature_valid?(bank_signature, service_msg_number, sigparams) ⇒ Boolean
A helper method to parse the raw post of the request & return the right Notification subclass based on the sender id.
- #complete? ⇒ Boolean
- #currency ⇒ Object
- #failed? ⇒ Boolean
-
#gross ⇒ Object
The money amount we received, string.
-
#item_id ⇒ Object
The order id we passed to the form helper.
-
#received_at ⇒ Object
When was this payment received by the client.
- #signature ⇒ Object
-
#status ⇒ Object
TODO what should be here?.
- #success? ⇒ Boolean
-
#test? ⇒ Boolean
Was this a test transaction?.
- #transaction_id ⇒ Object
- #wait? ⇒ Boolean
Instance Method Details
#acknowledge ⇒ Object
We don’t actually acknowledge the notification by making another request ourself, instead, we check the notification by checking the signature that came with the notification. This method has to be called when handling the notification & deciding whether to process the order. Example:
def notify
notify = Notification.new(params)
if notify.acknowledge
... process order ... if notify.complete?
else
... log possible hacking attempt ...
end
94 95 96 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 94 def acknowledge bank_signature_valid?(signature, params['VK_SERVICE'], params) end |
#automatic? ⇒ Boolean
If our request was sent automatically by the bank (true) or manually by the user triggering the callback by pressing a “return” button (false).
73 74 75 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 73 def automatic? params['VK_AUTO'].upcase == 'Y' end |
#bank_signature_valid?(bank_signature, service_msg_number, sigparams) ⇒ Boolean
A helper method to parse the raw post of the request & return the right Notification subclass based on the sender id. def self.get_notification(http_raw_data)
params = ActiveMerchant::Billing::Integrations::Notification.new(http_raw_data).params
Banklink.get_class(params)::Notification.new(http_raw_data)
end
14 15 16 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 14 def bank_signature_valid?(bank_signature, service_msg_number, sigparams) self.class.parent.get_bank_public_key.verify(OpenSSL::Digest::SHA1.new, bank_signature, generate_data_string(service_msg_number, sigparams)) end |
#complete? ⇒ Boolean
18 19 20 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 18 def complete? params['VK_SERVICE'] == '1101' end |
#currency ⇒ Object
30 31 32 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 30 def currency params['VK_CURR'] end |
#failed? ⇒ Boolean
26 27 28 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 26 def failed? params['VK_SERVICE'] == '1901' end |
#gross ⇒ Object
The money amount we received, string.
57 58 59 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 57 def gross params['VK_AMOUNT'] end |
#item_id ⇒ Object
The order id we passed to the form helper.
35 36 37 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 35 def item_id params['VK_STAMP'] end |
#received_at ⇒ Object
When was this payment received by the client. We’re expecting a dd.mm.yyyy format.
45 46 47 48 49 50 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 45 def received_at date = params['VK_T_DATE'] return nil unless date day, month, year = *date.split('.').map(&:to_i) Date.civil(year, month, day) end |
#signature ⇒ Object
52 53 54 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 52 def signature Base64.decode64(params['VK_MAC']) end |
#status ⇒ Object
TODO what should be here?
67 68 69 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 67 def status complete? ? 'Completed' : 'Failed' end |
#success? ⇒ Boolean
77 78 79 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 77 def success? acknowledge && complete? end |
#test? ⇒ Boolean
Was this a test transaction?
62 63 64 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 62 def test? params['VK_REC_ID'] == 'testvpos' end |
#transaction_id ⇒ Object
39 40 41 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 39 def transaction_id params['VK_T_NO'] end |
#wait? ⇒ Boolean
22 23 24 |
# File 'lib/active_merchant/billing/integrations/banklink/notification.rb', line 22 def wait? params['VK_SERVICE'] == '1201' end |