mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
parent
d34e6430a2
commit
1dc6ef7ddf
9 changed files with 269 additions and 0 deletions
73
lib/tasks/dev/create_bank_transactions/bank_transactions.xml
Normal file
73
lib/tasks/dev/create_bank_transactions/bank_transactions.xml
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
|
||||
<CstmrCdtTrfInitn>
|
||||
<GrpHdr>
|
||||
<MsgId>populated by rake task</MsgId>
|
||||
<CreDtTm>2019-07-28T10:00:00</CreDtTm>
|
||||
<NbOfTxs>1</NbOfTxs>
|
||||
<!-- Amount of all transactions; acts as a checksum -->
|
||||
<CtrlSum>0.1</CtrlSum>
|
||||
<InitgPty>
|
||||
<Nm>ABC Corporation</Nm>
|
||||
</InitgPty>
|
||||
</GrpHdr>
|
||||
<PmtInf>
|
||||
<PmtInfId>test3</PmtInfId>
|
||||
<PmtMtd>TRF</PmtMtd>
|
||||
<BtchBookg>false</BtchBookg>
|
||||
<NbOfTxs>1</NbOfTxs>
|
||||
<ReqdExctnDt>2019-07-28</ReqdExctnDt>
|
||||
<Dbtr>
|
||||
<Nm>test</Nm>
|
||||
</Dbtr>
|
||||
<DbtrAcct>
|
||||
<Id>
|
||||
<IBAN>populated by rake task</IBAN>
|
||||
</Id>
|
||||
<Ccy>EUR</Ccy>
|
||||
</DbtrAcct>
|
||||
<DbtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC>LHVBEE22</BIC>
|
||||
</FinInstnId>
|
||||
</DbtrAgt>
|
||||
<CdtTrfTxInf>
|
||||
<PmtId>
|
||||
<InstrId>ABC/090928/CCT001/01</InstrId>
|
||||
<EndToEndId>ABC/4562/2009-09-08</EndToEndId>
|
||||
</PmtId>
|
||||
<Amt>
|
||||
<!-- Transaction amount. Use the smallest amount possible in dev mode, since account balance is not infinite -->
|
||||
<InstdAmt Ccy="EUR">0.1</InstdAmt>
|
||||
</Amt>
|
||||
<ChrgBr>SHAR</ChrgBr>
|
||||
<CdtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC>LHVBEE22</BIC>
|
||||
</FinInstnId>
|
||||
</CdtrAgt>
|
||||
<Cdtr>
|
||||
<Nm>DEF Electronics</Nm>
|
||||
<PstlAdr>
|
||||
<AdrLine>Corn Exchange 5th Floor</AdrLine>
|
||||
</PstlAdr>
|
||||
</Cdtr>
|
||||
<CdtrAcct>
|
||||
<Id>
|
||||
<IBAN>populated by rake task</IBAN>
|
||||
</Id>
|
||||
</CdtrAcct>
|
||||
<RmtInf>
|
||||
<!-- payment description -->
|
||||
<Ustrd>1</Ustrd>
|
||||
<Strd>
|
||||
<CdtrRefInf>
|
||||
<!-- payment reference number -->
|
||||
<Ref>13</Ref>
|
||||
</CdtrRefInf>
|
||||
</Strd>
|
||||
</RmtInf>
|
||||
</CdtTrfTxInf>
|
||||
</PmtInf>
|
||||
</CstmrCdtTrfInitn>
|
||||
</Document>
|
|
@ -0,0 +1,41 @@
|
|||
namespace :dev do
|
||||
task create_bank_transactions: :environment do
|
||||
remitter_iban = ENV['remitter_iban']
|
||||
beneficiary_iban = Setting.registry_iban
|
||||
|
||||
keystore_password = ENV['lhv_keystore_password']
|
||||
keystore_alias = ENV['lhv_keystore_alias']
|
||||
keystore = Keystores::JavaKeystore.new
|
||||
keystore.load(ENV['lhv_keystore'], keystore_password)
|
||||
cert = keystore.get_certificate(keystore_alias)
|
||||
key = keystore.get_key(keystore_alias, keystore_password)
|
||||
|
||||
api_base_uri = URI.parse('https://testconnect.lhv.eu/connect-prelive')
|
||||
request_headers = { 'content-type' => 'application/xml' }
|
||||
|
||||
request_xml = File.binread(File.join(__dir__, 'bank_transactions.xml'))
|
||||
request_xml_doc = Nokogiri::XML(request_xml)
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > GrpHdr > MsgId').content = SecureRandom.hex
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > PmtInf > DbtrAcct > Id > IBAN')
|
||||
.content = remitter_iban
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > PmtInf > CdtTrfTxInf > CdtrAcct > Id > IBAN')
|
||||
.content = beneficiary_iban
|
||||
request_body = request_xml_doc.to_xml
|
||||
|
||||
http = Net::HTTP.new(api_base_uri.host, api_base_uri.port)
|
||||
http.use_ssl = api_base_uri.is_a?(URI::HTTPS)
|
||||
http.cert = cert
|
||||
http.key = key
|
||||
http.ca_file = ENV['lhv_ca_file']
|
||||
|
||||
http.start do
|
||||
response = http.post(api_base_uri.path + '/payment', request_body, request_headers)
|
||||
|
||||
if response.is_a?(Net::HTTPSuccess)
|
||||
puts 'Success'
|
||||
else
|
||||
puts 'Failure'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue