Categorygithub.com/moov-io/imagecashletter
modulepackage
0.11.0
Repository: https://github.com/moov-io/imagecashletter.git
Documentation: pkg.go.dev

# README

Moov Banner Logo

Project Documentation · API Endpoints · API Guide · Community · Blog

GoDoc Build Status Coverage Status Go Report Card Repo Size Apache 2 License Slack Channel Docker Pulls GitHub Stars Twitter

moov-io/imagecashletter

Moov's mission is to give developers an easy way to create and integrate bank processing into their own software products. Our open source projects are each focused on solving a single responsibility in financial services and designed around performance, scalability, and ease of use.

ImageCashLetter implements a reader, writer, and validator for X9’s Specifications for Image Cash Letter (ICL) to provide Check 21 services in an HTTP server and Go library. The HTTP server is available in a Docker image and the Go package github.com/moov-io/imagecashletter is available.

Table of contents

Project status

Moov ImageCashLetter is actively used in multiple production environments. Please star the project if you are interested in its progress. If you have layers above ImageCashLetter to simplify tasks, perform business operations, or found bugs we would appreciate an issue or pull request. Thanks!

Usage

The Image Cash Letter project implements an HTTP server and Go library for creating and modifying ICL files. We also have some examples of the reader and writer.

Docker

We publish a public Docker image moov/imagecashletter from Docker Hub or use this repository. No configuration is required to serve on :8083 and metrics at :9093/metrics in Prometheus format. We also have Docker images for OpenShift published as quay.io/moov/imagecashletter.

Pull & start the Docker image:

docker pull moov/imagecashletter:latest
docker run -p 8083:8083 -p 9093:9093 moov/imagecashletter:latest

List files stored in-memory:

curl localhost:8083/files
null

Upload an x9 file (binary):

curl -X POST --data-binary "@./test/testdata/valid-ascii.x937" http://localhost:8083/files/create
{"id":"<YOUR-UNIQUE-FILE-ID>","fileHeader":{"id":"","standardLevel":"03","testIndicator":"T","immediateDestination":"061000146","immediateOrigin":"026073150", ...

Retrieve an existing x9 file (JSON):

curl http://localhost:8083/files/<YOUR-UNIQUE-FILE-ID>
{"id":"<YOUR-UNIQUE-FILE-ID>","fileHeader":{"id":"","standardLevel":"03","testIndicator":"T","immediateDestination":"061000146","immediateOrigin":"026073150", ...

Create an x9 file from JSON:

curl -X POST -H "content-type: application/json" localhost:8083/files/create --data @./test/testdata/icl-valid.json
{"id":"<YOUR-UNIQUE-FILE-ID>","fileHeader":{"id":"","standardLevel":"35","testIndicator":"T","immediateDestination":"231380104","immediateOrigin":"121042882", ...

Get the formatted file:

curl localhost:8083/files/<YOUR-UNIQUE-FILE-ID>/contents
P0135T231380104121042882201810032219NCitadel      Wells Fargo    US   P100123138010412104288220181003201810032219IGA1   Contact Name 5558675552  P200123138010412104288220181003201810039999   1  01             P25   123456789 031300012       555888100001000001       GD1Y030BP261121042882201810031       938383      01  Test Payee   Y10
...

Google Cloud Run

To get started in a hosted environment you can deploy this project to the Google Cloud Platform.

From your Google Cloud dashboard create a new project and call it:

moov-icl-demo

Enable the Container Registry API for your project and associate a billing account if needed. Then, open the Cloud Shell terminal and run the following Docker commands, substituting your unique project ID:

docker pull moov/imagecashletter
docker tag moov/imagecashletter gcr.io/<PROJECT-ID>/imagecashletter
docker push gcr.io/<PROJECT-ID>/imagecashletter

Deploy the container to Cloud Run:

gcloud run deploy --image gcr.io/<PROJECT-ID>/imagecashletter --port 8083

Select your target platform to 1, service name to imagecashletter, and region to the one closest to you (enable Google API service if a prompt appears). Upon a successful build you will be given a URL where the API has been deployed:

https://YOUR-ICL-APP-URL.a.run.app

Now you can list files stored in-memory:

curl https://YOUR-ICL-APP-URL.a.run.app/files

You should get this response:

null

Configuration settings

The following environmental variables can be set to configure behavior in ImageCashLetter.

Environmental VariableDescriptionDefault
READER_BUFFER_SIZESize of buffer to use with bufio.Scanner.Check bufio.MaxScanTokenSize
HTTPS_CERT_FILEFilepath containing a certificate (or intermediate chain) to be served by the HTTP server. Requires all traffic be over secure HTTP.Empty
HTTPS_KEY_FILEFilepath of a private key matching the leaf certificate from HTTPS_CERT_FILE.Empty
FRB_COMPATIBILITY_MODEIf set, enables Federal Reserve Bank (FRB) compatibility mode.Empty

Data persistence

By design, ImageCashLetter does not persist (save) any data about the files or entry details created. The only storage occurs in memory of the process and upon restart ImageCashLetter will have no files or data saved. Also, no in-memory encryption of the data is performed.

Go library

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

$ [email protected]:moov-io/imagecashletter.git

# Pull down into the Go Module cache
$ go get -u github.com/moov-io/imagecashletter

$ go doc github.com/moov-io/imagecashletter CashLetter

The package github.com/moov-io/imagecashletter offers a Go-based Image Cash Letter file reader and writer. To get started, check out a specific example:

ICL FileReadWrite
LinkLinkLink

ImageCashLetter's file handling behaviors can be modified to accommodate your specific use case. This is done by passing options into ICL's reader and writer during instantiation. For example, to read EBCDID encoded files you would instantiate a reader with NewReader(fd, ReadVariableLineLengthOption(), ReadEbcdicEncodingOption()).

The following options are currently supported:

OptionDescription
ReadVariableLineLengthOptionAllows Reader to split ICL files based on the Inserted Length Field.
ReadEbcdicEncodingOptionAllows Reader to decode scanned lines from EBCDIC to UTF-8.
WriteVariableLineLengthOptionInstructs the Writer to begin each record with the appropriate Inserted Length Field.
WriteEbcdicEncodingOptionAllows Writer to write file in EBCDIC.

In-browser ICL file parser

Using our in-browser utility, you can instantly convert X9 files into JSON. Either paste in ICL file content directly or choose a file from your local machine. This tool is particularly useful if you're handling sensitive PII or want to perform some quick tests, as operations are fully client-side with nothing stored in memory. We plan to support bidirectional conversion in the near future.

Learn about Image Cash Letter

Getting help

channelinfo
Project DocumentationOur project documentation available online.
Twitter @moovYou can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories.
GitHub IssueIf you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error.
moov-io slackJoin our slack channel to have an interactive discussion about the development of the project.

Supported and tested platforms

  • 64-bit Linux (Ubuntu, Debian), macOS, and Windows
  • Raspberry Pi

Note: 32-bit platforms have known issues and are not supported.

Contributing

Yes please! Please review our Contributing guide and Code of Conduct to get started!

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

Releasing

To make a release of imagecashletter simply open a pull request with CHANGELOG.md and version.go updated with the next version number and details. You'll also need to push the tag (i.e. git push origin v1.0.0) to origin in order for CI to make the release.

Testing

We maintain a comprehensive suite of unit tests and recommend table-driven testing when a particular function warrants several very similar test cases. To run all test files in the current directory, use go test. Current overall coverage can be found on Codecov.

Fuzzing

We currently run fuzzing over ACH in the form of a Github Action. Please report crashes examples to [email protected]. Thanks!

Related projects

As part of Moov's initiative to offer open source fintech infrastructure, we have a large collection of active projects you may find useful:

  • Moov Watchman offers search functions over numerous trade sanction lists from the United States and European Union.

  • Moov Fed implements utility services for searching the United States Federal Reserve System such as ABA routing numbers, financial institution name lookup, and FedACH and Fedwire routing information.

  • Moov Wire implements an interface to write files for the Fedwire Funds Service, a real-time gross settlement funds transfer system operated by the United States Federal Reserve Banks.

  • Moov ACH provides ACH file generation and parsing, supporting all Standard Entry Codes for the primary method of money movement throughout the United States.

  • Moov Metro 2 provides a way to easily read, create, and validate Metro 2 format, which is used for consumer credit history reporting by the United States credit bureaus.

License

Apache License 2.0 - See LICENSE for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

BufferSizeOption creates a byte slice of the specified size and uses it as the buffer for the Reader's internal scanner.
DecodeEBCDIC will decode a line from EBCDIC-0037 to UTF-8.
FileFromJSON attempts to return a *File object assuming the input is valid JSON.
Determine if FRB (Federal Reserve Bank) compatibility mode is enabled.
NewBundle takes a BundleHeader and returns a Bundle.
NewBundleControl returns a new BundleControl with default values for non exported fields.
NewBundleHeader returns a new BundleHeader with default values for non exported fields.
NewCashLetter takes a CashLetterHeader and returns a CashLetter.
NewCashLetterControl returns a new CashLetterControl with default values for non exported fields.
NewCashLetterHeader returns a new CashLetterHeader with default values for non exported fields.
NewCheckDetail returns a new CheckDetail with default values for non exported fields.
NewCheckDetailAddendumA returns a new CheckDetailAddendumA with default values for non exported fields.
NewCheckDetailAddendumB returns a new CheckDetailAddendumB with default values for non exported fields.
NewCheckDetailAddendumC returns a new CheckDetailAddendumC with default values for non exported fields.
NewCredit returns a new credit with default values for non exported fields.
NewCreditItem returns a new CreditItem with default values for non exported fields.
NewFile constructs a file template with a FileHeader and FileControl.
NewFileControl returns a new FileControl with default values for non exported fields.
NewFileHeader returns a new FileHeader with default values for non exported fields.
NewImageViewAnalysis returns a new ImageViewAnalysis with default values for non exported fields.
NewImageViewData returns a new ImageViewData with default values for non exported fields.
NewImageViewDetail returns a new ImageViewDetail with default values for non exported fields.
NewReader returns a new ACH Reader that reads from r.
NewReturnDetail returns a new ReturnDetail with default values for non exported fields.
NewReturnDetailAddendumA returns a new ReturnDetailAddendumA with default values for non exported fields.
NewReturnDetailAddendumB returns a new ReturnDetailAddendumB with default values for non exported fields.
NewReturnDetailAddendumC returns a new ReturnDetailAddendumC with default values for non exported fields.
NewReturnDetailAddendumD returns a new ReturnDetailAddendumD with default values for non exported fields.
NewRoutingNumberSummary returns a new RoutingNumberSummary with default values for non exported fields.
NewUserGeneral returns a new UserGeneral with default values for non exported fields.
NewUserPayeeEndorsement returns a new UserPayeeEndorsement with default values for non exported fields.
NewWriter returns a new Writer that writes to w.
Passthrough will return line as is.
ReadEbcdicEncodingOption allows Reader to decode scanned lines from EBCDIC to UTF-8.
ReadVariableLineLengthOption allows Reader to split imagecashletter files based on encoded line lengths.
WriteEbcdicEncodingOption allows Writer to write file in EBCDIC Follows DSTU microformat as defined https://www.frbservices.org/assets/financial-services/check/setup/frb-x937-standards-reference.pdf.
WriteVariableLineLengthOption allows Writer to write control bytes ahead of record to describe how long the line is Follows DSTU microformat as defined https://www.frbservices.org/assets/financial-services/check/setup/frb-x937-standards-reference.pdf.

# Constants

Addendum Counts.
Addendum Counts.
Addendum Counts.
No description provided by the author
Addendum Counts.
Addendum Counts.
Addendum Counts.
Addendum Counts.
Version is the current version.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

AdministrativeReturnCode are customer return reason codes as defined in Part 6.3 of the ANSI X9.100-188-2018 Return Reasons for Check Image Exchange and IRDs.
Bundle contains forward items (checks).
BundleControl Record.
BundleError is an Error that describes bundle validation issues.
BundleHeader Record.
CashLetter contains CashLetterHeader, CashLetterControl and Bundle records.
CashLetterControl Record.
CashLetterError is an Error that describes CashLetter validation issues.
CashLetterHeader Record is mandatory.
CheckDetail Record.
CheckDetailAddendumA Record.
CheckDetailAddendumB Record.
CheckDetailAddendumC Record.
Credit Record.
CreditItem Record.
CustomerReturnCode are customer return reason codes as defined in Part 6.2 of the ANSI X9.100-188-2018 Return Reasons for Check Image Exchange and IRDs.
FieldError is returned for errors at a field level in a record.
File is an imagecashletter file.
FileControl Record.
FileError is an error describing issues validating a file.
FileHeader Record is mandatory.
ImageViewAnalysis Record.
ImageViewData Record.
ImageViewDetail Record.
ParseError is returned for parsing reader errors.
Reader reads records from a ACH-encoded file.
ReturnDetail Record.
ReturnDetailAddendumA Record.
ReturnDetailAddendumB Record.
ReturnDetailAddendumC Record.
ReturnDetailAddendumD Record.
RoutingNumberSummary Record.
UserGeneral Record.
UserPayeeEndorsement Record.
Writer writes an ImageCashLetter/X9 File to an encoded format.

# Interfaces

No description provided by the author

# Type aliases

DecodeLineFn is used to decode a scanned line into desired encoding.
ReaderOption can be used to change default behavior of Reader.
WriterOption allows Writer to be configured to write in different formats.