Skip to main content
The Modem Pay CLI is a tool designed to simplify integration testing by offering features like authentication, webhook management, and event simulation only in a test environment.

Installation

Ensure that both Node.js and npm are installed on your machine before proceeding.
To install the Modem Pay CLI, run:
bash

Commands

1. Login

Authenticates a user and generates an access token, business ID, and account ID. Authentication is required to access other CLI features. Usage:
bash

2. Listen

The listen command creates a secure public tunnel using Localtunnel to forward webhooks to a local endpoint. This is particularly useful for testing webhooks during development. Disclaimer:
  • The CLI leverages Localtunnel to generate the public URL. In some cases, a public URL might not be provisioned successfully due to network issues.
  • This feature should only be used in test environments.
Usage:
bash
Options:
  • --forward-url: Specifies your local endpoint to receive webhook events.
Example:
bash
This will create a public tunnel pointing to http://localhost:3000/webhook.

3. Trigger

Simulates events for testing purposes. Usage:
bash
Supported Event Types:
  • Customer Events: "customer.created", "customer.updated", "customer.deleted"
  • Payment Intent Events: "payment_intent.created", "payment_intent.cancelled"
  • Charge Events: "charge.succeeded", "charge.failed", "charge.cancelled", "charge.created", "charge.updated"
The listen command captures both manually triggered events and automatically triggered events from the Modem Pay system. For testing purposes, always use the webhook secret generated by the listen command. This secret is displayed in the terminal and can also be found in the Modem Pay dashboard, but only in test mode.Important: Production secrets and endpoints remain unaffected and are not impacted by the test mode configuration.
Example:
bash
This sends a charge.succeeded event payload to the configured webhook endpoint for testing.
Always respond to webhook events with an HTTP 200 OK status to confirm receipt. This ensures Modem Pay doesn’t retry the webhook unnecessarily.