P2p condition

[!info] Overview The P2P Condition REST API manages conditions for peer-to-peer payment routing in the pkbillms billing system. P2P conditions define matching rules and criteria used by P2P parameters to determine transaction routing between different payment processors.

📋 Table of Contents


Quick Reference

[!abstract] API Configuration

  • Base URL: /api

  • Entity Name: P2PCondition

  • Controller: P2pConditionResource

  • Framework: Spring Boot + JHipster

  • Auth: Required (Spring Security)

  • Content-Type: application/json

Endpoints Summary

Method
Endpoint
Description
Status

POST

/api/p-2-p-conditions

Create new condition

201

PUT

/api/p-2-p-conditions/{id}

Full update

200

PATCH

/api/p-2-p-conditions/{id}

Partial update

200

GET

/api/p-2-p-conditions

Get all with criteria

200

GET

/api/p-2-p-conditions/{id}

Get by ID

200

GET

/api/p-2-p-conditions/count

Count by criteria

200

DELETE

/api/p-2-p-conditions/{id}

Delete condition

204


Field Specifications

Field
Type
Required
Max/Range
DB Column
Description

id

Long

❌ Auto

-

id

Primary key

value

String

-

value

Unique condition value

description

String

-

description

Human-readable description

P2pConditionCriteria

[!note] Query Criteria Used for filtering and searching P2P conditions.

Available Filters:

  • id.equals, id.in, id.greaterThan, id.lessThan

  • value.equals, value.contains, value.specified

  • description.equals, description.contains, description.specified

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 P2P Condition

POST /api/p-2-p-conditions

Creates a new P2P condition entity.

Request

Headers:

Body:

[!warning] Validation Rules

  • id must be null (auto-generated)

  • value should be unique

  • Both fields are optional but recommended

Response

✅ Success (201 Created):

❌ Error (400 - Has ID):


Update P2P Condition

PUT /api/p-2-p-conditions/{id}

Completely updates an existing P2P condition.

Path Parameters

  • id (Long) - P2P condition identifier

Request

Headers:

Body:

[!warning] Validation

  • Body id must not be null

  • Path id must match body id

  • P2P condition must exist in database

  • value must remain unique

Response

✅ Success (200 OK):

❌ Errors:

Status
Detail
Message

400

Invalid id

error.not.null

400

Invalid ID

error.not.equal.id

400

Entity not found

error.entity.not.found


Partial Update

PATCH /api/p-2-p-conditions/{id}

Updates only specified fields. Null fields are ignored.

Path Parameters

  • id (Long) - P2P condition identifier

Request

Headers:

Body (Example - update description only):

Body (Example - update value only):

[!tip] Partial Update Behavior

  • Only non-null fields are updated

  • Other fields remain unchanged

  • Perfect for single field updates

  • Value uniqueness is still enforced

Response

✅ Success (200 OK):


Get All P2P Conditions

GET /api/p-2-p-conditions

Retrieves paginated list with filtering criteria.

Query Parameters

Pagination:

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

  • size - Items per page (default: 20)

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

  • unPaged - Boolean for unpaged results

Filters (P2pConditionCriteria):

  • id.equals, id.in, id.greaterThan, id.lessThan

  • value.equals, value.contains, value.specified

  • description.equals, description.contains, description.specified

Example Requests

Response

✅ Success (200 OK):


Get Single P2P Condition

GET /api/p-2-p-conditions/{id}

Retrieves a single P2P condition by ID.

Path Parameters

  • id (Long) - P2P condition identifier

Request

Response

✅ Success (200 OK):

❌ Error (404 Not Found):


Count P2P Conditions

GET /api/p-2-p-conditions/count

Returns count of P2P conditions matching criteria.

Query Parameters

Same filtering parameters as [[#Get All P2P Conditions]]

Example Requests

Response

✅ Success (200 OK):


Delete P2P Condition

DELETE /api/p-2-p-conditions/{id}

Permanently deletes a P2P condition from the database.

Path Parameters

  • id (Long) - P2P condition identifier

Request

Response

✅ Success (204 No Content):

[!danger] Delete Warning Permanently deletes:

  • P2P condition entity

  • May fail if condition is referenced by P2P parameters

  • Check dependencies before deletion

Use with caution! This cannot be undone.


Examples

Example 1: Create Card Type Conditions

  • Setup Card Type Conditions Request - HUMO Condition:

Request - UZCARD Condition:

Example 2: Create Amount-Based Conditions

  • Setup Amount Ranges Request - Small Transactions:

Request - Large Transactions:

Example 3: Update Condition Description

  • Update Description Request:

Response:

Example 4: Search by Value

  • Find Conditions Request:

Response:


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 value

500

Server Error

Internal error

Database error, foreign key conflict

Validation Error Example

[!bug] Field Validation Errors


Validation Rules

Field Constraints

Field
Rules
Error Messages

id

Null for POST

"cannot.have.id"

id

Not null for PUT/PATCH

"not.null"

value

Unique (recommended)

"value already exists"

Business Rules

[!info] Business Validation

  • value should be unique across all conditions

  • value typically contains identifiers or patterns (e.g., card prefixes, amount ranges)

  • description provides human-readable explanation of the condition

  • Conditions are referenced by P2P parameters for transaction routing

  • Deleting a condition may fail if it's used by active P2P parameters


Business Logic

Condition Usage in P2P Routing

[!info] How Conditions Work

P2P conditions are used by P2P parameters to match transactions:

Matching Process:

  1. Transaction arrives with sender/recipient details

  2. System checks all active P2P parameters

  3. Each parameter's conditions are evaluated

  4. First matching parameter (by priority) is selected

  5. Transaction routed according to selected parameter

Common Condition Types

[!tip] Typical Condition Categories

Card Type Conditions:

  • HUMO_CARDS - HUMO card numbers (9860****)

  • UZCARD_CARDS - UZCARD card numbers (8600****)

  • VISA_CARDS - VISA card numbers (4****)

  • MASTERCARD_CARDS - MasterCard numbers (5****)

Condition Value Format

[!note] Recommended Format


🔧 cURL Command Reference

Create

Update

Partial Update

Get All

Get Single

Count

Delete


📝 Use Cases

Use Case 1: Setup Card Type Routing

Scenario: Configure conditions to route transactions based on card types.

Implementation:

  1. Create condition for HUMO cards

  2. Create condition for UZCARD cards

  3. Use conditions in P2P parameters for routing



Last updated