Skip to content

An Open Source Connector for integrating with any financial service providers.

License

Notifications You must be signed in to change notification settings

hwslabs/hws-connectors-ruby

Repository files navigation

Hws Connectors

License Ruby gem PRs Welcome

An Open Source Connector to integrate with any financial service providers like banks, fintech, etc., providing a unified response across various providers.

NOTE: We are starting of with Hypto connectors & will be introducing the integrations of other financial service providers shortly.

Installation

Add this line to your application's Gemfile:

gem 'hws-connectors'

And then execute:

bundle install

Or install it yourself as:

gem install hws-connectors

Configuration

Hws::Connectors.configure do |config|
  config.logger = Rails.logger
  config.options = { skip_logging: %w(get) },
    config.webhooks = {
      'payouts' => {
        'callback' => -> (entity, response) { puts "#{entity.inspect} - #{response.inspect}" },
      },
      'virtual_accounts' => {
        'notify' => -> (entity, response) { puts "#{entity.inspect} - #{response.inspect}" }
      }
    }
end

Payout

# Initialise payout client (eg: Hypto)
CLIENT_INFO = { 'api_token' => "<HYPTO_API_TOKEN>", 'env' => 'development | production' }
$hypto_payout_client = Hws::Connectors::Hypto::Payout.new(CLIENT_INFO)

# Send to bank account
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', account_number: '12345678', account_ifsc: 'HDFC0005322', note: 'Connector testing')
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'IMPS', amount: 1)
resp = $hypto_payout_client.send_to_bank_account(request: request)

# Send to Upi Id
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', upi_id: 'ddlogesh@okhdfcbank', note: 'Connector testing')
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'UPI', amount: 1)
resp = $hypto_payout_client.send_to_upi_id(request: request)

# Fetch payout status
resp = $hypto_payout_client.status(reference_number: 'reference_number')

VirtualAccount

# Initialise virtual account client (eg: Hypto)
$hypto_va_client = Hws::Connectors::Hypto::VirtualAccount.new(CLIENT_INFO)

# Create a virtual account
request = Hws::Connectors::Dto::VirtualAccountRequest.new(reference_number: 'REF123')
resp = $hypto_va_client.create(request: request)

# Update an existing virtual account
request = Hws::Connectors::Dto::VirtualAccountRequest.new(reference_number: 'REF139856', meta: { id: 139856 })
resp = $hypto_va_client.update(request: request)

# Activate a virtual account
resp = $hypto_va_client.activate(reference_number: 139856)

# Deactivate a virtual account
resp = $hypto_va_client.deactivate(reference_number: 139856)

# Fetch a virtual account
resp = $hypto_va_client.fetch(reference_number: 139856)

Payout (From Virtual Account)

# Send to bank account
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', account_number: '12345678', account_ifsc: 'HDFC0005322', note: 'Connector testing')
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'IMPS', amount: 1, meta: { va_id: 139856 })
resp = $hypto_va_client.send_to_bank_account(request: request)

# Send to Upi Id
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', upi_id: 'ddlogesh@okhdfcbank', note: 'Connector testing')
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'UPI', amount: 1, meta: { va_id: 139856 })
resp = $hypto_va_client.send_to_upi_id(request: request)

# Fetch payout status
resp = $hypto_va_client.status(reference_number: 'reference_number', va_id: 139856)

Webhooks

Payout Status 
POST : {{host}}/hws/connectors/payouts/hypto/callback

Credit Virtual Account
POST : {{host}}/hws/connectors/virtual_accounts/hypto/notify

Contributing

We wish the Fintech community to come forward and contribute to this project, making the developer's life easier.

Fork our project and send us a pull request: may be a minor bug fix, new bank integrations or financial connectors.

Every contribution is welcome!