Complete invoice

The Complete invoice method is used for approving the payment linked to an approved postpaid invoice (see Approve invoice) with a third-party invoice issued to an account of the reseller by a third-party ERP system (see ).

For accounts with several invoices within the same billing period, use another API method and specify the ID of the required invoice — see Complete invoice by ID.

Optionally, a manager can approve an invoice for the Postpay model and the payment manually in the Operator Control Panel:

The platform matches a third-party invoice and invoice for the Postpay model using the start date of the billing period. 

POST {base_url}/api/v3/resellers/{reseller_id}/accounts/{account_id}/complete_invoices

Arguments

Name

Parameter Type

Data type

Required/Optional

Description

X-Api-Token

header

string

Required

API token of a manager that performs the operation (see


)

Content-Type

header

string

Required

Media type of the request. Specify the following: application/vnd.api+json

Accept

header

string

Required

Supported media types of the answer. Specify the following: application/vnd.api+json

base_url

path

string

Required

ActivePlatform URL

reseller_id

path

number

Required

ID of the current reseller or any of its downstream resellers (see 


)

account_id

path

number

Required

Account ID

document_id

form

string

Required

Third-party invoice name

billing_date

form

string

Required

Billing day (YYYY-MM-DD) — the start date of a billing period linked to the invoice

Response model

The response model is similar to Get invoice.

Errors

Status

Error code

Error text

Comment

400

INVOICE-0001

Required parameters are not provided

Specify all required parameters in the request

INVOICE-0017

Payment related to this invoice has been cancelled. Invoice completion is not possible

A manager manually cancelled a linked payment (see


). The invoice cannot be approved or completed

404

INVOICE-0002

Invoice for billing date {billing_date} was not found for account id {account_id}

  • The account does not have an invoice for the specified billing day billing_date.

  • An invoice for the specified billing day billing_date has the total amount equal to 0. A payment for the invoice cannot be approved because the invoice does not have information about the linked subscriptions.

422

INVOICE-0004

Unable to complete invoice one more time

The invoice is already completed

Request example

XML
POST /api/v3/resellers/1/accounts/505/complete_invoices
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+json
JSON
{
    "document_id": "NS2000015",
    "billing_date": "2020-04-01"
}

Response example

JSON
{
    "data": {
        "id": "2046",
        "type": "invoices",
        "attributes": {
            "created_at": "2019-04-18T09:02:01.257560+0300",
            "updated_at": "2019-05-02T06:12:41.990713+0300",
            "document_id": "NS2000015",
            "status": "closed",
            "total": "987.65",
            "account_id": 505,
            "from_date": "2019-04-17",
            "to_date": "2019-05-01",
            "payment_model": "postpay",
            "approved": "true"
        },
        "relationships": {
            "subscriptions": {
                "data": [
                    {
                        "id": "3009839",
                        "type": "subscriptions"
                    }
                ]
            },
            "payments": {
                "data": [
                    {
                        "id": "12201",
                        "type": "payments"
                    }
                ]
            },
            "charges": {
                "data": [
                    {
                        "id": "323740",
                        "type": "charges"
                    }
                ]
            },
            "corrections": {
                "data": []
            }
        }
    }
}