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
npm install -g modem-pay-cli  

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
$ modempay login 

 Please enter your Merchant ID (you can find this in your dashboard): › 2523017877
 Enter your Modem Pay email: mercury@modempay.com
 Enter your password: *******
 Login successful! Credentials saved.

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
$ modempay listen --forward-url <local-endpoint>  
Options:
  • --forward-url: Specifies your local endpoint to receive webhook events.
Example:
bash
$ modempay listen --forward-url=http://localhost:3000/webhook  

Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)
This will create a public tunnel pointing to http://localhost:3000/webhook.

3. Trigger

Simulates events for testing purposes. Usage:
bash
$ modempay trigger <event-type>  
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
$ modempay trigger charge.succeeded 

🔧 Executing event: "charge.succeeded"
 Event "charge.succeeded" triggered successfully.
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.