# Payment (Refund)

Upon receiving a bill for customer payments or refunds, a payment or refund process is required.

Payment is utilized for processing a range of transactions associated with the insurance business, such as premium refunds for endorsements and claim compensations.

## API List
*  /bcp-core/payment/v1/approvePaymentWithEs
*  /bcp-core/payment/v1/approvePaymentByArapIds
*  /bcp-core/payment/v1/approvePaymentAdvanced
*  /bcp-core/payment/v1/approveStatementPayment
*  /bcp-core/payment/v1/singlePayment
*  /bcp-core/payment/v1/massivePayment
*  /bcp-core/payment/v1/receiptRefund
*  /bcp-core/payment/v1/reversePayment

## Payment Approval API
Approved AP records are generated from various transactions. When a payment is received from a business module, business users should first approve the payment before the cash is actually disbursed.

Unlike collecting money, paying out money typically involves extensive approval processes for verification and validation.

During the approval process, related finance staff might decide which APs can be paid out and which are in dispute, requiring further investigation before payment.

### API Path - approvePaymentWithEs
/bcp-core/payment/v1/approvePaymentWithEs

### Business Usage
Use the Index field in ARAP to query AP records that meet the approval criteria and approve them; each approved AP record will generate a Payment record. During the query, the filterList parameter in Conditions can exclude all AP records that should be excluded.

Certain fields for Payment can be assigned within the PaymentInfo object when requesting data. Dynamic fields for Payment are also processed here. Note that these fields to be assigned must exist in the Payment Data Dictionary (DD). Additionally, since one AP generates one Payment in this API, the values of these fields for all Payments are the same during a single API processing cycle.

### API Sample
Sample Request
  ```json
{
  "Conditions": {
    "FilterList": [
      "CR20240500000143",
      "CR20240500000152"
    ],
    "IsApproved": "N",
    "ArapCate": "2",
    "ArapType": "-1001",
    "NeedStatement": "N",
    "FullOrgCode.multiLineExact": "10001",
    "PaymentInfo": {
      "PaymentMethod": "100",
      "CustomerField001":"Field001",
      "CustomerField002":"Field002"
    }
  },
  "FromRangeConditions": {
    "InsertTime": "2024-05-21"
  },
  "ToRangeConditions": {
    "InsertTime": "2024-05-21"
  },
  "Module": "Arap",
  "PageNo": 1,
  "PageSize": 10,
  "SortField": "ArapId",
  "SortType": "asc"
}
  ```

Sample Response
  ```json
  [
  {
    "@pk": 874333532,
    "@type": "BcpArap-Arap",
    "Amount": 1004.4,
    "ArapCate": "2",
    "ArapId": 874333532,
    "ArapNo": "CR20240500000070",
    "ArapStatus": "1",
    "ArapType": "-1001",
    "Balance": 1004.4,
    "BizTransId": 87XXXXX30,
    "BookingCurrencyCode": "USD",
    "BusinessObjectId": 1100002651088,
    "Commission": -93,
    "CurrencyCode": "USD",
    "CurrentPeriod": 1,
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "DueDate": "2024-05-22",
    "GenerateDate": "2024-05-21T11:22:01",
    "HasMandate": "N",
    "HasNote": "N",
    "IsApproved": "N",
    "IsOffsetByCommission": "N",
    "LocalCurrencyCode": "USD",
    "NeedStatement": "N",
    "OffsetAmount": 0,
    "OffsetByCommissionAmount": 0,
    "OperateTime": "2024-05-21T11:22:01",
    "PayerPayeeName": "PolicyCollection",
    "PayerPayeeType": "IndiCustomer",
    "PaymentMethod": "100",
    "PeriodEndDate": "2024-05-22",
    "PeriodStartDate": "2024-05-22",
    "RefFeeId": 874333531,
    "Tax": -74.4,
    "TotalPeriods": 1,
    "VersionSeq": 1
  }
]
  ```


### API Path - approvePaymentByArapIds
/bcp-core/payment/v1/approvePaymentByArapIds

### Business Usage
Using APIds to query AP records and approve them; each approved AP record will generate a corresponding payment record.

### API Sample
Sample Request
  ```json
[
  "11172824431,CCAE33D6B9229901187CFF406D664F69",
  "11172824430,BFDE7F7DE876BBC63C1B091FE120768A",
  "11172824432,F845345156E5DF8E9FFEE6C8C31115CF"

]
  ```

Sample Response
  ```json
{
  "Model": [
    {
      "@pk": 11509270002,
      "@type": "BcpPayment-Payment",
      "Amount": 1004.4,
      "ApproveBy": 10000046972028,
      "ApproveTime": "2025-08-28T18:00:59",
      "ArapIds": [
        11505284466
      ],
      "BizTransId": "115XXXXX464,B71XXXXXD14AEXXXXX08FAE57D3XXXXX",
      "BookingCurrencyCode": "CNY",
      "BranchCode": "10001",
      "BusinessObjectId": 1100002652600,
      "CurrencyCode": "CNY",
      "DetailList": [
        {
          "@pk": 11509270003,
          "@type": "BcpPaymentDetail-PaymentDetail",
          "Amount": 1004.4,
          "BookingCurrencyCode": "CNY",
          "BusinessObjectId": 1100002652739,
          "CurrencyCode": "CNY",
          "DirectBookingEr": 1,
          "DirectEr": 1,
          "IsExpense": "N",
          "LocalCurrencyCode": "CNY",
          "PaymentDetailId": 11509270003,
          "RefId": "11505284466,147F39A5606F021DF22C716896EB0CB6",
          "RefType": "3"
        }
      ],
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "HasMandate": "N",
      "HasNote": "N",
      "LastOperateBy": 10000046972028,
      "LastOperateTime": "2025-08-28T18:00:59",
      "LocalCurrencyCode": "CNY",
      "PayerPayeeName": "PolicyCollection",
      "PaymentId": "11509270002,7EC9485282C12CA9EF1DAC75FF7756DA",
      "PaymentMethod": "100",
      "PaymentNo": "PYMT20250800000103",
      "PaymentStatus": "2",
      "PaymentType": "1",
      "VersionSeq": 1
    }
  ],
  "Status": "OK"
}
  ```

### API Path - approvePaymentAdvanced
/bcp-core/payment/v1/approvePaymentAdvanced

### Business Usage

`approvePaymentAdvanced` is an **advanced payment approval** API that can handle complex refund and settlement scenarios in a single call. It is especially suitable for insurance cancellation / refund cases where:

- Multiple AR/AP entries must be approved together, and
- AP (credit/refund) needs to be offset against AR (debit/failed collection) first,
- Only the **net refundable amount** should finally be paid out.

This API can:

1. **Approve multiple AR/AP groups and generate multiple Payments in one request**
    - The request body contains an `approvePaymentList` array.
    - Each group will generate one independent Payment.
    - Each Payment can contain:
        - a single AP, or
        - multiple APs, or
        - a combination of APs and ARs (Offset AP against AR first, then create Payment for the net amount).

2. **Offset AP against AR within the same Payment group and pay only the net AP amount**
    - When a Payment group contains both AP and AR, the system will first calculate the **net amount** within the group:
    - Business rule: **Total AP amount > Total AR amount** is required.
    - System behavior:
        - Use AP amount to offset AR amount inside the group.
        - Only the **remaining net AP amount** will be used to generate the Payment.

   **Typical use case**

   For an installment premium policy, earlier installments have been paid while later installments remain unpaid. The customer then cancels the policy and a full refund is triggered, generating AP records for the full refundable amount. In this case, we need to use the refund APs to first offset the unpaid ARs, and only pay the net refund amount to the customer.

   **Real-world example:**
    - A policy is cancelled after the first four installments were initially marked as settled.
    - At cancellation, a credit refund (AP / CR) of –1,681.57 is generated, assuming all four installments were successfully collected.
    - The actual refundable amount should be –969.43, not –1,681.57.

   Using `approvePaymentAdvanced`, you can:
    - Put the original refund AP(s) and the outstanding AR(s) into the **same Payment group**.
    - Let the system **offset AP against AR** inside that group.
    - Automatically generate a Payment only for the **net amount –969.43**, effectively adjusting the over-refund.

3. **Support Commission offset against AR/AP during approval**

   If you need to use **commission (SalesCommission)** to offset part of AR/AP in the same process:

    - Use the `arapList` mode in the request, and
    - For each AR/AP object, set:
        - `IsOffsetByCommission = "Y"`
        - `OffsetByCommissionAmount = <amount to be offset by commission>`
          The system will:
    - Apply commission offset according to these fields,
    - Update `SalesCommission` balance and status accordingly,
    - Still support the same AP + AR netting logic inside each Payment group.

4. **Flexibly assign Payment fields and dynamic fields**

   When creating Payment records, you can directly specify:

    - Core fields such as `PaymentNo`, `PaymentMethod`, etc.
    - Any dynamic fields already configured in the Payment Data Dictionary (e.g. `CustomerField001`, etc.).

   Notes:

    - If `PaymentNo` is passed in the request, the system will **use this value directly** and will not auto-generate a new Payment No.
    - Dynamic fields must be pre-configured in the Payment Data Dictionary. Otherwise, the API will return a “field does not exist” error.


### Usage Modes

`approvePaymentAdvanced` provides **two usage modes** to match different business complexity levels:

#### Mode 1 – Use `arapIdList` (simple AP/AR grouping, no commission offset)

**Applicable scenarios:**
- You only need to specify which AP/AR entries each Payment is composed of.
- You do **not** need to use commission to offset AR/AP.
- Typical combinations:
    - AP + AP
    - AP + AP + AR (AP offsets AR inside the group, net AP generates Payment)
    - Single AP
      In this mode, you only pass AR/AP IDs via `arapIdList`.

**Key points:**
- In the request body, each group in `approvePaymentList` corresponds to **one Payment**:

System behavior:

- Automatically identify whether each ID in `arapIdList` is AP or AR.
- Validate that, **within each group**, total AP amount > total AR amount.
- Perform **internal netting** of AP – AR inside the group.
- Generate one Payment per group for the **net AP amount**.

API Sample
Sample Request
  ```json
{
  "ApprovePaymentList":[
    {
      "ArapIdList":[
        "11656842702", //AP 
        "11656842703", //AP
        "11656842704", //AP  
        "11656842680" //AR
      ],
      "PaymentNo":"PAY20221000035512"
      //"CustomerField001":"CR2XXXXX0003XXXX"

    },
    {
      "ArapIdList":["11656842705"],
      "CustomerField001":"CR2XXXXX0003XXXX"
    }

  ]
}
  ```

Sample Response
  ```json

[
  {
    "@pk": 11656922135,
    "@type": "BcpPayment-Payment",
    "Amount": 502.2,
    "ApproveBy": 10000080472063,
    "ApproveTime": "2025-12-05T10:46:06",
    "ArapIds": [
      11656842703,
      11656842702,
      11656842680,
      11656842704
    ],
    "BookingCurrencyCode": "CNY",
    "BranchCode": "10001",
    "BusinessObjectId": 1100002652600,
    "CurrencyCode": "CNY",
    "DetailList": [
      {
        "@pk": 11656922136,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 251.1,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922136,
        "RefId": "11656842702,70CF74FE0839A65B04B3AF6B41E529AF",
        "RefType": "3"
      },
      {
        "@pk": 11656922137,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 251.1,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922137,
        "RefId": "11656842703,01ED8BD490AD9C0F6AFA8C5D1242924E",
        "RefType": "3"
      },
      {
        "@pk": 11656922138,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 251.1,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922138,
        "RefId": "11656842704,893F48E7A52BCF4AA4D139644A9AFC93",
        "RefType": "3"
      },
      {
        "@pk": 11656922139,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": -251.1,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922139,
        "RefId": "11656842680,97C954F886EC4731ECE6705BD4F4E0BF",
        "RefType": "3"
      }
    ],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "InsertBy": 10000080472063,
    "InsertTime": "2025-12-05T10:46:05.904",
    "LastOperateBy": 10000080472063,
    "LastOperateTime": "2025-12-05T10:46:06",
    "LocalCurrencyCode": "CNY",
    "PayerPayeeName": "PolicyCollection",
    "PaymentId": "11656922135,A2EA903552BE577ED3A047F1C3D23019",
    "PaymentMethod": "100",
    "PaymentNo": "PAY20221000035512",
    "PaymentStatus": "2",
    "PaymentType": "1",
    "UpdateBy": 10000080472063,
    "UpdateTime": "2025-12-05T10:46:05.904",
    "VersionSeq": 1
  },
  {
    "@pk": 11656922142,
    "@type": "BcpPayment-Payment",
    "Amount": 251.1,
    "ApproveBy": 10000080472063,
    "ApproveTime": "2025-12-05T10:46:06",
    "ArapIds": [
      11656842705
    ],
    "BookingCurrencyCode": "CNY",
    "BranchCode": "10001",
    "BusinessObjectId": 1100002652600,
    "CurrencyCode": "CNY",
    "DetailList": [
      {
        "@pk": 11656922143,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 251.1,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922143,
        "RefId": "11656842705,F9E385D7CDE6DC7F9E5EBCF509AB5B79",
        "RefType": "3"
      }
    ],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "InsertBy": 10000080472063,
    "InsertTime": "2025-12-05T10:46:06.033",
    "LastOperateBy": 10000080472063,
    "LastOperateTime": "2025-12-05T10:46:06",
    "LocalCurrencyCode": "CNY",
    "PayerPayeeName": "PolicyCollection",
    "PaymentId": "11656922142,D7EAB3C06EABC492885F5A50CADE8773",
    "PaymentMethod": "100",
    "PaymentNo": "PYMT20251200000024",
    "PaymentStatus": "2",
    "PaymentType": "1",
    "UpdateBy": 10000080472063,
    "UpdateTime": "2025-12-05T10:46:06.033",
    "VersionSeq": 1,
    "CustomerField001": "CR2XXXXX0003XXXX"
  }
]
  ```

#### Mode 2 – Use `arapList` (full AR/AP objects, supports commission offset)

**Applicable scenarios:**
- You need to offset AR/AP with commission during Payment approval, for example:
- Settle channel commission together with refundable premium;
- Precisely control how much of each AR/AP is offset by commission.

System behavior:
- While generating Payments:
- Process commission offset based on `IsOffsetByCommission` and `OffsetByCommissionAmount`.
- Update `SalesCommission` balance and status.
- Apply the same AP + AR netting logic inside each Payment group.

In this mode, each item in `arapList` is a full AR/AP object (or at least contains required fields):

### API Sample
Sample Request
  ```json
  {
  "ApprovePaymentList": [
    {
      "ArapList": [
        {
          "@type": "BcpArap-Arap",
          "ArapId": "11656842808,9A2EC70A7895BDAEC3D74CF2EEE0098C",
          "IsOffsetByCommission": "Y",
          "OffsetByCommissionAmount": 38.25
        },
        {
          "@type": "BcpArap-Arap",
          "ArapId": "11656842809,D9084AB298337C8AA4BFB1C3158CBCB4",
          "IsOffsetByCommission": "Y",
          "OffsetByCommissionAmount": 38.25
        },
        {
          "@type": "BcpArap-Arap",
          "ArapId": "11656842773,9E8414F41574191642D28CF248F64C8D",
          "IsOffsetByCommission": "Y",
          "OffsetByCommissionAmount": -38.25
        }
      ],
      "PaymentNo": "PAY20221000036789"
    },
    {
      "ArapList": [
        {
          "@type": "BcpArap-Arap",
          "ArapId": "11656842810,6627C9185D3E1D8715D793CA9508C3B2",
          "IsOffsetByCommission": "Y",
          "OffsetByCommissionAmount": 38.25
        }
      ]
    }
  ]
}
  ```

Sample Response
  ```json
  [
  {
    "@pk": 11656922255,
    "@type": "BcpPayment-Payment",
    "Amount": 374.85,
    "ApproveBy": 10000080472063,
    "ApproveTime": "2025-12-05T12:08:54",
    "ArapIds": [
      11656842809,
      11656842808,
      11656842773
    ],
    "BookingCurrencyCode": "CNY",
    "BranchCode": "10001",
    "BusinessObjectId": 1100002652600,
    "CurrencyCode": "CNY",
    "DetailList": [
      {
        "@pk": 11656922256,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 374.85,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922256,
        "RefId": "11656842808,9A2EC70A7895BDAEC3D74CF2EEE0098C",
        "RefType": "3"
      },
      {
        "@pk": 11656922257,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 374.85,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922257,
        "RefId": "11656842809,D9084AB298337C8AA4BFB1C3158CBCB4",
        "RefType": "3"
      },
      {
        "@pk": 11656922258,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": -374.85,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922258,
        "RefId": "11656842773,9E8414F41574191642D28CF248F64C8D",
        "RefType": "3"
      }
    ],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "InsertBy": 10000080472063,
    "InsertTime": "2025-12-05T12:08:54.042",
    "LastOperateBy": 10000080472063,
    "LastOperateTime": "2025-12-05T12:08:54",
    "LocalCurrencyCode": "CNY",
    "PayerPayeeCode": "CI00001023",
    "PayerPayeeName": "StatementPayment",
    "PaymentId": "11656922255,9206A8E0CA51F982AC1575F4338B357C",
    "PaymentNo": "PAY20221000036789",
    "PaymentStatus": "2",
    "PaymentType": "1",
    "UpdateBy": 10000080472063,
    "UpdateTime": "2025-12-05T12:08:54.042",
    "VersionSeq": 1
  },
  {
    "@pk": 11656922266,
    "@type": "BcpPayment-Payment",
    "Amount": 374.85,
    "ApproveBy": 10000080472063,
    "ApproveTime": "2025-12-05T12:08:54",
    "ArapIds": [
      11656842810
    ],
    "BookingCurrencyCode": "CNY",
    "BranchCode": "10001",
    "BusinessObjectId": 1100002652600,
    "CurrencyCode": "CNY",
    "DetailList": [
      {
        "@pk": 11656922267,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 374.85,
        "BookingCurrencyCode": "CNY",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "CNY",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "CNY",
        "PaymentDetailId": 11656922267,
        "RefId": "11656842810,6627C9185D3E1D8715D793CA9508C3B2",
        "RefType": "3"
      }
    ],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "InsertBy": 10000080472063,
    "InsertTime": "2025-12-05T12:08:54.205",
    "LastOperateBy": 10000080472063,
    "LastOperateTime": "2025-12-05T12:08:54",
    "LocalCurrencyCode": "CNY",
    "PayerPayeeCode": "CI00001023",
    "PayerPayeeName": "StatementPayment",
    "PaymentId": "11656922266,31728F0E49B60793BEE184CFF0B10667",
    "PaymentNo": "PYMT20251200000026",
    "PaymentStatus": "2",
    "PaymentType": "1",
    "UpdateBy": 10000080472063,
    "UpdateTime": "2025-12-05T12:08:54.205",
    "VersionSeq": 1
  }
]
  ```

### API Path - approveStatementPayment
/bcp-core/payment/v1/approveStatementPayment

### Business Usage
Merge the AR and AP specified in the Statement, perform an approval operation, and finally generate a Payment data

### API Sample
Sample Request
  ```json
{
  "PaymentAmount": 1014.44,
  "CurrencyCode": "CNY",
  "BranchCode": 10001,
  "PaymentMethod": 30,
  "ArapList":[
    {"@type":"BcpArap-Arap","ArapId":"11509060027,2668F304DE65645CD8D35332BF9506FB","ArapNo":"DR20250800005310"},
    {"@type":"BcpArap-Arap","ArapId":"11509060028,7096E4F26A1F33E81A9499A7DE333727","ArapNo":"DR20250800005311"}
  ]

}
  ```

Sample Response
  ```json
{
  "@pk": 11509060077,
  "@type": "BcpPayment-Payment",
  "Amount": -1014.44,
  "ApproveBy": 10000046972028,
  "ApproveTime": "2025-08-28T17:58:28",
  "ArapIds": [
    11509060028,
    11509060027
  ],
  "BookingCurrencyCode": "CNY",
  "BranchCode": "10001",
  "BusinessObjectId": 1100002652600,
  "CurrencyCode": "CNY",
  "DetailList": [
    {
      "@pk": 11509060078,
      "@type": "BcpPaymentDetail-PaymentDetail",
      "Amount": -507.22,
      "BookingCurrencyCode": "CNY",
      "BusinessObjectId": 1100002652739,
      "CurrencyCode": "CNY",
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "IsExpense": "N",
      "LocalCurrencyCode": "BRL",
      "PaymentDetailId": 11509060078,
      "RefId": "11509060027,2668F304DE65645CD8D35332BF9506FB",
      "RefType": "3"
    },
    {
      "@pk": 11509060079,
      "@type": "BcpPaymentDetail-PaymentDetail",
      "Amount": -507.22,
      "BookingCurrencyCode": "CNY",
      "BusinessObjectId": 1100002652739,
      "CurrencyCode": "CNY",
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "IsExpense": "N",
      "LocalCurrencyCode": "BRL",
      "PaymentDetailId": 11509060079,
      "RefId": "11509060028,7096E4F26A1F33E81A9499A7DE333727",
      "RefType": "3"
    }
  ],
  "DirectBookingEr": 1,
  "DirectEr": 1,
  "HasMandate": "N",
  "HasNote": "N",
  "LastOperateBy": 10000046972028,
  "LastOperateTime": "2025-08-28T17:58:28",
  "LocalCurrencyCode": "CNY",
  "PaymentId": "11509060077,6DCE09A2D4E5E8EDD4232B5BBEDC70DD",
  "PaymentMethod": "30",
  "PaymentNo": "PYMT20250800000102",
  "PaymentStatus": "2",
  "PaymentType": "1",
  "VersionSeq": 1
}
  ```

### Internal Data Behavior
The business models involved in the approval payment operation have the following associative relationships:
1.	Generate new `BcpPayment` business data, with the basic data originating from the main transaction model `BcpBizTransaction` and associating with `BcpArap` through the **ArapIds** field.
2.	Generate the payment schedule data of `BcpPaymentDetail` whose main data comes from `BcpArap`.

## Single Payment API
### API Path
/bcp-core/payment/v1/singlePayment

### Business Usage

Single Payment is used to support payment confirmation for a single transaction.

### API Sample
Sample Request
  ```json
  [
  {
    "@pk":9699282032,
    "@type":"BcpPayment-Payment",
    "Amount":1004.4,
    "ApproveBy":10000001178005,
    "ApproveTime":"2023-12-20T03:50:21",
    "ArapIds":[
      9699282029
    ],
    "BookingCurrencyCode":"USD",
    "BranchCode":"10006",
    "BusinessObjectId":1100002652600,
    "CurrencyCode":"USD",
    "DetailList":[
      {
        "@pk":9699282033,
        "@type":"BcpPaymentDetail-PaymentDetail",
        "Amount":1004.4,
        "BookingCurrencyCode":"USD",
        "BusinessObjectId":1100002652739,
        "CurrencyCode":"USD",
        "DirectBookingEr":1,
        "DirectEr":1,
        "IsExpense":"N",
        "LocalCurrencyCode":"USD",
        "PaymentDetailId":9699282033,
        "RefId":"9699282029,3E2DABCEE975307D998DC5199434D1DF",
        "RefType":"3"
      }
    ],
    "DirectBookingEr":1,
    "DirectEr":1,
    "HasMandate":"N",
    "HasNote":"N",
    "LocalCurrencyCode":"USD",
    "PayerPayeeName":"PolicyCollection",
    "PaymentId":"9699282032,87A1872BA3A3DBA061E5026A83D65E7B",
    "PaymentMethod":"100",
    "PaymentNo":"PYMT20231200000079",
    "PaymentStatus":"2",
    "PaymentType":"1",
    "PolicyNo":"POTBTI01226628",
    "VersionSeq":1
  }
]

```

Sample Response
  ```json
  {
  "Model": [{
    "@pk": 9699282032,
    "@type": "BcpPayment-Payment",
    "Amount": 1004.4,
    "ApproveBy": 10000001178005,
    "ApproveTime": "2023-12-20T03:50:21",
    "ArapIds": [9699282029],
    "BookingCurrencyCode": "USD",
    "BranchCode": "10006",
    "BusinessObjectId": 1100002652600,
    "CompleteBy": 10000001178005,
    "CompleteTime": "2023-12-20T03:50:25.418",
    "CurrencyCode": "USD",
    "DetailList": [{
      "@pk": 9699282033,
      "@type": "BcpPaymentDetail-PaymentDetail",
      "Amount": 1004.4,
      "BookingCurrencyCode": "USD",
      "BusinessObjectId": 1100002652739,
      "CurrencyCode": "USD",
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "IsExpense": "N",
      "LocalCurrencyCode": "USD",
      "PaymentDetailId": 9699282033,
      "RefId": "9699282029,3E2DABCEE975307D998DC5199434D1DF",
      "RefType": "3"
    }],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "LocalCurrencyCode": "USD",
    "PayerPayeeName": "PolicyCollection",
    "PaymentId": "9699282032,87A1872BA3A3DBA061E5026A83D65E7B",
    "PaymentMethod": "100",
    "PaymentNo": "PYMT20231200000079",
    "PaymentStatus": "3",
    "PaymentType": "1",
    "VersionSeq": 2
  }],
  "Status": "OK"
}

```
### Internal Data Behavior

The business models involved in the single payment operation have the following associative relationships:
1.	Change the **ArapStatus** of `BcpPayment` data generated from the approved payment to 3 (paid).
2.	Query the associated AP data through the **ArapIds** of `BcpPayment`, and change the AP balance to 0 and the **ArapStatus** to 2 (settled).
3.	Obtain the associated `SalesCommission` data through the **BizTransId** and **CurrentPeriod** of `BcpArap`, and change **CommissionStatus** to 2 (waiting for issue).
4.	Accumulate the amount of `SalesCommission` to the **ReleaseCommissionAmount** field of `BcpPaymentDetail`.

### What You Can Extend
After the payment has been completed as described above, it is necessary to transmit data back to the business party and send data to the sales channel commission.

## Massive Payment API
### API Path
/bcp-core/payment/v1/massivePayment

### Business Usage
Massive payment API is designed for confirming payments across a bulk of businesses.

### API Sample
Sample Request
  ```json
  {
  "SearchCondition": {
    "Conditions": {
      "PaymentMethod": "100",
      "ArapType": null,
      "CurrencyCode": "USD",
      "BranchCode": "10001",
      "PaymentStatus": "2",
      "IsFullOrg": true,
      "InsurerAccountCode": "10001"
    },
    "FuzzyConditions": {
      "PolicyNo": null,
      "ClaimNo": null,
      "PayerPayeeName": null
    },
    "OrFuzzyConditions": {},
    "FromRangeConditions": {
      "ApproveTime": "2023-12-20"
    },
    "ToRangeConditions": {
      "ApproveTime": "2023-12-20"
    },
    "PageNo": 1,
    "PageSize": 10,
    "SortField": "index_time",
    "SortType": "desc",
    "Module": "BcpPayment"
  }
}

  ```

Sample Response
  ```json
  {"Status":"OK"}
  ```

### Internal Data Behavior
Massive Payment is the bulk operation mode of Single Payment. The business models and data flows involved are consistent.

### What You Can Extend
After the payment has been completed as described above, it is necessary to transmit data back to the business party and send data to the sales channel commission.

## Receipt Refund API
### API Path
/bcp-core/payment/v1/receiptRefund

### Business Usage
The Receipt refund API is used to refund the remaining amount on a specific receipt.

### API Sample
Sample Request
  ```json
  {
  "BranchCode": "10001",
  "PayerPayeeCode": "CI00001023",
  "PayerPayeeName": "PrePaidPolicy",
  "PaymentAmount": 1004.4,
  "PaymentMethod": "101",
  "BankCode": "",
  "BankAccountNo": "",
  "CurrencyCode": "USD",
  "CollectionList": [
    {
      "@pk": 9699282056,
      "@type": "BcpCollection-Collection",
      "Amount": 1004.4,
      "Balance": 1004.4,
      "BankAccountNo": "",
      "BankCode": "",
      "BookingCurrencyCode": "USD",
      "BranchCode": "10002",
      "BusinessObjectId": 1100002651715,
      "ChequeNo": "",
      "CollectionId": "9699282056,BA2899973AD6BC4EDD53206180E10D52",
      "CollectionStatus": "1",
      "CollectionType": "1",
      "CurrencyCode": "USD",
      "DetailList": [
        {
          "@pk": 9699282057,
          "@type": "BcpCollectionDetail-CollectionDetail",
          "Amount": 1004.4,
          "BookingCurrencyCode": "USD",
          "BusinessObjectId": 1100002651850,
          "CollectionDetailId": 9699282057,
          "CurrencyCode": "USD",
          "DirectBookingEr": 1,
          "DirectEr": 1,
          "IsExpense": "N",
          "LocalCurrencyCode": "USD",
          "RefId": "9699282058,2AC05A99671BF5162671225863DF334C",
          "RefType": "2"
        }
      ],
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "HasMandate": "N",
      "HasNote": "N",
      "IsManualReceipt": "N",
      "LocalCurrencyCode": "USD",
      "OrderIds": [
        9699282055
      ],
      "PayerPayeeCode": "CI00001023",
      "PayerPayeeName": "PrePaidPolicy",
      "PayerPayeeType": "1",
      "PaymentMethod": "100",
      "ReceiptNo": "RCT20231200000020",
      "ReceiveBy": 10000001178005,
      "ReceiveTime": "2023-12-20T14:02:36",
      "ReferencePerson": "",
      "VersionSeq": 1
    }
  ],
  "DynamicFieldMap": {
    "PolicyNo": "POTBTI01233981"
  }
}

```

Sample Response
  ```json
  {
  "Model": {
    "@pk": 9699282246,
    "@type": "BcpPayment-Payment",
    "Amount": 1004.4,
    "ApproveBy": 10000046972028,
    "ApproveTime": "2023-12-20T07:32:17.664",
    "BankAccountNo": "",
    "BankCode": "",
    "BookingCurrencyCode": "USD",
    "BranchCode": "10001",
    "BusinessObjectId": 1100002652600,
    "CurrencyCode": "USD",
    "DetailList": [
      {
        "@pk": 9699282249,
        "@type": "BcpPaymentDetail-PaymentDetail",
        "Amount": 1004.4,
        "BookingCurrencyCode": "USD",
        "BusinessObjectId": 1100002652739,
        "CurrencyCode": "USD",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "USD",
        "PaymentDetailId": 9699282249,
        "RefId": "9699282058,2AC05A99671BF5162671225863DF334C",
        "RefType": "2"
      }
    ],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "LocalCurrencyCode": "USD",
    "PayerPayeeCode": "CI00001023",
    "PayerPayeeName": "PrePaidPolicy",
    "PaymentId": "9699282246,F0FCF7563A8A4D533FE497F6F4B1F545",
    "PaymentMethod": "101",
    "PaymentNo": "PYMT20231200000098",
    "PaymentStatus": "2",
    "VersionSeq": 1
  },
  "Status": "OK"
}
  ```
### Internal Data Behavior

The business models involved in the receipt refund operation have the following relationships:
1.	Query the information of `BcpCollectionDetail` through the collection information transmitted in the UI.
2.	Query the data of `BcpSuspense` through the **RefId** of `BcpCollectionDetail`.
3.	Generate new payment information. The basic data of `BcpPayment` and `BcpPaymentDetail` come from the collection.
4.	Associate `BcpPaymentDetail` with `BcpPayment` through **PaymentId**, and with `BcpSuspense` through **RefId**. The amount is the balance field of suspense.
5.	Update the balance field of `BcpSuspense` to 0.

## Reverse Payment API
### API Path
/bcp-core/payment/v1/reversePayment

### Business Usage
The Reverse Payment API is used to reverse the payment transaction.

### API Sample
Sample Request
  ```json
  [
  {
    "@pk":9699282032,
    "@type":"BcpPayment-Payment",
    "Amount":1004.4,
    "ApproveBy":10000001178005,
    "ApproveTime":"2023-12-20T03:50:21",
    "ArapIds":[
      9699282029
    ],
    "BookingCurrencyCode":"USD",
    "BranchCode":"10006",
    "BusinessObjectId":1100002652600,
    "CompleteBy":10000001178005,
    "CompleteTime":"2023-12-20T03:50:25",
    "CurrencyCode":"USD",
    "DetailList":[
      {
        "@pk":9699282033,
        "@type":"BcpPaymentDetail-PaymentDetail",
        "Amount":1004.4,
        "BookingCurrencyCode":"USD",
        "BusinessObjectId":1100002652739,
        "CurrencyCode":"USD",
        "DirectBookingEr":1,
        "DirectEr":1,
        "IsExpense":"N",
        "LocalCurrencyCode":"USD",
        "PaymentDetailId":9699282033,
        "RefId":"9699282029,3E2DABCEE975307D998DC5199434D1DF",
        "RefType":"3"
      }
    ],
    "DirectBookingEr":1,
    "DirectEr":1,
    "HasMandate":"N",
    "HasNote":"N",
    "LocalCurrencyCode":"USD",
    "PayerPayeeName":"PolicyCollection",
    "PaymentId":"9699282032,87A1872BA3A3DBA061E5026A83D65E7B",
    "PaymentMethod":"100",
    "PaymentNo":"PYMT20231200000079",
    "PaymentStatus":"3",
    "PaymentType":"1",
    "PolicyNo":"POTBTI01226628",
    "VersionSeq":2
  }
]

```

Sample Response
  ```json
  {
  "Model": [{
    "@pk": 9699282032,
    "@type": "BcpPayment-Payment",
    "Amount": 1004.4,
    "ApproveBy": 10000001178005,
    "ApproveTime": "2023-12-20T03:50:21",
    "ArapIds": [9699282029],
    "BookingCurrencyCode": "USD",
    "BranchCode": "10006",
    "BusinessObjectId": 1100002652600,
    "CompleteBy": 10000001178005,
    "CompleteTime": "2023-12-20T03:50:25",
    "CurrencyCode": "USD",
    "DetailList": [{
      "@pk": 9699282033,
      "@type": "BcpPaymentDetail-PaymentDetail",
      "Amount": 1004.4,
      "BookingCurrencyCode": "USD",
      "BusinessObjectId": 1100002652739,
      "CurrencyCode": "USD",
      "DirectBookingEr": 1,
      "DirectEr": 1,
      "IsExpense": "N",
      "LocalCurrencyCode": "USD",
      "PaymentDetailId": 9699282033,
      "RefId": "9699282029,3E2DABCEE975307D998DC5199434D1DF",
      "RefType": "3"
    }],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "LocalCurrencyCode": "USD",
    "PayerPayeeName": "PolicyCollection",
    "PaymentId": "9699282032,87A1872BA3A3DBA061E5026A83D65E7B",
    "PaymentMethod": "100",
    "PaymentNo": "PYMT20231200000079",
    "PaymentStatus": "5",
    "PaymentType": "1",
    "ReverseBy": 10000001178005,
    "ReverseId": 9699282048,
    "ReverseTime": "2023-12-20T03:50:29.518",
    "VersionSeq": 3
  }],
  "Status": "OK"
}
  ```
### Internal Data Behavior

The business models involved in the reverse payment operation have the following relationships:
1.	Query the data related to `BcpPaymentDetail` through the payment information.
2.	There are two reverse scenarios: Reversing the data for single and mass payments, and the data for receipt refunds.

•	When the **RefType** of `BcpPaymentDetail` is 2 (suspense), reverse the receipt refund data.  
•	When the **RefType** is of other types, reverse the data of single and mass payments. At the same time, distinguish the reverse actions by judging the **PaymentStatus** field of `BcpPayment`. When **PaymentStatus** is 2 (approved), just update the ARAP model; when **PaymentStatus** is 3 (paid), update both the ARAP and commission model simultaneously.

### What You Can Extend
After completing the reverse, it is necessary to transmit data back to the business party and to send data to the sales channel commission.
