Complete guide to creating and managing customers through the API, including merchant-managed and full consumer accounts
The customer lifecycle in Paygentic involves creating customer relationships, establishing subscriptions, and tracking usage. This guide covers the programmatic approach to managing customers through the API.
Paygentic supports two distinct types of consumer accounts, each with different capabilities and use cases:
Managed Consumers
Created via API by merchants for quick onboarding. Customers only access Paygentic in relation to this one merchant.
These customer do not have Paygentic users and only use Paygentic through the merchant integration.
Full Consumer Accounts
When the customer interacts with multiple merchants they can choose to keep everything in one account and sign in to Paygentic to manage their usage.
Normally customers will start off as a managed customer and only transition to a full account when needed.
The key point for merchants is that in managed accounts the account funds are exclusively available to that merchant.
If you’ve already created a managed consumer, you can reuse it:
Copy
Ask AI
async function createCustomerWithExistingConsumer() { try { const response = await axios.post( 'https://api.paygentic.io/v0/customers', { merchantId: 'org_YS8jkP59V71TdUvj', consumerId: 'org_EXISTING_CONSUMER_ID' // Must be managed consumer }, { headers: { 'Authorization': 'Bearer sk_live_YOUR_API_KEY', 'Content-Type': 'application/json' } } ); return response.data.customerId; } catch (error) { // Error code 403: Attempting to use unauthorized consumerId if (error.response?.status === 403) { console.error('Cannot use this consumerId - not a managed consumer'); } throw error; }}
Idempotency: If a customer already exists for the consumer-merchant pair, the API returns 200 with the existing customer ID instead of creating a duplicate.
Once you have a customer, you can create subscriptions. The plan you choose determines which fees and usage-based prices apply.Prepaid fees need to be paid before the subscription starts. In the subscription response there will be a payment link where the customer can pay for this charge. The payment link is also present if the subscription has a “prefundAmount”, this should be used to add funds for pay-as-you-go (instantly priced usage billable metrics).
The customer portal allows your customers to view their subscription details, usage metrics, invoices, and manage payment sources - all within a secure, hosted interface.