api_banking 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e63a465927362f8c7808ef15e1ab5d4d1c3a49d
4
- data.tar.gz: a42ef24e251ca232fdb939f43a991bcab998f47e
3
+ metadata.gz: 6fb3ab5328b473b53f06e6b72223930a527fed0e
4
+ data.tar.gz: dde79ce6b87eeaea4cb67ca3889087d4c94a0ce7
5
5
  SHA512:
6
- metadata.gz: faec58c29f86519b8ee494dcfbb0f13faf6cd4044b2c4dd4369f887d26b7437b56ec5f3df155d31d294d3870283b2d650ae7754ae5da81c01d4100cd201f2d72
7
- data.tar.gz: fe0860ea590bcb76a86021fdd632254ef2945ad967ce098860dbe7cab7ae7ffbe7f8ba600a2650f6f7c711d2dd807ea27cb446987368248175ec1f6e126ce89f
6
+ metadata.gz: 6f5c64588f9e40ed140cd59ad33a99be2fe4e386378f2b367caf04517653962339baee6afcd5581ddf5db2e382a93ae5dd157361680c2467e2434aab5348dc58
7
+ data.tar.gz: 22e9289472462aa42671c1b80f3b63fe206b9911537ea31c5b2547ce3d00f0ea2da2aa0827f104ecee5d8b9e805775006034333604b7e6f971694ff14452609b
data/README.md CHANGED
@@ -24,6 +24,28 @@ You'll need to sign up with your chosen bank to get your credentials.
24
24
 
25
25
  Most banks require 3 factors, you'll need a certificate to esablish 2 way trust, and your bank will give you a client id/secret and also a user/password.
26
26
 
27
+ ## FundsTransferByCustomerService
28
+
29
+ This service, provided by https://www.yesbank.in/, allows you do to do inter and intra bank transfers (NEFT,RTGS,IMPS) , check the status of a transaction and view your balance.
30
+
31
+ To operate this service, in a sandbox environment, you need a client id, client secret, and a user/password, these details are available only from the bank.
32
+
33
+ Once you have them, using the gem makes it simple.
34
+
35
+
36
+ ```ruby
37
+ require 'api_banking'
38
+
39
+ ApiBanking::FundsTransferByCustomerService.configure do |config|
40
+ config.environment = ApiBanking::Environment::YBL::UAT.new(ENV['API_UAT_USER'], ENV['API_UAT_PASSWORD'], ENV['API_UAT_CLIENT_ID'], ENV['API_UAT_CLIENT_SECRET'] )
41
+ end
42
+
43
+ request = ApiBanking::FundsTransferByCustomerService::GetStatus::Request.new()
44
+ request.customerID = '' # your customer id
45
+ request.requestReferenceNo = '' # your reference no
46
+
47
+ puts ApiBanking::FundsTransferByCustomerService.get_status(request)
48
+ ```
27
49
 
28
50
  ## Contributing
29
51
 
data/lib/api_banking.rb CHANGED
@@ -4,11 +4,15 @@ require "api_banking/version"
4
4
  require_relative "api_banking/config"
5
5
  require_relative "api_banking/environment/rbl/env"
6
6
  require_relative "api_banking/environment/ybl/env"
7
+
7
8
  require_relative "api_banking/soap/fault"
8
9
  require_relative "api_banking/soap/soap_client"
9
10
  require_relative "api_banking/soap/fundsTransferByCustomerService"
10
11
  require_relative "api_banking/soap/fundsTransferByCustomerService2"
11
12
 
13
+ require_relative "api_banking/json/json_client"
14
+ require_relative "api_banking/json/singlePayment"
15
+
12
16
  module ApiBanking
13
17
 
14
18
  end
@@ -1,8 +1,13 @@
1
1
  module ApiBanking
2
2
  module Environment
3
3
  module RBL
4
- UAT = Struct.new(:code, :subCode, :reasonText)
5
- PRD = Struct.new(:code)
4
+ UAT = Struct.new(:user, :password, :client_id, :client_secret, :ssl_client_cert, :ssl_client_key, :ssl_ca_file, :url) do
5
+ def initialize(*)
6
+ super
7
+ self.ssl_ca_file ||= File.expand_path('./uat.pem', File.dirname(__FILE__))
8
+ self.url ||= 'https://apideveloper.rblbank.com'
9
+ end
10
+ end
6
11
  end
7
12
  end
8
13
  end
@@ -0,0 +1,31 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFQDCCBCigAwIBAgIRAJVMtSU8gbHVAAAAAFDYRiAwDQYJKoZIhvcNAQELBQAw
3
+ gboxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL
4
+ Ex9TZWUgd3d3LmVudHJ1c3QubmV0L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B
20
+ BFwwWjAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYIKwYB
21
+ BQUHMAKGJ2h0dHA6Ly9haWEuZW50cnVzdC5uZXQvbDFrLWNoYWluMjU2LmNlcjAl
22
+ BgNVHREEHjAcgg0qLnJibGJhbmsuY29tggtyYmxiYW5rLmNvbTAfBgNVHSMEGDAW
23
+ gBSConB03bxTP8971PfNf6dgxgpMvzAdBgNVHQ4EFgQU91Mybk3FtkOD37ZeuYSA
24
+ Qchj/YMwCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAwb7gpLeeeffKmhVv
25
+ uoWZH9GTCHEhdYerb3QnZ6dPQSm5SgzWrP0M+NAHdoDCT8X91Ou1giCzFQE1hFW8
26
+ 5UZf/E1FXHZNg9m/E5r7mq7kf7B0psXR6ZnG9+uLSlvZEZjCJ0BtUN+0nz7PN8vS
27
+ JFZ+mXNft7Uh2tSd7fyfD0mgIK+olkdSl3yPpW72SzxXMkzVo2somJI9sahSCETO
28
+ uJqQ+XWVgrsh98xPXlvxd9juQkfXUUFdhNNWIrtzFhCtjC4soUd0tPRf9qK2FmXQ
29
+ q0ZbKCBBQVkupM2Ij0rpHwykdCAvhTbWp+A2PbyZ73l0zo7GyoCP95+gF9IdlATu
30
+ XYdMpw==
31
+ -----END CERTIFICATE-----
@@ -0,0 +1,100 @@
1
+ require 'json'
2
+ module ApiBanking
3
+
4
+ class JsonClient
5
+
6
+ def self.do_remote_call(dataHash)
7
+ options = {}
8
+ options[:method] = :post
9
+
10
+ add_signature(dataHash)
11
+ options[:body] = JSON.generate(dataHash)
12
+
13
+ options[:headers] = {'Content-Type' => "application/json; charset=utf-8"}
14
+
15
+ options[:proxy] = self.configuration.proxy
16
+ options[:timeout] = self.configuration.timeout
17
+
18
+ set_options_for_environment(options)
19
+ set_params_for_environment(options)
20
+
21
+ request = Typhoeus::Request.new(self.configuration.environment.url + uri, options)
22
+ response = request.run
23
+
24
+ parse_response(response)
25
+ end
26
+
27
+
28
+ private
29
+
30
+ def self.add_signature(dataHash)
31
+ dataHash[:Single_Payment_Corp_Req][:Signature] = {}
32
+ dataHash[:Single_Payment_Corp_Req][:Signature][:Signature] = 'Signature'
33
+ end
34
+
35
+ def self.set_params_for_environment(options)
36
+ params = {}
37
+ params[:client_id] = self.configuration.environment.client_id
38
+ params[:client_secret] = self.configuration.environment.client_secret
39
+ options[:params] = params
40
+ end
41
+
42
+ def self.set_options_for_environment(options)
43
+ if self.configuration.environment.kind_of?ApiBanking::Environment::RBL::UAT
44
+ options[:userpwd] = "#{self.configuration.environment.user}:#{self.configuration.environment.password}"
45
+ options[:cainfo] = self.configuration.environment.ssl_ca_file
46
+ options[:sslkey] = self.configuration.environment.ssl_client_key
47
+ options[:sslcert] = self.configuration.environment.ssl_client_cert
48
+ options[:ssl_verifypeer] = true
49
+ end
50
+ puts "#{options}"
51
+ end
52
+
53
+ def self.parse_response(response)
54
+ if response.success?
55
+ if response.headers['Content-Type'] =~ /json/ then
56
+ j = JSON::parse(response.response_body)
57
+ if j[:Status] = 'FAILED' then
58
+ return Fault.new(j[:Status], j.first[1]['Header']['Error_Cde'], j.first[1]['Header']['Error_Desc'])
59
+ end
60
+ return j
61
+ end
62
+ elsif response.timed_out?
63
+ return Fault.new("502", "", "#{response.return_message}")
64
+ elsif response.code == 0
65
+ return Fault.new(response.code, "", response.return_message)
66
+ else
67
+ # http status indicating error
68
+ if response.headers['Content-Type'] =~ /xml/ then
69
+ reply = Nokogiri::XML(response.response_body)
70
+
71
+ # service failures return a fault
72
+ unless reply.at_xpath('//soapenv12:Fault', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope').nil? then
73
+ return parse_fault(reply)
74
+ end
75
+
76
+ # datapower failures return an xml
77
+ unless reply.at_xpath('//errorResponse').nil? then
78
+ return parse_dp_reply(reply)
79
+ end
80
+
81
+ end
82
+ return Fault.new("#{response.code.to_s}", "", response.status_message)
83
+ end
84
+ end
85
+
86
+ def self.parse_dp_reply(reply)
87
+ code = content_at(reply.at_xpath('/errorResponse/httpCode'))
88
+ reasonText = content_at(reply.at_xpath('/errorResponse/moreInformation'))
89
+ return Fault.new(code, "", reasonText)
90
+ end
91
+
92
+ def self.parse_fault(reply)
93
+ code = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
94
+ subcode = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Code/soapenv12:Subcode/soapenv12:Subcode/soapenv12:Value', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
95
+ reasonText = content_at(reply.at_xpath('//soapenv12:Fault/soapenv12:Reason/soapenv12:Text', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope'))
96
+ return Fault.new(code, subcode, reasonText)
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,93 @@
1
+ module ApiBanking
2
+ class SinglePayment < JsonClient
3
+
4
+ SERVICE_VERSION = 1
5
+
6
+ attr_accessor :request, :result
7
+
8
+ #transfer
9
+ Remitter = Struct.new(:accountNo, :accountName, :accountIFSC, :mobileNo, :tranParticulars, :partTranRemarks)
10
+ Beneficiary = Struct.new(:fullName, :address, :accountNo, :accountIFSC, :bankName, :bankCode, :branchCode, :email, :mobileNo, :mmid, :tranParticulars, :partTranRemarks)
11
+ Request = Struct.new(:uniqueRequestNo, :corpID, :makerID, :checkerID, :approverID, :remitter, :beneficiary, :amount, :issueBranchCode, :modeOfPay, :remarks, :rptCode)
12
+
13
+ Result = Struct.new(:status, :errorCode, :errorDescription)
14
+
15
+ class << self
16
+ attr_accessor :configuration
17
+ end
18
+
19
+ def self.configure
20
+ self.configuration ||= Configuration.new
21
+ yield(configuration)
22
+ end
23
+
24
+ class Configuration
25
+ attr_accessor :environment, :proxy, :timeout
26
+ end
27
+
28
+ def self.transfer(request)
29
+ dataHash = {}
30
+ dataHash[:Single_Payment_Corp_Req] = {}
31
+ dataHash[:Single_Payment_Corp_Req][:Header] = {}
32
+ dataHash[:Single_Payment_Corp_Req][:Body] = {}
33
+
34
+ dataHash[:Single_Payment_Corp_Req][:Header][:TranID] = request.uniqueRequestNo
35
+ dataHash[:Single_Payment_Corp_Req][:Header][:Corp_ID] = request.corpID
36
+ dataHash[:Single_Payment_Corp_Req][:Header][:Maker_ID] = request.makerID
37
+ dataHash[:Single_Payment_Corp_Req][:Header][:Checker_ID] = request.checkerID
38
+ dataHash[:Single_Payment_Corp_Req][:Header][:Approver_ID] = request.approverID
39
+
40
+ dataHash[:Single_Payment_Corp_Req][:Body][:Amount] = request.amount
41
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_Acct_No] = request.remitter.accountNo
42
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_Acct_Name] = request.remitter.accountName
43
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_IFSC] = request.remitter.accountIFSC
44
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_Mobile] = request.remitter.mobileNo
45
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_TrnParticulars] = request.remitter.tranParticulars
46
+ dataHash[:Single_Payment_Corp_Req][:Body][:Debit_PartTrnRmks] = request.remitter.partTranRemarks
47
+
48
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_IFSC] = request.beneficiary.accountIFSC
49
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_Acct_No] = request.beneficiary.accountNo
50
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_Name] = request.beneficiary.fullName
51
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_Address] = request.beneficiary.address
52
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_BankName] = request.beneficiary.bankName
53
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_BankCd] = request.beneficiary.bankCode
54
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_BranchCd] = request.beneficiary.branchCode
55
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_Email] = request.beneficiary.email
56
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_Mobile] = request.beneficiary.mobileNo
57
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_TrnParticulars] = request.beneficiary.tranParticulars
58
+ dataHash[:Single_Payment_Corp_Req][:Body][:Ben_PartTrnRmks] = request.beneficiary.partTranRemarks
59
+ dataHash[:Single_Payment_Corp_Req][:Body][:Issue_BranchCd] = request.issueBranchCode
60
+ dataHash[:Single_Payment_Corp_Req][:Body][:Mode_of_Pay] = request.modeOfPay
61
+ dataHash[:Single_Payment_Corp_Req][:Body][:Remarks] = request.remarks
62
+ dataHash[:Single_Payment_Corp_Req][:Body][:RptCode] = request.rptCode
63
+
64
+
65
+ reply = do_remote_call(dataHash)
66
+
67
+ parse_reply(:transferResponse, reply)
68
+ end
69
+
70
+
71
+ private
72
+
73
+ def self.uri()
74
+ if self.configuration.environment.kind_of?ApiBanking::Environment::RBL::UAT
75
+ return '/test/sb/rbl/v1/payments/corp/payment'
76
+ else
77
+ return '/sb/rbl/v1/payments/corp/payment'
78
+ end
79
+ end
80
+
81
+ def self.parse_reply(operationName, reply)
82
+ if reply.kind_of?Fault
83
+ return reply
84
+ else
85
+ puts reply
86
+ case operationName
87
+ when :transferResponse
88
+ end
89
+ end
90
+ end
91
+
92
+ end
93
+ end
@@ -1,3 +1,3 @@
1
1
  module ApiBanking
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_banking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - akil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2016-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,8 +100,11 @@ files:
100
100
  - lib/api_banking.rb
101
101
  - lib/api_banking/config.rb
102
102
  - lib/api_banking/environment/rbl/env.rb
103
+ - lib/api_banking/environment/rbl/uat.pem
103
104
  - lib/api_banking/environment/ybl/env.rb
104
105
  - lib/api_banking/environment/ybl/prd.pem
106
+ - lib/api_banking/json/json_client.rb
107
+ - lib/api_banking/json/singlePayment.rb
105
108
  - lib/api_banking/soap/fault.rb
106
109
  - lib/api_banking/soap/fundsTransferByCustomerService.rb
107
110
  - lib/api_banking/soap/fundsTransferByCustomerService2.rb