Methods

/Api/v2/points/add/ - awarding of bonus points

Method's Use

The method is used to award bonus points to the user.

Request Parameters

Is the parameter mandatory? Parameter Name Parameter Description
yes user_phone or email or origin_user_id More detailed The ID the Client  see found here .
yes token  see here
yes store_department_id  see here
yes points  Bonus points to be awarded to this user
no comment  A comment to the operation of awarding points. It will be displayed to the user on the popup in the tab with the list of actions. The comment should have the following format: "Bonus points awarded for XXX".
no order_num  Unique request ID. If the request with this ID has been already processed, SailPlay's server will return an error. The use of this parameter will allow the repeat awarding of points when Internet connection is not stable, and it will also simplify matching actions in your system and in SailPlay's system. ".

Server Response

Parameter Name Parameter Description
status  
points The parameter from the request
public_key The key to add in the JS-code.
receipt_date Date and time when bonus points have been awarded to the user.

Request Example

http://sailplay.net/api/v2/points/add/?store_department_id=111&token=da32f321d2516c8e56142f2430bea4f72a80a6ae&points=1170&comment=awarding%20bonus%20points%20за%20comment%20on%20website&origin_user_id=dbsajfbjk12bjb12112321&order_num=239

/Api/v2/points/calc/ - calculation of permissible amount of awarded and written off points

Method's Use

The method is used to calculate the maximum amount of points that can be awarded or written off towards a discount factoring in the cart's content and the client's status. This method helps to accurately project awarded and written off points, as well as to avoid the duplication of the logic for the client in case of complex logic for bonus points processing.

This method can also be used to check the client's registration in the loyalty program.

Request Parameters

Is the parameter mandatory? Parameter Name Parameter Description
yes user_phone or email or origin_user_id More detailed The ID the Client  see found here .
yes token  see here
yes store_department_id  see here
yes positions   Array of products in this purchase (cart's content). It has the format "positions = 1899,13,200: 101,10,379" - products IDs in your system, product groups ID (optional) and the cost are submitted in groups separated by colons. If there are several purchases with this product ID, you should submit this ID several times. Important: The amounts should be of type int.
no max_discount  The maximum discount that can be received for written off points. The integer value of percentage is specified. When this parameter is not specified, the value from settings is used
no points_rate   Conversion rate from local currency to points. It can take on a value from half-interval (0,1]. When this parameter is not specified, the value from settings is used. Format points_rate = 0.45
no reverse_conversion_rate   The reverse conversion rate from points to local currency. Format points_rate = 1.2 It specifies a number of point required for a discount of 1 ruble. For example, if the rate is 3, to receive a 100 dollars discount you will need 300 points. When this parameter is not specified, the value from settings is used. 
no current_discount_value  The current discount value in local currency. If the parameter is not specified, the discount rate is considered to be 0. If the parameter value exceeds the permissible value, the maximum allowed discount value is used.

Server Response

Parameter Name Parameter Description
status  
user_points   The amount of available confirmed at this time bonus points.
max_points_receive  Maximum amount of bonus points that can be received with the current cart's content. This amount of points will be awarded if no points will be written off towards a discount.
min_points_receive  Minimum amount of bonus points that can be received with the current cart's content. This amount of points will be awarded if the maximum permissible amount of points will be written off towards a discount.
max_discount_value  The maximum available discount amount in local currency.
max_points_result  The amount of client's bonus points after maximum bonus points have been awarded.
min_points_result  The amount of client's bonus points after maximum bonus points have been written off towards a discount.
min_price_result  The total order price when the maximum available bonus points have been written off towards a discount.
current_price_result  The total order price when the specified amount of bonus points has been requested to be written off towards a discount.
current_points_result  The amount of client's bonus points after a specified amount of bonus points has been requested to be written off towards a discount.
current_points_receive  The amount of bonus points that will be awarded for the purchase with the specified discount rate.
positions  The object that contains information about maximum permissible and current discount rate and the amount of bonus points awarded for a purchase.

Description of the elements positions

Parameter Name Parameter Description
sku  Product ID in the store
max_points_receive  Maximum amount of bonus points that can be received for the purchase of this product. This amount of points will be awarded if no points will be written off towards a discount.
min_points_receive     Minimum amount of bonus points that can be received for the purchase of this product. This amount of points will be awarded if the maximum permissible amount of points will be written off towards a discount.
max_discount_value  Maximum discount rate for the specified product.
value  Current cost of the product
value_after_max_discount  Product cost after applying the maximum discount.
current_points_receive  The amount of client's bonus points awarded for the purchase of the product after a specified amount of bonus points has been written off towards a discount.
current_discount_value   Current discount rate for the product.

Request Example

http://sailplay.net/api/v2/points/calc/?store_department_id=111&token=da32f321d2516c8e56142f2430bea4f72a80a6ae&&origin_user_id=dbsajfbjk12bjb12112321&positions=1899,200:101,300&max_discount=20

Response Example

{
"The status": "ok The",
"min_points_receive": 75,
"user_points": 50,
"current_points_receive": 85,
"current_points_result": 135,
"max_points_receive": 85,
"current_price_result": 579,
"max_discount_value": 50 ,
"positions": [
{
"sku": "1899",
"max_points_receive": 10,
"min_points_receive": 7,
"max_discount_value": 50,
"of value": 200,
"value_after_max_discount": 150,
"current_points_receive": 10 ,
"current_discount_value": 0
},
{
"sku": "101",
"max_points_receive": 75,
"min_points_receive": 75,
"max_discount_value": 0,
"value": 379,
"value_after_max_discount": 379,
"current_points_receive" : 75,
"current_discount_value": 0
}
],
"min_price_result": 529,
"min_points_result": 75,
"max_points_result": 135
}