BillingPlanRpc
BillingPlanRpc exposes RPC methods for creating, updating, archiving, retrieving, and listing billing plans. It also includes a reference-data helper for form fields and a public listing method that returns a sanitized subset of public plans.
Endpoints
POST /api/rpc (Method: BillingPlanRpc.create)
Description: Creates a new billing plan by forwarding the validated request body to the billing plan service.
Request Body:
{ "method": "BillingPlanRpc.create", "params": { // fields accepted by BillingPlanSchema excluding _id, createdAt, and updatedAt } }Parameters:
Name Type Required Description paramsObjectYes Billing plan data validated by BillingPlanSchemawith_id,createdAt, andupdatedAtomitted. The exact field set is defined by the imported schema.Response:
{ "success": true, "data": { // return value from BillingPlanService.createPlan(...) } }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.create", "params": { "...": "..." } }'
POST /api/rpc (Method: BillingPlanRpc.update)
Description: Updates an existing billing plan by separating the
_idfield from the remaining update fields and passing both to the billing plan service.Request Body:
{ "method": "BillingPlanRpc.update", "params": { "_id": "string", // any partial billing plan fields accepted by BillingPlanSchema.partial() } }Parameters:
Name Type Required Description _idStringYes Identifier of the billing plan to update. paramsObjectYes Partial billing plan data validated by BillingPlanSchema.partial().extend({ _id: z.string() }). The exact update fields are defined by the imported schema.Response:
{ "success": true, "data": { // return value from BillingPlanService.updatePlan(...) } }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.update", "params": { "_id": "plan-id", "...": "..." } }'
POST /api/rpc (Method: BillingPlanRpc.delete)
Description: Archives a billing plan by
_idand returns a success message.Request Body:
{ "method": "BillingPlanRpc.delete", "params": { "_id": "string" } }Parameters:
Name Type Required Description _idStringYes Identifier of the billing plan to archive. Response:
{ "success": true, "data": { "success": true, "message": "Plan archived." } }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.delete", "params": { "_id": "plan-id" } }'
POST /api/rpc (Method: BillingPlanRpc.findById)
Description: Retrieves a billing plan by
_id. The optionalresolveFeaturesflag is forwarded to the billing plan service.Request Body:
{ "method": "BillingPlanRpc.findById", "params": { "_id": "string", "resolveFeatures": false } }Parameters:
Name Type Required Description _idStringYes Identifier of the billing plan to retrieve. resolveFeaturesBooleanNo Optional flag forwarded to the service to resolve feature data. Defaults to falsewhen omitted.Response:
{ "success": true, "data": { // return value from BillingPlanService.getPlanById(...) } }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.findById", "params": { "_id": "plan-id", "resolveFeatures": true } }'
POST /api/rpc (Method: BillingPlanRpc.getData)
Description: Returns a paginated list of billing plans using the supplied filter, sort, page, and page size values. The optional
resolveFeaturesflag is forwarded to the billing plan service.Request Body:
{ "method": "BillingPlanRpc.getData", "params": { "filter": {}, "sort": {}, "page": 1, "pageSize": 25, "resolveFeatures": false } }Parameters:
Name Type Required Description filterAnyYes Filter object passed to the billing plan service. The schema accepts any value. sortAnyYes Sort specification passed to the billing plan service. The schema accepts any value. pageNumberYes Page number used to calculate skipas(page - 1) * pageSize.pageSizeNumberYes Number of records per page used as the limit.resolveFeaturesBooleanNo Optional flag forwarded to the service to resolve feature data. Defaults to falsewhen omitted.Response:
{ "success": true, "data": { // return value from BillingPlanService.listPlans(...) } }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.getData", "params": { "filter": {}, "sort": {}, "page": 1, "pageSize": 25, "resolveFeatures": false } }'
POST /api/rpc (Method: BillingPlanRpc.getFieldValues)
Description: Provides reference values for form fields by listing billing plans and mapping each record to a
{ value, label }pair.Request Body:
{ "method": "BillingPlanRpc.getFieldValues", "params": { "fieldName": "string", "reference": { "valueField": "string", "displayField": "string", "filter": {} } } }Parameters:
Name Type Required Description fieldNameStringYes Field name supplied by the caller. It is validated but not used in the method body. referenceObjectYes Reference configuration used to build the output mapping. reference.valueFieldStringYes Object property name used for the returned value.reference.displayFieldStringYes Object property name used for the returned label.reference.filterRecord<string, Any>No Optional filter passed to the billing plan list query. Defaults to {}when omitted.Response:
{ "success": true, "data": [ { "value": "any", "label": "any" } ] }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.getFieldValues", "params": { "fieldName": "billingPlan", "reference": { "valueField": "_id", "displayField": "name", "filter": {} } } }'
POST /api/rpc (Method: BillingPlanRpc.listPublicPlans)
Description: Returns a sanitized list of billing plans marked as public and not archived. The response includes only the selected fields for each plan.
Request Body:
{ "method": "BillingPlanRpc.listPublicPlans", "params": {} }Parameters:
Name Type Required Description paramsObjectYes Empty object. The schema is z.object({}).Response:
{ "success": true, "data": [ { "planId": "string", "name": "string", "description": "string", "currency": "string", "oneTimeCost": "any", "recurringCost": "any", "billingCycle": "any" } ] }Example (cURL):
curl -X POST "${APP_BASE_URL}/api/rpc" \ -H "Content-Type: application/json" \ -d '{ "method": "BillingPlanRpc.listPublicPlans", "params": {} }'