starkit_banking 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c32d1300efd0f8584d0654e7b2cb7fecb8001b3
4
+ data.tar.gz: 186e2edcb7a863265a2664687e14ce9b5d53c74a
5
+ SHA512:
6
+ metadata.gz: 6b04fccbf78e0fb94574e0e34a7d61660590a592376b4148793bbcfcb074be18cbb02eab38e7bf93c193a5b37e494c31e975d1c9fa87e094c613aadbbd296729
7
+ data.tar.gz: 3184c793b11137d1ca9a832be821bbbe97f369ad2c4e39e6d5735cac15504aebd1efd2309a664dab49b8984d5363e7a12aebbc8ff3c112caa9703f9099b626a6
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'api_banking', git: 'git@github.com:quantiguous/api_banking.git'
4
+
5
+ # Specify your gem's dependencies in starkit_banking.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 akil
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,21 @@
1
+ # Assumptions
2
+
3
+ 1. ApiBankingCred has 'password'
4
+ 2. Payment should have IMT passcode (to resend email)
5
+ ~~3. Payment Account to have credential method, that will return the ApiBankingCred (basis the envronment/star/bank_name of self)~~
6
+
7
+
8
+ # Questions
9
+
10
+ 1. How do I get api credentials from a bank_beneficiary?
11
+ 2. How do I get service subscriptions from a bank_beneficary?
12
+
13
+ # Improvements
14
+
15
+ 1. Payment should have the debit account detail & complete beneficiary address
16
+ 2. Payment should not have environment (it can pick it up from Payment Account), unless payment_account_id is being removed
17
+ 3. Payment Account should not have transfer_type
18
+ 4. Payment Account to be renamed Bank Account
19
+ 5. Service Subscription needs to be per service, not for an operation
20
+ 6. Service Subscription to store a config hash, instead of app_id (different services will have different configs)
21
+ 7. Use t.number for migration
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "lib"
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/test_*.rb']
8
+ t.verbose = true
9
+ end
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "starkit_banking"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ require_relative 'fault'
2
+ require_relative 'response'
3
+
4
+ module StarkitBanking
5
+ module ApiClient
6
+ def initialize(step_name = nil)
7
+ @step_name = step_name
8
+ end
9
+
10
+ def exec(model)
11
+ env = Environment.build(credentials(model))
12
+ req = request(model)
13
+
14
+ res = invoke(env, req)
15
+
16
+ if res.instance_of?ApiBanking::Fault
17
+ # for certain API calls, certain faults are expected, for example, when a retry is made it is not an error
18
+ raise ApiFault.new(res)
19
+ else
20
+ response(res)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module StarkitBanking
2
+ class Environment
3
+ def self.build(credentials)
4
+ if credentials.environment.try(:upcase) == 'UAT'
5
+ ::ApiBanking::Environment::YBL::UAT.new(
6
+ credentials.decrypt_username,
7
+ credentials.password,
8
+ credentials.decrypt_client_id,
9
+ credentials.decrypt_client_secret
10
+ )
11
+ elsif credentials.environment.try(:upcase) == 'PROD'
12
+ ::ApiBanking::Environment::YBL::PRD.new(
13
+ credentials.decrypt_username,
14
+ credentials.password,
15
+ credentials.decrypt_client_id,
16
+ credentials.decrypt_client_secret,
17
+ credentials.client_certificate.path,
18
+ credentials.client_private_key.path,
19
+ credentials.decrypt_client_private_key_pwd
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module StarkitBanking
2
+ module API
3
+ class Factory
4
+
5
+ def self.get_client(model, action = nil)
6
+ klass = model.class.name.demodulize
7
+ case klass
8
+ when 'Payment'
9
+ if action.nil?
10
+ svc = model.transfer_type == 'IMT' ? 'IMT' : 'FT2'
11
+ return "StarkitBanking::#{model.payment_account.bank_name}::Payment::By#{svc}".constantize.new(model.transfer_type)
12
+ else
13
+ return "StarkitBanking::#{model.payment_account.bank_name}::Payment::#{action}".constantize.new(action)
14
+ end
15
+ when 'PaymentAccount'
16
+ return "StarkitBanking::#{model.bank_name}::Account::#{action}".constantize.new(action)
17
+ when 'BankBeneficiary'
18
+ return "StarkitBanking::#{model.bank_name}::Beneficiary::#{model.transfer_type}::#{action}".constantize.new(action)
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module StarkitBanking
2
+ class ApiFault < StandardError
3
+ attr_reader :code, :subCode, :reason, :message
4
+
5
+ def initialize(fault)
6
+ @code = fault.code
7
+ @subCode = fault.subCode || ''
8
+ @reason = fault.reasonText || ''
9
+ @message = "#{fault.code} : #{fault.subCode} : #{fault.reasonText}"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module StarkitBanking
2
+ class MiniStatement
3
+ Entry = Struct.new(:recordDate, :spent, :received, :narrative)
4
+ end
5
+
6
+ class Transfer
7
+ Status = Struct.new(:status, :utr, :transferType)
8
+ end
9
+ end
10
+
@@ -0,0 +1,40 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Account
4
+ class GetBalance
5
+ include ApiClient
6
+
7
+ private
8
+
9
+ def invoke(env, req)
10
+ ApiBanking::FundsTransferByCustomerService2.get_balance(env, req)
11
+ end
12
+
13
+ def response(rep)
14
+ Money.new(rep.accountBalanceAmount, rep.accountCurrencyCode)
15
+ end
16
+
17
+ def credentials(payment_account)
18
+ payment_account.credentials
19
+ end
20
+
21
+ def request(payment_account)
22
+
23
+ request = ApiBanking::FundsTransferByCustomerService2::GetBalance::Request.new()
24
+
25
+ request.appID = app_id(payment_account)
26
+ request.customerID = payment_account.customer_id
27
+ request.AccountNumber = payment_account.account_number
28
+
29
+ request
30
+ end
31
+
32
+ def app_id(payment_account)
33
+ payment_account.service_subscriptions.find_by(service_name: 'FUNDS TRANSFER').app_id
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,59 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Account
4
+ class GetMiniStatement
5
+ include ApiClient
6
+
7
+ private
8
+
9
+ def invoke(env, req)
10
+ ApiBanking::SocialBankingService.getTransactions(env, req)
11
+ end
12
+
13
+ def response(res)
14
+ entries = Array.new
15
+
16
+ res.transactionsArray.each do |r|
17
+ if (r.transactionType == "D" && r.amount > 0) || (r.transactionType == "C" && r.amount < 0)
18
+ e = MiniStatement::Entry.new(r.recordDate, Money.new(r.amount.abs, r.currencyCode), nil, r.narrative)
19
+ else
20
+ e = MiniStatement::Entry.new(r.recordDate, nil, Money.new(r.amount.abs, r.currencyCode), r.narrative)
21
+ end
22
+ entries << e
23
+
24
+ end
25
+
26
+ entries
27
+ end
28
+
29
+ def credentials(payment_account)
30
+ payment_account.credentials
31
+ end
32
+
33
+ def request(payment_account)
34
+ customerIdentity = ApiBanking::SocialBankingService::GetTransactions::CustomerIdentity.new()
35
+ accountIdentity = ApiBanking::SocialBankingService::GetTransactions::AccountIdentity.new()
36
+ request = ApiBanking::SocialBankingService::GetTransactions::Request.new()
37
+
38
+ customerIdentity.customerID = payment_account.customer_id
39
+
40
+ accountIdentity.accountNo = payment_account.account_number
41
+
42
+ request.appID = app_id(payment_account)
43
+
44
+ request.customerIdentity = customerIdentity
45
+ request.deviceID = rand(1000..9999).to_s
46
+ request.accountIdentity = accountIdentity
47
+ request.numTransactions = 10
48
+
49
+ request
50
+ end
51
+
52
+ def app_id(payment_account)
53
+ payment_account.service_subscriptions.find_by(service_name: 'GET TRANSACTIONS').app_id
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,50 @@
1
+ module StarkitBanking
2
+ module Sync
3
+ module Beneficiary
4
+
5
+ class Job < ApplicationJob
6
+ def perform(*args)
7
+ Activity.exec(action, class_name, obj_id)
8
+ end
9
+ end
10
+
11
+ class Activity
12
+
13
+ def self.exec(action, class_name, id)
14
+ b = class_name.constantize.find(id)
15
+
16
+ # get the steps
17
+ # call step-engine
18
+ # update result in beneficiary
19
+
20
+ b.synced_version = b.lock_version
21
+ b.synced_at = Time.now
22
+ b.save
23
+ end
24
+
25
+ private
26
+
27
+ def self.steps(action, beneficiary)
28
+ if payment.payment_account.bank_name == "YBL"
29
+ subscription = payment.payment_account.service_subscriptions.find_by(service_name: Finance::ServiceSubscription::IMT_TRANSFER)
30
+ if action == ADD
31
+ [StarkitBanking::Sync::Beneficiary::ByIMT.new(action, subscription, credentials)]
32
+ elsif action == MOD
33
+ [StarkitBanking::Sync::Beneficiary::ByIMT.new(DEL, subscription, credentials),
34
+ StarkitBanking::Sync::Beneficiary::ByIMT.new(ADD, subscription, credentials)]
35
+ end
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ # orchestratable gem (see the code for pre-requisites) : for pass-word availability & restart when api's are down
45
+ # unique_job support in active-job, perform_later should return a false
46
+
47
+ beneficiary
48
+ after_save
49
+ StarkitBanking::Sync::Beneficiary::Job.perform_later(:ADD, self.class_name, self.id)
50
+ StarkitBanking::Sync::Beneficiary::Activity.exec(:ADD, self.class_name, self.id)
@@ -0,0 +1,86 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Beneficiary
4
+ module IMT
5
+ class Add
6
+ include ApiClient
7
+
8
+ private
9
+
10
+ def invoke(env, req)
11
+ ApiBanking::InstantMoneyTransferService.add_beneficiary(env, request)
12
+ end
13
+
14
+ def credentials(beneficiary)
15
+ beneficiary.credentials
16
+ end
17
+
18
+ def request(beneficiary)
19
+
20
+ beneficiaryAddress = ApiBanking::InstantMoneyTransferService::AddBeneficiary::Address.new()
21
+ request = ApiBanking::InstantMoneyTransferService::AddBeneficiary::Request.new()
22
+
23
+ @req_reference = request.uniqueRequestNo = beneficiary.id
24
+
25
+ request.appID = app_id(beneficiary)
26
+ request.customerID = customer_id(beneficiary)
27
+
28
+ request.beneficiaryMobileNo = beneficiary.mobile
29
+ request.beneficiaryName = beneficiary.name
30
+ beneficiaryAddress.addressLine = beneficiary.address_line
31
+ beneficiaryAddress.cityName = beneficiary.city
32
+ beneficiaryAddress.postalCode = beneficiary.postal_code
33
+ request.beneficiaryAddress = beneficiaryAddress
34
+
35
+ request
36
+ end
37
+
38
+ def customer_id(beneficiary)
39
+ beneficiary.customer_id #TODO customer_id column to be added to bank_beneficiaries table
40
+ end
41
+
42
+ def app_id(beneficiary)
43
+ beneficiary.service_subscriptions.find_by('IMT TRANSFER').app_id
44
+ end
45
+
46
+ end
47
+
48
+ class Delete
49
+ include ApiClient
50
+
51
+ private
52
+
53
+ def invoke(env, req)
54
+ ApiBanking::InstantMoneyTransferService.delete_beneficiary(env, request)
55
+ end
56
+
57
+ def credentials(beneficiary)
58
+ beneficiary.credentials
59
+ end
60
+
61
+ def request(beneficiary)
62
+
63
+ request = ApiBanking::InstantMoneyTransferService::DeleteBeneficiary::Request.new()
64
+
65
+ request.uniqueRequestNo = SecureRandom.uuid.gsub!('-','')
66
+ request.appID = app_id(beneficiary)
67
+ request.customerID = customer_id(beneficiary)
68
+ request.beneficiaryMobileNo = beneficiary.mobile_no
69
+
70
+ request
71
+ end
72
+
73
+ def customer_id(beneficiary)
74
+ beneficiary.customer_id #TODO customer_id column to be added to bank_beneficiaries table
75
+ end
76
+
77
+ def app_id(beneficiary)
78
+ beneficiary.service_subscriptions.find_by('IMT TRANSFER').app_id
79
+ end
80
+
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+
@@ -0,0 +1,25 @@
1
+ module StarkitBanking
2
+ module Payment
3
+ class Activity
4
+
5
+ def self.exec
6
+ end
7
+
8
+ def self.do(payment)
9
+ if payment.payment_account.bank_name = "YBL"
10
+ if payment.transfer_type = "IMT"
11
+ subscription = payment.payment_account.service_subscriptions.find_by(service_name: Finance::ServiceSubscription::IMT_TRANSFER)
12
+ x = StarkitBanking::Payment::ByIMT.new(payment.transfer_type, subscription, credentials)
13
+ else
14
+ subscription = payment.payment_account.service_subscriptions.find_by(service_name: Finance::ServiceSubscription::FUNDS_TRANSFER)
15
+ x = StarkitBanking::Payment::ByFT2.new(payment.transfer_type, subscription, credentials)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ credentials = Finance::ApiBankingCred.find_by(environment: 'UAT', bank_name: payment.payment_account.bank_name, star_id: payment.payment_account.star_id)
24
+ x = StarkitBanking::Payment::ByFT2.new(subscription, credentials)
25
+ x.exec(payment)
@@ -0,0 +1,55 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Payment
4
+ class ByFT2
5
+ include ApiClient
6
+
7
+ private
8
+
9
+ def invoke(env, req)
10
+ ApiBanking::FundsTransferByCustomerService2.transfer(env, req)
11
+ end
12
+
13
+ def response(res)
14
+ Transfer::Status.new(res.transactionStatus.statusCode, res.transactionStatus.bankReferenceNo, res.transferType)
15
+ end
16
+
17
+ def credentials(payment)
18
+ payment.payment_account.credentials
19
+ end
20
+
21
+ def request(payment)
22
+
23
+ address = ApiBanking::FundsTransferByCustomerService2::Transfer::Address.new()
24
+ beneficiary = ApiBanking::FundsTransferByCustomerService2::Transfer::Beneficiary.new()
25
+ request = ApiBanking::FundsTransferByCustomerService2::Transfer::Request.new()
26
+
27
+ # every payment is identified by its ID, repeated API attempts can be identified when the ID is used as the URN
28
+ @req_reference = request.uniqueRequestNo = payment.id
29
+
30
+ request.appID = app_id(payment)
31
+ request.customerID = payment.payment_account.customer_id
32
+ request.debitAccountNo = payment.payment_account.account_number
33
+ request.transferType = payment.transfer_type || payment.transfer_type
34
+ request.transferAmount = payment.transfer_amount
35
+ request.remitterToBeneficiaryInfo = payment.transfer_description
36
+
37
+ beneficiary.accountNo = payment.beneficiary_account_number
38
+ beneficiary.accountIFSC = payment.beneficiary_ifsc
39
+ beneficiary.fullName = payment.beneficiary_name
40
+ beneficiary.address = payment.beneficiary_address_line1
41
+
42
+ request.beneficiary = beneficiary
43
+
44
+ request
45
+ end
46
+
47
+ def app_id(payment)
48
+ payment.payment_account.service_subscriptions.find_by(service_name: 'FUNDS TRANSFER').app_id
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,40 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Payment
4
+ class GetStatus
5
+ include ApiClient
6
+
7
+ private
8
+
9
+ def invoke(env, req)
10
+ ApiBanking::FundsTransferByCustomerService2.get_status(env, req)
11
+ end
12
+
13
+ def response(res)
14
+ Transfer::Status.new(res.transactionStatus.statusCode, res.transactionStatus.bankReferenceNo, res.transferType)
15
+ end
16
+
17
+ def credentials(payment)
18
+ payment.payment_account.credentials
19
+ end
20
+
21
+ def request(payment)
22
+
23
+ request = ApiBanking::FundsTransferByCustomerService2::GetStatus::Request.new()
24
+
25
+ request.appID = app_id(payment)
26
+ request.customerID = payment.payment_account.customer_id
27
+ request.requestReferenceNo = payment.id
28
+
29
+ request
30
+ end
31
+
32
+ def app_id(payment)
33
+ payment.payment_account.service_subscriptions.find_by(service_name: 'STATUS ENQUIRY').app_id
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,45 @@
1
+ module StarkitBanking
2
+ module YBL
3
+ module Payment
4
+ class ByIMT
5
+ include ApiClient
6
+
7
+ private
8
+
9
+ def invoke(env, req)
10
+ ApiBanking::InstantMoneyTransferService.transfer(env, req)
11
+ # send email
12
+ end
13
+
14
+ def credentials(payment)
15
+ payment.payment_account.credentials
16
+ end
17
+
18
+ def response(res)
19
+ Transfer::Status.new('INITIATED', res.initiateTransferResult.bankReferenceNo, 'IMT')
20
+ end
21
+
22
+ def request(payment)
23
+ request = ApiBanking::InstantMoneyTransferService::InitiateTransfer::Request.new()
24
+
25
+ # every payment is identified by its ID, repeated API attempts can be identified when the ID is used as the URN
26
+ @req_reference = request.uniqueRequestNo = payment.id
27
+
28
+ request.appID = app_id(payment)
29
+ request.customerID = payment.payment_account.customer_id
30
+ request.beneficiaryMobileNo = payment.beneficiary_mobile_no
31
+ request.transferAmount = payment.transfer_amount
32
+ request.passCode = payment.imt_passcode
33
+ request.remitterToBeneficiaryInfo = payment.transfer_description
34
+
35
+ request
36
+ end
37
+
38
+ def app_id(payment)
39
+ payment.payment_account.service_subscriptions.find_by(service_name: 'IMT TRANSFER').app_id
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ require 'active_support/concern'
2
+
3
+ module StarkitBanking
4
+ module BankAccount
5
+ extend ActiveSupport::Concern
6
+
7
+ def balance(opts = {})
8
+ @password = opts[:api_password]
9
+ StarkitBanking::API::Factory.get_client(self, 'GetBalance').exec(self)
10
+ end
11
+
12
+ def transactions(opts = {})
13
+ @password = opts[:api_password]
14
+ StarkitBanking::API::Factory.get_client(self, 'GetMiniStatement').exec(self)
15
+ end
16
+
17
+ def credentials
18
+ c = Finance::ApiBankingCred.find_by(environment: self.environment, bank_name: self.bank_name)
19
+ c.password = @password unless @password.nil?
20
+ c
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'active_support/concern'
2
+
3
+ module StarkitBanking
4
+ module Payment
5
+ extend ActiveSupport::Concern
6
+
7
+ def is_imt
8
+ self.transfer_type == 'IMT'
9
+ end
10
+
11
+ def is_eft
12
+ self.transfer_type != 'IMT'
13
+ end
14
+
15
+ def release(opts = {})
16
+ self.payment_account.instance_variable_set(:@password, opts[:api_password])
17
+ self.environment = self.payment_account.environment
18
+ self.updated_by = opts[:current_user_id]
19
+ self.approve
20
+ self.reference_no = self.id
21
+ self.response = StarkitBanking::API::Factory.get_client(self).exec(self)
22
+ end
23
+
24
+ def sync_status(opts = {})
25
+ self.payment_account.instance_variable_set(:@password, opts[:api_password])
26
+ self.response = StarkitBanking::API::Factory.get_client(self, 'GetStatus').exec(self)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ class CreateApiSteps < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :api_steps, force: true do |table|
4
+ table.integer :star_id null: false,
5
+ table.string :step_name null: false,
6
+ table.string :auditable_type null: false,
7
+ table.integer :auditable_id null:false,
8
+ table.string :status_code,
9
+ table.string :req_reference,
10
+ table.datetime :req_timestamp
11
+ table.text :req_bistream
12
+ table.string :rep_reference,
13
+ table.datetime :rep_timestamp
14
+ table.text :rep_bistream
15
+ table.string :fault_code,
16
+ table.string :fault_subcode,
17
+ table.string :fault_reason,
18
+ end
19
+
20
+ add_index :api_steps, [:star_id, :auditable_type, :auditable_id]
21
+ end
22
+
23
+ def self.down
24
+ drop_table :api_steps
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module StarkitBanking
2
+ class ApiStep < ActiveRecord::Base
3
+
4
+ end
5
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ module StarkitBanking
2
+ module Sync
3
+ ADD = 'ADD'
4
+ MOD = 'MOD'
5
+ DEL = 'DEL'
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module StarkitBanking
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ require 'money'
2
+ require 'active_record'
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+ require 'api_banking'
6
+
7
+ require "starkit_banking/version"
8
+
9
+ require_relative "starkit_banking/models/api_step"
10
+
11
+ require_relative "starkit_banking/api/client"
12
+ require_relative "starkit_banking/api/environment"
13
+ require_relative "starkit_banking/api/factory"
14
+
15
+ require_relative "starkit_banking/api/ybl/account/balance"
16
+ require_relative "starkit_banking/api/ybl/account/mini_statement"
17
+ require_relative "starkit_banking/api/ybl/payment/ft2"
18
+ require_relative "starkit_banking/api/ybl/payment/imt"
19
+ require_relative "starkit_banking/api/ybl/payment/get_status"
20
+
21
+ require_relative "starkit_banking/api/ybl/beneficiary/imt"
22
+
23
+ require_relative "starkit_banking/concerns/bank_account"
24
+ require_relative "starkit_banking/concerns/payment"
25
+
26
+ module StarkitBanking
27
+ # Your code goes here...
28
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'starkit_banking/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "starkit_banking"
8
+ spec.version = StarkitBanking::VERSION
9
+ spec.authors = ["akil"]
10
+ spec.email = ["hello@quantiguous.com"]
11
+
12
+ spec.summary = %q{StarKit Banking Interface}
13
+ spec.homepage = "https://starkit.quantiguous.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "vcr"
25
+ spec.add_development_dependency "webmock"
26
+
27
+ spec.add_dependency "money"
28
+ spec.add_dependency "activesupport"
29
+ spec.add_dependency "activerecord"
30
+ # spec.add_dependency "api_banking"
31
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: starkit_banking
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - akil
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: money
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activerecord
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - hello@quantiguous.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
134
+ - CODE_OF_CONDUCT.md
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - lib/starkit_banking.rb
142
+ - lib/starkit_banking/api/client.rb
143
+ - lib/starkit_banking/api/environment.rb
144
+ - lib/starkit_banking/api/factory.rb
145
+ - lib/starkit_banking/api/fault.rb
146
+ - lib/starkit_banking/api/response.rb
147
+ - lib/starkit_banking/api/ybl/account/balance.rb
148
+ - lib/starkit_banking/api/ybl/account/mini_statement.rb
149
+ - lib/starkit_banking/api/ybl/beneficiary/activity.rb
150
+ - lib/starkit_banking/api/ybl/beneficiary/imt.rb
151
+ - lib/starkit_banking/api/ybl/payment/activity.rb
152
+ - lib/starkit_banking/api/ybl/payment/ft2.rb
153
+ - lib/starkit_banking/api/ybl/payment/get_status.rb
154
+ - lib/starkit_banking/api/ybl/payment/imt.rb
155
+ - lib/starkit_banking/concerns/bank_account.rb
156
+ - lib/starkit_banking/concerns/payment.rb
157
+ - lib/starkit_banking/generators/active_record_generator.rb
158
+ - lib/starkit_banking/generators/templates/migration.rb
159
+ - lib/starkit_banking/models/api_step.rb
160
+ - lib/starkit_banking/step_engine.rb
161
+ - lib/starkit_banking/sync/action.rb
162
+ - lib/starkit_banking/version.rb
163
+ - starkit_banking.gemspec
164
+ homepage: https://starkit.quantiguous.com
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.4.6
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: StarKit Banking Interface
188
+ test_files: []