Sha256: 037a18a54cacde2b140039109b5e4ac89e171e6291487d448bfc9755d90f8cc7

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

class PaymentOperationsDemoRailtie < Rails::Railtie # :nodoc:
  initializer 'PaymentOperationsDemo.connector_initialization' do # rubocop:disable Metrics/BlockLength
    Hws::Connectors.configure do |config| # rubocop:disable Metrics/BlockLength
      config.webhooks = {
        'payouts' => {
          'callback' => lambda do |_entity, response|
                          Rails.logger.debug response.inspect

                          begin
                            Hws::PaymentOperationsDemo::VirtualAccount.record_txn_status_change(
                              response.reference_number, response.status, response.bank_ref_num
                            )
                          rescue StandardError => e
                            Rails.logger.info e.backtrace
                            raise e
                          end
                        end
        },
        'virtual_accounts' => {
          'notify' => lambda do |_entity, response|
                        Rails.logger.debug response.inspect
                        begin
                          Hws::PaymentOperationsDemo::VirtualAccount.funds_received_webhook(
                            va_num: response.beneficiary.account_number,
                            amount: response.amount,
                            payment_type: response.payment_type,
                            txn_time: response.credit_time,
                            status: 'COMPLETED',
                            bank_ref_id: response.bank_ref_num,
                            beneficiary: response.beneficiary,
                            remitter: response.remitter
                          )
                        rescue StandardError => e
                          Rails.logger.info e.backtrace
                          raise e
                        end
                      end
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hws-payment_operations_demo-0.1.0 lib/hws/payment_operations_demo/railtie.rb