Skip to content

Commit

Permalink
Add CIP order type
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Nov 27, 2024
1 parent 2e45652 commit df67b5f
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

- [ENHANCEMENT] Adds CIP order type (instant transfers)
- [ENHANCEMENT] Added gem metadata (thanks to @Nymuxyzo)

### 2.5.0
Expand Down
1 change: 1 addition & 0 deletions lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
require "epics/cd1"
require "epics/cct"
require "epics/ccs"
require "epics/cip"
require "epics/cdb"
require "epics/cdd"
require "epics/xe2"
Expand Down
13 changes: 13 additions & 0 deletions lib/epics/cip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Epics::CIP < Epics::GenericUploadRequest
def header
client.header_request.build(
nonce: nonce,
timestamp: timestamp,
order_type: 'CIP',
order_attribute: 'OZHNN',
order_params: {},
num_segments: 1,
mutable: { TransactionPhase: 'Initialisation' }
)
end
end
4 changes: 4 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def CCT(document)
upload(Epics::CCT, document)
end

def CIP(document)
upload(Epics::CIP, document)
end

def CCS(document)
upload(Epics::CCS, document)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
end

it 'extracts the accessible order types of a subscriber' do
expect(subject.order_types).to match_array(%w(PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDB CDD))
expect(subject.order_types).to match_array(%w(PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CIP CD1 CDB CDD))
end
end

Expand Down
86 changes: 86 additions & 0 deletions spec/fixtures/xml/cip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09 pain.001.001.09.xsd">
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>Message-ID-0815</MsgId>
<CreDtTm>2022-09-15T09:31:39.000Z</CreDtTm>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>1122.33</CtrlSum>
<InitgPty>
<Nm>Initiator Name</Nm>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>Payment-Information-ID-0815</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<BtchBookg>true</BtchBookg>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>1122.33</CtrlSum>
<PmtTpInf>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm>
<Cd>INST</Cd>
</LclInstrm>
</PmtTpInf>
<ReqdExctnDt>
<DtTm>2022-09-16T10:00:00</DtTm>
</ReqdExctnDt>
<Dbtr>
<Nm>Herr Schnellzahler</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE89370400440532013000</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<Othr>
<Id>NOTPROVIDED</Id>
</Othr>
</FinInstnId>
</DbtrAgt>
<ChrgBr>SLEV</ChrgBr>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>OriginID1</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">1022.00</InstdAmt>
</Amt>
<Cdtr>
<Nm>John Dough</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>AT611904300234573201</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Unstructured Remittance Information</Ustrd>
</RmtInf>
</CdtTrfTxInf>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>OriginID2</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">100.33</InstdAmt>
</Amt>
<Cdtr>
<Nm>Cookie Cutter</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>AT611904300234573201</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Unstructured Remittance Information</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf>
</CstmrCdtTrfInitn>
</Document>
8 changes: 7 additions & 1 deletion spec/fixtures/xml/htd_order_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
<Description>Credit Transfer Initiation</Description>
<NumSigRequired>1</NumSigRequired>
</OrderInfo>
<OrderInfo>
<OrderType>CIP</OrderType>
<TransferType>Upload</TransferType>
<Description>Instant Credit Transfer Initiation</Description>
<NumSigRequired>1</NumSigRequired>
</OrderInfo>
<OrderInfo>
<OrderType>CD1</OrderType>
<TransferType>Upload</TransferType>
Expand All @@ -153,7 +159,7 @@
<OrderTypes>PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ</OrderTypes>
</Permission>
<Permission AuthorisationLevel="E">
<OrderTypes>INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDB CDD</OrderTypes>
<OrderTypes>INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CIP CD1 CDB CDD</OrderTypes>
</Permission>
</UserInfo>
</HTDResponseOrderData>
23 changes: 23 additions & 0 deletions spec/orders/cip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RSpec.describe Epics::CIP do

let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') }
let(:document) { File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'cip.xml') ) }
subject { described_class.new(client, document) }

describe 'order attributes' do
it { expect(subject.header.to_s).to include('<OrderAttribute>OZHNN</OrderAttribute>') }
it { expect(subject.header.to_s).to include('<OrderType>CIP</OrderType>') }
end

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
end

describe '#to_transfer_xml' do
before { subject.transaction_id = SecureRandom.hex(16) }

specify { expect(subject.to_transfer_xml).to be_a_valid_ebics_doc }
end

end

0 comments on commit df67b5f

Please sign in to comment.