Skip to content

nekuda-ai/acp-validator-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ACP Agentic Checkout Test CLI

image

Test and validate your ACP Agentic Checkout implementation

A CLI tool for testing ACP (Agentic Commerce Protocol) Agentic Checkout API endpoints against OpenAI's official specification. Perfect for merchants building AI-native checkout experiences for ChatGPT and other AI platforms.

Features

βœ… Comprehensive Testing

  • Full API Coverage: Tests all 5 ACP Checkout endpoints (CREATE, UPDATE, COMPLETE, CANCEL, GET)
  • 151 Test Cases: Production-grade test suite covering happy paths, edge cases, and error scenarios
  • Spec Compliance: Validates responses against OpenAI's official OpenAPI schema

🎯 Smart Validation

  • Automatic Schema Validation: Ensures your API responses match the ACP specification
  • Totals Calculation Checks: Validates monetary calculations (subtotal, tax, fees, totals)
  • State Management Testing: Verifies correct checkout session state transitions
  • Idempotency Verification: Tests retry safety for CREATE and COMPLETE operations

πŸ“Š Developer-Friendly Output

  • Clear Test Reports: See exactly what passed and what needs fixing
  • Error Details: Detailed messages showing what went wrong and why
  • Fast Execution: Runs 151 tests in seconds

πŸ”§ Flexible Configuration

  • Config File: Use acp.config.yaml for persistent settings
  • CLI Arguments: Override config with command-line flags
  • Interactive Mode: Prompts for missing required fields

Installation

Prerequisites

  • Node.js 20.0.0 or higher
  • npm or yarn

Install via npm

npm install -g @nekuda/acp-test

Install from source

git clone <repo-url>
cd acp-test-cli
npm install
npm run build
npm link

Quick Start

1. Initialize Configuration

Create a config file with your API details:

acp-test init

This creates acp.config.yaml:

checkoutUrl: https://your-api.com
apiKey: your_api_key_here
apiVersion: '2025-09-29'

2. Run Tests

Run the full test suite against your API:

acp-test run

Or specify options directly:

acp-test run \
  --checkout-url https://your-api.com \
  --api-key your_key_here \
  --api-version 2025-09-29

3. Review Results

The CLI will show you test results in real-time:

βœ“ should create checkout session with items (125ms)
βœ“ should update session with shipping address (89ms)
βœ“ should select fulfillment option (76ms)
βœ“ should complete checkout with payment (152ms)

Test Files  1 passed (1)
     Tests  151 passed (151)

Usage

Commands

init

Create or update your ACP test configuration file.

acp-test init

run

Execute the full ACP compliance test suite.

acp-test run [options]

Options:

  • -u, --checkout-url <url> - Your ACP Checkout API base URL
  • -k, --api-key <key> - API key for authentication
  • -v, --api-version <version> - ACP API version (default: 2025-09-29)
  • -c, --config <path> - Path to config file (default: acp.config.yaml)

validate

Validate your ACP API implementation.

acp-test validate [options]

Same options as run command.

Configuration File

Create acp.config.yaml in your project root:

# Required: Your ACP Checkout API endpoint
checkoutUrl: https://api.yourstore.com

# Required: Authentication key
apiKey: sk_test_abc123

# Optional: API version (defaults to latest)
apiVersion: '2025-09-29'

# Optional: Request timeout in milliseconds
timeout: 30000

What Gets Tested

Core Checkout Flow

  • βœ… Session creation with/without addresses
  • βœ… Updating items, quantities, and customer details
  • βœ… Shipping address validation and fulfillment options
  • βœ… Fulfillment selection and cost calculation
  • βœ… Payment token handling
  • βœ… Session completion and order confirmation
  • βœ… Session cancellation

Validation & Error Handling

  • βœ… Missing required fields (missing error code)
  • βœ… Invalid data formats (invalid error code)
  • βœ… Out of stock scenarios (out_of_stock error code)
  • βœ… Payment declines (payment_declined error code)
  • βœ… Proper HTTP status codes (200, 201, 400, 409)

Data Integrity

  • βœ… Currency format validation (ISO 4217)
  • βœ… Address format validation (ISO 3166)
  • βœ… Monetary calculations (amounts in minor units)
  • βœ… Totals formula: total = subtotal - discount + fulfillment + tax + fee
  • βœ… Line item calculations: total = subtotal + tax, subtotal = base_amount - discount

Advanced Features

  • βœ… Idempotency key handling
  • βœ… Request ID tracing
  • βœ… API versioning
  • βœ… Webhook payload validation
  • βœ… Links (ToS, Privacy Policy)

Example Test Output

PASS  src/tests/checkout.test.ts (4.2s)
  Checkout Session Management
    βœ“ should create session with single item
    βœ“ should create session with multiple items
    βœ“ should update session with buyer info
    βœ“ should add shipping address
    βœ“ should retrieve fulfillment options
    βœ“ should select shipping method
    βœ“ should complete checkout with payment

  Idempotency
    βœ“ should return same session for duplicate CREATE with same key
    βœ“ should return 409 for same key with different body
    βœ“ should return same result for duplicate COMPLETE

  Error Scenarios
    βœ“ should handle missing items field (400)
    βœ“ should handle invalid postal code
    βœ“ should handle out of stock items
    βœ“ should handle payment declined

βœ“ 151 tests passed

Testing Against OpenAI ChatGPT

Before going live with ChatGPT Instant Checkout:

  1. Run Full Test Suite: Ensure all 151 tests pass
  2. Review Error Handling: Verify all error codes are implemented
  3. Check Totals: Confirm monetary calculations are accurate
  4. Test Idempotency: Verify safe retry behavior
  5. Validate Webhooks: Ensure order events are emitted correctly

Development

Build

npm run build

Outputs compiled CLI to dist/cli.js with TypeScript declarations.

Type Checking

npm run typecheck

Linting

npm run lint
npm run format

Run Tests

npm test

Project Structure

acp-test-cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.ts                 # Main CLI entry point
β”‚   β”œβ”€β”€ commands/              # CLI command implementations
β”‚   β”‚   β”œβ”€β”€ init.ts
β”‚   β”‚   β”œβ”€β”€ run.ts
β”‚   β”‚   └── validate.ts
β”‚   β”œβ”€β”€ config/                # Configuration handling
β”‚   β”œβ”€β”€ tests/                 # ACP test suite (151 tests)
β”‚   β”‚   β”œβ”€β”€ checkout.test.ts
β”‚   β”‚   β”œβ”€β”€ error-scenarios.test.ts
β”‚   β”‚   β”œβ”€β”€ idempotency.test.ts
β”‚   β”‚   └── totals-validation.test.ts
β”‚   └── types/                 # TypeScript definitions
β”œβ”€β”€ spec/                      # OpenAPI schema
β”œβ”€β”€ package.json
└── tsup.config.ts             # Build configuration

Resources

Contributing

If you're interested in collaborating or contributing, get in touch at founder@nekuda.ai.

License

Licensed under the Apache 2.0 License.


About

CLI tool to test and validate ACP Agentic Checkout endpoints for full ACP spec compliance.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages