Documentation

sale.paysystem.handler.add

sale.paysystem.handler.add(
 fiedls
)

The method adds REST handler.

Parameters

Parameter Description Available from version
fiedls Set of fields(array type array("field":"value"[, ...])), containing value that describe the handler. Available fields:
  • NAME - Handler name
  • CODE - unique handler code in the system
  • SETTINGS - handler settings
  • SORT - sorting

Example

BX24.callMethod(
	"sale.paysystem.handler.add",
	{
		'NAME' : 'REST handler', 							// Handler name
		'SORT' : 100, 										// Sorting
		'CODE' : 'resthandlercode', 							// Unique handler code in the system
		'SETTINGS' : { 									// Handler settings
			'CURRENCY' : {'RUB'}, 							// List of currencies supported by the handler
			'FORM_DATA' : { 								 // Form settings
				'ACTION_URI' : 'https://payment_service_url', 	// URL to send the form  
				'METHOD' : 'POST', 						// Method to send the form
				'PARAMS' : { 								// Map of corresponding form fields and handler parameters: array type (field_code => handler_parameter_code)
					'serviceid' : 'REST_SERVICE_ID',
					'invoiceNumber' : 'PAYMENT_ID',
					'Sum' : 'PAYMENT_SHOULD_PAY',
					'customer' : 'PAYMENT_BUYER_ID',
				}
			},
			'CODES' : {										// List of handler parameters
				"REST_SERVICE_ID" : {							// Parameter code
					"NAME" : 'Store number',					// Parameter name
					"DESCRIPTION" : 'Store number',			        // Parameter description
					'SORT' : 100,								// Sorting
				},
				"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 sum',
					'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 ID code',
					'SORT' : 1000,
					'GROUP' : 'PAYMENT',						// String value type, checkbox and etc.
					'DEFAULT' : {								// Default value
						'PROVIDER_KEY' : 'ORDER',				// Value type (see available list below)
						'PROVIDER_VALUE' : 'USER_ID'			// Value (see available list below)
					}
				}
			}
		}
	},
	function(result)
	{
		if(result.error())
			console.error(result.error());
		else
			console.info("Handler added with ID " + result.data());
	}
);

Example No. 2

Starting from the Sale module version 20.5.0, a new value FIELDS is added instead of the legacy PARAMS (now arbitrary fields can be passed for payment system's REST handlers).

If the CODE key's value is a string, then the value is used for searching for a match between form's fields and handler parameters: array type array('CODE' => 'handler_parameter_code'). Name and value will be retrieved from handler parameters ('CODES').

If the CODE key passes an object, the fields of specified type will be added in the payment's form. The following types are supported:

  • STRING (string)
  • Y/N (checkbox)
  • ENUM (list)

Form fields are hidden by default. To male them visible, pass 'VISIBLE' : 'Y'.

BX.rest.callMethod(
    "sale.paysystem.handler.add",
    {
        'NAME' : 'Rest.Handler',
        'SORT' : 100,
        'CODE' : 'resthandlercodedoc',
        'SETTINGS' : {
            'CURRENCY' : ['USD'],
            'FORM_DATA' : {
                'ACTION_URI' : 'https://payment_service_url',
                'METHOD' : 'POST',
                'FIELDS' : { 
                    'phone' : {
                        'CODE': {
                            'NAME' : 'Phone number',
                            'TYPE' : 'STRING',
                        }
                        'VISIBLE' : 'Y',
                    },
                    'paymentId' : {
                        'CODE' : 'PAYMENT_ID',
                        'VISIBLE' : 'Y'
                    },
                    'serviceid' : {
                        'CODE' : 'REST_SERVICE_ID'  
                    }
                }
            },
            'CODES' : {
                "REST_SERVICE_ID" : {
                    "NAME" : 'Store's number',
                    "DESCRIPTION" : 'Store's 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" : 'Payment status automatic update',
                    'SORT' : 700,
                    "INPUT" : {
                        'TYPE' : 'Y/N'
                    },
                },
                "PAYMENT_BUYER_ID" : {
                    "NAME" : 'Buyer ID code',
                    'SORT' : 1000,
                    'GROUP' : 'PAYMENT',
                    'DEFAULT' : {
                        'PROVIDER_KEY' : 'ORDER',
                        'PROVIDER_VALUE' : 'USER_ID'
                    }
                }
            }
        }
    },
    function(result)
    {
        if(result.error())
            console.error(result.error());
        else
            console.info("Handler added with ID " + result.data());
    }
);

Note: If passing both FIELDS and PARAMS, only FIELDS is used.

Possible values

PROVIDER_KEY possible values
ORDER Parameters
PROPERTY Invoice properties
PAYMENT Payment
USER User
VALUE String type value
Y\N Checkbox
PROVIDER_KEY possible values
ORDER ID: ID (for invoices corresponds to invoice ID),
ACCOUNT_NUMBER: Order number (for invoices corresponds to invoice number),
ORDER_TOPIC: Topic,
DATE_INSERT: Order date (for invoices corresponds to invoice date),
DATE_INSERT_DATE: Order date (without time) (for invoices corresponds to invoice date (without time)),
DATE_BILL: Data and time of issue,
DATE_BILL_DATE: Date of issue,
DATE_PAY_BEFORE: Payment date,
SHOULD_PAY: Invoice sum (for invoices corresponds to invoice sum),
CURRENCY: Currency,
PRICE: Order price (for invoices corresponds to invoice price),
PRICE_DELIVERY: Delivery price,
DISCOUNT_VALUE: Discount value,
USER_ID: Buyer code,
PAY_SYSTEM_ID: Payment system code,
DELIVERY_ID: Delivery service code,
TAX_VALUE: Tax,
USER_DESCRIPTION: Commentary
PAYMENT ID: ID
ACCOUNT_NUMBER: Payment number,
DATE_BILL: ДатаDate and time of issue,
DATE_BILL_DATE: Date of issue (without time),
SUM: Payment sum,
CURRENCY: Currency
USER ID: Buyer code,
LOGIN: Login,
NAME: Name,
SECOND_NAME: Second name,
LAST_NAME: Last name,
EMAIL: EMail,
PERSONAL_PROFESSION: Professional occupation,
PERSONAL_WWW: Personal website,
PERSONAL_ICQ: ICQ number,
PERSONAL_GENDER: Gender ,
PERSONAL_FAX: Fax number,
PERSONAL_MOBILE: Phone number,
PERSONAL_STREET: Address,
PERSONAL_MAILBOX: Mailbox,
PERSONAL_CITY: City,
PERSONAL_STATE: State,
PERSONAL_ZIP: Zip code,
PERSONAL_COUNTRY: Country,
WORK_COMPANY: Company,
WORK_DEPARTMENT: Department,
WORK_POSITION: Position,
WORK_WWW: Company site,
WORK_PHONE: Work phone,
WORK_FAX: Work fax,
WORK_STREET: Company address,
WORK_MAILBOX: Work mailbox,
WORK_CITY: Company city,
WORK_STATE: Company state,
WORK_ZIP: Company zip code,
WORK_COUNTRY: Company country


User Comments

User comments are not part of official documentation. Use information provided by other users in the comments at your own risk.

The User Comments section is not to be used as a feature discussion board. Only registered users can post comments. Your comment will be visible once it has been approved by the moderator.
© «Bitrix Inc.», 2001-2021, «Bitrix Inc.», 2021