sepay-cli

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0

README

sepay

The command-line tool for SePay. Log in, watch transactions, create webhooks and stream them to localhost, create hosted-checkout orders, and simulate all of it in sandbox.

sepay <command> <subcommand> [flags]

Install

npm install --save-dev sepay-cli@<version>   # pin the version
npx sepay-cli version
npx sepay-cli@next version                    # latest release candidate

Per-platform archives and the cosign-signed checksums.txt are attached to each GitHub Release.

Updating
npm install -g sepay-cli@latest      # global install
npm install -D sepay-cli@latest      # pinned in a project (or let Dependabot / Renovate open the PR)

Once a day an interactive run checks for a newer release, and whether the version you run has been deprecated (withdrawn or vulnerable), and prints a short notice to stderr after the command. It never installs anything and stays quiet in CI, under --json, and when SEPAY_NO_UPDATE_NOTIFIER=1.

Get started

sepay login          # opens a browser to approve a one-time code
sepay auth status    # the account and company you are on

The token is stored in your OS keychain. On a machine with no browser: sepay login --with-token. With no usable keychain (a server, a container): add --insecure-storage to keep it in a 0600 file.

Every command runs against sandbox by default. Add --env production to touch live data.

Receive your first webhook on localhost

No public URL, no tunnel.

# Your handler is running on localhost:3000

sepay sandbox init --with-va --with-webhook-listen        # sandbox account + webhook
sepay webhook listen --forward localhost:3000 --print     # stream events to the handler

# Second shell: fire a transaction
sepay bank-account list                                   # note the xid
sepay sandbox simulate payment_in --bank-account <ba_xid> --amount 50000 --code ABC123

Each event carries the same body and signature headers SePay sends, so your handler runs its real path, including its own signature check. Assert the handler responds correctly: sepay webhook test --forward localhost:3000 --amount 50000.

Commands

Command What it does
transaction List and inspect transactions
bank-account Manage bank accounts
webhook Create, update, view logs, listen, test, replay
va Manage virtual accounts
paycode Payment code prefix
pg Payment Gateway orders and merchant
bankhub Bank Hub companies, accounts, and link tokens
einvoice Electronic invoices
apikey API keys
quota Plan quota and usage
sandbox init, seed, simulate, reset (sandbox only)
api Call any SePay API endpoint with the stored token
auth status, switch, refresh, sessions, revoke, token
config CLI settings
docs Reference topics in the terminal

sepay --help lists everything. sepay --map=paths prints every command; --map=json adds machine-readable metadata.

Global flags

Flag Meaning
--env sandbox|production Environment, default sandbox
--json, -o json|yaml Machine-readable output, no color; every read command supports it
-p, --profile Account to use, when more than one is logged in
-y, --yes Skip the confirmation on write commands (scripts, CI); cannot bypass OTP
--no-input Never prompt; a missing value is an error
--idempotency-key Retry an interrupted write without repeating it
-v, --verbose Debug logging; tokens and OTP are always redacted

Environment variables: SEPAY_PROFILE, SEPAY_CONFIG_DIR, SEPAY_NO_UPDATE_NOTIFIER, NO_COLOR. Details: sepay docs environment.

Exit codes

Code Meaning
0 Success
1 Server error or rejected input; read error_code before retrying
2 Bad flags, bad arguments, unknown command
4 Not authenticated: sepay login
5 Token lacks the required scope: sepay auth refresh --scopes <scope>
6 Your local handler did not accept the event (webhook test)
7 The server demanded an OTP; do this action in the web app
8 Your account or company is not allowed to do this

Errors go to stderr, output to stdout. Under --json the error is JSON too, with error_code and exit_code. Full list: sepay docs exit-codes.

Shell completion

From a release archive or npm, run once:

mkdir -p ~/.local/share/bash-completion/completions && sepay completion bash > ~/.local/share/bash-completion/completions/sepay   # needs bash-completion
mkdir -p ~/.zfunc && sepay completion zsh > ~/.zfunc/_sepay   # ~/.zshrc: fpath+=~/.zfunc before compinit
sepay completion fish > ~/.config/fish/completions/sepay.fish
sepay completion powershell | Out-String | Invoke-Expression   # append to $PROFILE

Documentation

Topic Command
What SePay is, which payment path to pick sepay docs overview
Command order for common tasks sepay docs flows
Webhook body and signature headers sepay docs webhook-payload
Payment Gateway order IPN sepay docs ipn-payload
Calling the SePay API directly from your app sepay docs api

Full documentation: developer.sepay.vn/vi/tien-ich-khac/sepay-cli.

Contributing

CONTRIBUTING.md. Report a security vulnerability: SECURITY.md.

License

Apache-2.0 © SePay JSC.

Directories

Path Synopsis
cmd
sepay command
Command sepay is the SePay CLI entry point.
Command sepay is the SePay CLI entry point.
internal
api
Package api is the SePay API v2 HTTP client.
Package api is the SePay API v2 HTTP client.
auth
Package auth implements the OAuth2 device-authorization-grant client (RFC 8628).
Package auth implements the OAuth2 device-authorization-grant client (RFC 8628).
bankhub
Package bankhub is the Bank Hub v1 HTTP client, authenticated with a broker-minted product credential.
Package bankhub is the Bank Hub v1 HTTP client, authenticated with a broker-minted product credential.
build
Package build holds version info injected via -ldflags.
Package build holds version info injected via -ldflags.
config
Package config reads/writes the sepay config (config.yml) via Viper.
Package config reads/writes the sepay config (config.yml) via Viper.
einvoice
Package einvoice is the E-Invoice v1 HTTP client, authenticated with a broker-minted product credential.
Package einvoice is the E-Invoice v1 HTTP client, authenticated with a broker-minted product credential.
envvar
Package envvar reads the CLI's on/off environment switches.
Package envvar reads the CLI's on/off environment switches.
forward
Package forward replays a webhook event verbatim, headers included, to a local handler.
Package forward replays a webhook event verbatim, headers included, to a local handler.
pg
Package pg is the Payment Gateway v1 HTTP client, authenticated with a broker-minted product credential.
Package pg is the Payment Gateway v1 HTTP client, authenticated with a broker-minted product credential.
product
Package product brokers and caches product-native credentials (PG, eInvoice, Bank Hub).
Package product brokers and caches product-native credentials (PG, eInvoice, Bank Hub).
sse
Package sse subscribes to the SePay webhook hub over Server-Sent Events.
Package sse subscribes to the SePay webhook hub over Server-Sent Events.
update
Package update notifies, at most once a day, of a newer or deprecated release.
Package update notifies, at most once a day, of a newer or deprecated release.
pkg
cmd/api
Package api implements "sepay api", an authenticated raw passthrough to the public SePay API.
Package api implements "sepay api", an authenticated raw passthrough to the public SePay API.
cmd/apikey
Package apikey implements "sepay apikey".
Package apikey implements "sepay apikey".
cmd/auth
Package auth implements "sepay auth" and the root "login"/"logout" aliases.
Package auth implements "sepay auth" and the root "login"/"logout" aliases.
cmd/bank-account
Package bankaccount implements "sepay bank-account".
Package bankaccount implements "sepay bank-account".
cmd/bankhub
Package bankhub implements "sepay bankhub", the Bank Hub server API.
Package bankhub implements "sepay bankhub", the Bank Hub server API.
cmd/completion
Package completion implements "sepay completion".
Package completion implements "sepay completion".
cmd/config
Package config implements "sepay config" (persistent CLI settings).
Package config implements "sepay config" (persistent CLI settings).
cmd/docs
Package docs implements "sepay docs", the embedded reference for agents.
Package docs implements "sepay docs", the embedded reference for agents.
cmd/einvoice
Package einvoice implements "sepay einvoice".
Package einvoice implements "sepay einvoice".
cmd/paycode
Package paycode implements "sepay paycode" (get, set).
Package paycode implements "sepay paycode" (get, set).
cmd/pg
Package pg implements "sepay pg" (Payment Gateway).
Package pg implements "sepay pg" (Payment Gateway).
cmd/quota
Package quota implements "sepay quota".
Package quota implements "sepay quota".
cmd/report
Package report implements "sepay report" (cashflow).
Package report implements "sepay report" (cashflow).
cmd/root
Package root builds the top-level "sepay" command and its global flags.
Package root builds the top-level "sepay" command and its global flags.
cmd/sandbox
Package sandbox implements "sepay sandbox", the sandbox-only utilities.
Package sandbox implements "sepay sandbox", the sandbox-only utilities.
cmd/transaction
Package transaction implements "sepay transaction".
Package transaction implements "sepay transaction".
cmd/va
Package va implements "sepay va".
Package va implements "sepay va".
cmd/version
Package version implements "sepay version".
Package version implements "sepay version".
cmd/webhook
Package webhook implements "sepay webhook" and its verbs (listen, test, list, get, create, update, delete, logs, replay).
Package webhook implements "sepay webhook" and its verbs (listen, test, list, get, create, update, delete, logs, replay).
cmdutil
Package cmdutil provides the shared Factory and error types used by every command.
Package cmdutil provides the shared Factory and error types used by every command.
iostreams
Package iostreams bundles a command's streams and TTY/color state.
Package iostreams bundles a command's streams and TTY/color state.
jsonfmt
Package jsonfmt renders output as an aligned table or JSON/YAML.
Package jsonfmt renders output as an aligned table or JSON/YAML.
listen
Package listen streams one SePay delivery channel over SSE and replays each delivery to a local HTTP handler.
Package listen streams one SePay delivery channel over SSE and replays each delivery to a local HTTP handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL