JSPM

@domdanao/magpie-cli

1.0.3
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 8
    • Score
      100M100P100Q80301F
    • License MIT

    Command-line interface for the Magpie Payment Platform. Process payments, create checkout sessions, manage payment requests, and handle payment links from your terminal.

    Package Exports

    • @domdanao/magpie-cli
    • @domdanao/magpie-cli/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@domdanao/magpie-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    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-cli

    Or run directly with npx:

    npx @domdanao/magpie-cli --help

    Quick Start

    1. Configure your API keys

    magpie config set publicKey pk_live_xxxx
    magpie config set secretKey sk_live_xxxx

    Or use environment variables:

    export MAGPIE_PUBLIC_KEY=pk_live_xxxx
    export MAGPIE_SECRET_KEY=sk_live_xxxx

    2. 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_abc123

    Commands

    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 location

    Payment 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_xxxx

    Customers

    magpie customer create -e customer@email.com -d "VIP Customer"
    magpie customer get cus_xxxx
    magpie customer find customer@email.com
    magpie customer update cus_xxxx -m "+639123456789"
    magpie customer attach-source cus_xxxx src_xxxx
    magpie customer detach-source cus_xxxx src_xxxx

    Charges

    # 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 refund

    Checkout 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_xxxx

    Payment 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_xxxx
    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_xxxx

    Global 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 staging

    Precedence

    Configuration values are resolved in this order:

    1. CLI flags (e.g. --test-mode)
    2. Environment variables (MAGPIE_PUBLIC_KEY, MAGPIE_SECRET_KEY, etc.)
    3. 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