hws-connectors 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +123 -0
- data/Rakefile +2 -0
- data/app/controllers/hws/connectors/payouts_controller.rb +18 -0
- data/app/controllers/hws/connectors/virtual_accounts_controller.rb +15 -0
- data/app/controllers/hws/connectors/webhooks_controller.rb +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/routes.rb +12 -0
- data/hws-connectors.gemspec +38 -0
- data/lib/hws-connectors/base.rb +12 -0
- data/lib/hws-connectors/dto/base.rb +6 -0
- data/lib/hws-connectors/dto/common/account_detail.rb +13 -0
- data/lib/hws-connectors/dto/common/base.rb +4 -0
- data/lib/hws-connectors/dto/common/entity.rb +7 -0
- data/lib/hws-connectors/dto/common/request.rb +8 -0
- data/lib/hws-connectors/dto/common/response.rb +8 -0
- data/lib/hws-connectors/dto/payout/base.rb +2 -0
- data/lib/hws-connectors/dto/payout/payout_request.rb +10 -0
- data/lib/hws-connectors/dto/payout/payout_response.rb +17 -0
- data/lib/hws-connectors/dto/virtual_account/base.rb +3 -0
- data/lib/hws-connectors/dto/virtual_account/credit_virtual_account_response.rb +13 -0
- data/lib/hws-connectors/dto/virtual_account/virtual_account_request.rb +8 -0
- data/lib/hws-connectors/dto/virtual_account/virtual_account_response.rb +12 -0
- data/lib/hws-connectors/engine.rb +4 -0
- data/lib/hws-connectors/exception.rb +33 -0
- data/lib/hws-connectors/helper.rb +23 -0
- data/lib/hws-connectors/hypto/base.rb +57 -0
- data/lib/hws-connectors/hypto/endpoints.yml +36 -0
- data/lib/hws-connectors/hypto/payout/base.rb +48 -0
- data/lib/hws-connectors/hypto/virtual_account/base.rb +69 -0
- data/lib/hws-connectors/hypto/virtual_account/transaction.rb +46 -0
- data/lib/hws-connectors/railtie.rb +10 -0
- data/lib/hws-connectors.rb +30 -0
- metadata +170 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6bec6f19f3cc3493448142dff0b5943455739586d828bc5ddbf59cf06169af26
|
|
4
|
+
data.tar.gz: 55b3283003d97292a98fe62ac60982f6b9992012a86d457f8b291cd19cd9c085
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 03572de21caf450e084421d525f4dee719e3b123d48292e7840b96879948b086461e1b220ee55fd500d667596a53fc45944bf4eb474cf69d614cc55e929c844f
|
|
7
|
+
data.tar.gz: 37ac5ddb408afac8f21d5d4355ffd630f0832f9404b1163ba6b8d8f0481e01435e282ce9491c5d9b0166b4a10736d47ebf9d45184d4b727f5376e31b02d5483e
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.5
|
|
3
|
+
NewCops: enable
|
|
4
|
+
|
|
5
|
+
Style/StringLiterals:
|
|
6
|
+
Enabled: true
|
|
7
|
+
EnforcedStyle: single_quotes
|
|
8
|
+
|
|
9
|
+
Style/StringLiteralsInInterpolation:
|
|
10
|
+
Enabled: true
|
|
11
|
+
EnforcedStyle: double_quotes
|
|
12
|
+
|
|
13
|
+
Style/ClassAndModuleChildren:
|
|
14
|
+
Enabled: true
|
|
15
|
+
EnforcedStyle: compact
|
|
16
|
+
|
|
17
|
+
Style/RedundantSelf:
|
|
18
|
+
Enabled: false
|
|
19
|
+
|
|
20
|
+
Layout/LineLength:
|
|
21
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at tholkappiyan@hypto.in. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Tholkappiyan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
Hws Connectors
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="LICENSE.txt"><img alt="License" src="https://img.shields.io/github/license/hwslabs/hws-connectors-ruby"></a>
|
|
7
|
+
<a href="https://github.com/hwslabs/hws-connectors-ruby/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square"></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'hws-connectors'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
bundle install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install it yourself as:
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
gem install hws-connectors
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Configuration
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
Hws::Connectors.configure do |config|
|
|
34
|
+
config.logger = Rails.logger
|
|
35
|
+
config.options = { skip_logging: %w(get) },
|
|
36
|
+
config.webhooks = {
|
|
37
|
+
'payouts' => {
|
|
38
|
+
'callback' => -> (entity, response) { puts "#{entity.inspect} - #{response.inspect}" },
|
|
39
|
+
},
|
|
40
|
+
'virtual_accounts' => {
|
|
41
|
+
'notify' => -> (entity, response) { puts "#{entity.inspect} - #{response.inspect}" }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Payout
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
# Initialise payout client (eg: Hypto)
|
|
51
|
+
CLIENT_INFO = { 'api_token' => "<HYPTO_API_TOKEN>", 'env' => 'development | production' }
|
|
52
|
+
$hypto_payout_client = Hws::Connectors::Hypto::Payout.new(CLIENT_INFO)
|
|
53
|
+
|
|
54
|
+
# Send to bank account
|
|
55
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', account_number: '12345678', account_ifsc: 'HDFC0005322', note: 'Connector testing')
|
|
56
|
+
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'IMPS', amount: 1)
|
|
57
|
+
resp = $hypto_payout_client.send_to_bank_account(request: request)
|
|
58
|
+
|
|
59
|
+
# Send to Upi Id
|
|
60
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', upi_id: 'ddlogesh@okhdfcbank', note: 'Connector testing')
|
|
61
|
+
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'UPI', amount: 1)
|
|
62
|
+
resp = $hypto_payout_client.send_to_upi_id(request: request)
|
|
63
|
+
|
|
64
|
+
# Fetch payout status
|
|
65
|
+
resp = $hypto_payout_client.status(reference_number: 'reference_number')
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### VirtualAccount
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
# Initialise virtual account client (eg: Hypto)
|
|
72
|
+
$hypto_va_client = Hws::Connectors::Hypto::VirtualAccount.new(CLIENT_INFO)
|
|
73
|
+
|
|
74
|
+
# Create a virtual account
|
|
75
|
+
request = Hws::Connectors::Dto::VirtualAccountRequest.new(reference_number: 'REF123')
|
|
76
|
+
resp = $hypto_va_client.create(request: request)
|
|
77
|
+
|
|
78
|
+
# Update an existing virtual account
|
|
79
|
+
request = Hws::Connectors::Dto::VirtualAccountRequest.new(reference_number: 'REF139856', meta: { id: 139856 })
|
|
80
|
+
resp = $hypto_va_client.update(request: request)
|
|
81
|
+
|
|
82
|
+
# Activate a virtual account
|
|
83
|
+
resp = $hypto_va_client.activate(reference_number: 139856)
|
|
84
|
+
|
|
85
|
+
# Deactivate a virtual account
|
|
86
|
+
resp = $hypto_va_client.deactivate(reference_number: 139856)
|
|
87
|
+
|
|
88
|
+
# Fetch a virtual account
|
|
89
|
+
resp = $hypto_va_client.fetch(reference_number: 139856)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Payout (From Virtual Account)
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
# Send to bank account
|
|
96
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', account_number: '12345678', account_ifsc: 'HDFC0005322', note: 'Connector testing')
|
|
97
|
+
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'IMPS', amount: 1, meta: { va_id: 139856 })
|
|
98
|
+
resp = $hypto_va_client.send_to_bank_account(request: request)
|
|
99
|
+
|
|
100
|
+
# Send to Upi Id
|
|
101
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(name: 'Logesh', upi_id: 'ddlogesh@okhdfcbank', note: 'Connector testing')
|
|
102
|
+
request = Hws::Connectors::Dto::PayoutRequest.new(beneficiary: beneficiary, payment_type: 'UPI', amount: 1, meta: { va_id: 139856 })
|
|
103
|
+
resp = $hypto_va_client.send_to_upi_id(request: request)
|
|
104
|
+
|
|
105
|
+
# Fetch payout status
|
|
106
|
+
resp = $hypto_va_client.status(reference_number: 'reference_number', va_id: 139856)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Webhooks
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Payout Status
|
|
113
|
+
POST : {{host}}/hws/connectors/payouts/hypto/callback
|
|
114
|
+
|
|
115
|
+
Credit Virtual Account
|
|
116
|
+
POST : {{host}}/hws/connectors/virtual_accounts/hypto/notify
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Contributing
|
|
120
|
+
|
|
121
|
+
Fork our project and send us your pull request: may be a minor bug, extension or major improvements.
|
|
122
|
+
|
|
123
|
+
**Every contribution is welcome!**
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Hws::Connectors::PayoutsController < Hws::Connectors::WebhooksController
|
|
2
|
+
HYPTO_META_RESPONSES = %w(id txn_time created_at txn_type charges_gst settled_amount connected_banking udf1 udf2 udf3 initiated_account_ifsc
|
|
3
|
+
va_closing_balance hypto_va_id va_wallet_amount va_settler_id)
|
|
4
|
+
|
|
5
|
+
def callback
|
|
6
|
+
Hws::Connectors.logger.debug "===== Hws::Connectors::PayoutsController.callback - Payload: #{params.inspect} ====="
|
|
7
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail
|
|
8
|
+
.new(name: params['beneficiary_name'], account_number: params['account_number'],
|
|
9
|
+
account_ifsc: params['account_ifsc'], note: params['note'])
|
|
10
|
+
response = Hws::Connectors::Dto::PayoutResponse
|
|
11
|
+
.new(reference_number: params['reference_number'], beneficiary: beneficiary, account_holder: params['account_holder'],
|
|
12
|
+
amount: params['amount'].to_f, payment_type: params['payment_type'], status: params['status'],
|
|
13
|
+
bank_ref_num: params['bank_ref_num'], txn_time: Time.strptime(params['txn_time'], '%Y-%m-%d %H:%M:%S'),
|
|
14
|
+
meta: params.as_json.slice(*HYPTO_META_RESPONSES))
|
|
15
|
+
|
|
16
|
+
render_response(response)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Hws::Connectors::VirtualAccountsController < Hws::Connectors::WebhooksController
|
|
2
|
+
HYPTO_META_RESPONSES = %w(id va_closing_balance va_settler_id charges_gst settled_amount txn_time created_at hypto_va_id va_wallet_amount va_lien_amount)
|
|
3
|
+
|
|
4
|
+
def notify
|
|
5
|
+
Hws::Connectors.logger.debug "===== Hws::Connectors::VirtualAccountsController.notify - Payload: #{params.inspect} ====="
|
|
6
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(account_number: params['bene_account_no'], account_ifsc: params['bene_account_ifsc'])
|
|
7
|
+
remitter = Hws::Connectors::Dto::AccountDetail.new(account_number: params['rmtr_account_no'], account_ifsc: params['rmtr_account_ifsc'],
|
|
8
|
+
note: params['rmtr_to_bene_note'], name: params['rmtr_full_name'])
|
|
9
|
+
|
|
10
|
+
response = Hws::Connectors::Dto::CreditVirtualAccountResponse
|
|
11
|
+
.new(credit_time: Time.strptime(params['credited_at'], '%Y-%m-%d %H:%M:%S'), beneficiary: beneficiary, remitter: remitter, amount: params['amount'].to_f,
|
|
12
|
+
payment_type: params['payment_type'], bank_ref_num: params['bank_ref_num'], meta: params.as_json.slice(*HYPTO_META_RESPONSES))
|
|
13
|
+
render_response(response)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class Hws::Connectors::WebhooksController < ApplicationController
|
|
2
|
+
protect_from_forgery
|
|
3
|
+
|
|
4
|
+
protected
|
|
5
|
+
|
|
6
|
+
def render_response(response)
|
|
7
|
+
entity = Hws::Connectors::Dto::Entity.new(name: params['entity'])
|
|
8
|
+
Hws::Connectors.webhooks.to_h[params['controller'].split('/').last].to_h[params['action']].try(:call, entity, response)
|
|
9
|
+
render status: 200, json: { success: true, message: 'success' }
|
|
10
|
+
end
|
|
11
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "hws/connectors"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/config/routes.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
namespace :hws do
|
|
3
|
+
namespace :connectors do
|
|
4
|
+
resource :payouts, only: :none do
|
|
5
|
+
collection { post ':entity/callback', action: :callback }
|
|
6
|
+
end
|
|
7
|
+
resource :virtual_accounts, only: :none do
|
|
8
|
+
collection { post ':entity/notify', action: :notify }
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'hws-connectors'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'hws-connectors'
|
|
7
|
+
spec.version = Hws::Connectors::VERSION
|
|
8
|
+
spec.authors = ['Hypto Engineering Team']
|
|
9
|
+
spec.email = ['engineering@hypto.in']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'HWS Connector'
|
|
12
|
+
spec.description = 'Primitive for connecting to the financial services'
|
|
13
|
+
spec.homepage = 'https://github.com/hwslabs/hws-connectors-ruby'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 2.4.0'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/hwslabs/hws-connectors-ruby'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/hwslabs/hws-connectors-ruby/blob/main/CHANGELOG.md'
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = 'exe'
|
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ['lib']
|
|
30
|
+
|
|
31
|
+
spec.add_dependency 'rails', '~> 5.0'
|
|
32
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency 'bundler', '~> 2.2.33'
|
|
35
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 0.49'
|
|
38
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class Hws::Connectors::Base
|
|
2
|
+
ALLOWED_ACTION_CLASSES = [String, Symbol].freeze
|
|
3
|
+
|
|
4
|
+
def self.execute_action action, *args
|
|
5
|
+
return nil unless ALLOWED_ACTION_CLASSES.include?(action.class)
|
|
6
|
+
|
|
7
|
+
action = action.to_sym
|
|
8
|
+
return nil unless self.methods.include?(action)
|
|
9
|
+
|
|
10
|
+
self.send(action, *args)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Hws::Connectors::Dto::AccountDetail
|
|
2
|
+
attr_accessor :name, :account_number, :account_ifsc, :upi_id, :note, :created_at, :updated_at
|
|
3
|
+
|
|
4
|
+
def initialize(name: nil, account_number: nil, account_ifsc: nil, upi_id: nil, note: nil, created_at: nil, updated_at: nil)
|
|
5
|
+
@name = name
|
|
6
|
+
@account_number = account_number
|
|
7
|
+
@account_ifsc = account_ifsc
|
|
8
|
+
@upi_id = upi_id
|
|
9
|
+
@note = note
|
|
10
|
+
@created_at = created_at
|
|
11
|
+
@updated_at = updated_at
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class Hws::Connectors::Dto::PayoutRequest < Hws::Connectors::Request
|
|
2
|
+
attr_accessor :beneficiary, :amount, :payment_type
|
|
3
|
+
|
|
4
|
+
def initialize(beneficiary:, amount:, payment_type:, reference_number: nil, meta: {})
|
|
5
|
+
@beneficiary = beneficiary
|
|
6
|
+
@amount = amount
|
|
7
|
+
@payment_type = payment_type
|
|
8
|
+
super(reference_number: reference_number, meta: meta)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Hws::Connectors::Dto::PayoutResponse < Hws::Connectors::Response
|
|
2
|
+
attr_accessor :reference_number, :account_holder, :amount, :payment_type, :beneficiary
|
|
3
|
+
attr_accessor :txn_time, :status, :bank_ref_num
|
|
4
|
+
|
|
5
|
+
def initialize(reference_number:, beneficiary:, account_holder: nil, amount:, payment_type:, txn_time:, status:, bank_ref_num: nil,
|
|
6
|
+
message: nil, meta: {})
|
|
7
|
+
@reference_number = reference_number
|
|
8
|
+
@beneficiary = beneficiary
|
|
9
|
+
@account_holder = account_holder
|
|
10
|
+
@amount = amount
|
|
11
|
+
@payment_type = payment_type
|
|
12
|
+
@txn_time = txn_time
|
|
13
|
+
@status = status
|
|
14
|
+
@bank_ref_num = bank_ref_num
|
|
15
|
+
super(message: message, meta: meta)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Hws::Connectors::Dto::CreditVirtualAccountResponse < Hws::Connectors::Response
|
|
2
|
+
attr_accessor :credit_time, :beneficiary, :remitter, :amount, :payment_type, :bank_ref_num
|
|
3
|
+
|
|
4
|
+
def initialize(credit_time:, beneficiary:, remitter:, amount:, payment_type:, bank_ref_num:, meta: {})
|
|
5
|
+
@credit_time = credit_time
|
|
6
|
+
@beneficiary = beneficiary
|
|
7
|
+
@remitter = remitter
|
|
8
|
+
@amount = amount
|
|
9
|
+
@payment_type = payment_type
|
|
10
|
+
@bank_ref_num = bank_ref_num
|
|
11
|
+
super(meta: meta)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class Hws::Connectors::Dto::VirtualAccountResponse < Hws::Connectors::Response
|
|
2
|
+
attr_accessor :reference_number, :beneficiary, :remitters, :status, :balance
|
|
3
|
+
|
|
4
|
+
def initialize(reference_number:, beneficiary:, remitters: [], status: nil, balance: nil, message: nil, meta: {})
|
|
5
|
+
@reference_number = reference_number
|
|
6
|
+
@beneficiary = beneficiary
|
|
7
|
+
@remitters = remitters
|
|
8
|
+
@status = status
|
|
9
|
+
@balance = balance
|
|
10
|
+
super(message: message, meta: meta)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Hws::Connectors::Exception
|
|
2
|
+
class Error < StandardError
|
|
3
|
+
attr_accessor :reason
|
|
4
|
+
|
|
5
|
+
def initialize(err = nil)
|
|
6
|
+
case err.class.name
|
|
7
|
+
when 'Hash'
|
|
8
|
+
@reason = err['reason']
|
|
9
|
+
super(err['message'])
|
|
10
|
+
else
|
|
11
|
+
super(err)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class UnAuthorized < Error
|
|
17
|
+
def initialize(msg = 'Invalid credentials')
|
|
18
|
+
super(msg)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class LowBalance < Error
|
|
23
|
+
def initialize(msg = 'Your account balance is low')
|
|
24
|
+
super(msg)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class RatelimitExceeded < Error
|
|
29
|
+
def initialize(msg = 'You have exceeded the number of attempts')
|
|
30
|
+
super(msg)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Hws::Connectors::Helper
|
|
2
|
+
class << self
|
|
3
|
+
def included(base)
|
|
4
|
+
base.extend ClassMethods
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ClassMethods
|
|
9
|
+
def option(param, block = nil)
|
|
10
|
+
[self, self.class].each do |_class|
|
|
11
|
+
_class.class_eval do
|
|
12
|
+
attr_accessor(param)
|
|
13
|
+
next if block.nil?
|
|
14
|
+
|
|
15
|
+
define_method(param) do
|
|
16
|
+
instance_variable_set("@#{param}", block.call) if instance_variable_get("@#{param}").nil?
|
|
17
|
+
instance_variable_get("@#{param}")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'rest-client'
|
|
3
|
+
|
|
4
|
+
class Hws::Connectors::Hypto < Hws::Connectors
|
|
5
|
+
NAME = 'hypto'.freeze
|
|
6
|
+
END_POINTS = ::YAML.load_file(File.join(__dir__, 'endpoints.yml')).freeze
|
|
7
|
+
|
|
8
|
+
def initialize(options = {})
|
|
9
|
+
@api_token = options['api_token']
|
|
10
|
+
@base_url = "https://partners.hypto#{'.co' if options['env'].try(:to_sym) != :production}.in"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
protected
|
|
14
|
+
|
|
15
|
+
def initiate_request(method, payload = {})
|
|
16
|
+
begin
|
|
17
|
+
_class = self.class.name
|
|
18
|
+
Hws::Connectors.logger.debug "===== #{_class}.#{method} - args: #{payload} ====="
|
|
19
|
+
|
|
20
|
+
end_point = END_POINTS[_class][method.to_s].clone
|
|
21
|
+
end_point['path'] = end_point['path'] % payload if end_point['path'].include?('%')
|
|
22
|
+
|
|
23
|
+
resp = RestClient::Request.execute(url: "#{@base_url}#{end_point['path']}", method: end_point['method'], payload: payload.to_json, headers: headers).body
|
|
24
|
+
Hws::Connectors.logger.debug "===== #{_class}.#{method} - Response: #{resp} =====" if Hws::Connectors.logging?(end_point['method'])
|
|
25
|
+
return JSON.parse(resp)
|
|
26
|
+
rescue => e
|
|
27
|
+
error = e.try(:response).try(:body)
|
|
28
|
+
Hws::Connectors.logger.error "===== #{_class}.#{method} - Error: #{error} ====="
|
|
29
|
+
error = JSON.parse(error) if error.present?
|
|
30
|
+
|
|
31
|
+
case e.class.name
|
|
32
|
+
when 'RestClient::Unauthorized'
|
|
33
|
+
raise Hws::Connectors::Exception::UnAuthorized.new(error)
|
|
34
|
+
when 'RestClient::TooManyRequests'
|
|
35
|
+
raise Hws::Connectors::Exception::RatelimitExceeded.new(error)
|
|
36
|
+
when 'RestClient::BadRequest', 'RestClient::NotFound'
|
|
37
|
+
case error['reason']
|
|
38
|
+
when 'Action Denied. Your account balance is negative'
|
|
39
|
+
raise Hws::Connectors::Exception::LowBalance.new(error)
|
|
40
|
+
else
|
|
41
|
+
raise Hws::Connectors::Exception::Error.new(error)
|
|
42
|
+
end
|
|
43
|
+
else
|
|
44
|
+
raise Hws::Connectors::Exception::Error.new(e.message)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def headers
|
|
52
|
+
{ 'Authorization' => @api_token, 'Content-Type' => 'application/json' }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
require_relative 'virtual_account/base'
|
|
57
|
+
require_relative 'payout/base'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Hws::Connectors::Hypto::VirtualAccount:
|
|
2
|
+
create:
|
|
3
|
+
method: post
|
|
4
|
+
path: /api/virtual_accounts
|
|
5
|
+
fetch:
|
|
6
|
+
method: get
|
|
7
|
+
path: /api/virtual_accounts/%{id}
|
|
8
|
+
update:
|
|
9
|
+
method: post
|
|
10
|
+
path: /api/virtual_accounts/%{id}/modify
|
|
11
|
+
activate:
|
|
12
|
+
method: post
|
|
13
|
+
path: /api/virtual_accounts/%{id}/activate
|
|
14
|
+
deactivate:
|
|
15
|
+
method: post
|
|
16
|
+
path: /api/virtual_accounts/%{id}/deactivate
|
|
17
|
+
send_to_bank_account:
|
|
18
|
+
method: post
|
|
19
|
+
path: /api/virtual_accounts/%{id}/transfer
|
|
20
|
+
send_to_upi_id:
|
|
21
|
+
method: post
|
|
22
|
+
path: /api/virtual_accounts/%{id}/transfer
|
|
23
|
+
status:
|
|
24
|
+
method: get
|
|
25
|
+
path: /api/virtual_accounts/%{id}/transfer/%{reference_number}
|
|
26
|
+
|
|
27
|
+
Hws::Connectors::Hypto::Payout:
|
|
28
|
+
send_to_bank_account:
|
|
29
|
+
method: post
|
|
30
|
+
path: /api/transfers/initiate
|
|
31
|
+
send_to_upi_id:
|
|
32
|
+
method: post
|
|
33
|
+
path: /api/transfers/initiate
|
|
34
|
+
status:
|
|
35
|
+
method: get
|
|
36
|
+
path: /api/transfers/status/%{reference_number}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class Hws::Connectors::Hypto::Payout < Hws::Connectors::Hypto
|
|
2
|
+
META_RESPONSES = %w(id txn_time created_at txn_type charges_gst settled_amount closing_balance connected_banking transfer_udf1 transfer_udf2 transfer_udf3 transfer_initiated_account_ifsc)
|
|
3
|
+
|
|
4
|
+
# @!group Actions
|
|
5
|
+
|
|
6
|
+
# @param [Types::PayoutRequest] request
|
|
7
|
+
# @return [Types::PayoutResponse]
|
|
8
|
+
def send_to_bank_account(request:)
|
|
9
|
+
beneficiary = request.beneficiary
|
|
10
|
+
payload = { reference_number: request.reference_number, number: beneficiary.account_number, ifsc: beneficiary.account_ifsc, amount: request.amount,
|
|
11
|
+
payment_type: request.payment_type, note: beneficiary.note, beneficiary_name: beneficiary.name, udf1: request.meta[:udf1],
|
|
12
|
+
udf2: request.meta[:udf2], udf3: request.meta[:udf3] }
|
|
13
|
+
resp = initiate_request(__method__, payload)
|
|
14
|
+
to_response(resp['data'], resp['message'])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @param [Types::PayoutRequest] request
|
|
18
|
+
# @return [Types::PayoutResponse]
|
|
19
|
+
def send_to_upi_id(request:)
|
|
20
|
+
beneficiary = request.beneficiary
|
|
21
|
+
payload = { reference_number: request.reference_number, upi_id: beneficiary.upi_id, amount: request.amount, payment_type: 'UPI',
|
|
22
|
+
note: beneficiary.note, beneficiary_name: beneficiary.name, udf1: request.meta[:udf1],
|
|
23
|
+
udf2: request.meta[:udf2], udf3: request.meta[:udf3] }
|
|
24
|
+
resp = initiate_request(__method__, payload)
|
|
25
|
+
to_response(resp['data'], resp['message'])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @param [Types::String] reference_number
|
|
29
|
+
# @return [Types::PayoutResponse]
|
|
30
|
+
def status(reference_number:)
|
|
31
|
+
payload = { reference_number: reference_number }
|
|
32
|
+
resp = initiate_request(__method__, payload)
|
|
33
|
+
to_response(resp['data'], resp['message'])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def to_response(resp_data, message)
|
|
39
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail
|
|
40
|
+
.new(name: resp_data['transfer_beneficiary_name'], account_number: resp_data['transfer_account_number'],
|
|
41
|
+
account_ifsc: resp_data['transfer_account_ifsc'], note: resp_data['transfer_note'])
|
|
42
|
+
Hws::Connectors::Dto::PayoutResponse
|
|
43
|
+
.new(reference_number: resp_data['reference_number'], beneficiary: beneficiary, account_holder: resp_data['transfer_account_holder'],
|
|
44
|
+
amount: resp_data['settled_amount'], payment_type: resp_data['payment_type'], status: resp_data['status'], message: message,
|
|
45
|
+
bank_ref_num: resp_data['bank_ref_num'], txn_time: Time.strptime(resp_data['txn_time'], '%Y-%m-%d %H:%M:%S'),
|
|
46
|
+
meta: resp_data.slice(*META_RESPONSES))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
class Hws::Connectors::Hypto::VirtualAccount < Hws::Connectors::Hypto
|
|
2
|
+
META_RESPONSES = %w(id account_number udf1 udf2 udf3 settle_to parent_id parent_type level hierarchy created_at updated_at link_upi upi_details)
|
|
3
|
+
|
|
4
|
+
# @!group Actions
|
|
5
|
+
|
|
6
|
+
# @param [Types::VirtualAccountRequest] request
|
|
7
|
+
# @return [Types::VirtualAccountResponse]
|
|
8
|
+
def create(request:)
|
|
9
|
+
payload = { reference_number: request.reference_number, udf1: request.meta[:udf1], udf2: request.meta[:udf2], udf3: request.meta[:udf3],
|
|
10
|
+
parent_id: request.meta[:parent_id], link_upi: request.meta[:link_upi], upi_name: request.meta[:upi_name],
|
|
11
|
+
whitelisted_remitters: request.remitters.map { |remitter| { number: remitter.beneficiary.account_number, ifsc: remitter.beneficiary.account_ifsc } } }
|
|
12
|
+
payload[:settle_to] = request.meta[:settle_to] if request.meta[:settle_to].present?
|
|
13
|
+
payload[:parent_type] = request.meta[:parent_type] if request.meta[:parent_type].present?
|
|
14
|
+
resp = initiate_request(__method__, payload)
|
|
15
|
+
to_response(resp['data']['virtual_account'], resp['message'])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @param [Types::String] reference_number
|
|
19
|
+
# @return [Types::VirtualAccountResponse]
|
|
20
|
+
def fetch(reference_number:)
|
|
21
|
+
payload = { id: reference_number }
|
|
22
|
+
resp = initiate_request(__method__, payload)
|
|
23
|
+
to_response(resp['data'], resp['message'])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @param [Types::VirtualAccountRequest] request
|
|
27
|
+
# @return [Types::VirtualAccountResponse]
|
|
28
|
+
def update(request:)
|
|
29
|
+
payload = { id: request.meta[:id], reference_number: request.reference_number, udf1: request.meta[:udf1], udf2: request.meta[:udf2], udf3: request.meta[:udf3],
|
|
30
|
+
whitelisted_remitters: request.remitters.map { |remitter| { number: remitter.beneficiary.account_number, ifsc: remitter.beneficiary.account_ifsc } } }
|
|
31
|
+
resp = initiate_request(__method__, payload)
|
|
32
|
+
to_response(resp['data']['virtual_account'], resp['message'])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @param [Types::String] reference_number
|
|
36
|
+
# @return [Types::VirtualAccountResponse]
|
|
37
|
+
def activate(reference_number:)
|
|
38
|
+
payload = { id: reference_number }
|
|
39
|
+
resp = initiate_request(__method__, payload)
|
|
40
|
+
to_response(resp['data'], resp['message'])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @param [Types::String] reference_number
|
|
44
|
+
# @return [Types::VirtualAccountResponse]
|
|
45
|
+
def deactivate(reference_number:)
|
|
46
|
+
payload = { id: reference_number }
|
|
47
|
+
resp = initiate_request(__method__, payload)
|
|
48
|
+
to_response(resp['data'], resp['message'])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
require_relative 'transaction'
|
|
52
|
+
include Transaction
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def to_response(resp_data, message)
|
|
57
|
+
resp_account_data = resp_data['details'][0]
|
|
58
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail.new(account_number: resp_account_data['account_number'], account_ifsc: resp_account_data['account_ifsc'])
|
|
59
|
+
|
|
60
|
+
remitters = []
|
|
61
|
+
resp_data['whitelisted_remitters'].each do |wl_rmtr|
|
|
62
|
+
remitters << Hws::Connectors::Dto::AccountDetail.new(account_number: wl_rmtr['number'], account_ifsc: wl_rmtr['ifsc'], created_at: wl_rmtr['created_at'], updated_at: wl_rmtr['updated_at'])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Hws::Connectors::Dto::VirtualAccountResponse
|
|
66
|
+
.new(reference_number: resp_data['reference_number'], beneficiary: beneficiary, remitters: remitters, status: resp_data['status'],
|
|
67
|
+
balance: resp_data['account_balance'], message: message, meta: resp_data.slice(*META_RESPONSES))
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Hws::Connectors::Hypto::VirtualAccount::Transaction
|
|
2
|
+
TXN_META_RESPONSES = %w(id txn_time created_at txn_type charges_gst settled_amount closing_balance connected_banking transfer_udf1 transfer_udf2 transfer_udf3 transfer_initiated_account_ifsc hypto_va_id va_closing_balance va_wallet_amount)
|
|
3
|
+
|
|
4
|
+
# @param [Types::PayoutRequest] request
|
|
5
|
+
# @return [Types::PayoutResponse]
|
|
6
|
+
def send_to_bank_account(request:)
|
|
7
|
+
beneficiary = request.beneficiary
|
|
8
|
+
payload = { reference_number: request.reference_number, number: beneficiary.account_number, ifsc: beneficiary.account_ifsc, amount: request.amount,
|
|
9
|
+
payment_type: request.payment_type, note: beneficiary.note, beneficiary_name: beneficiary.name, udf1: request.meta[:udf1],
|
|
10
|
+
udf2: request.meta[:udf2], udf3: request.meta[:udf3], id: request.meta[:va_id] }
|
|
11
|
+
resp = initiate_request(__method__, payload)
|
|
12
|
+
to_txn_response(resp['data'], resp['message'])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param [Types::PayoutRequest] request
|
|
16
|
+
# @return [Types::PayoutResponse]
|
|
17
|
+
def send_to_upi_id(request:)
|
|
18
|
+
beneficiary = request.beneficiary
|
|
19
|
+
payload = { reference_number: request.reference_number, upi_id: beneficiary.upi_id, amount: request.amount, payment_type: 'UPI',
|
|
20
|
+
note: beneficiary.note, beneficiary_name: beneficiary.name, udf1: request.meta[:udf1],
|
|
21
|
+
udf2: request.meta[:udf2], udf3: request.meta[:udf3], id: request.meta[:va_id] }
|
|
22
|
+
resp = initiate_request(__method__, payload)
|
|
23
|
+
to_txn_response(resp['data'], resp['message'])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @param [Types::String] reference_number
|
|
27
|
+
# @return [Types::PayoutResponse]
|
|
28
|
+
def status(reference_number:, va_id: nil)
|
|
29
|
+
payload = { reference_number: reference_number, id: va_id }
|
|
30
|
+
resp = initiate_request(__method__, payload)
|
|
31
|
+
to_txn_response(resp['data'], resp['message'])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def to_txn_response(resp_data, message)
|
|
37
|
+
beneficiary = Hws::Connectors::Dto::AccountDetail
|
|
38
|
+
.new(name: resp_data['transfer_beneficiary_name'], account_number: resp_data['transfer_account_number'],
|
|
39
|
+
account_ifsc: resp_data['transfer_account_ifsc'], note: resp_data['transfer_note'])
|
|
40
|
+
Hws::Connectors::Dto::PayoutResponse
|
|
41
|
+
.new(reference_number: resp_data['reference_number'], beneficiary: beneficiary, account_holder: resp_data['transfer_account_holder'],
|
|
42
|
+
amount: resp_data['settled_amount'], payment_type: resp_data['payment_type'], status: resp_data['status'], message: message,
|
|
43
|
+
bank_ref_num: resp_data['bank_ref_num'], txn_time: Time.strptime(resp_data['txn_time'], '%Y-%m-%d %H:%M:%S'),
|
|
44
|
+
meta: resp_data.slice(*TXN_META_RESPONSES))
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Hws
|
|
2
|
+
class Connectors
|
|
3
|
+
VERSION = '0.1.0'.freeze
|
|
4
|
+
|
|
5
|
+
require 'hws-connectors/exception'
|
|
6
|
+
include Hws::Connectors::Exception
|
|
7
|
+
require 'hws-connectors/helper'
|
|
8
|
+
include Hws::Connectors::Helper
|
|
9
|
+
|
|
10
|
+
option :logger
|
|
11
|
+
option :options
|
|
12
|
+
option :webhooks
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
def configure
|
|
16
|
+
yield self
|
|
17
|
+
self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def logging?(method)
|
|
21
|
+
!options[:skip_logging].to_a.include?(method.to_s)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require 'hws-connectors/railtie'
|
|
28
|
+
require 'hws-connectors/engine'
|
|
29
|
+
require 'hws-connectors/dto/base'
|
|
30
|
+
require 'hws-connectors/hypto/base'
|
metadata
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hws-connectors
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hypto Engineering Team
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '5.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rest-client
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 2.2.33
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 2.2.33
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 12.3.3
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 12.3.3
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.6'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.6'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.49'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.49'
|
|
97
|
+
description: Primitive for connecting to the financial services
|
|
98
|
+
email:
|
|
99
|
+
- engineering@hypto.in
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".rubocop.yml"
|
|
106
|
+
- CHANGELOG.md
|
|
107
|
+
- CODE_OF_CONDUCT.md
|
|
108
|
+
- Gemfile
|
|
109
|
+
- LICENSE.txt
|
|
110
|
+
- README.md
|
|
111
|
+
- Rakefile
|
|
112
|
+
- app/controllers/hws/connectors/payouts_controller.rb
|
|
113
|
+
- app/controllers/hws/connectors/virtual_accounts_controller.rb
|
|
114
|
+
- app/controllers/hws/connectors/webhooks_controller.rb
|
|
115
|
+
- bin/console
|
|
116
|
+
- bin/setup
|
|
117
|
+
- config/routes.rb
|
|
118
|
+
- hws-connectors.gemspec
|
|
119
|
+
- lib/hws-connectors.rb
|
|
120
|
+
- lib/hws-connectors/base.rb
|
|
121
|
+
- lib/hws-connectors/dto/base.rb
|
|
122
|
+
- lib/hws-connectors/dto/common/account_detail.rb
|
|
123
|
+
- lib/hws-connectors/dto/common/base.rb
|
|
124
|
+
- lib/hws-connectors/dto/common/entity.rb
|
|
125
|
+
- lib/hws-connectors/dto/common/request.rb
|
|
126
|
+
- lib/hws-connectors/dto/common/response.rb
|
|
127
|
+
- lib/hws-connectors/dto/payout/base.rb
|
|
128
|
+
- lib/hws-connectors/dto/payout/payout_request.rb
|
|
129
|
+
- lib/hws-connectors/dto/payout/payout_response.rb
|
|
130
|
+
- lib/hws-connectors/dto/virtual_account/base.rb
|
|
131
|
+
- lib/hws-connectors/dto/virtual_account/credit_virtual_account_response.rb
|
|
132
|
+
- lib/hws-connectors/dto/virtual_account/virtual_account_request.rb
|
|
133
|
+
- lib/hws-connectors/dto/virtual_account/virtual_account_response.rb
|
|
134
|
+
- lib/hws-connectors/engine.rb
|
|
135
|
+
- lib/hws-connectors/exception.rb
|
|
136
|
+
- lib/hws-connectors/helper.rb
|
|
137
|
+
- lib/hws-connectors/hypto/base.rb
|
|
138
|
+
- lib/hws-connectors/hypto/endpoints.yml
|
|
139
|
+
- lib/hws-connectors/hypto/payout/base.rb
|
|
140
|
+
- lib/hws-connectors/hypto/virtual_account/base.rb
|
|
141
|
+
- lib/hws-connectors/hypto/virtual_account/transaction.rb
|
|
142
|
+
- lib/hws-connectors/railtie.rb
|
|
143
|
+
homepage: https://github.com/hwslabs/hws-connectors-ruby
|
|
144
|
+
licenses:
|
|
145
|
+
- MIT
|
|
146
|
+
metadata:
|
|
147
|
+
homepage_uri: https://github.com/hwslabs/hws-connectors-ruby
|
|
148
|
+
source_code_uri: https://github.com/hwslabs/hws-connectors-ruby
|
|
149
|
+
changelog_uri: https://github.com/hwslabs/hws-connectors-ruby/blob/main/CHANGELOG.md
|
|
150
|
+
rubygems_mfa_required: 'true'
|
|
151
|
+
post_install_message:
|
|
152
|
+
rdoc_options: []
|
|
153
|
+
require_paths:
|
|
154
|
+
- lib
|
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: 2.4.0
|
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
|
+
requirements:
|
|
162
|
+
- - ">="
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: '0'
|
|
165
|
+
requirements: []
|
|
166
|
+
rubygems_version: 3.2.22
|
|
167
|
+
signing_key:
|
|
168
|
+
specification_version: 4
|
|
169
|
+
summary: HWS Connector
|
|
170
|
+
test_files: []
|