Charging interface processing method and system, electronic equipment and storage medium
By introducing a billing rule engine and real-time data warehouse in the API call billing system, combined with anti-cheating measures, the problems of inflexible billing strategies, untimely data updates and security in the existing technology are solved, and flexible, real-time and secure API call billing processing is achieved.
Patent Information
- Application Number
- CN202411828583.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-21
AI Technical Summary
The existing technology lacks flexibility in API call billing, and it is difficult to adapt to changing market demands, the billing data is not updated in time, the system is highly coupled, it is difficult to respond to market changes quickly, and security issues such as API abuse and fraud are difficult to effectively control.
Provide a billing interface processing method, including initiating API call requests, authenticating and authorizing requests, calculating fees based on preset billing rules through the billing rule engine, supporting billing strategies based on the number of requests, data volume and annual and monthly packages, and ensuring data accuracy and security through real-time data warehouses and anti-cheating measures.
A flexible billing strategy is realized to meet different customers and market needs, ensure the real-time and accuracy of billing data, and effectively control API abuse and fraud through anti-cheating measures.
Smart Images

Figure CN119676007A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interface billing, and in particular to a billing interface processing method, system, electronic equipment and storage medium. Background Art
[0002] In the era of cloud computing and big data, the API as a Service model is becoming increasingly popular. Enterprises open API interfaces to allow external developers or internal systems to call their data and services. However, with the surge in the number of API calls, how to effectively manage and bill has become a major challenge. Traditional billing systems often adopt a static billing model, which lacks flexibility and scalability and is difficult to adapt to the changing needs of different customers and markets.
[0003] The existing technology usually uses a centralized billing server to monitor and bill API calls. This method has the following disadvantages:
[0004] The billing strategy lacks flexibility and is difficult to adapt to changing market demands;
[0005] Billing data is not updated in a timely manner, and customers cannot obtain consumption information in real time;
[0006] The system is highly coupled, making it difficult to respond quickly to market changes;
[0007] Security issues such as API abuse and fraud are difficult to control effectively. Summary of the invention
[0008] In view of the shortcomings existing in the above problems, the present invention provides a billing interface processing method, system, electronic device and storage medium.
[0009] To achieve the above object, the present invention provides a billing interface processing method, comprising:
[0010] Initiate an API call request;
[0011] Authenticating and authorizing the API call request;
[0012] After authentication, the billing rules engine calculates the fees according to the preset billing rules;
[0013] The billing rules include billing based on the number of requests, billing based on the amount of data, and annual or monthly billing.
[0014] Preferably, the API call request and billing data are written in real time and stored in a data warehouse.
[0015] Preferably, the data warehouse queries historical records through a web interface or a mobile application.
[0016] Preferably, after calculating the fee, an anti-cheating check is performed based on IP restrictions, request frequency restrictions, and signature verification.
[0017] Preferably, the authentication authorization includes concatenating the interface code, request time, token, and interface parameters to form a signature, and comparing the signature with the sign.
[0018] The present application also provides a billing interface processing system, including:
[0019] The initiation module is used to initiate an API call request;
[0020] An authentication module, used to authenticate and authorize the API call request;
[0021] The calculation module is used for calculating the fee according to the preset billing rules by the billing rule engine after the authentication is passed;
[0022] The billing rules include billing based on the number of requests, billing based on the amount of data, and annual or monthly billing.
[0023] The present invention also provides an electronic device, comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes the above method.
[0024] The present invention also provides a storage medium storing a computer program executable by an electronic device, and when the program runs on the electronic device, the electronic device executes the above method.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] The present invention can select different charging strategies according to the actual situation of the customer, thereby meeting the flexible system configuration. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of the billing interface processing method of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] Reference Figure 1 The present invention provides a charging interface processing method, comprising:
[0030] Initiate an API call request;
[0031] Authenticate and authorize API call requests;
[0032] Specifically, based on signature technology and token technology, request message tamper-proof and user authentication are implemented. It supports national encryption and other mainstream signature and encryption and decryption technologies, and its input parameters are shown in Table 1.
[0033] Table 1
[0034] Serial number Field Name Field Type default Must lose? illustrate 1 token character yes Token 2 intfCode character yes Interface Coding 3 sign character yes sign 4 rqetTime Integer yes Request time 5 intfParms Key-value pairs yes Interface parameters
[0035] Processing logic:
[0036] The interface code + request time + token + interface parameters (natural sorting) are sequentially concatenated to form a signature, which is then compared with the sign to perform data tamper-proof verification;
[0037] Verification request time rqetTime, no more than 10 minutes;
[0038] Get user information based on Token and verify user interface permissions based on intfCode;
[0039] If the above signature verification fails, the request time exceeds 10 minutes, or the token is invalid, the authentication fails, the process ends and an error message is returned;
[0040] If the above conditions are verified successfully, the authentication is successful and the process continues to the billing rules engine.
[0041] The output parameters are shown in Table 2.
[0042] Table 2
[0043] Serial number Field Name Field Type default Must lose? illustrate 1 code character yes Coding, success 2 mesg character yes information
[0044] After authentication, the billing rules engine calculates the fees according to the preset billing rules;
[0045] Among them, the billing rules include billing based on the number of requests, billing based on the amount of data, and annual and monthly billing.
[0046] Specifically, the component uses the rule engine as the core to support customized billing rules. The rule engine allows users to define complex billing logic, such as multiple billing modes based on the number of requests, data volume, time window, etc.
[0047] Billing rules details:
[0048] Query-based billing rules: calculated based on each query;
[0049] Based on the found billing rules: Customize the billing rules calculation on demand;
[0050] When selecting a billing rule based on a query, the rule engine supports visual rule configuration. Configure the parameters, arithmetic operators, and logical operators of the billing rule. For example, the rule engine configuration result example: channel type = PC and interface code = weatherIntfCode;
[0051] Billing policy details:
[0052] Based on the number of requests: users purchase the number of requests, and the number of requests is deducted;
[0053] Based on data volume: The billing mode is based on the requested data volume and request unit price;
[0054] Time window: annual or monthly package mode; its input parameters are shown in Table 3.
[0055] Table 3
[0056] Serial number Field Name Field Type default Must lose? illustrate 1 invokeCode character yes Caller Encoding 2 intfCode character yes Interface Coding 3 rqetTime Integer yes Request time 4 channelType Integer yes Channel Type 5 intfParms Key-value pairs yes Interface parameters
[0057] Processing Logic
[0058] Obtain the billing rules based on the interface code;
[0059] If the billing rule is query, each request is billed;
[0060] If the billing rule is found, the rule engine is called to determine whether the found rule is matched;
[0061] When one of the following conditions is met, the billing mode processing is performed;
[0062] The billing rule is the query type;
[0063] The billing rule is to check the type and match the rule.
[0064] Billing model processing logic:
[0065] Based on the number of requests: return the number of records by single record or batch;
[0066] Based on time window: Request information is recorded within the time window purchased by the user, and no fee is charged;
[0067] Based on data volume: Fees are deducted based on the number of requests, fee = number of requests × price per request;
[0068] The execution is successful. The next step is to process the real-time data.
[0069] If the execution fails, the process returns an error message; its output parameters are shown in Table 4.
[0070] Table 4
[0071]
[0072]
[0073] In this embodiment, the component integrates a real-time data warehouse, and all API call records and billing data are written in real time to ensure the accuracy and real-time nature of the data. Customers can query their consumption records and balances at any time through the API. The data warehouse queries historical records through the web interface or mobile application.
[0074] Furthermore, the component integrates anti-cheating measures such as IP restriction, request frequency restriction, signature verification, etc., and supports integration with third-party security services to effectively prevent API abuse and fraud. After calculating the fee, anti-cheating checks are performed based on IP restriction, request frequency restriction, and signature verification.
[0075] Specifically, the blacklist database is checked based on the IP address to determine whether it is on the blacklist;
[0076] Token verification, obtain user information based on token, determine whether it exists, and determine whether it has the permission to request the interface.
[0077] IP-level current limiting: Based on the current limiting configuration per second, the number of requests per IP per second is accumulated and judged based on the Redis cache;
[0078] Token-level current limiting: Based on the current limiting configuration per second and the redis cache, the number of token requests per second is accumulated and judged;
[0079] Interface-level current limiting: Based on the current limiting configuration per second and the redis cache, the number of token requests per second is accumulated and judged;
[0080] When any of the IP request count per second, token request count per second, and interface overall request count per second does not exceed the current limit, proceed to the next step: billing;
[0081] When any of the IP request count per second, token request count per second, and interface overall request count per second exceeds the current limit, a process error message is returned;
[0082] Supports expansion of anti-cheating checking mechanisms through integration with third-party security services.
[0083] In this embodiment, anti-cheating measures such as IP restriction, request frequency restriction, signature verification, etc. are integrated, and integration with third-party security services is supported to effectively prevent API abuse and fraud.
[0084] Furthermore, the billing process is performed according to the following billing strategy:
[0085] When the billing strategy is the number of requests: deduct the number of requests;
[0086] When the calculation strategy is time window: determine whether it is within the time window;
[0087] Based on data volume: deduct user fees;
[0088] According to the billing policy, the above billing process fails, or the billing fails to be stored;
[0089] It is regarded as a billing failure, and the failure information is recorded and the user is notified;
[0090] When the billing deduction is successful or within the validity period and the execution is successful, the billing information is recorded and the user is notified.
[0091] In this embodiment, a new charging policy can be extended and configured through a configuration file or annotation. If the computing policy management does not have a computing policy, it is determined whether there is an extended charging policy; if there is a corresponding extended configuration, it is loaded into the memory; and the relevant charging policy is executed.
[0092] In this embodiment, the rule engine is implemented as follows: the rule engine is based on the open source EL expression ElExpress to implement the open source rule engine, and users can define and manage billing rules through a user-friendly rule editor.
[0093] Billing rules details:
[0094] Query-based billing rules: calculated based on each query;
[0095] Based on the found billing rules: Customize the billing rules calculation on demand;
[0096] When selecting a billing rule based on a query, the rule engine supports visual rule configuration. Configure the parameters, arithmetic operators, and logical operators of the billing rule. For example, the rule engine configuration result example: channel type = PC and interface code = weatherIntfCode;
[0097] Real-time data stream processing: Use message queue technologies such as Apache Kafka to achieve real-time collection and transmission of API call data. Use stream processing frameworks such as Apache Flink to process and analyze data streams in real time.
[0098] Microservice communication: Use microservice frameworks such as Spring Cloud to achieve lightweight communication between services. Use protocols such as RESTful API or gRPC to achieve calls and data exchange between services.
[0099] Security framework integration: Integrate Spring Security and other security frameworks to implement API authentication and authorization. Support OAuth2.0, JWT and other authentication mechanisms to ensure the security of API calls.
[0100] Billing data display: Provides a web interface and mobile applications to allow users to view billing data and history in real time. Through charts and reports, consumption trends and patterns are intuitively displayed.
[0101] Billing strategy extension: Supports billing strategy extension through plug-ins or modules. Developers can develop custom billing plug-ins and integrate them into the system through APIs or interfaces.
[0102] The detailed steps of the present invention include:
[0103] API request: A user or system initiates an API call request.
[0104] Authentication and authorization: The system authenticates and authorizes API requests to ensure that the requests are legal.
[0105] If authentication fails, the process ends and an error message is returned.
[0106] If authentication is successful, the flow continues to the billing rules engine.
[0107] Billing rules engine: After the request is authenticated, the billing rules engine calculates the fee based on the preset billing rules.
[0108] Real-time data stream processing and storage: API call and billing data are collected in real time, transmitted to the stream processing system through the message queue, and then stored in the data warehouse.
[0109] Billing data query and display: Users can query their billing data and history through the web interface or mobile application.
[0110] Anti-cheating mechanism check: The system implements anti-cheating measures such as IP restrictions and request frequency limits to prevent API abuse.
[0111] If the check passes, the process continues with normal billing.
[0112] If the check fails, the process goes to billing failure processing.
[0113] Normal billing: If the anti-cheating check passes, normal billing will be processed.
[0114] Billing success: After billing is successful, the billing information is recorded and the user is notified.
[0115] Billing failure: If billing fails, the failure information is recorded and the user is notified.
[0116] Billing policy extension and configuration: Administrators can extend and configure new billing policies through configuration files or annotations.
[0117] The present application also provides a billing interface processing system, including:
[0118] The initiation module is used to initiate an API call request;
[0119] Authentication module, used to authenticate and authorize API call requests;
[0120] The calculation module is used for calculating the fee according to the preset billing rules by the billing rule engine after the authentication is passed;
[0121] Among them, the billing rules include billing based on the number of requests, billing based on the amount of data, and annual and monthly billing.
[0122] The present invention also provides an electronic device, comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes the above method.
[0123] The present invention also provides a storage medium storing a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device executes the above method.
[0124] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A billing interface processing method, characterized in that: include: Initiate an API call request; Authenticating and authorizing the API call request; After authentication, the billing rules engine calculates the fees according to the preset billing rules; The billing rules include billing based on the number of requests, billing based on the amount of data, and annual or monthly billing.
2. The charging interface processing method according to claim 1, characterized in that: The API call request and billing data are written in real time and stored in the data warehouse.
3. The charging interface processing method according to claim 2, characterized in that: The data warehouse queries historical records through a web interface or mobile application.
4. The charging interface processing method according to claim 3, characterized in that: After calculating the fee, anti-cheating checks are performed based on IP restrictions, request frequency restrictions, and signature verification.
5. The charging interface processing method according to claim 4, characterized in that: Authentication and authorization include concatenating the interface code, request time, token, and interface parameters to make a signature, and comparing the signature with the sign.
6. A billing interface processing system, characterized in that: include: The initiation module is used to initiate an API call request; An authentication module, used to authenticate and authorize the API call request; The calculation module is used for calculating the fee according to the preset billing rules by the billing rule engine after the authentication is passed; The billing rules include billing based on the number of requests, billing based on the amount of data, and annual or monthly billing.
7. An electronic device, characterized in that: The method comprises at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes the method according to any one of claims 1 to 5.
8. A storage medium, characterized in that: It stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device executes the method described in any one of claims 1 to 5.