Add Payment sale.payment.add
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
Scope:
saleWho can execute the method: administrator
The method sale.payment.add 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>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
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,
}
try:
bitrix_response = client.sale.payment.add(
fields=fields,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Bitrix API error",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Bitrix SDK error: {error.message}")
except Exception as error:
print(f"Unexpected 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>';
// client and ctx are already created — see the Go SDK section
res, err := client.Core().Call(ctx, "sale.payment.add", b24.Params{
"fields": b24.Params{
"orderId": 200,
"paySystemId": 1,
"paid": "Y",
"datePaid": "2024-04-10T10:00:00",
"empPaidId": 1,
"psStatus": "Y",
"psStatusCode": "",
"psStatusDescription": "",
"psStatusMessage": "",
"psSum": 100,
"psCurrency": "EUR",
"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,
},
})
if err != nil {
return fmt.Errorf("sale.payment.add: %w", err)
}
// The method wraps the response in an object with the "payment" key.
raw, ok := b24.Unwrap(res.Result, "payment")
if !ok {
return fmt.Errorf("no payment key in the response")
}
var item struct {
AccountNumber string `json:"accountNumber"`
Comments string `json:"comments"`
CompanyID b24.ID `json:"companyId"`
Currency string `json:"currency"`
DateBill string `json:"dateBill"`
DateMarked string `json:"dateMarked"`
}
if err := json.Unmarshal(raw, &item); err != nil {
return fmt.Errorf("parse response: %w", err)
}
fmt.Println(item.AccountNumber, item.Comments)
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 consists of digits, Latin letters, and underscores. It may arrive empty — in that case only |
|
error_description |
Error message for the developer. Do not show it to the end user without processing |
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: 4xx, 5xx
The errors described below are returned by the REST API itself, not by the logic of a specific method. They can arrive in response to any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The server returned an unexpected response. Retry the call, and if the error persists, contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The method is blocked because the request resource intensity limit has been exceeded. The block is lifted automatically once the accumulated execution time of the method no longer exceeds the limit |
|
|
|
The request contains no authorization data: neither an access token nor a webhook code was passed |
|
|
|
Methods are called over the HTTPS protocol only |
|
|
|
The REST API is blocked due to overload. This is a manual individual block. To have it lifted, contact Bitrix24 technical support |
|
|
|
REST API access is not active for this account. In Bitrix24 Cloud, check the current plan or trial status: Vibe+ plans include REST API access, while Essentials plans do not. A webhook receives a different error message — |
|
|
|
No active webhook with the specified user identifier and secret code was found |
|
|
|
No method with this name was found. The name is misspelled, the method does not exist in the REST API, or it is unavailable without the required scope |
|
|
|
The request requires broader permissions than the token has: for a webhook these are the permissions granted to it, for an application it is the scope. For an application, the error message ends with |
|
|
|
The access token has expired |
|
|
|
The application is installed, but the Bitrix24 administrator has granted access to it only to specific users |
|
|
|
The public part of the site is closed. To open it 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 |