Class: GenesisRuby::Api::Notification
- Inherits:
-
Object
- Object
- GenesisRuby::Api::Notification
- Defined in:
- lib/genesis_ruby/api/notification.rb
Overview
Gateway Notification handler
Constant Summary collapse
- SHA1_SIGNATURE_TYPE =
Signature algorithms
'SHA1'- SHA256_SIGNATURE_TYPE =
'SHA256'- SHA512_SIGNATURE_TYPE =
'SHA512'- API_UNIQUE_FIELD =
Possible request/response identifier fields
'unique_id'- WPF_UNIQUE_FIELD =
'wpf_unique_id'- KYC_UNIQUE_FIELD =
'reference_id'
Instance Attribute Summary collapse
-
#notification ⇒ Object
readonly
Returns the value of attribute notification.
-
#reconciliation ⇒ Object
readonly
Returns the value of attribute reconciliation.
-
#unique_id ⇒ Object
readonly
Returns the value of attribute unique_id.
Instance Method Summary collapse
-
#api_notification? ⇒ Boolean
Check if the given data is API notification.
-
#generate_response ⇒ Object
Generates XML document expected from the Gateway.
-
#initialize(configuration, data) ⇒ Notification
constructor
Class constructor.
-
#kyc_notification? ⇒ Boolean
Check if the given data is Know Your Customer notification.
-
#reconcile ⇒ Object
Execute Reconcile API Request.
-
#transaction_reconciliation? ⇒ Boolean
Determinate if the executed reconciliation response contains transaction data.
-
#wpf_notification? ⇒ Boolean
Check if the given data is Web Payment Form notification.
Constructor Details
#initialize(configuration, data) ⇒ Notification
Class constructor
24 25 26 27 28 |
# File 'lib/genesis_ruby/api/notification.rb', line 24 def initialize(configuration, data) @configuration = configuration parse_notification data end |
Instance Attribute Details
#notification ⇒ Object (readonly)
Returns the value of attribute notification.
11 12 13 |
# File 'lib/genesis_ruby/api/notification.rb', line 11 def notification @notification end |
#reconciliation ⇒ Object (readonly)
Returns the value of attribute reconciliation.
11 12 13 |
# File 'lib/genesis_ruby/api/notification.rb', line 11 def reconciliation @reconciliation end |
#unique_id ⇒ Object (readonly)
Returns the value of attribute unique_id.
11 12 13 |
# File 'lib/genesis_ruby/api/notification.rb', line 11 def unique_id @unique_id end |
Instance Method Details
#api_notification? ⇒ Boolean
Check if the given data is API notification
31 32 33 |
# File 'lib/genesis_ruby/api/notification.rb', line 31 def api_notification? notification.key? :unique_id end |
#generate_response ⇒ Object
Generates XML document expected from the Gateway
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/genesis_ruby/api/notification.rb', line 46 def generate_response response = { notification_echo: [[fetch_response_unique_field, unique_id]].to_h } builder = GenesisRuby::Builder.new Builder::XML builder.parse_structure response builder.document end |
#kyc_notification? ⇒ Boolean
Check if the given data is Know Your Customer notification
41 42 43 |
# File 'lib/genesis_ruby/api/notification.rb', line 41 def kyc_notification? notification.key? :reference_id end |
#reconcile ⇒ Object
Execute Reconcile API Request
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/genesis_ruby/api/notification.rb', line 58 def reconcile request_object = fetch_reconciliation_request begin genesis = Genesis.for config: @configuration, request: request_object do |req| req.unique_id = unique_id end.execute @reconciliation = genesis.response rescue Error @reconciliation = nil end end |
#transaction_reconciliation? ⇒ Boolean
Determinate if the executed reconciliation response contains transaction data
73 74 75 76 77 78 79 |
# File 'lib/genesis_ruby/api/notification.rb', line 73 def transaction_reconciliation? response_object = reconciliation&.response_object return false if response_object.nil? response_object.key?(:unique_id) && response_object.key?(:transaction_id) && response_object.key?(:status) end |
#wpf_notification? ⇒ Boolean
Check if the given data is Web Payment Form notification
36 37 38 |
# File 'lib/genesis_ruby/api/notification.rb', line 36 def wpf_notification? notification.key? :wpf_unique_id end |