Invoice

Generates an invoice in HTML format.

Specify the shared accounts and payment amounts when calling this action. The action returns the URL of the invoice. Only the user who the method was called on behalf of can access the invoice (the user must log in on Yandex).

Recommendations and restrictions

We recommend generating invoices using as few calls of AccountManagement.Invoice per day as possible. This recommendation is aimed at increasing the productivity of the Yandex.Direct API. From the point of view of productivity, it is better to create several invoices in a single operation than to use multiple operations to generate each invoice separately.

Input data

The input data structure in JSON is shown below.

Attention. It is mandatory to include the finance_token and operation_num parameters in the request. For information on generating the token, see the section Working with the shared account.
{
   "method": "AccountManagement",
   "finance_token": (string),
   "operation_num": (int),
   "param": {
      /* AccountManagementRequest */
      "Action": (string),
      "Payments": [
         {  /* Payment */
            "AccountID": (int),
            "Amount": (float),
            "Currency": (string)
         }
         ...
      ]
   }
}

Parameters are described below.

Parameter Description Required
AccountManagementRequest object
Action Action: Invoice. Yes
Payments Array of Payment objects (no more than 50). Each object contains the ID of the shared account and the payment amount. Yes
Payment object
AccountID ID of the shared account to add funds to. Yes
Amount

The invoice amount in the currency specified in the Currency parameter. The value in a real currency should include the client's VAT.

Before creating an invoice, the specified amount is rounded mathematically to the second decimal point (for all currencies, including the tenge).

To get the minimum acceptable value, use the Dictionaries.get method for version 5 of the API and specify the dictionary name Currencies in the request.

Yes
Currency

The currency that the amount is shown in.

Acceptable values: RUB, CHF, EUR, KZT, TRY, UAH, USD, BYN. The value must match the currency of the shared account; otherwise, an error is returned with code 245.

Yes

Output data

The output data structure in JSON is shown below.

Attention. An error when generating one of the invoices does not cause the entire operation to be canceled, and does not affect the success of generating the other invoices.
{
   "data": {
      /* AccountManagementResponse */
      "ActionsResult": [
         {  /* AccountActionResult */
            "URL": (string),
            "Errors": [
               {  /* Error */
                  "FaultCode": (int),
                  "FaultString": (string),
                  "FaultDetail": (string)
               }
               ...
            ]
         }
         ...
      ]
   }
}

Parameters are described below.

Parameter Description
AccountManagementResponse object
ActionsResult

Array of AccountActionResult objects Each object corresponds to an item in the Payments input array and contains:

  • The URL of the invoice, if the invoice was created successfully.
  • The Errors array, if an error occurred.

The items in the array are in the same order as the objects in the Payments input array.

AccountActionResult object
URL URL of the invoice.
Errors Array of Error objects with errors that occurred while adding funds to the account.
Error object
FaultCode Error code.
FaultString Textual message about the error.
FaultDetail Detailed description of the reason for the error.

Examples of input data

Python

{
   'Action': 'Invoice',
   'Payments': [
      {
         'AccountID': 3193244,
         'Amount': 5000.0,
         'Currency': 'RUB'
      }
   ]
}

PHP

array(
   'Action' => 'Invoice',
   'Payments' => array(
      array(
         'AccountID' => 3193244,
         'Amount' => 5000.0,
         'Currency' => 'RUB'
      )
   )
)

Perl

{
   'Action' => 'Invoice',
   'Payments' => [
      {
         'AccountID' => 3193244,
         'Amount' => 5000.0,
         'Currency' => 'RUB'
      }
   ]
}