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
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame, ISODate } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type PaymentAddResult = {
payment: {
accountNumber: string
comments: string
companyId: number
currency: string
dateBill: ISODate | null
dateMarked: ISODate | null
datePaid: ISODate | null
datePayBefore: ISODate | null
dateResponsibleId: ISODate | null
empMarkedId: number
empPaidId: number
empResponsibleId: number
empReturnId: number
externalPayment: string
id: number
id1c: string
isReturn: string
marked: string
orderId: number
paid: string
payReturnComment: string
payReturnDate: ISODate | null
payReturnNum: string
paySystemId: number
paySystemIsCash: string
paySystemName: string
paySystemXmlId: string
payVoucherDate: ISODate | null
payVoucherNum: string
priceCod: string
psCurrency: string
psInvoiceId: number
psResponseDate: ISODate | null
psStatus: string
psStatusCode: string
psStatusDescription: string
psStatusMessage: string
psSum: number
reasonMarked: string
responsibleId: number
sum: number
updated1c: string
version1c: string
xmlId: string
}
}
try {
const response = await $b24.actions.v2.call.make<PaymentAddResult>({
method: 'sale.payment.add',
params: {
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,
},
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Added payment id:', result.payment.id, 'order:', result.payment.orderId)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function addPayment() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'sale.payment.add',
params: {
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,
},
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Added payment id:', result.payment.id, 'order:', result.payment.orderId)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', addPayment)
</script>
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 |