Complete invoice by ID

The Complete invoice by ID method is used for approving the payment linked to an approved postpaid invoice by ID in the platform (see Approve invoice by ID) with a third-party invoice issued to an account of the reseller by a third-party ERP system (see Managing invoices for the Postpay model by a third-party ERP system). This method is used to specify the ID of the required invoice for accounts with several invoices in the platform within the same billing period. If an account has only one invoice in the platform within a billing period, it is possible to use another method without specifying the invoice ID — see Complete invoice.

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 (billing_date). 

An API token of a manager is required for authorization. To get an API token via the Operator Control Panel, see Viewing and updating manager's information

The manager's API token specified in an API request determines:

  • The role and access level of the manager, which determine the availability of a method.
  • The current reseller and downstream resellers accessible within a method.

POST {base_url}/api/v3/resellers/{reseller_id}/invoices/{invoice_id}/complete

Arguments

Name

Parameter Type

Data type

Required/Optional

Description

X-Api-TokenheaderstringRequiredAPI token of a manager that performs the operation (see Viewing and updating manager's information)
Content-TypeheaderstringRequiredMedia type of the request. Specify the following: application/vnd.api+json
AcceptheaderstringRequired

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

base_urlpathstringRequiredActivePlatform URL
reseller_idpathnumberRequiredID of the current reseller or any of its downstream resellers (see Viewing and updating reseller general information)
invoice_idpathnumberRequiredID of the invoice in the platform to complete
document_idformstringRequiredThird-party invoice name
billing_dateformstringRequiredBilling 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

StatusError codeError textComment
400INVOICE-0001Required parameters are not providedSpecify all required parameters in the request
INVOICE-0005Incorrect specified billing date for the invoiceThe specified billing day billing_date does not match the specified invoice in the platform
INVOICE-0006Incorrect specified document_id for the invoiceThe specified third-party invoice name document_id does not match the specified invoice in the platform
INVOICE-0010Only postpaid invoice can be completedThe payment model of the specified invoice is not Postpay, so the invoice cannot be completed (see Get invoice)
INVOICE-0011Only closed invoice can be completedThe status of the specified invoice is not Closed, so the invoice cannot be completed (see Get invoice)
INVOICE-0012Only non-zero invoice can be completedThe amount of the specified invoice is 0, so the invoice cannot be completed (see Get invoice)
INVOICE-0017Payment related to this invoice has been cancelled. Invoice completion is not possibleA manager manually cancelled a linked payment (see Managing Invoices for the Postpay model by a third-party ERP system). The invoice cannot be approved or completed
422INVOICE-0004Unable to complete invoice one more timeThe invoice is already completed

Request example

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

Response example

{
    "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": []
            }
        }
    }
}