-
Notifications
You must be signed in to change notification settings - Fork 40
/
main.go
243 lines (206 loc) · 7.59 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package main
import (
"log"
"os"
"time"
"github.com/moov-io/wire"
)
func main() {
file := wire.NewFile()
fwm := wire.FEDWireMessage{}
// Mandatory Fields
ss := wire.NewSenderSupplied()
ss.UserRequestCorrelation = "User Req"
ss.MessageDuplicationCode = wire.MessageDuplicationOriginal
fwm.SenderSupplied = ss
tst := wire.NewTypeSubType()
tst.TypeCode = wire.FundsTransfer
tst.SubTypeCode = wire.BasicFundsTransfer
fwm.TypeSubType = tst
imad := wire.NewInputMessageAccountabilityData()
imad.InputCycleDate = time.Now().Format("20060102")
imad.InputSource = "Source08"
imad.InputSequenceNumber = "000001"
fwm.InputMessageAccountabilityData = imad
amt := wire.NewAmount()
amt.Amount = "000001234567"
fwm.Amount = amt
sdi := wire.NewSenderDepositoryInstitution()
sdi.SenderABANumber = "121042882"
sdi.SenderShortName = "Wells Fargo NA"
fwm.SenderDepositoryInstitution = sdi
rdi := wire.NewReceiverDepositoryInstitution()
rdi.ReceiverABANumber = "231380104"
rdi.ReceiverShortName = "Citadel"
fwm.ReceiverDepositoryInstitution = rdi
bfc := wire.NewBusinessFunctionCode()
bfc.BusinessFunctionCode = wire.CustomerTransfer
bfc.TransactionTypeCode = " "
fwm.BusinessFunctionCode = bfc
// Other Transfer Information
sr := wire.NewSenderReference()
sr.SenderReference = "Sender Reference"
fwm.SenderReference = sr
pmi := wire.NewPreviousMessageIdentifier()
pmi.PreviousMessageIdentifier = "Previous Message Ident"
fwm.PreviousMessageIdentifier = pmi
c := wire.NewCharges()
c.ChargeDetails = "B"
c.SendersChargesOne = "USD0,99"
c.SendersChargesTwo = "USD2,99"
c.SendersChargesThree = "USD3,99"
c.SendersChargesFour = "USD1,00"
fwm.Charges = c
ia := wire.NewInstructedAmount()
ia.CurrencyCode = "USD"
ia.Amount = "4567,89"
fwm.InstructedAmount = ia
eRate := wire.NewExchangeRate()
eRate.ExchangeRate = "1,2345"
fwm.ExchangeRate = eRate
// Beneficiary
bifi := wire.NewBeneficiaryIntermediaryFI()
bifi.FinancialInstitution.IdentificationCode = wire.DemandDepositAccountNumber
bifi.FinancialInstitution.Identifier = "123456789"
bifi.FinancialInstitution.Name = "FI Name"
bifi.FinancialInstitution.Address.AddressLineOne = "Address One"
bifi.FinancialInstitution.Address.AddressLineTwo = "Address Two"
bifi.FinancialInstitution.Address.AddressLineThree = "Address Three"
fwm.BeneficiaryIntermediaryFI = bifi
bfi := wire.NewBeneficiaryFI()
bfi.FinancialInstitution.IdentificationCode = wire.DemandDepositAccountNumber
bfi.FinancialInstitution.Identifier = "123456789"
bfi.FinancialInstitution.Name = "FI Name"
bfi.FinancialInstitution.Address.AddressLineOne = "Address One"
bfi.FinancialInstitution.Address.AddressLineTwo = "Address Two"
bfi.FinancialInstitution.Address.AddressLineThree = "Address Three"
fwm.BeneficiaryFI = bfi
ben := wire.NewBeneficiary()
ben.Personal.IdentificationCode = wire.DriversLicenseNumber
ben.Personal.Identifier = "1234"
ben.Personal.Name = "Name"
ben.Personal.Address.AddressLineOne = "Address One"
ben.Personal.Address.AddressLineTwo = "Address Two"
ben.Personal.Address.AddressLineThree = "Address Three"
fwm.Beneficiary = ben
br := wire.NewBeneficiaryReference()
br.BeneficiaryReference = "Reference"
fwm.BeneficiaryReference = br
// Originator
o := wire.NewOriginator()
o.Personal.IdentificationCode = wire.PassportNumber
o.Personal.Identifier = "1234"
o.Personal.Name = "Name"
o.Personal.Address.AddressLineOne = "Address One"
o.Personal.Address.AddressLineTwo = "Address Two"
o.Personal.Address.AddressLineThree = "Address Three"
fwm.Originator = o
ofi := wire.NewOriginatorFI()
ofi.FinancialInstitution.IdentificationCode = wire.DemandDepositAccountNumber
ofi.FinancialInstitution.Identifier = "123456789"
ofi.FinancialInstitution.Name = "FI Name"
ofi.FinancialInstitution.Address.AddressLineOne = "Address One"
ofi.FinancialInstitution.Address.AddressLineTwo = "Address Two"
ofi.FinancialInstitution.Address.AddressLineThree = "Address Three"
fwm.OriginatorFI = ofi
ifi := wire.NewInstructingFI()
ifi.FinancialInstitution.IdentificationCode = wire.DemandDepositAccountNumber
ifi.FinancialInstitution.Identifier = "123456789"
ifi.FinancialInstitution.Name = "FI Name"
ifi.FinancialInstitution.Address.AddressLineOne = "Address One"
ifi.FinancialInstitution.Address.AddressLineTwo = "Address Two"
ifi.FinancialInstitution.Address.AddressLineThree = "Address Three"
fwm.InstructingFI = ifi
ob := wire.NewOriginatorToBeneficiary()
ob.LineOne = "LineOne"
ob.LineTwo = "LineTwo"
ob.LineThree = "LineThree"
ob.LineFour = "LineFour"
fwm.OriginatorToBeneficiary = ob
// FI to FI
firfi := wire.NewFIReceiverFI()
firfi.FIToFI.LineOne = "Line One"
firfi.FIToFI.LineOne = "Line Two"
firfi.FIToFI.LineOne = "Line Three"
firfi.FIToFI.LineOne = "Line Four"
firfi.FIToFI.LineOne = "Line Five"
firfi.FIToFI.LineOne = "Line Six"
fwm.FIReceiverFI = firfi
fiifi := wire.NewFIIntermediaryFI()
fiifi.FIToFI.LineOne = "Line One"
fiifi.FIToFI.LineOne = "Line Two"
fiifi.FIToFI.LineOne = "Line Three"
fiifi.FIToFI.LineOne = "Line Four"
fiifi.FIToFI.LineOne = "Line Five"
fiifi.FIToFI.LineOne = "Line Six"
fwm.FIIntermediaryFI = fiifi
fiifia := wire.NewFIIntermediaryFIAdvice()
fiifia.Advice.AdviceCode = wire.AdviceCodeLetter
fiifia.Advice.LineOne = "Line One"
fiifia.Advice.LineTwo = "Line Two"
fiifia.Advice.LineThree = "Line Three"
fiifia.Advice.LineFour = "Line Four"
fiifia.Advice.LineFive = "Line Five"
fiifia.Advice.LineSix = "Line Six"
fwm.FIIntermediaryFIAdvice = fiifia
fibfi := wire.NewFIBeneficiaryFI()
fibfi.FIToFI.LineOne = "Line One"
fibfi.FIToFI.LineTwo = "Line Two"
fibfi.FIToFI.LineThree = "Line Three"
fibfi.FIToFI.LineFour = "Line Four"
fibfi.FIToFI.LineFive = "Line Five"
fibfi.FIToFI.LineSix = "Line Six"
fwm.FIBeneficiaryFI = fibfi
fibfia := wire.NewFIBeneficiaryFIAdvice()
fibfia.Advice.AdviceCode = wire.AdviceCodeTelex
fibfia.Advice.LineOne = "Line One"
fibfia.Advice.LineTwo = "Line Two"
fibfia.Advice.LineThree = "Line Three"
fibfia.Advice.LineFour = "Line Four"
fibfia.Advice.LineFive = "Line Five"
fibfia.Advice.LineSix = "Line Six"
fwm.FIBeneficiaryFIAdvice = fibfia
fib := wire.NewFIBeneficiary()
fib.FIToFI.LineOne = "Line One"
fib.FIToFI.LineTwo = "Line Two"
fib.FIToFI.LineThree = "Line Three"
fib.FIToFI.LineFour = "Line Four"
fib.FIToFI.LineFive = "Line Five"
fib.FIToFI.LineSix = "Line Six"
fwm.FIBeneficiary = fib
fiba := wire.NewFIBeneficiaryAdvice()
fiba.Advice.AdviceCode = wire.AdviceCodeLetter
fiba.Advice.LineOne = "Line One"
fiba.Advice.LineTwo = "Line Two"
fiba.Advice.LineThree = "Line Three"
fiba.Advice.LineFour = "Line Four"
fiba.Advice.LineFive = "Line Five"
fiba.Advice.LineSix = "Line Six"
fwm.FIBeneficiaryAdvice = fiba
pm := wire.NewFIPaymentMethodToBeneficiary()
pm.AdditionalInformation = "Additional Information"
fwm.FIPaymentMethodToBeneficiary = pm
fifi := wire.NewFIAdditionalFIToFI()
fifi.AdditionalFIToFI.LineOne = "Line One"
fifi.AdditionalFIToFI.LineTwo = "Line Two"
fifi.AdditionalFIToFI.LineThree = "Line Three"
fifi.AdditionalFIToFI.LineFour = "Line Four"
fifi.AdditionalFIToFI.LineFive = "Line Five"
fifi.AdditionalFIToFI.LineSix = "Line Six"
fwm.FIAdditionalFIToFI = fifi
file.AddFEDWireMessage(fwm)
if err := file.Create(); err != nil {
log.Fatalf("Could not create FEDWireMessage: %s\n", err)
}
if err := file.Validate(); err != nil {
log.Fatalf("Could not validate FEDWireMessage: %s\n", err)
}
w := wire.NewWriter(os.Stdout)
if err := w.Write(file); err != nil {
log.Fatalf("Unexpected error: %s\n", err)
}
w.Flush()
}