Add REST Handler for Payment System sale.paysystem.handler.add
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so the assistant can use the official REST documentation.
Scope:
pay_systemWho can execute the method: CRM administrator (permission "Allow changing settings")
This method adds a REST handler for the payment system.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
NAME* |
Name of the REST handler |
|
SORT |
Sorting order. Default is |
|
CODE* |
Code of the REST handler. Must be unique among all handlers |
|
SETTINGS* |
Handler settings (detailed description provided below) |
SETTINGS Parameter
Required parameters are marked with *
Depending on the operating mode used, at least one of the following parameters must be present: FORM_DATA, CHECKOUT_DATA, IFRAME_DATA.
|
Name |
Description |
|
CODES* |
List of handler parameters. Keys are parameter codes ( Parameter values will be available to the administrator for filling in the settings of the created payment system. They can be specified when adding the payment system in the method sale.paysystem.add in the |
|
FORM_DATA |
Form settings when using the operating mode in form |
|
CHECKOUT_DATA |
Settings for the Checkout mode (creating an order on the service side and redirecting the buyer to this page for payment) |
|
IFRAME_DATA |
Settings for the page displayed in the iframe on the seller's site on the payment page |
|
CLIENT_TYPE |
Type of buyers that the handler can work with. Available values:
Default value is |
|
CURRENCY |
List of currencies supported by the payment system. Default is empty |
CODES Parameter
|
Name |
Description |
|
NAME |
Name of the parameter |
|
DESCRIPTION |
Description of the parameter |
|
SORT |
Sorting order |
|
GROUP |
Code of the group to which the parameter belongs |
|
DEFAULT |
Description of the default value (detailed description provided below) |
|
INPUT |
Object describing the input field. The structure of the object contains the
|
DEFAULT Parameter
|
Name |
Description |
|
PROVIDER_KEY |
Key of the provider from which the default value will be taken. Possible key values are listed below |
|
PROVIDER_VALUE |
Code of the value that will be taken from the provider. Possible key values are listed below |
Possible Values for PROVIDER_KEY
|
Name |
Description |
|
ORDER |
Order |
|
PROPERTY |
Invoice properties |
|
PAYMENT |
Payment |
|
USER |
User |
|
VALUE |
Arbitrary string type value |
|
Y\N |
Checkbox |
Possible Values for PROVIDER_VALUE
|
Name |
Description |
|
ORDER |
|
|
PAYMENT |
|
|
USER |
|
Form Operating Mode
When adding a handler, the FORM_DATA parameter must be passed. This method is suitable if no information needs to be requested from the buyer or if only a small set of data needs to be requested.
Form fields are automatically displayed according to the design of the payment page.
Form data (the FIELDS values from FORM_DATA) will be sent to ACTION_URI. In addition to the data defined in FORM_DATA, two system keys will also be sent with the form:
|
Name |
Description |
|
BX_PAYSYSTEM_ID |
Identifier of the payment system through which the payment is made. Can be used to call the payment method sale.paysystem.pay.payment |
|
BX_RETURN_URL |
URL of the store site to which the user will be redirected |
Parameters Passed When Adding a Handler in the FORM_DATA Array
Required parameters are marked with *
|
Name |
Description |
|
ACTION_URI* |
URL to which the form is sent |
|
METHOD |
HTTP method used when submitting the form. Default is empty, in which case the GET method is used |
|
FIELDS |
Description of form fields (detailed description provided below) |
|
PARAMS |
Description of form fields. This parameter is deprecated; it is recommended to use the Represents a mapping between field names in the form ( Fields are added to the form as If both |
FIELDS Parameter
Required parameters are marked with *
Represents an array of descriptions of fields displayed in the form and sent to ACTION_URI. The key is the field code used as the field name in the form. The values are the field parameter objects.
|
Name |
Description |
|
|
CODE* |
|
If the value of the If an |
|
VISIBLE |
Whether the field is displayed in the form for input. Available values:
Default value is |
CODE Parameter
|
Name |
Description |
|
NAME |
Name of the field |
|
INPUT |
Description of the input field. Contains the
|
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest FORM","CODE":"resthandlerform","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","FORM_DATA":{"ACTION_URI":"http://example.com/payment_form.php","METHOD":"POST","FIELDS":{"phone":{"VISIBLE":"Y","CODE":{"NAME":"Phone Number","TYPE":"STRING"}},"selection":{"VISIBLE":"Y","CODE":{"NAME":"Illusion of Choice","INPUT":{"TYPE":"Y/N"}}},"paymentId":{"CODE":"PAYMENT_ID","VISIBLE":"Y"},"serviceid":{"CODE":"REST_SERVICE_ID"}}},"CODES":{"REST_SERVICE_ID":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PAYMENT_ID":{"NAME":"Payment Number","SORT":"400","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"PAYMENT","PROVIDER_VALUE":"ACCOUNT_NUMBER"}},"PAYMENT_SHOULD_PAY":{"NAME":"Payment Amount","SORT":"600","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"PAYMENT","PROVIDER_VALUE":"SUM"}},"PS_CHANGE_STATUS_PAY":{"NAME":"Automatic Payment Status Change","SORT":"700","INPUT":{"TYPE":"Y/N"}},"PAYMENT_BUYER_ID":{"NAME":"Buyer Code","SORT":"1000","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"ORDER","PROVIDER_VALUE":"USER_ID"}},"PS_WORK_MODE":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.paysystem.handler.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest FORM","CODE":"resthandlerform","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","FORM_DATA":{"ACTION_URI":"http://example.com/payment_form.php","METHOD":"POST","FIELDS":{"phone":{"VISIBLE":"Y","CODE":{"NAME":"Phone Number","TYPE":"STRING"}},"selection":{"VISIBLE":"Y","CODE":{"NAME":"Illusion of Choice","INPUT":{"TYPE":"Y/N"}}},"paymentId":{"CODE":"PAYMENT_ID","VISIBLE":"Y"},"serviceid":{"CODE":"REST_SERVICE_ID"}}},"CODES":{"REST_SERVICE_ID":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PAYMENT_ID":{"NAME":"Payment Number","SORT":"400","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"PAYMENT","PROVIDER_VALUE":"ACCOUNT_NUMBER"}},"PAYMENT_SHOULD_PAY":{"NAME":"Payment Amount","SORT":"600","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"PAYMENT","PROVIDER_VALUE":"SUM"}},"PS_CHANGE_STATUS_PAY":{"NAME":"Automatic Payment Status Change","SORT":"700","INPUT":{"TYPE":"Y/N"}},"PAYMENT_BUYER_ID":{"NAME":"Buyer Code","SORT":"1000","GROUP":"PAYMENT","DEFAULT":{"PROVIDER_KEY":"ORDER","PROVIDER_VALUE":"USER_ID"}},"PS_WORK_MODE":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.paysystem.handler.add
try
{
const response = await $b24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest FORM",
"CODE": "resthandlerform",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"FORM_DATA": {
"ACTION_URI": "http://example.com/payment_form.php",
"METHOD": "POST",
"FIELDS": {
"phone": {
"VISIBLE": "Y",
"CODE": {
"NAME": "Phone Number",
"TYPE": "STRING"
}
},
"selection": {
"VISIBLE": "Y",
"CODE": {
"NAME": "Illusion of Choice",
"INPUT": {
"TYPE": "Y/N"
}
}
},
"paymentId": {
"CODE": "PAYMENT_ID",
"VISIBLE": "Y"
},
"serviceid": {
"CODE": "REST_SERVICE_ID"
}
}
},
"CODES": {
"REST_SERVICE_ID": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PAYMENT_ID": {
"NAME": "Payment Number",
"SORT": "400",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "PAYMENT",
"PROVIDER_VALUE": "ACCOUNT_NUMBER"
}
},
"PAYMENT_SHOULD_PAY": {
"NAME": "Payment Amount",
"SORT": "600",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "PAYMENT",
"PROVIDER_VALUE": "SUM"
}
},
"PS_CHANGE_STATUS_PAY": {
"NAME": "Automatic Payment Status Change",
"SORT": "700",
"INPUT": {
"TYPE": "Y/N"
}
},
"PAYMENT_BUYER_ID": {
"NAME": "Buyer Code",
"SORT": "1000",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "ORDER",
"PROVIDER_VALUE": "USER_ID"
}
},
"PS_WORK_MODE": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
);
const result = response.getData().result;
console.info(result);
}
catch(error)
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest FORM',
'CODE' => 'resthandlerform',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'FORM_DATA' => [
'ACTION_URI' => 'http://example.com/payment_form.php',
'METHOD' => 'POST',
'FIELDS' => [
'phone' => [
'VISIBLE' => 'Y',
'CODE' => [
'NAME' => 'Phone Number',
'TYPE' => 'STRING',
],
],
'selection' => [
'VISIBLE' => 'Y',
'CODE' => [
'NAME' => 'Illusion of Choice',
'INPUT' => [
'TYPE' => 'Y/N',
],
],
],
'paymentId' => [
'CODE' => 'PAYMENT_ID',
'VISIBLE' => 'Y',
],
'serviceid' => [
'CODE' => 'REST_SERVICE_ID',
],
],
],
'CODES' => [
'REST_SERVICE_ID' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100',
],
'REST_SERVICE_KEY' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300',
],
'PAYMENT_ID' => [
'NAME' => 'Payment Number',
'SORT' => '400',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'PAYMENT',
'PROVIDER_VALUE' => 'ACCOUNT_NUMBER',
],
],
'PAYMENT_SHOULD_PAY' => [
'NAME' => 'Payment Amount',
'SORT' => '600',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'PAYMENT',
'PROVIDER_VALUE' => 'SUM',
],
],
'PS_CHANGE_STATUS_PAY' => [
'NAME' => 'Automatic Payment Status Change',
'SORT' => '700',
'INPUT' => [
'TYPE' => 'Y/N',
],
],
'PAYMENT_BUYER_ID' => [
'NAME' => 'Buyer Code',
'SORT' => '1000',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'ORDER',
'PROVIDER_VALUE' => 'USER_ID',
],
],
'PS_WORK_MODE' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live',
],
],
],
],
],
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding payment system handler: ' . $e->getMessage();
}
BX24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest FORM",
"CODE": "resthandlerform",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"FORM_DATA": {
"ACTION_URI": "http://example.com/payment_form.php",
"METHOD": "POST",
"FIELDS": {
"phone": {
"VISIBLE": "Y",
"CODE": {
"NAME": "Phone Number",
"TYPE": "STRING"
}
},
"selection": {
"VISIBLE": "Y",
"CODE": {
"NAME": "Illusion of Choice",
"INPUT": {
"TYPE": "Y/N"
}
}
},
"paymentId": {
"CODE": "PAYMENT_ID",
"VISIBLE": "Y"
},
"serviceid": {
"CODE": "REST_SERVICE_ID"
}
}
},
"CODES": {
"REST_SERVICE_ID": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PAYMENT_ID": {
"NAME": "Payment Number",
"SORT": "400",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "PAYMENT",
"PROVIDER_VALUE": "ACCOUNT_NUMBER"
}
},
"PAYMENT_SHOULD_PAY": {
"NAME": "Payment Amount",
"SORT": "600",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "PAYMENT",
"PROVIDER_VALUE": "SUM"
}
},
"PS_CHANGE_STATUS_PAY": {
"NAME": "Automatic Payment Status Change",
"SORT": "700",
"INPUT": {
"TYPE": "Y/N"
}
},
"PAYMENT_BUYER_ID": {
"NAME": "Buyer Code",
"SORT": "1000",
"GROUP": "PAYMENT",
"DEFAULT": {
"PROVIDER_KEY": "ORDER",
"PROVIDER_VALUE": "USER_ID"
}
},
"PS_WORK_MODE": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
,
function (result) {
if (result.error())
{
console.error(result.error());
}
else
{
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest FORM',
'CODE' => 'resthandlerform',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'FORM_DATA' => [
'ACTION_URI' => 'http://example.com/payment_form.php',
'METHOD' => 'POST',
'FIELDS' => [
'phone' => [
'VISIBLE' => 'Y',
'CODE' => [
'NAME' => 'Phone Number',
'TYPE' => 'STRING'
]
],
'selection' => [
'VISIBLE' => 'Y',
'CODE' => [
'NAME' => 'Illusion of Choice',
'INPUT' => [
'TYPE' => 'Y/N'
]
]
],
'paymentId' => [
'CODE' => 'PAYMENT_ID',
'VISIBLE' => 'Y'
],
'serviceid' => [
'CODE' => 'REST_SERVICE_ID'
]
]
],
'CODES' => [
'REST_SERVICE_ID' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100'
],
'REST_SERVICE_KEY' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300'
],
'PAYMENT_ID' => [
'NAME' => 'Payment Number',
'SORT' => '400',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'PAYMENT',
'PROVIDER_VALUE' => 'ACCOUNT_NUMBER'
]
],
'PAYMENT_SHOULD_PAY' => [
'NAME' => 'Payment Amount',
'SORT' => '600',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'PAYMENT',
'PROVIDER_VALUE' => 'SUM'
]
],
'PS_CHANGE_STATUS_PAY' => [
'NAME' => 'Automatic Payment Status Change',
'SORT' => '700',
'INPUT' => [
'TYPE' => 'Y/N'
]
],
'PAYMENT_BUYER_ID' => [
'NAME' => 'Buyer Code',
'SORT' => '1000',
'GROUP' => 'PAYMENT',
'DEFAULT' => [
'PROVIDER_KEY' => 'ORDER',
'PROVIDER_VALUE' => 'USER_ID'
]
],
'PS_WORK_MODE' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live'
]
]
]
]
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Checkout Operating Mode
When adding a handler, the CHECKOUT_DATA must be passed in the SETTINGS parameter.
A script that will process the received data, create the payment, and return the identifier of the created payment and the URL of the payment page must be located at the address specified in ACTION_URI.
Data for payment will be sent to ACTION_URI in the form of an array. It contains an array of system parameters under the key BX_SYSTEM_PARAMS and the values of FIELDS from CHECKOUT_DATA, each as a separate key at the top level of the array.
Structure of the BX_SYSTEM_PARAMS array:
|
Name |
Description |
|
RETURN_URL |
Current page |
|
PAYSYSTEM_ID |
Identifier of the payment system |
|
PAYMENT_ID |
Identifier of the payment |
|
SUM |
Payment amount |
|
CURRENCY |
Currency |
|
EXTERNAL_PAYMENT_ID |
Identifier of the payment in the payment system (if any). For example, if a request for the current payment has already been sent to |
In response to a request to ACTION_URI, the script must return the identifier of the created payment and the URL of the payment page.
|
Name |
Description |
|
PAYMENT_URL |
URL of the payment page |
|
PAYMENT_ID |
Identifier of the payment in the payment system |
The buyer will be redirected to the link from PAYMENT_URL automatically or by clicking the "Buy" button. If fields intended for filling through the form are passed among others in FIELDS, a form will be displayed to the buyer.
As a result, an array of errors can be returned under the key PAYMENT_ERRORS. The manager will see the errors in the timeline or on the payment page (depending on the template used).
|
Name |
Description |
|
PAYMENT_ERRORS |
List of errors that occurred during payment creation |
If nothing is returned, the default error Error registering order in payment system will be used.
Parameters Passed When Adding a Handler in the CHECKOUT_DATA Array
Required parameters are marked with *
|
Name |
Description |
|
ACTION_URI* |
URL to which the request for payment creation is sent |
|
FIELDS |
Description of fields sent to |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest CHECKOUT","CODE":"resthandlercheckout","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","CHECKOUT_DATA":{"ACTION_URI":"http://example.com/payment_checkout.php","FIELDS":{"serviceKey":{"CODE":"REST_SERVICE_KEY_CHECKOUT"},"serviceid":{"CODE":"REST_SERVICE_ID_CHECKOUT"}}},"CODES":{"REST_SERVICE_ID_CHECKOUT":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY_CHECKOUT":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PS_WORK_MODE_CHECKOUT":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.paysystem.handler.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest CHECKOUT","CODE":"resthandlercheckout","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","CHECKOUT_DATA":{"ACTION_URI":"http://example.com/payment_checkout.php","FIELDS":{"serviceKey":{"CODE":"REST_SERVICE_KEY_CHECKOUT"},"serviceid":{"CODE":"REST_SERVICE_ID_CHECKOUT"}}},"CODES":{"REST_SERVICE_ID_CHECKOUT":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY_CHECKOUT":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PS_WORK_MODE_CHECKOUT":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.paysystem.handler.add
try
{
const response = await $b24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest CHECKOUT",
"CODE": "resthandlercheckout",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"CHECKOUT_DATA": {
"ACTION_URI": "http://example.com/payment_checkout.php",
"FIELDS": {
"serviceKey": {
"CODE": "REST_SERVICE_KEY_CHECKOUT",
},
"serviceid": {
"CODE": "REST_SERVICE_ID_CHECKOUT"
}
}
},
"CODES": {
"REST_SERVICE_ID_CHECKOUT": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY_CHECKOUT": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PS_WORK_MODE_CHECKOUT": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
);
const result = response.getData().result;
console.info("Handler added with ID " + result);
}
catch( error )
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest CHECKOUT',
'CODE' => 'resthandlercheckout',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'CHECKOUT_DATA' => [
'ACTION_URI' => 'http://example.com/payment_checkout.php',
'FIELDS' => [
'serviceKey' => [
'CODE' => 'REST_SERVICE_KEY_CHECKOUT',
],
'serviceid' => [
'CODE' => 'REST_SERVICE_ID_CHECKOUT'
]
]
],
'CODES' => [
'REST_SERVICE_ID_CHECKOUT' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100'
],
'REST_SERVICE_KEY_CHECKOUT' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300'
],
'PS_WORK_MODE_CHECKOUT' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live'
]
]
]
]
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Handler added with ID ' . $result;
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding payment system handler: ' . $e->getMessage();
}
BX24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest CHECKOUT",
"CODE": "resthandlercheckout",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"CHECKOUT_DATA": {
"ACTION_URI": "http://example.com/payment_checkout.php",
"FIELDS": {
"serviceKey": {
"CODE": "REST_SERVICE_KEY_CHECKOUT",
},
"serviceid": {
"CODE": "REST_SERVICE_ID_CHECKOUT"
}
}
},
"CODES": {
"REST_SERVICE_ID_CHECKOUT": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY_CHECKOUT": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PS_WORK_MODE_CHECKOUT": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
,
function (result) {
if (result.error())
{
console.error(result.error());
}
else
{
console.info("Handler added with ID " + result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest CHECKOUT',
'CODE' => 'resthandlercheckout',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'CHECKOUT_DATA' => [
'ACTION_URI' => 'http://example.com/payment_checkout.php',
'FIELDS' => [
'serviceKey' => [
'CODE' => 'REST_SERVICE_KEY_CHECKOUT',
],
'serviceid' => [
'CODE' => 'REST_SERVICE_ID_CHECKOUT'
]
]
],
'CODES' => [
'REST_SERVICE_ID_CHECKOUT' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100'
],
'REST_SERVICE_KEY_CHECKOUT' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300'
],
'PS_WORK_MODE_CHECKOUT' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live'
]
]
]
]
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
IFrame Operating Mode
When adding a handler, the IFRAME_DATA must be passed in the SETTINGS parameter.
A page that will be loaded in an iframe on the seller's site must be located at the address specified in ACTION_URI.
When loading the iframe via the Window.postMessage() method, the values of FIELDS from IFRAME_DATA will be sent to ACTION_URI (each as a separate key at the top level of the array), as well as the following data:
|
Name |
Description |
|
BX_SYSTEM_PARAMS |
System parameters |
|
BX_COMPUTED_STYLE |
Styles of the parent iframe element obtained via the window.getComputedStyle() method |
Data sent in BX_SYSTEM_PARAMS:
|
Name |
Description |
|
RETURN_URL |
Current page |
|
PAYSYSTEM_ID |
Identifier of the payment system |
|
PAYMENT_ID |
Identifier of the payment |
|
SUM |
Payment amount |
|
CURRENCY |
Currency |
You can get values in the iframe through the message event handler, for example:
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener("message", function (event) {
// receiving data from the site (from the payment system)
var paymentData = event.data;
// working with BX_SYSTEM_PARAMS
if (paymentData.BX_SYSTEM_PARAMS)
{
// ...
}
// using site styles
if (paymentData.BX_COMPUTED_STYLE)
{
document.body.style.background = paymentData.BX_COMPUTED_STYLE.background;
document.body.style.color = paymentData.BX_COMPUTED_STYLE.color;
}
}, false);
});
By default, the width of the iframe is 100% of the parent element, and the height is 350px.
The dimensions of the iframe can be changed. To do this, the height and/or width must be sent from the iframe to the seller's site. For example:
document.addEventListener("DOMContentLoaded", function() {
var size = {
width: document.body.scrollWidth,
height: document.body.scrollHeight
};
// sending data to the seller's site
parent.postMessage(size, "*");
});
width and height are reserved variable names, and only they are processed on the seller's site.
Parameters Passed When Adding a Handler in the IFRAME_DATA Array
Required parameters are marked with *
|
Name |
Description |
|
ACTION_URI* |
URL of the page that will be displayed in the iframe |
|
FIELDS |
Description of fields sent to the |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest IFrame","CODE":"resthandleriframe","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","IFRAME_DATA":{"ACTION_URI":"http://example.com/payment_iframe.php","FIELDS":{"serviceKey":{"CODE":"REST_SERVICE_KEY_IFRAME"},"serviceid":{"CODE":"REST_SERVICE_ID_IFRAME"}}},"CODES":{"REST_SERVICE_ID_IFRAME":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY_IFRAME":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PS_WORK_MODE_IFRAME":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.paysystem.handler.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"NAME":"Handler.Rest IFrame","CODE":"resthandleriframe","SORT":100,"SETTINGS":{"CURRENCY":["RUB"],"CLIENT_TYPE":"b2c","IFRAME_DATA":{"ACTION_URI":"http://example.com/payment_iframe.php","FIELDS":{"serviceKey":{"CODE":"REST_SERVICE_KEY_IFRAME"},"serviceid":{"CODE":"REST_SERVICE_ID_IFRAME"}}},"CODES":{"REST_SERVICE_ID_IFRAME":{"NAME":"Store Number","DESCRIPTION":"Store Number","SORT":"100"},"REST_SERVICE_KEY_IFRAME":{"NAME":"Secret Key","DESCRIPTION":"Secret Key","SORT":"300"},"PS_WORK_MODE_IFRAME":{"NAME":"Payment System Operating Mode","SORT":"1100","INPUT":{"TYPE":"ENUM","OPTIONS":{"TEST":"Test","REGULAR":"Live"}}}},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.paysystem.handler.add
try
{
const response = await $b24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest IFrame",
"CODE": "resthandleriframe",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"IFRAME_DATA": {
"ACTION_URI": "http://example.com/payment_iframe.php",
"FIELDS": {
"serviceKey": {
"CODE": "REST_SERVICE_KEY_IFRAME",
},
"serviceid": {
"CODE": "REST_SERVICE_ID_IFRAME"
}
}
},
"CODES": {
"REST_SERVICE_ID_IFRAME": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY_IFRAME": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PS_WORK_MODE_IFRAME": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
);
const result = response.getData().result;
console.info(result);
}
catch( error )
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest IFrame',
'CODE' => 'resthandleriframe',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'IFRAME_DATA' => [
'ACTION_URI' => 'http://example.com/payment_iframe.php',
'FIELDS' => [
'serviceKey' => [
'CODE' => 'REST_SERVICE_KEY_IFRAME',
],
'serviceid' => [
'CODE' => 'REST_SERVICE_ID_IFRAME'
]
]
],
'CODES' => [
'REST_SERVICE_ID_IFRAME' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100'
],
'REST_SERVICE_KEY_IFRAME' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300'
],
'PS_WORK_MODE_IFRAME' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live'
]
]
]
]
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding payment system handler: ' . $e->getMessage();
}
BX24.callMethod(
"sale.paysystem.handler.add",
{
"NAME": "Handler.Rest IFrame",
"CODE": "resthandleriframe",
"SORT": 100,
"SETTINGS": {
"CURRENCY": [
"RUB"
],
"CLIENT_TYPE": "b2c",
"IFRAME_DATA": {
"ACTION_URI": "http://example.com/payment_iframe.php",
"FIELDS": {
"serviceKey": {
"CODE": "REST_SERVICE_KEY_IFRAME",
},
"serviceid": {
"CODE": "REST_SERVICE_ID_IFRAME"
}
}
},
"CODES": {
"REST_SERVICE_ID_IFRAME": {
"NAME": "Store Number",
"DESCRIPTION": "Store Number",
"SORT": "100"
},
"REST_SERVICE_KEY_IFRAME": {
"NAME": "Secret Key",
"DESCRIPTION": "Secret Key",
"SORT": "300"
},
"PS_WORK_MODE_IFRAME": {
"NAME": "Payment System Operating Mode",
"SORT": "1100",
"INPUT": {
"TYPE": "ENUM",
"OPTIONS": {
"TEST": "Test",
"REGULAR": "Live"
}
}
}
}
}
}
,
function (result) {
if (result.error())
{
console.error(result.error());
}
else
{
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'sale.paysystem.handler.add',
[
'NAME' => 'Handler.Rest IFrame',
'CODE' => 'resthandleriframe',
'SORT' => 100,
'SETTINGS' => [
'CURRENCY' => ['RUB'],
'CLIENT_TYPE' => 'b2c',
'IFRAME_DATA' => [
'ACTION_URI' => 'http://example.com/payment_iframe.php',
'FIELDS' => [
'serviceKey' => [
'CODE' => 'REST_SERVICE_KEY_IFRAME',
},
'serviceid' => [
'CODE' => 'REST_SERVICE_ID_IFRAME'
]
]
],
'CODES' => [
'REST_SERVICE_ID_IFRAME' => [
'NAME' => 'Store Number',
'DESCRIPTION' => 'Store Number',
'SORT' => '100'
],
'REST_SERVICE_KEY_IFRAME' => [
'NAME' => 'Secret Key',
'DESCRIPTION' => 'Secret Key',
'SORT' => '300'
],
'PS_WORK_MODE_IFRAME' => [
'NAME' => 'Payment System Operating Mode',
'SORT' => '1100',
'INPUT' => [
'TYPE' => 'ENUM',
'OPTIONS' => [
'TEST' => 'Test',
'REGULAR' => 'Live'
]
]
]
]
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Response Handling
HTTP Status: 200
{
"result": 5,
"time": {
"start": 1712132792.910734,
"finish": 1712132793.530359,
"duration": 0.6196250915527344,
"processing": 0.032338857650756836,
"date_start": "2024-04-03T10:26:32+02:00",
"date_finish": "2024-04-03T10:26:33+02:00",
"operating_reset_at": 1705765533,
"operating": 3.3076241016387939
}
}
Returned Data
|
Name |
Description |
|
result |
Identifier of the created handler, used later for updating and deleting it |
|
time |
Information about the request execution time |
Error Handling
HTTP Status: 400, 403
{
"error": "ERROR_HANDLER_ALREADY_EXIST",
"error_description": "Handler already exists!"
}
|
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 |
Status |
|
|
Insufficient permissions to add the handler |
403 |
|
|
Required field value is not specified or one of the field values is incorrect |
400 |
|
|
A handler with the code specified in the |
400 |
|
|
Other errors. For detailed information about the error, see |
400 |
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
- Update REST Handler for Payment System sale.paysystem.handler.update
- Get a List of REST Handlers for the Payment System sale.paysystem.handler.list
- Delete the REST handler for the payment system sale.paysystem.handler.delete
- Add Payment System sale.paysystem.add
- Update Payment System sale.paysystem.update
- Get a List of Payment Systems sale.paysystem.list
- Get Payment System Settings sale.paysystem.settings.get
- Update Payment System Settings sale.paysystem.settings.update
- Delete Payment System sale.paysystem.delete
- Pay for an Order via a Specific Payment System sale.paysystem.pay.payment
- Get Payment System Settings for a Specific Payment sale.paysystem.settings.payment.get