Add Payment sale.payment.add
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
saleWho can execute the method: administrator
This method adds a new payment.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
fields* |
Field values (detailed description provided below) for creating a payment in the form of a structure:
|
Parameter fields
Required parameters are marked with *
|
Name |
Description |
|
orderId* |
Order identifier |
|
paySystemId* |
Payment system identifier |
|
paid |
Payment status:
Defaults to |
|
datePaid |
Payment date |
|
empPaidId |
Identifier of the user who made the payment |
|
psStatus |
Payment system status flag — whether the payment was successful. Options:
Defaults to |
|
psStatusCode |
Payment system status code |
|
psStatusDescription |
Description of the payment system's result |
|
psStatusMessage |
Message from the payment system |
|
psSum |
Payment system amount |
|
psCurrency |
Payment system currency |
|
psResponseDate |
Payment system response date |
|
payVoucherNum |
Payment document number |
|
payVoucherDate |
Payment document date |
|
datePayBefore |
Deprecated. |
|
dateBill |
Invoice date |
|
xmlId |
External identifier |
|
sum |
Payment amount |
|
companyId |
Identifier of the company that will receive the payment Currently not used |
|
payReturnNum |
Return document number |
|
priceCod |
Relevant only for on-premise version |
|
payReturnDate |
Return document date |
|
empReturnId |
Identifier of the user who processed the return |
|
payReturnComment |
Return comment |
|
responsibleId |
Identifier of the user responsible for the payment |
|
empResponsibleId |
Identifier of the user who assigned the responsible person |
|
isReturn |
Was the return processed:
Defaults to N |
|
comments |
Payment comments |
|
updated1c |
Payment updated via QuickBooks and other similar platforms:
Defaults to |
|
id1c |
Identifier in QuickBooks and other similar platforms |
|
version1c |
Payment document version from QuickBooks and other similar platforms |
|
externalPayment |
Relevant only for on-premise version
Defaults to |
|
psInvoiceId |
Payment identifier in the payment system |
|
marked |
Marking flag. Indicates whether the payment is marked as problematic:
Defaults to |
|
reasonMarked |
Reason for marking |
|
empMarkedId |
Identifier of the user who marked the payment |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"orderId":200,"paySystemId":1,"paid":"Y","datePaid":"2024-04-10T10:00:00","empPaidId":1,"psStatus":"Y","psStatusCode":"","psStatusDescription":"","psStatusMessage":"","psSum":100,"psCurrency":"USD","psResponseDate":"2024-04-10T10:00:00","payVoucherNum":"","payVoucherDate":"2024-04-10T10:00:00","datePayBefore":"2024-04-10T10:00:00","dateBill":"2024-04-10T10:00:00","xmlId":"","sum":100,"companyId":1,"payReturnNum":"","priceCod":100,"payReturnDate":"2024-04-10T10:00:00","empReturnId":1,"payReturnComment":"","responsibleId":1,"empResponsibleId":1,"isReturn":"N","comments":"","updated1c":"N","id1c":"","version1c":"","externalPayment":"N","psInvoiceId":1,"marked":"N","reasonMarked":"","empMarkedId":1}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.payment.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"orderId":200,"paySystemId":1,"paid":"Y","datePaid":"2024-04-10T10:00:00","empPaidId":1,"psStatus":"Y","psStatusCode":"","psStatusDescription":"","psStatusMessage":"","psSum":100,"psCurrency":"USD","psResponseDate":"2024-04-10T10:00:00","payVoucherNum":"","payVoucherDate":"2024-04-10T10:00:00","datePayBefore":"2024-04-10T10:00:00","dateBill":"2024-04-10T10:00:00","xmlId":"","sum":100,"companyId":1,"payReturnNum":"","priceCod":100,"payReturnDate":"2024-04-10T10:00:00","empReturnId":1,"payReturnComment":"","responsibleId":1,"empResponsibleId":1,"isReturn":"N","comments":"","updated1c":"N","id1c":"","version1c":"","externalPayment":"N","psInvoiceId":1,"marked":"N","reasonMarked":"","empMarkedId":1},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.payment.add
try
{
const response = await $b24.callMethod(
'sale.payment.add',
{
fields: {
orderId: 200,
paySystemId: 1,
paid: 'Y',
datePaid: '2024-04-10T10:00:00',
empPaidId: 1,
psStatus: 'Y',
psStatusCode: '',
psStatusDescription: '',
psStatusMessage: '',
psSum: 100,
psCurrency: 'USD',
psResponseDate: '2024-04-10T10:00:00',
payVoucherNum: '',
payVoucherDate: '2024-04-10T10:00:00',
datePayBefore: '2024-04-10T10:00:00',
dateBill: '2024-04-10T10:00:00',
xmlId: '',
sum: 100,
companyId: 1,
payReturnNum: '',
priceCod: 100,
payReturnDate: '2024-04-10T10:00:00',
empReturnId: 1,
payReturnComment: '',
responsibleId: 1,
empResponsibleId: 1,
isReturn: 'N',
comments: '',
updated1c: 'N',
id1c: '',
version1c: '',
externalPayment: 'N',
psInvoiceId: 1,
marked: 'N',
reasonMarked: '',
empMarkedId: 1,
}
}
);
const result = response.getData().result;
console.info(result);
}
catch( error )
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'sale.payment.add',
[
'fields' => [
'orderId' => 200,
'paySystemId' => 1,
'paid' => 'Y',
'datePaid' => '2024-04-10T10:00:00',
'empPaidId' => 1,
'psStatus' => 'Y',
'psStatusCode' => '',
'psStatusDescription' => '',
'psStatusMessage' => '',
'psSum' => 100,
'psCurrency' => 'USD',
'psResponseDate' => '2024-04-10T10:00:00',
'payVoucherNum' => '',
'payVoucherDate' => '2024-04-10T10:00:00',
'datePayBefore' => '2024-04-10T10:00:00',
'dateBill' => '2024-04-10T10:00:00',
'xmlId' => '',
'sum' => 100,
'companyId' => 1,
'payReturnNum' => '',
'priceCod' => 100,
'payReturnDate' => '2024-04-10T10:00:00',
'empReturnId' => 1,
'payReturnComment' => '',
'responsibleId' => 1,
'empResponsibleId' => 1,
'isReturn' => 'N',
'comments' => '',
'updated1c' => 'N',
'id1c' => '',
'version1c' => '',
'externalPayment' => 'N',
'psInvoiceId' => 1,
'marked' => 'N',
'reasonMarked' => '',
'empMarkedId' => 1,
],
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding payment: ' . $e->getMessage();
}
BX24.callMethod(
'sale.payment.add',
{
fields: {
orderId: 200,
paySystemId: 1,
paid: 'Y',
datePaid: '2024-04-10T10:00:00',
empPaidId: 1,
psStatus: 'Y',
psStatusCode: '',
psStatusDescription: '',
psStatusMessage: '',
psSum: 100,
psCurrency: 'USD',
psResponseDate: '2024-04-10T10:00:00',
payVoucherNum: '',
payVoucherDate: '2024-04-10T10:00:00',
datePayBefore: '2024-04-10T10:00:00',
dateBill: '2024-04-10T10:00:00',
xmlId: '',
sum: 100,
companyId: 1,
payReturnNum: '',
priceCod: 100,
payReturnDate: '2024-04-10T10:00:00',
empReturnId: 1,
payReturnComment: '',
responsibleId: 1,
empResponsibleId: 1,
isReturn: 'N',
comments: '',
updated1c: 'N',
id1c: '',
version1c: '',
externalPayment: 'N',
psInvoiceId: 1,
marked: 'N',
reasonMarked: '',
empMarkedId: 1,
}
},
function(result) {
if (result.error()) {
console.error(result.error());
} else {
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'sale.payment.add',
[
'fields' => [
'orderId' => 200,
'paySystemId' => 1,
'paid' => 'Y',
'datePaid' => '2024-04-10T10:00:00',
'empPaidId' => 1,
'psStatus' => 'Y',
'psStatusCode' => '',
'psStatusDescription' => '',
'psStatusMessage' => '',
'psSum' => 100,
'psCurrency' => 'USD',
'psResponseDate' => '2024-04-10T10:00:00',
'payVoucherNum' => '',
'payVoucherDate' => '2024-04-10T10:00:00',
'datePayBefore' => '2024-04-10T10:00:00',
'dateBill' => '2024-04-10T10:00:00',
'xmlId' => '',
'sum' => 100,
'companyId' => 1,
'payReturnNum' => '',
'priceCod' => 100,
'payReturnDate' => '2024-04-10T10:00:00',
'empReturnId' => 1,
'payReturnComment' => '',
'responsibleId' => 1,
'empResponsibleId' => 1,
'isReturn' => 'N',
'comments' => '',
'updated1c' => 'N',
'id1c' => '',
'version1c' => '',
'externalPayment' => 'N',
'psInvoiceId' => 1,
'marked' => 'N',
'reasonMarked' => '',
'empMarkedId' => 1,
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": {
"payment": {
"accountNumber": "356\/1",
"comments": "",
"companyId": 1,
"currency": "USD",
"dateBill": "2024-04-10T09:00:00+02:00",
"dateMarked": "2024-04-16T16:32:49+02:00",
"datePaid": "2024-04-10T09:00:00+02:00",
"datePayBefore": "2024-04-10T09:00:00+02:00",
"dateResponsibleId": "2024-04-16T16:32:49+02:00",
"empMarkedId": 1,
"empPaidId": 1,
"empResponsibleId": 1,
"empReturnId": 1,
"externalPayment": "N",
"id": 144,
"id1c": "",
"isReturn": "N",
"marked": "N",
"orderId": 200,
"paid": "Y",
"payReturnComment": "",
"payReturnDate": "2024-04-10T09:00:00+02:00",
"payReturnNum": "",
"paySystemId": 1,
"paySystemIsCash": "N",
"paySystemName": "Bank Transfer (Company)",
"paySystemXmlId": "",
"payVoucherDate": "2024-04-10T09:00:00+02:00",
"payVoucherNum": "",
"priceCod": "100",
"psCurrency": "USD",
"psInvoiceId": 1,
"psResponseDate": "2024-04-10T09:00:00+02:00",
"psStatus": "Y",
"psStatusCode": "",
"psStatusDescription": "",
"psStatusMessage": "",
"psSum": 100,
"reasonMarked": "",
"responsibleId": 1,
"sum": 100,
"updated1c": "N",
"version1c": "",
"xmlId": ""
}
},
"time": {
"start": 1713277968.822151,
"finish": 1713277972.577136,
"duration": 3.7549850940704346,
"processing": 3.3574018478393555,
"date_start": "2024-04-16T17:32:48+02:00",
"date_finish": "2024-04-16T17:32:52+02:00"
}
}
Returned Data
|
Name |
Description |
|
result |
Root element of the response |
|
payment |
Object with information about the added payment |
|
time |
Information about the request execution time |
Error Handling
HTTP status: 400
{
"error":200040300020,
"error_description":"Access Denied"
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
|
|
Insufficient rights to add payment |
|
|
Parameter |
|
|
Required fields are not provided |
|
|
Other errors (e.g., fatal errors) |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred. Please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not permitted for calls using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The HTTPS protocol is required for method calls |
|
|
|
The REST API is blocked due to overload. This is a manual individual block; please contact Bitrix24 technical support to lift it |
|
|
|
The REST API is only available on commercial plans |
|
|
|
The user associated with the access token or webhook used to call the method lacks the necessary permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the portal administrator has restricted access to this application to specific users only |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the "Temporary closure of the public part of the site" option. Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Payments in the Online Store: Overview of Methods
- Update Payment sale.payment.update
- Get Payment by Id sale.payment.get
- Get the list of payments sale.payment.list
- Delete Payment sale.payment.delete
- Get Payment Fields sale.payment.getFields