Skip to main content

Payment Gateway CLI

A powerful command-line interface for interacting with the Payment Gateway API. Perfect for testing, automation, and quick merchant operations without building a full integration.
Current Status: v1.1.0 - Production ReadyCore authentication, merchant management, API keys, and payment intents with hosted checkout are fully functional.

Why Use the CLI?

Rapid Testing

Test payment flows without writing codeInstant feedback on API responses

Hosted Checkout

Create payment intents with browser checkoutReal-time payment status polling

Developer Friendly

Interactive prompts with validationColored output, tables, and progress indicators

Multi-Environment

Switch between development and productionProduction-first configuration

Installation

Prerequisites

Go 1.23 or higherCheck your version:
Install Go: Visit go.dev/dl or use your package manager.

1

Download Latest Release

Download the CLI binary for your operating system:Using curl:
2

Make Executable (Linux/macOS)

3

Move to PATH

Linux/macOS:
Windows: Move payment-cli.exe to a directory in your PATH, or add its location to PATH.
4

Verify Installation


Method 2: Build from Source

1

Clone Repository

2

Install Dependencies

This installs:
  • cobra - CLI framework
  • color - Colored terminal output
  • tablewriter - Table formatting
  • spinner - Loading animations
  • promptui - Interactive prompts
  • yaml.v3 - Config file handling
3

Build Binary

Using Go:
Using Makefile (if available):
4

Install Globally (Optional)


Quick Start

Initialize CLI

1

Run Init Command

What it does:
  • Creates config directory: ~/.payment-cli/
  • Generates default config file with production URLs
  • Sets up environment profiles (development, production)
  • Defaults to production environment
2

Verify Configuration

Output:
3

Register and Login


Core Commands

Authentication

Create a new user account:
Interactive prompts:
Output:

Merchant Management

Create a new merchant profile:
Interactive prompts:
Output:
Non-Interactive:

API Key Management

Generate a new API key for payment processing:
Interactive prompt:
Output:
IMPORTANT: Save this key immediately! It cannot be retrieved again.

Roles Management

List all available roles:
Output:

Configuration Management

Display complete configuration:
Output:

Payment Operations

Payment Intents (Hosted Checkout)

Payment Intents provide a hosted checkout page where customers can securely enter their payment details. The CLI opens the checkout in your browser and polls for completion.
Create a payment intent with hosted checkout:
Interactive prompts:
Output:
After customer completes payment:
How Payment Intent Polling Works:
  1. CLI creates payment intent via API
  2. Browser opens automatically with checkout URL
  3. Customer enters payment details on hosted page
  4. CLI polls payment status every 3 seconds
  5. Shows success/failure when payment completes
  6. Times out after 15 minutes if no completion
The checkout page handles all PCI compliance and security.

Direct Payment Authorization

Authorize a payment directly (without hosted checkout):
Interactive prompts:
Output:

Transaction Management

View all transactions:
Interactive prompts:
Output:

Advanced Features

Health Check

Verify API connectivity:
Output:

Debug Mode

Enable verbose logging for troubleshooting:
Or enable globally:

Output Formats

Human-readable tables:

Example Workflows

Workflow 1: Complete Setup

From zero to payment-ready in 3 minutes:

Workflow 2: Testing Payment Flow

Test a complete payment with hosted checkout:

Workflow 3: Environment Switching

Switch between development and production:

Configuration File

The CLI stores configuration in ~/.payment-cli/config.yaml:
Security Note:The config file contains your access token and API key. Protect it like a password:

Troubleshooting

Cause: Binary not in PATHSolutions:Option 1: Move to PATH
Option 2: Run from current directory
Option 3: Add to PATH
Cause: CLI not initializedSolution:
Verify:
Cause: Wrong environment or API server not reachableSolutions:Check environment:
Switch to production:
Test connectivity:
Cause: Not logged in or token expiredSolution:
Cause: No API key stored in configSolution:
Cause: Platform not supported or browser not availableSolution: The checkout URL is displayed in the terminal. Copy and paste it into your browser manually. The CLI will still poll for payment completion.
Cause: Payment took longer than 15 minutesSolution: Check your merchant dashboard for payment status, or create a new payment intent.

Scripting & Automation

Bash Script Example


CI/CD Integration


Command Reference

Complete Command List

Initialize CLI configurationUsage: payment-cli initCreates config directory and default settings file.
Register new user accountUsage: payment-cli auth register [--email EMAIL] [--name NAME] [--password PASSWORD]Interactive: If flags omitted, prompts for input
Authenticate userUsage: payment-cli auth login [--email EMAIL] [--password PASSWORD]Interactive: If flags omitted, prompts for input
Revoke current sessionUsage: payment-cli auth logout
Show current user infoUsage: payment-cli whoami
Show detailed user profileUsage: payment-cli auth profile
Change user passwordUsage: payment-cli auth change-password [--old-password OLD] [--new-password NEW]
Create new merchantUsage: payment-cli merchant create [FLAGS]Flags:
  • --business-name: Business name
  • --legal-name: Legal name
  • --email: Business email
Get merchant detailsUsage: payment-cli merchant get
Access merchant accountsUsage: payment-cli merchant access-accounts [--merchant-id ID]
List team membersUsage: payment-cli merchant team
Invite team memberUsage: payment-cli merchant invite
List pending invitationsUsage: payment-cli merchant invitations
View merchant settingsUsage: payment-cli merchant setting
Create new API keyUsage: payment-cli apikey create
Store API key locallyUsage: payment-cli apikey store <plain_key>
View all available rolesUsage: payment-cli roles view
Create payment intent with hosted checkoutUsage: payment-cli payment intent create [FLAGS]Flags:
  • --amount, -a: Amount in cents
  • --currency, -c: Currency (USD, EUR, MAD)
  • --email, -e: Customer email
  • --description, -d: Payment description
  • --capture: Capture method (automatic/manual)
  • --order-id: Your internal order ID
Authorize payment directlyUsage: payment-cli payment authorize
List transactionsUsage: payment-cli payment transactions
Capture payment (dashboard only)Usage: payment-cli payment capture
Void payment (dashboard only)Usage: payment-cli payment void
Refund payment (dashboard only)Usage: payment-cli payment refund
Show current configurationUsage: payment-cli config show
Set configuration valueUsage: payment-cli config set <key> <value>Keys: output_format, color_enabled, debug_mode
Switch environmentUsage: payment-cli config use <environment>Environments: production, development
Reset configuration to defaultsUsage: payment-cli config reset
Check CLI and API healthUsage: payment-cli health

Global Flags


Tips & Best Practices

The CLI defaults to production environment for safety. If you’re testing locally:
Never commit API keys to version control:
For CI/CD, use environment variables instead of storing credentials in config:
Use test card numbers for testing payment intents:
  • Success: 4242 4242 4242 4242
  • Decline: 4000 0000 0000 0002
  • Expired: 4000 0000 0000 0069
Any future expiry date and any 3-digit CVV will work.
The CLI polls payment status automatically, but you can also check your merchant dashboard for real-time updates.

What’s New in v1.1.0

Payment Intents

Create payment intents with hosted checkoutBrowser-based payment flow with automatic polling

Enhanced Config

Production-first configurationEasy environment switching

Better UX

Improved error messages and feedbackReal-time status updates

More Commands

Config set/use/reset commandsRoles management

Support

Need help? We’re here for you:

License

MIT License - See LICENSE file for details.
**Built with ❀️ for **Reda haloubi