> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidoc.dreamclass.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidoc.dreamclass.io/_mcp/server.

# PayInvoice

POST https://dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D
Content-Type: application/json

Used to issue a payment against an invoice.

Input variables

- invoiceId: number of the invoice (path variable)
    
- json representation of a payment object
    
    - amount (decimal)
        
    - privateNotes (if any)
        
    - publicNotes (if any)
        
    - paymentmethod (1 Cash, 2 Bank Transfer, 3 Online, 4 Check,...)
        
    - createdAt (optional)

Reference: https://apidoc.dreamclass.io/dream-class-api/invoices/pay-invoice

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D:
    post:
      operationId: pay-invoice
      summary: PayInvoice
      description: |-
        Used to issue a payment against an invoice.

        Input variables

        - invoiceId: number of the invoice (path variable)
            
        - json representation of a payment object
            
            - amount (decimal)
                
            - privateNotes (if any)
                
            - publicNotes (if any)
                
            - paymentmethod (1 Cash, 2 Bank Transfer, 3 Online, 4 Check,...)
                
            - createdAt (optional)
      tags:
        - subpackage_invoices
      parameters:
        - name: tenant
          in: header
          required: false
          schema:
            type: string
        - name: schoolCode
          in: header
          required: false
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoices_PayInvoice_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: string
                createdAt:
                  type: string
                  format: date-time
                publicNotes:
                  type: string
                privateNotes:
                  description: Any type
                paymentmethod:
                  $ref: >-
                    #/components/schemas/DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostRequestBodyContentApplicationJsonSchemaPaymentmethod
              required:
                - amount
                - createdAt
                - publicNotes
                - paymentmethod
servers:
  - url: https:/
    description: https://{server}
  - url: https://your-webhook-url
    description: https://your-webhook-url
components:
  schemas:
    DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostRequestBodyContentApplicationJsonSchemaPaymentmethod:
      type: object
      properties:
        id:
          type: integer
      required:
        - id
      title: >-
        DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostRequestBodyContentApplicationJsonSchemaPaymentmethod
    DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaFeesItems:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        type:
          description: Any type
        amount:
          type: integer
        status:
          type: string
        expireDate:
          description: Any type
        paidamount:
          type: integer
      required:
        - id
        - name
        - amount
        - status
        - paidamount
      title: >-
        DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaFeesItems
    DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaPaymentsItems:
      type: object
      properties:
        id:
          type: integer
        amount:
          type: integer
        createdAt:
          type: string
          format: date-time
        invoiceId:
          type: integer
        publicNotes:
          description: Any type
        privateNotes:
          description: Any type
        paymentmethod:
          description: Any type
      required:
        - id
        - amount
        - createdAt
        - invoiceId
      title: >-
        DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaPaymentsItems
    Invoices_PayInvoice_Response_200:
      type: object
      properties:
        id:
          type: integer
        fees:
          type: array
          items:
            $ref: >-
              #/components/schemas/DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaFeesItems
        email:
          description: Any type
        amount:
          type: integer
        status:
          type: integer
        address:
          type: string
        dueDate:
          type: string
          format: date
        fullname:
          type: string
        payments:
          type: array
          items:
            $ref: >-
              #/components/schemas/DreamclassapiV1FinancialInvoicesPay7BinvoiceId7DPostResponsesContentApplicationJsonSchemaPaymentsItems
        createdAt:
          type: string
          format: date-time
        issueDate:
          type: string
          format: date
        telephone:
          description: Any type
        paidAmount:
          type: integer
        publicNotes:
          description: Any type
        invoiceRefId:
          description: Any type
        privateNotes:
          description: Any type
      required:
        - id
        - fees
        - amount
        - status
        - address
        - dueDate
        - fullname
        - payments
        - createdAt
        - issueDate
        - paidAmount
      title: Invoices_PayInvoice_Response_200

```

## Examples



**Request**

```json
{
  "amount": "10",
  "createdAt": "2021-04-25T15:23:00Z",
  "publicNotes": "test",
  "paymentmethod": {
    "id": 1
  }
}
```

**Response**

```json
{
  "id": 3,
  "fees": [
    {
      "id": 18,
      "name": "Registration Fee",
      "amount": 10,
      "status": "PAID",
      "paidamount": 10
    }
  ],
  "amount": 10,
  "status": 3,
  "address": "123 Clement Street",
  "dueDate": "2024-04-30",
  "fullname": "John  Johnson",
  "payments": [
    {
      "id": 2,
      "amount": 5,
      "createdAt": "2024-04-21T12:24:06.877+00:00",
      "invoiceId": 3
    },
    {
      "id": 1,
      "amount": 5,
      "createdAt": "2024-04-21T12:23:07.533+00:00",
      "invoiceId": 3,
      "paymentmethod": null
    }
  ],
  "createdAt": "2024-04-21T12:22:40.661+00:00",
  "issueDate": "2024-04-01",
  "paidAmount": 10
}
```

**SDK Code**

```python Invoices_PayInvoice_example
import requests

url = "https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D"

payload = {
    "amount": "10",
    "createdAt": "2021-04-25T15:23:00Z",
    "publicNotes": "test",
    "paymentmethod": { "id": 1 }
}
headers = {
    "tenant": "{{tenant}}",
    "schoolCode": "{{schoolCode}}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Invoices_PayInvoice_example
const url = 'https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D';
const options = {
  method: 'POST',
  headers: {
    tenant: '{{tenant}}',
    schoolCode: '{{schoolCode}}',
    'Content-Type': 'application/json'
  },
  body: '{"amount":"10","createdAt":"2021-04-25T15:23:00Z","publicNotes":"test","paymentmethod":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Invoices_PayInvoice_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D"

	payload := strings.NewReader("{\n  \"amount\": \"10\",\n  \"createdAt\": \"2021-04-25T15:23:00Z\",\n  \"publicNotes\": \"test\",\n  \"paymentmethod\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("tenant", "{{tenant}}")
	req.Header.Add("schoolCode", "{{schoolCode}}")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Invoices_PayInvoice_example
require 'uri'
require 'net/http'

url = URI("https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["tenant"] = '{{tenant}}'
request["schoolCode"] = '{{schoolCode}}'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount\": \"10\",\n  \"createdAt\": \"2021-04-25T15:23:00Z\",\n  \"publicNotes\": \"test\",\n  \"paymentmethod\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Invoices_PayInvoice_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D")
  .header("tenant", "{{tenant}}")
  .header("schoolCode", "{{schoolCode}}")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": \"10\",\n  \"createdAt\": \"2021-04-25T15:23:00Z\",\n  \"publicNotes\": \"test\",\n  \"paymentmethod\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php Invoices_PayInvoice_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D', [
  'body' => '{
  "amount": "10",
  "createdAt": "2021-04-25T15:23:00Z",
  "publicNotes": "test",
  "paymentmethod": {
    "id": 1
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'schoolCode' => '{{schoolCode}}',
    'tenant' => '{{tenant}}',
  ],
]);

echo $response->getBody();
```

```csharp Invoices_PayInvoice_example
using RestSharp;

var client = new RestClient("https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D");
var request = new RestRequest(Method.POST);
request.AddHeader("tenant", "{{tenant}}");
request.AddHeader("schoolCode", "{{schoolCode}}");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": \"10\",\n  \"createdAt\": \"2021-04-25T15:23:00Z\",\n  \"publicNotes\": \"test\",\n  \"paymentmethod\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Invoices_PayInvoice_example
import Foundation

let headers = [
  "tenant": "{{tenant}}",
  "schoolCode": "{{schoolCode}}",
  "Content-Type": "application/json"
]
let parameters = [
  "amount": "10",
  "createdAt": "2021-04-25T15:23:00Z",
  "publicNotes": "test",
  "paymentmethod": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://https/dreamclassapi/v1/financial/invoices/pay/%7BinvoiceId%7D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```