Recipient

[!info] Overview The Recipient REST API manages service providers (recipients) in the pkbillms billing system. Recipients are entities that receive payments through various gateways and categories.

📋 Table of Contents


Quick Reference

[!abstract] API Configuration

  • Base URL: /api

  • Entity Name: pkbillmsRecipient

  • Controller: RecipientResource

  • Framework: Spring Boot + JHipster

  • Auth: Required (Spring Security)

  • Content-Type: application/json

Endpoints Summary

Method
Endpoint
Description
Status

POST

/api/recipients

Create new recipient

201

PUT

/api/recipients/{id}

Full update

200

PATCH

/api/recipients/{id}

Partial update

200

GET

/api/recipients

Get all (read-only projection)

200

GET

/api/recipients/all

Get all for Excel export

200

GET

/api/recipients/criteria

Get by gateway/category

200

GET

/api/recipients/{id}

Get by ID

200

GET

/api/recipients/count

Count by criteria

200

DELETE

/api/recipients/{id}

Delete recipient

204

DELETE

/api/recipients/cascaded/{id}

Cascaded delete

200


Data Models

Recipient DTO Structure

[!note] Data Transfer Object Service provider/payment recipient entity with multilingual support and gateway integration.

Field Specifications

Field
Type
Required
Max
DB Column
Description

id

Long

❌ Auto

-

id

Primary key

shortName

String

64

short_name

Unique gateway name

serviceId

String

64

service_id

Internal service ID

thumbnail

String

64

thumbnail

Thumbnail path/URL

logo

String

64

logo

Logo path/URL

logoFile

byte[]

-

-

Logo binary data (LOB)

amountRatio

Integer

-

amount_ratio

Amount precision (1 or 100)

ccy

Integer

-

ccy

Currency code

minAmount

Long

-

min_amount

Min payment (limitRatio)

maxAmount

Long

-

max_amount

Max payment (limitRatio)

limitRatio

Integer

-

limit_ratio

Limit amount precision

commission

Double

-

commission

Recipient commission %

fee

Double

-

fee

Recipient fee amount

systemCommission

Double

-

system_commission

System commission %

systemFee

Double

-

system_fee

System fee amount

senderCommission

Double

-

sender_commission

Sender reward

ord

Integer

-

ord

Display order

active

Boolean

-

active

Active/Inactive

check

Boolean

-

jhi_check

Check operation

pay

Boolean

-

pay

Payment operation

status

Boolean

-

status

Status check

cancel

Boolean

-

cancel

Cancel operation

canDeposit

Boolean

-

can_deposit

Deposit capability

info

Boolean

-

info

Info operation

settlementAccount

String

32

settlement_account

Bank account

mfo

String

16

mfo

Bank MFO code

phoneNumber

String

-

-

Contact phone

inn

String

32

inn

Tax ID number

reconcile

Boolean

-

reconcile

Reconciliation flag

jsonParams

String

-

json_params

JSON parameters (LOB)

type

RecipientType

-

jhi_type

Recipient type (ENUM)

gateway

GatewayDTO

-

gateway_id

Associated gateway

category

CategoryDTO

-

category_id

Service category

titles

Set

-

rel_recipient__title

Multilingual titles

fullNames

Set

-

rel_recipient__full_name

Multilingual names

RecipientType Enum

Audit Fields (Inherited)

[!success] Auto-managed These fields are automatically populated by the system.

Field
Type
Description

createdBy

String

Creator username

createdDate

Instant

Creation timestamp

lastModifiedBy

String

Last modifier

lastModifiedDate

Instant

Last modification


API Endpoints

Create Recipient

POST /api/recipients

Creates a new recipient (service provider) entity.

Request

Headers:

Body:

[!warning] Validation Rules

  • id must be null (auto-generated)

  • shortName, serviceId, amountRatio, ccy, limitRatio, active are required

  • titles and fullNames must not be empty

  • String fields must respect max length

  • Boolean operation flags default to false if not specified

Response

✅ Success (201 Created):

❌ Error (400 - ID exists):


Update Recipient

PUT /api/recipients/{id}

Completely updates an existing recipient. All required fields must be provided.

Path Parameters

  • id (Long) - Recipient identifier

Request

Headers:

Body:

[!warning] Validation

  • Body id must not be null

  • Path id must match body id

  • Recipient must exist in database

  • All required fields must be provided

Response

✅ Success (200 OK):

❌ Errors:

Status
Detail
Message

400

Invalid id

error.idnull

400

Invalid ID

error.idinvalid

400

Entity not found

error.idnotfound


Partial Update

PATCH /api/recipients/{id}

Updates only specified fields. Null fields are ignored.

Path Parameters

  • id (Long) - Recipient identifier

Request

Headers:

Body (Example - toggle active status and update commission):

[!tip] Partial Update Behavior

  • Only non-null fields are updated

  • Other fields remain unchanged

  • Perfect for status toggles or single field updates

  • Relationships can be partially updated

Response

✅ Success (200 OK):


Get All Recipients

GET /api/recipients

Retrieves paginated list with read-only projection for optimized queries.

Query Parameters

Pagination:

  • page - Page number (0-indexed, default: 0)

  • size - Items per page (default: 20)

  • sort - Sort criteria (e.g., shortName,asc)

Filters (RecipientReadOnlyCriteria):

  • id.equals, id.in

  • shortName.contains, shortName.equals

  • serviceId.equals

  • active.equals

  • type.equals, type.in

  • gatewayId.equals

  • categoryId.equals

  • minAmount.greaterThanOrEqual

  • maxAmount.lessThanOrEqual

Example Requests

Response

✅ Success (200 OK):

[!info] Read-Only Projection This endpoint uses RecipientReadOnly projection for better performance. It returns minimal fields without relationships.


Export to Excel

GET /api/recipients/all

Retrieves all recipients for Excel export with full DTO structure.

Query Parameters

Same as [[#Get All Recipients]] but returns RecipientReadOnlyDTO with more fields.

Example Request

Response

✅ Success (200 OK):

[!tip] Use Case Use this endpoint when exporting data to Excel or other formats requiring complete data.


Get Recipients with Criteria

GET /api/recipients/criteria

Advanced filtering by gateway name and category shortName.

Query Parameters

Standard Filters:

  • All RecipientCriteria filters

  • Pagination parameters

Special Parameters:

  • gatewayName (String) - Filter by gateway name

  • categoryShortName (String) - Filter by category short name

Example Requests

Response

✅ Success (200 OK):

[!info] Business Logic

  • Gateway and Category are resolved by name/shortName

  • If not found, filter is not applied

  • Results include full DTO with relationships


Get Single Recipient

GET /api/recipients/{id}

Retrieves a single recipient by ID with all relationships.

Path Parameters

  • id (Long) - Recipient identifier

Request

Response

✅ Success (200 OK):

❌ Error (404 Not Found):


Count Recipients

GET /api/recipients/count

Returns count of recipients matching criteria.

Query Parameters

Same filtering parameters as [[#Get All Recipients]]

Example Requests

Response

✅ Success (200 OK):


Delete Recipient

DELETE /api/recipients/{id}

Deletes a recipient by ID (standard delete).

Path Parameters

  • id (Long) - Recipient identifier

Request

Response

✅ Success (204 No Content):

[!danger] Standard Delete Warning This is a standard delete. May fail if recipient has dependent relationships.


Cascaded Delete

DELETE /api/recipients/cascaded/{id}

Deletes a recipient and all dependent entities (cascaded delete).

Path Parameters

  • id (Long) - Recipient identifier

Request

Response

✅ Success (200 OK):

[!danger] Cascaded Delete Warning This operation will delete:

  • The recipient entity

  • All associated I18n entries (titles, fullNames)

  • Any other dependent relationships

Use with extreme caution! This operation cannot be undone.


Examples

Example 1: Create Utility Service Provider

Create Water Service Request:

Example 2: Toggle Recipient Status

  • Deactivate Recipient Request:

Response:

Example 3: Search Financial Recipients

Filter by Type and Gateway Request:

Example 4: Get Recipients by Gateway and Category Names

Named Filter Query Request:


Error Handling

Error Response Format

[!failure] RFC 7807 Problem Details All errors follow standardized format.

HTTP Status Codes

Code
Type
Description
Common Causes

400

Bad Request

Invalid request

Validation failure, ID mismatch

401

Unauthorized

Auth required

Missing/invalid token

403

Forbidden

Access denied

Insufficient permissions

404

Not Found

Resource missing

Invalid ID, deleted entity

409

Conflict

Resource conflict

Duplicate shortName, constraints

500

Server Error

Internal error

Database error, exception

Validation Error Example

[!bug] Field Validation Errors


Validation Rules

Required Fields

[!check] Mandatory Fields

  • shortName - Unique name in gateway

  • serviceId - Internal service identifier

  • amountRatio - Amount precision (1 or 100)

  • ccy - Currency code (e.g., 860 for UZS)

  • limitRatio - Limit precision

  • active - Active status flag

  • titles - At least one title required

  • fullNames - At least one full name required

Field Constraints

Field
Rules
Error Messages

id

Null for POST

"A new recipient cannot already have an ID"

id

Not null for PUT/PATCH

"Invalid id"

shortName

@NotNull, @Size(max=64), unique

"must not be null", "size must be between 0 and 64"

serviceId

@Size(max=64)

"size must be between 0 and 64"

thumbnail

@Size(max=64)

"size must be between 0 and 64"

logo

@Size(max=64)

"size must be between 0 and 64"

amountRatio

@NotNull, 1 or 100

"must not be null"

ccy

@NotNull, valid currency code

"must not be null"

limitRatio

@NotNull

"must not be null"

settlementAccount

@Size(max=32)

"size must be between 0 and 32"

mfo

@Size(max=16)

"size must be between 0 and 16"

inn

@Size(max=32)

"size must be between 0 and 32"

titles

@NotNull, not empty

"must not be null", "must not be empty"

fullNames

@NotNull, not empty

"must not be null", "must not be empty"

Business Rules

[!info] Business Validation

  • shortName must be unique within the system

  • minAmount must be less than maxAmount (if both specified)

  • amountRatio typically 1 (sum) or 100 (tiyin)

  • limitRatio typically matches amountRatio

  • Commission and fee values should be non-negative

  • Gateway and Category must exist if specified

  • At least one operation flag (check, pay, status, etc.) should be true


Business Logic

Amount Precision System

[!abstract] Understanding Amount Ratios

The recipient entity uses a dual-precision system for amounts:

amountRatio:

  • 1 = Amount in sums (whole units)

  • 100 = Amount in tiyins (1/100 units)

limitRatio:

  • Defines precision for minAmount and maxAmount

  • Should typically match amountRatio

Example:

Means:

  • Amounts processed in tiyins

  • Min: 1,000.00 sum (100,000 tiyins)

  • Max: 100,000,000.00 sum (10,000,000,000 tiyins)

Commission Structure

[!info] Fee Calculation

Recipients can have multiple commission types:

Commission Type
Description
Usage

commission

Recipient commission %

Charged to customer

fee

Recipient fixed fee

Added to transaction

systemCommission

System commission %

Platform revenue

systemFee

System fixed fee

Platform revenue

senderCommission

Sender reward %

If sender participates

Example Calculation:

Multilingual Support

[!tip] I18n Integration

Recipients support multiple languages through I18n entities:

Titles: Short display names

Full Names: Complete service names

Operation Flags

[!abstract] Service Capabilities

Boolean flags define what operations the recipient supports:

Flag
Purpose
Example Use Case

check

Balance/debt inquiry

Check utility bill

pay

Payment processing

Pay bill

status

Transaction status

Check payment status

cancel

Cancel transaction

Reverse payment

canDeposit

Accept deposits

Mobile top-up

info

Service information

Get tariff info

reconcile

Financial reconciliation

Daily settlement

Typical Configurations:

Utility Service:

Mobile Operator:

Gateway Integration

[!info] Gateway Relationship

Each recipient belongs to a gateway that handles:

  • Payment routing

  • Protocol implementation

  • Transaction processing

  • Response handling

The jsonParams field stores gateway-specific configuration:


🔧 cURL Command Reference

Create

Update

Partial Update

Get All

Get with Gateway/Category Filter

Get Single

Count

Delete

Cascaded Delete


📌 Metadata

[!metadata] Version: 1.0 Last Updated: 2024-01-29 API Version: v1 Team: pkbillms Development Team Status: 🟢 Active Complexity: 🔴 High (Complex entity with relationships)


🏷️ Tags

#api #recipient #service-provider #rest #jhipster #payment #multilingual #gateway #category #i18n #commission #fee #crud #spring-boot #backend #pkbillms

Last updated