PayCampaigns (Live)

Paying for campaigns using an advertising agency's credit limit, or the advertiser's overdraft.

This method allows advertising agencies and direct advertisers to add funds to the campaign balance with deferred payment (see Paying by credit and overdraft).

Attention.

Direct advertisers can pay for a campaign only when it has been approved by a moderator (see the campaign parameter StatusModerate).

Recommendations and restrictions

Attention. All campaigns specified in the same method call must be of the same type. More information about campaign types

We recommend paying for campaigns using as few calls of the PayCampaign method per day as possible. This recommendation is aimed at improving the performance of the Yandex Direct API. In terms of productivity, it is better to pay for several campaigns at once using a single method call than to make multiple calls to pay for each campaign individually.

Restrictions on method calls:

Exceeding these limits results in the error 56.

Currency restrictions

Attention. There is no provision for paying for multiple campaigns in different currencies using a single method call.

All campaigns specified in the same method call must be in the same currency.

Payment amounts (the Sum parameter) should be specified in the campaign currency (by setting the corresponding value for the Currency parameter). All amounts must be specified in the same currency.

New in the Live 4 version

The Currency input parameter is required.

Added the “Overdraft” payment method (the PayMethod parameter).

Added the Currency input parameter.

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 more information, see the Accessing finance methods.
{
   "method": "PayCampaigns",
   "finance_token": (string),
   "operation_num": (int),
   "param": {
      /* PayCampaignsInfo */
      "Payments": [
         {  /* PayCampElement */
            "CampaignID": (int),
            "Sum": (float),
            "Currency": (string)
         }
         ...
      ],
      "ContractID": (string),
      "PayMethod": (string)
   }
}

Parameters are described below.

Parameter Description Required
PayCampaignsInfo object
Payments Array of PayCampElement objects. Each object indicates the campaign and payment amount. Yes
ContractID The number of the credit agreement. For advertising agencies
PayMethod

Campaign payment method:

  • Bank — Payment by credit (for advertising agencies).
  • Overdraft — Payment by overdraft (for direct advertisers).

Yes
PayCampElement object
CampaignID The campaign ID. Yes
Sum

The payment amount in the currency specified in the Currency parameter. When creating an invoice, the amount is rounded mathematically to the second decimal place (for all currencies, including the tenge).

The value in the real currency must include the client's VAT.

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 campaign currency; otherwise, an error is returned with code 245.

Yes
Parameter Description Required
PayCampaignsInfo object
Payments Array of PayCampElement objects. Each object indicates the campaign and payment amount. Yes
ContractID The number of the credit agreement. For advertising agencies
PayMethod

Campaign payment method:

  • Bank — Payment by credit (for advertising agencies).
  • Overdraft — Payment by overdraft (for direct advertisers).

Yes
PayCampElement object
CampaignID The campaign ID. Yes
Sum

The payment amount in the currency specified in the Currency parameter. When creating an invoice, the amount is rounded mathematically to the second decimal place (for all currencies, including the tenge).

The value in the real currency must include the client's VAT.

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 campaign currency; otherwise, an error is returned with code 245.

Yes

Output data

Returns 1 if successful, as shown in the following example.

{
   "data": 1
}

For an invalid request, possible error codes are 245, 355, 356, 357, 363, and 364.

Examples of input data

Python

{
   'Payments': [
      {'CampaignID': 3193279, 'Sum': 50000.0, 'Currency': 'RUB'},
      {'CampaignID': 3193244, 'Sum': 1200.0, 'Currency': 'RUB'}
   ],
   'ContractID': '23452345/67',
   'PayMethod': 'Bank'
}

PHP

array(
   'Payments' => array(
      array('CampaignID' => 3193279, 'Sum' => 50000.0, 'Currency' => 'RUB'),
      array('CampaignID' => 3193244, 'Sum' => 1200.0, 'Currency' => 'RUB')
   ),
   'ContractID' => '23452345/67',
   'PayMethod' => 'Bank'
)

Perl

{
   'Payments' => [
      {'CampaignID' => 3193279, 'Sum' => 50000.0, 'Currency' => 'RUB'},
      {'CampaignID' => 3193279, 'Sum' => 1200.0, 'Currency' => 'RUB'}
   ],
   'ContractID' => '23452345/67',
   'PayMethod' => 'Bank'
}