Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.monei.cc/llms.txt

Use this file to discover all available pages before exploring further.

monei.business provides methods to manage business customers under a specific business ID. With this service, you can:
  • Create a business customer
  • Retrieve all business customers
  • Get customer details
  • Update a customer
  • Disable a customer

Create Business Customer

Create a new customer under a specific business.
const businessId = "your-business-id";

const customer = await monei.business.createBusinessCustomer(
  businessId,
  {
    firstName: "John",
    lastName: "Doe",
    email: "john@example.com",
    phoneNumber: "+2348012345678"
  }
);

console.log(customer);

Get Business Customers

Retrieve all customers associated with a business.
const businessId = "your-business-id";

const customers = await monei.business.getBusinessCustomers(
  businessId
);

console.log(customers);

Get Customer Details

Retrieve detailed information about a specific customer.
const businessId = "your-business-id";
const customerId = "customer-id";

const customer = await monei.business.getCustomerDetails(
  businessId,
  customerId
);

console.log(customer);

Update Customer

Update an existing customer’s information.
const businessId = "your-business-id";
const customerId = "customer-id";

const updatedCustomer = await monei.business.updateCustomer(
  businessId,
  customerId,
  {
    firstName: "Jane",
    lastName: "Doe",
    email: "jane@example.com"
  }
);

console.log(updatedCustomer);

Disable Customer

Disable a customer under a business.
const businessId = "your-business-id";
const customerId = "customer-id";

const response = await monei.business.disableCustomer(
  businessId,
  customerId
);

console.log(response);

Working with Response Objects

All methods return objects with property access:
// Create customer response
const customer = await monei.business.createBusinessCustomer(businessId, {
  firstName: "John",
  lastName: "Doe",
  email: "john@example.com",
  phoneNumber: "+2348012345678"
});
console.log(customer.id);           // Customer ID
console.log(customer.firstName);    // First name
console.log(customer.lastName);     // Last name
console.log(customer.email);        // Email address
console.log(customer.phoneNumber);  // Phone number
console.log(customer.status);       // Customer status
console.log(customer.createdAt);    // Creation date

// Get business customers response
const customers = await monei.business.getBusinessCustomers(businessId);
customers.data.forEach(customer => {
  console.log(customer.id);           // Customer ID
  console.log(customer.firstName);    // First name
  console.log(customer.lastName);     // Last name
  console.log(customer.email);        // Email address
  console.log(customer.phoneNumber);  // Phone number
  console.log(customer.status);       // Customer status
});
console.log(customers.pagination);    // Pagination info

// Get customer details response
const customer = await monei.business.getCustomerDetails(businessId, customerId);
console.log(customer.id);           // Customer ID
console.log(customer.firstName);    // First name
console.log(customer.lastName);     // Last name
console.log(customer.email);        // Email address
console.log(customer.phoneNumber);  // Phone number
console.log(customer.status);       // Customer status
console.log(customer.createdAt);    // Creation date
console.log(customer.updatedAt);    // Last update date

// Update customer response
const updatedCustomer = await monei.business.updateCustomer(
  businessId,
  customerId,
  {
    firstName: "Jane",
    lastName: "Doe",
    email: "jane@example.com"
  }
);
console.log(updatedCustomer.id);         // Customer ID
console.log(updatedCustomer.firstName);  // Updated first name
console.log(updatedCustomer.lastName);   // Updated last name
console.log(updatedCustomer.email);      // Updated email
console.log(updatedCustomer.updatedAt);  // Update timestamp

// Disable customer response
const response = await monei.business.disableCustomer(businessId, customerId);
console.log(response.message);      // Success message
console.log(response.customerId);   // Disabled customer ID
console.log(response.status);       // New status

Response Types

BusinessCustomerDto

{
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  phoneNumber: string;
  status: 'active' | 'disabled';
  createdAt: string;
  updatedAt: string;
}

BusinessCustomersListDto

{
  data: BusinessCustomerDto[];
  pagination: {
    total: number;
    page: number;
    limit: number;
    totalPages: number;
  };
}

DisableCustomerResponseDto

{
  message: string;
  customerId: string;
  status: 'disabled';
}

Error Handling

All business service calls may throw an error if the request fails.
import { MoneiError } from 'monei-sdk';

try {
  const customer = await monei.business.createBusinessCustomer(
    businessId,
    {
      firstName: "John",
      lastName: "Doe",
      email: "john@example.com",
      phoneNumber: "+2348012345678"
    }
  );
  console.log(customer.id);
} catch (error) {
  if (error instanceof MoneiError) {
    console.error(error.statusCode);  // HTTP status code
    console.error(error.message);     // Error message
    console.error(error.code);        // Error code
  }
}

Service Overview

MethodDescription
createBusinessCustomer(businessId, data)Create a new business customer
getBusinessCustomers(businessId)Retrieve all business customers
getCustomerDetails(businessId, customerId)Get customer details
updateCustomer(businessId, customerId, data)Update customer information
disableCustomer(businessId, customerId)Disable a customer

Notes

  • All methods require a valid business_id
  • A properly configured MoneiClient instance is required
  • Ensure authentication headers are set before making requests
  • All responses are strongly typed objects with property access
  • Disabled customers cannot perform transactions until re-enabled