Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "TypeScript example",
"dockerComposeFile": ["docker-compose.yml"],
// The name of the following service has to match one of the services in docker-compose.yml
"service": "card-cli",
"workspaceFolder": "/work",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"donjayamanne.githistory",
"editorconfig.editorconfig",
"firsttris.vscode-jest-runner",
"github.copilot@prerelease",
"github.copilot-chat@prerelease",
"github.copilot-labs@prerelease",
"mhutchie.git-graph",
"ms-vsliveshare.vsliveshare",
"mutantdino.resourcemonitor",
"qcz.restart-ts-server-button",
"rtbenfield.vscode-jest-test-adapter",
"usernamehw.errorlens"
]
}
},
"shutdownAction": "stopCompose",
"remoteUser": "node"
}

"name": "TypeScript example",
"dockerComposeFile": ["docker-compose.yml"],
// The name of the following service has to match one of the services in docker-compose.yml
"service": "card-cli",
"workspaceFolder": "/work",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"donjayamanne.githistory",
"editorconfig.editorconfig",
"firsttris.vscode-jest-runner",
"github.copilot@prerelease",
"github.copilot-chat@prerelease",
"github.copilot-labs@prerelease",
"mhutchie.git-graph",
"ms-vsliveshare.vsliveshare",
"mutantdino.resourcemonitor",
"qcz.restart-ts-server-button",
"rtbenfield.vscode-jest-test-adapter",
"usernamehw.errorlens"
]
}
},
"shutdownAction": "stopCompose",
"remoteUser": "node"
}
50 changes: 25 additions & 25 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ name: 'card-cli'
# [Manfred, 21apr2023]

services:
# change the service name, the container name and the hostname for each dev container that connects
# to the same virtual network. [Manfred, 29jul2022]
card-cli:
image: typescript-dev:0.1
build: .
container_name: card-cli
hostname: card-cli.local
working_dir: /work
ports:
# Change the port number in case you have more than one dev container based on this
# template. For example, you could use something like:
# - "3100:3000"
# [Manfred, 29jul2022]
- "3100:3000" # <<<<<< if preferred, explicit forward the port used by express
# Using double quotes for port mapping to avoid YAML reading it as a number with a different base
# e.g. "3333:22" would result in port numbers greater than 130000 which are clearly invalid.
# Without double quotes YAML interprets it as a number based on 22. [Manfred, 24aug2022]
volumes:
- ..:/work
command: bash -c "/work/.devcontainer/init.sh && sleep infinity"
networks:
card-cli:
# change the service name, the container name and the hostname for each dev container that connects
# to the same virtual network. [Manfred, 29jul2022]
card-cli:
image: typescript-dev:0.1
build: .
container_name: card-cli
hostname: card-cli.local
working_dir: /work
ports:
# Change the port number in case you have more than one dev container based on this
# template. For example, you could use something like:
# - "3100:3000"
# [Manfred, 29jul2022]
- '3100:3000' # <<<<<< if preferred, explicit forward the port used by express
# Using double quotes for port mapping to avoid YAML reading it as a number with a different base
# e.g. "3333:22" would result in port numbers greater than 130000 which are clearly invalid.
# Without double quotes YAML interprets it as a number based on 22. [Manfred, 24aug2022]
volumes:
- ..:/work
command: bash -c "/work/.devcontainer/init.sh && sleep infinity"
networks:
card-cli:

# If you list further services (ie containers) here, place them in the same virtual network if
# you want them being visible to each other. [Manfred, 10sep2022]
# If you list further services (ie containers) here, place them in the same virtual network if
# you want them being visible to each other. [Manfred, 10sep2022]

networks:
card-cli:
card-cli:
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22, 24]
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm

- run: npm ci
- run: npm run build
- run: npm run check-format
- run: npm run check-exports
- run: npm test
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to npm

on:
push:
tags:
- 'v*'
workflow_dispatch:

permissions:
contents: read
id-token: write # Required for npm trusted publishing (OIDC)

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false

- run: npm ci
- run: npm run build
- run: npm test
- run: npm publish --access public
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
templates/budget-breeze
templates/investec-swipe-n-save
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Write and test programmable card code in a safe environment.
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Table of Contents

- [About](#about)
- [Templates](#templates)
- [Installation](#installation)
Expand Down Expand Up @@ -37,45 +38,40 @@ Current Templates:
- `postman-echo` - A template for sending a transaction to [Postman Echo](https://learning.postman.com/docs/developer/echo-api/)

## Installation

Before installing, [download and install Node.js](https://nodejs.org/en/download/).

```bash
git clone https://github.com/devinpearson/programmable-banking-card-issuer.git
cd programmable-banking-card-issuer
```

```bash
npm install
```

## DevContainer (VSCode)
VS Code will automatically detect the `.devcontainer` folder and prompt you to open the project in a container. This will set up the environment for you to run the server in a Docker container.

VS Code will automatically detect the `.devcontainer` folder and prompt you to open the project in a container. This will set up the environment for you to run the server in a Docker container.

```bash
docker-compose -f .devcontainer/docker-compose.yml up
```

## Docker

```bash
docker build -t card-emu .
docker run card-emu -t petrol_card
```

![](./media/docker-example.gif)

### Usage
Commands:
run [filename] run your code locally
fetch-cards list cards
fetch [cardkey] [filename] fetches your saved code
fetch-published [cardkey] [filename] fetches your published code
fetch-env [cardkey] [filename] fetches your environmental variables
upload [cardkey] [filename] uploads your code to saved code
publish [cardkey] [codeid] [filename] publishes your saved code
upload-env [cardkey] [filename] publishes your environmental variables
toggle [cardkey] [enabled] enable/disable card code
executions [cardkey] [filename] card execution logs

Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Commands: run [filename] run your code locally fetch-cards list cards fetch [cardkey] [filename] fetches your saved code fetch-published [cardkey] [filename] fetches your published code fetch-env [cardkey] [filename] fetches your environmental variables upload [cardkey] [filename] uploads your code to saved code publish [cardkey] [codeid] [filename] publishes your saved code upload-env [cardkey] [filename] publishes your environmental variables toggle [cardkey] [enabled] enable/disable card code executions [cardkey] [filename] card execution logs

Options: -h, --help Show help [boolean] -v, --version Show version number [boolean]

![](./media/card-code-example.gif)

Expand Down Expand Up @@ -104,12 +100,15 @@ To run a transaction against a template, run the following command:
```
node . main.js -e env.json --amount 60000 --currency ZAR --mcc 0000 --merchant "Test Merchant" --city "Test City" --country ZA
```

## Testing

To run the tests, use the following command:

```bash
npm test
```

## Contributing

Contributions are welcome! Please submit a pull request or open an issue for any suggestions or improvements.
Expand All @@ -128,6 +127,7 @@ For inquiries, please open an issue.
- [Chalk](https://github.com/chalk/chalk)

## Other Projects

- [Banking API Simulator](https://github.com/devinpearson/programmable-banking-sim)
- [Random banking data generator](https://github.com/devinpearson/programmable-banking-faker)
- [Open Banking Point of Sales device](https://github.com/devinpearson/programmable-banking-pos)
Expand Down
Loading