Charges closing with Charge Closer
Charge Closer is a background process that monitors system messages about completing orders. These messages include the subscription ID and the value of the Deletion period of subscription by customer (days) parameter in the linked service term (see Creating a service term). Charge Closer receives a message about completing an order and checks the billing type for the corresponding subscription. If the billing type is listed in the Charge Closer settings, Charge Closer calls the API method Close charges to close all charges for the subscription on behalf of a manager.
For a sales, renewal, and switch plan order, Charge Closer performs one of the following actions, depending on the value of the Deletion period of subscription by customer (days) parameter:
- Deletion period of subscription by customer (days) is set to -1 or 0 — calls the API method Close charges to close all charges for the subscription on behalf of a manager.
- Deletion period of subscription by customer (days) is set to any N > 0 — creates a delayed operation for calling the API method Close charges. The operation is delayed depending on the number of days until the next billing day as follows:
- If the number of days until the next billing day is greater than or equal to the value of the Deletion period of subscription by customer (days) parameter, the operation is delayed to
N × 24
hours. For renewal orders, the delay period may be reduced. The period is reduced by the number of hours that have passed since the subscription expiration date if a renewal order is completed after the subscription expiration date and the linked service term has the Expired subscription is renewed from the expiration date option selected. - If the number of days until the next billing day is less than the value of the Deletion period of subscription by customer (days) parameter, the operation is delayed to the next billing day (UTC+3). The charges are closed at 00:00 on the next billing day. If the next billing day is less than in one hour, the charges are closed immediately.
- If the number of days until the next billing day is greater than or equal to the value of the Deletion period of subscription by customer (days) parameter, the operation is delayed to
The Charge Closer settings include the following:
- API v3 base URL.
- List of billing types for closing all charges.
- List of pairs "reseller ID — manager API token" to access API. Charges are closed for the specified reseller and all downstream resellers.
If the charges closing fails, Charge Closer calls the API method one more time. It performs up to 5 attempts with a 60-second interval. All results are stored in the Charge Closer log.