@domdanao/magpie-cli
v1.0.3
Published
Command-line interface for the Magpie Payment Platform. Process payments, create checkout sessions, manage payment requests, and handle payment links from your terminal.
Maintainers
Readme
Magpie CLI
A command-line interface for the Magpie Payment Platform. Process payments, create checkout sessions, send invoices, and manage payment links — all from your terminal.
Installation
npm install -g @domdanao/magpie-cliOr run directly with npx:
npx @domdanao/magpie-cli --helpQuick Start
1. Configure your API keys
magpie config set publicKey pk_live_xxxx
magpie config set secretKey sk_live_xxxxOr use environment variables:
export MAGPIE_PUBLIC_KEY=pk_live_xxxx
export MAGPIE_SECRET_KEY=sk_live_xxxx2. Start using the CLI
# List your checkout sessions
magpie checkout list
# Create a payment link
magpie link create \
--name "Monthly Subscription" \
--items '[{"name":"Pro Plan","quantity":1,"amount":49900}]' \
--methods card,gcash,maya
# Check a charge status
magpie charge get chr_abc123Commands
Configuration
magpie config set <key> <value> # Store a config value
magpie config get <key> # Read a config value
magpie config list # Show all config (secrets redacted)
magpie config profiles # List all profiles
magpie config use <profile> # Switch default profile
magpie config path # Show config file locationPayment Sources
# Create a card source
magpie source create -t card \
--card-name "Juan Dela Cruz" \
--card-number "4012001037141112" \
--exp-month "12" --exp-year "2027" --cvc "123"
# Create a GCash source
magpie source create -t gcash \
--success-url https://mysite.com/success \
--fail-url https://mysite.com/fail
# Get source details
magpie source get src_xxxxCustomers
magpie customer create -e [email protected] -d "VIP Customer"
magpie customer get cus_xxxx
magpie customer find [email protected]
magpie customer update cus_xxxx -m "+639123456789"
magpie customer attach-source cus_xxxx src_xxxx
magpie customer detach-source cus_xxxx src_xxxxCharges
# Create a charge (amount in cents: 5000 = PHP 50.00)
magpie charge create -a 5000 -s src_xxxx -d "Order #123" --statement "MYSHOP"
# List, capture, void, refund
magpie charge list
magpie charge capture chr_xxxx -a 5000
magpie charge void chr_xxxx
magpie charge refund chr_xxxx -a 2000 # Partial refund
magpie charge refund chr_xxxx # Full refundCheckout Sessions
magpie checkout create \
--success-url https://mysite.com/success \
--cancel-url https://mysite.com/cancel \
--items '[{"name":"Premium Plan","quantity":1,"amount":99900}]' \
--mode payment \
--methods card,gcash,maya
magpie checkout list
magpie checkout get cs_xxxx
magpie checkout expire cs_xxxx
magpie checkout capture cs_xxxxPayment Requests
magpie request create \
--items '[{"name":"Web Design","quantity":1,"amount":250000}]' \
--methods card,gcash \
--deliver email
magpie request list --status open
magpie request get pr_xxxx
magpie request void pr_xxxx -r "Customer cancelled"
magpie request resend pr_xxxxPayment Links
magpie link create \
--name "T-Shirt Sale" \
--items '[{"name":"T-Shirt","quantity":100,"amount":59900}]' \
--methods card,gcash,paymaya
magpie link list --status active
magpie link get plink_xxxx
magpie link deactivate plink_xxxx
magpie link activate plink_xxxxGlobal Options
| Flag | Description |
|------|-------------|
| --profile <name> | Use a specific configuration profile |
| --test-mode | Enable test mode for the request |
| --json | Output raw JSON (no colors, pipe-friendly) |
| --compact | Output compact single-line JSON |
| --verbose | Show detailed request/response info |
| -V, --version | Show version number |
| -h, --help | Show help |
Configuration
Profiles
Use profiles to manage multiple Magpie accounts (e.g. production and staging):
# Set up a staging profile
magpie config set publicKey pk_test_xxxx --profile staging
magpie config set secretKey sk_test_xxxx --profile staging
# Use staging for a single command
magpie checkout list --profile staging
# Switch default profile
magpie config use stagingPrecedence
Configuration values are resolved in this order:
- CLI flags (e.g.
--test-mode) - Environment variables (
MAGPIE_PUBLIC_KEY,MAGPIE_SECRET_KEY, etc.) - Config file (
~/.config/magpie-cli/config.json)
Piping & Scripting
The CLI is designed to be pipe-friendly:
# Get a checkout session URL
magpie checkout get cs_xxxx --json | jq '.url'
# List all paid payment requests as compact JSON
magpie request list --status paid --compact
# Use in shell scripts
CHARGE_ID=$(magpie charge create -a 5000 -s src_xxxx -d "Auto charge" --statement "AUTO" --json | jq -r '.id')
echo "Created charge: $CHARGE_ID"Supported Payment Methods
| Method | Code |
|--------|------|
| Credit/Debit Card | card |
| GCash | gcash |
| Maya / PayMaya | maya, paymaya |
| BPI | bpi |
| Alipay | alipay |
| UnionPay | unionpay |
| WeChat Pay | wechat |
Not all payment methods are available on every API. See Magpie documentation for details.
License
MIT
