Approve postpaid invoice by ID

The Approve postpaid invoice by ID method is used for approving a postpaid invoice by ID in the platform 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. As a result:

  • Optionally, the third-party ERP system can attach to the payment linked to the postpaid invoice a receipt as a file or a link.
  • The platform sets the due date for the payment according to the account class of the account.

After receiving payment for a third-party invoice, it is necessary to approve the payment in the platform by calling the method Complete postpaid invoice by ID. Optionally, a manager can approve the payment manually in the Operator Control Panel (see Processing a payment linked to an invoice issued by a third-party ERP system).

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 current reseller and downstream resellers accessible within a method.

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

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
invoice_idpathintegerRequiredID of the invoice in the platform to approve
account_idpathintegerRequiredAccount ID
document_idformstringRequiredThird-party invoice name
billing_dateformstringRequiredStart date of the billing period for which the invoice is issued (YYYY-MM-DD)
fileformobjectOptionalData about a third-party invoice file issued by an ERP system. It is possible to specify a file or a link to the file but not both

dataformstringOptional

Third-party invoice file in the base64 encoding. Required if the data about a third-party invoice file is specified

The maximum file size is defined by the settings of the given installation of the platform. To change the limit, please contact the support team.


nameformstringOptional

Third-party invoice file name. Required if the data about a third-party invoice file is specified

linkformobjectOptionalData about a link to a third-party invoice file issued by an ERP system. It is possible to specify a file or a link to the file but not both

dataformstringOptionalLink to a third-party invoice file. Required if the data about a link to a third-party invoice file is specified

nameformstringOptionalThird-party invoice file in the link. Required if the data about a link to a third-party invoice file is specified

Response model

Name

Data type

Description

dataobjectResponse data


id

string

Invoice ID in the platform

typestringData type

attributesobjectPostpaid invoice information


created_at

string

Date and time of invoice creation


updated_at

string

Data and time of invoice last update


document_id

stringInvoice number


status

stringInvoice status


total

stringInvoice total


account_id

integerID of the account for which the invoice was issued


from_date

stringStart date of the period covered by the invoice (YYYY-MM-DD)


to_date

stringEnd date of the period covered by the invoice (YYYY-MM-DD)


payment_model

string

Invoice payment model: postpay


relationshipsobjectRelated objects


subscriptionsobjectSubscriptions data



dataarray of objects

Related object information:

NameData typeDescription
idstringID of the object
typestringData type


paymentsobjectPayment data



dataarray of objects

Related object information:

NameData typeDescription
idstringID of the object
typestringData type


chargesobjectCharges data



dataarray of objects

Related object information:

NameData typeDescription
idstringID of the object
typestringData type


correctionsobjectCorrections data



dataarray of objects

Related object information:

NameData typeDescription
idstringID of the object
typestringData type

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 start date of the billing period billing_date does not match the specified invoice in the platform
INVOICE-0007Only postpaid invoice can be approvedThe payment model of the specified invoice is not Postpay, so the invoice cannot be approved (see Get invoice)
INVOICE-0008Only closed invoice can be approvedThe status of the specified invoice is not Closed, so the invoice cannot be approved (see Get invoice)
INVOICE-0009Only non-zero invoice can be approvedThe amount of the specified invoice is 0, so the invoice cannot be approved (see Get invoice)
422INVOICE-0003Unable to approve invoice one more timeThe invoice is already approved

Only one attribute can be present: file or linkIt is possible to specify file or link to the file but not both

Request example

POST /api/v3/resellers/1/invoices/2046/approve
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",
    "file": {
        "data": "data:application/pdf;base64,'SSBob2xkIHRoZSBwb3NpdGlvbiBvZiBhIHFhIGVuZ2luZWVyLiBRQSBlbmdpbmVlciByZXNwb25zaWJpbGl0aWVzIGluY2x1ZGUgZGVzaWduaW5nIGFuZCBpbXBsZW1lbnRpbmcgdGVzdHMsIGRlYnVnZ2luZyBhbmQgZGVmaW5pbmcgY29ycmVjdGl2ZSBhY3Rpb25zLiBJIGFsc28gcmV2aWV3IHN5c3RlbSByZXF1aXJlbWVudHMgYW5kIHRyYWNrIHF1YWxpdHkgYXNzdXJhbmNlIG1ldHJpY3MgKGUuZy4gZGVmZWN0IGRlbnNpdGllcyBhbmQgb3BlbiBkZWZlY3QgY291bnRzLikgVGhlIFFBIHRlY2huaWNpYW4gcm9sZSBwbGF5cyBhbiBpbXBvcnRhbnQgcGFydCBpbiBvdXIgY29tcGFueeKAmXMgcHJvZHVjdCBkZXZlbG9wbWVudCBwcm9jZXNzLg=='",
        "name": "Invoice NS2000015"
    }
}

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": "0.32",
            "account_id": 505,
            "from_date": "2019-04-17",
            "to_date": "2019-05-01",
            "payment_model": "postpay"
        },
        "relationships": {
            "subscriptions": {
                "data": [
                    {
                        "id": "3009839",
                        "type": "subscriptions"
                    }
                ]
            },
            "payments": {
                "data": [
                    {
                        "id": "12201",
                        "type": "payments"
                    }
                ]
            },
            "charges": {
                "data": [
                    {
                        "id": "323740",
                        "type": "charges"
                    }
                ]
            },
            "corrections": {
                "data": []
            }
        }
    }
}