A payment channel automated testing method, system and device based on JS MOCK

By adopting an automated testing method based on JS MOCK in the financial payment channel testing, the problem of insufficient channel cooperation and difficult to simulate the test environment is solved, efficient automation use case coverage and strict code verification are achieved, and fast-paced version iteration is adapted to cycle.

CN118916295BActive Publication Date: 2025-02-11JIANGSU SUNING BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411405089.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-11
Estimated Expiration
2044-10-10

AI Technical Summary

Technical Problem

During the financial payment channel testing process, the return of the channel party cannot be controlled, the returned data does not meet the requirements, and the channel party does not cooperate enough, which makes it difficult to achieve abnormal scenarios, affecting the test progress and quality.

Method used

Adopt the payment channel automation test method based on JS MOCK, by configuring channel templates, running automated test cases, assembling payment request messages, calling payment system, initiating channel requests, and responding to channel requests through the channel MOCK service module to parse payment request messages , match the channel template, generate reply messages, and simulate accounting results.

Benefits of technology

Improve the coverage of automated use cases, adapt to the efficient and fast-paced version iteration cycle, and achieve comprehensive test case coverage, ensuring that each code change can be strictly verified, reducing the cost of joint debugging, and solving the difficulty of simulation of channel environments and Risk problems caused by high dependence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916295B_ABST
    Figure CN118916295B_ABST
Patent Text Reader

Abstract

The invention relates to the field of financial payment services, and discloses a payment channel automatic testing method, system and device based on JS MOCK, which solves the barrier problem that the payment channel is difficult to realize automation. The key points of the technical solution are: configuring a channel template, running an automatic test case, and initiating a channel request; parsing a payment request message, obtaining a channel name, a channel transaction type and a payment request keyword; matching a channel template for the payment request keyword; if a corresponding keyword template is matched, obtaining a corresponding response keyword, reconstructing it through a message template, and obtaining a response message; if no keyword template is matched, returning to generate a response message through an initialized channel message template; performing core accounting according to the response message, and simulating the accounting result. The solution of the invention can improve the coverage of automatic use cases and can adapt to a high-efficiency, fast-paced version iteration cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial payment services, and more specifically, to a payment channel automatic testing method, system and device based on JS MOCK. Background Art

[0002] During the financial payment channel testing process, the testing team often faces a series of challenges, such as:

[0003] Unable to control the return of the channel party, and the returned data does not meet the requirements;

[0004] The channel party’s cooperation is not strong enough, and abnormal scenarios are difficult to implement, which affects the progress and quality of the test;

[0005] The channel's test environment is offline, and the bank cannot test new merchants when it subsequently connects them to the channel;

[0006] The channel party does not provide a test environment. When testing in the channel party's production environment, it will affect the bank's accounting problems in production and cause risks to real cards.

[0007] Many factors hinder the progress of testing and reduce the quality of testing. Abnormal scenario testing is highly dependent on the cooperation of the channel party, making the test very passive. For example, if the channel contract fails or is unknown, the channel payment times out, the channel verification fails or times out, or the notification times out, if the channel party does not actively cooperate, it will lead to low test coverage, and the system will be launched with hidden dangers. Without channel MOCK, only a small number of test cases can be automated. The automated test cases are generally too simple and rigid, with low coverage, which is a drop in the bucket for improving the coverage of automated test cases and cannot achieve the expected results. It is difficult for testing to survive in the high-efficiency, fast-paced version iteration cycle. Summary of the invention

[0008] The purpose of the present invention is to provide a payment channel automated testing method, system and device based on JS MOCK, which can improve the coverage of automated use cases and adapt to high-efficiency and fast-paced version iteration cycles.

[0009] The above technical purpose of the present invention is achieved through the following technical solutions: a payment channel automatic testing method based on JS MOCK, comprising the following steps:

[0010] S1. Configure a channel template for the payment channel, where the channel template includes a message template and a keyword template;

[0011] S2. Run automated test cases, assemble payment request messages, call the payment system, and initiate channel requests;

[0012] S3. In response to the channel request, parse the payment request message to obtain the channel name, channel transaction type and payment request keyword;

[0013] S4. Match the channel template according to the channel name and channel transaction type;

[0014] If the payment request keyword matches the corresponding keyword template, the corresponding response keyword is obtained, and the response keyword is reconstructed through the corresponding message template to obtain a response message;

[0015] If the payment request keyword does not match the keyword template, a response message generated by the initialization channel message template is returned;

[0016] S5. Send the response message to the payment system, and respond to the accounting request issued by the payment system, perform core accounting according to the response message, and simulate the accounting results.

[0017] As a preferred technical solution of the present invention, in S2, when the payment system initiates a channel request, the payment request message is encrypted;

[0018] In S3, before parsing the payment request message, the payment request message is decrypted;

[0019] In S4, after the response message is generated, the response message is encrypted;

[0020] In S5, when the payment system receives the response message, it decrypts the response message.

[0021] A payment channel automatic testing system based on JS MOCK, including:

[0022] A configuration management module, used to configure a channel template for a payment channel, wherein the channel template includes a message template and a keyword template;

[0023] Test-side tools are used to run automated test cases, assemble payment request messages, call the payment system, and initiate channel requests;

[0024] The channel MOCK service module is used to respond to channel requests, parse payment request messages, obtain channel names, channel transaction types, and payment request keywords; match channel templates according to channel names and channel transaction types; if the payment request keyword matches the corresponding keyword template, the corresponding response keyword is obtained, and the response keyword is reconstructed through the corresponding message template to obtain a response message; if the payment request keyword does not match the keyword template, the response message is generated by initializing the channel message template; and the response message is also sent to the payment system;

[0025] The core MOCK service module is used to respond to the accounting request issued by the payment system, perform core accounting according to the response message, and simulate the accounting results.

[0026] As a preferred technical solution of the present invention, in the core MOCK service module, if the accounting result is successful, the core accounting is performed directly; if the accounting result is failed and there is a compensation mechanism, a supplementary accounting operation is performed, otherwise it is treated as a deduction failure; if the accounting result is a timeout, a verification operation is triggered.

[0027] As a preferred technical solution of the present invention, the message template is an initialization channel message template named after the channel name and the channel transaction type, and the keyword template includes corresponding request keywords and response keywords.

[0028] As a preferred technical solution of the present invention, the channel MOCK service module is provided with a dynamic MOCK interface, and the dynamic MOCK interface is used to dynamically modify the keyword assignment in the keyword template in real time to obtain the expected result.

[0029] As a preferred technical solution of the present invention, the payment system pre-uploads the payment public key to the channel MOCK service module, and the channel MOCK service module pre-uploads the channel public key to the payment system;

[0030] When initiating a channel request, the payment system uses the payment private key to encrypt the payment request message and sends it to the channel MOCK service module;

[0031] When processing the channel request issued by the payment system, the channel MOCK service module decrypts the payment request message through the payment public key to obtain the channel request content;

[0032] After generating a response message, the channel MOCK service module encrypts the response message using the channel private key and then sends it back to the payment system;

[0033] When receiving the response message, the payment system decrypts the response message using the channel public key to obtain the response message content.

[0034] A payment channel automatic testing device based on JS MOCK includes: a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor implements the above method when executing the computer program.

[0035] In summary, the present invention has the following beneficial effects: it can achieve comprehensive test case coverage, ensure that each code change can be strictly verified, improve test efficiency, and quickly respond to version iteration. It has higher flexibility and scalability, can adapt to customized scheduling methods and internal RPC frameworks, and when some non-standard capabilities are required, external tools are often difficult to quickly meet actual needs, and may not even provide the required functions. The design scheme adopted by the present invention has strong scalability and readability, that is, the background configuration is convenient, the request keywords and the response keywords correspond to each other to facilitate reading configuration, and are integrated with the core MOCK service module. When the simulation accounting is abnormal, the verification callback is triggered to form a business logic closed loop, which can flexibly respond to various abnormal and non-standard scenarios; it solves the various risk problems caused by the difficulty of simulating the channel environment and high dependence, and solves the barriers to automation of the payment channel. It can not only support the research and development, joint debugging, and testing of the entire project activities, but also can adapt to the high-efficiency and fast-paced version iteration cycle by improving the coverage of automated use cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 is a flow chart of the system operation of the present invention;

[0037] Figure 2 is an interactive schematic diagram of a channel template of the present invention;

[0038] Figure 3 It is a schematic diagram of key interaction of the present invention. DETAILED DESCRIPTION

[0039] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0040] like Figure 1 As shown, the present invention provides a payment channel automated testing method and system based on JS MOCK, the system includes a configuration management module, a test end tool, a channel MOCK service module, and a core MOCK service module, wherein the method includes the following steps:

[0041] S1. Through the configuration management module, a channel template is configured for the payment channel. The channel template includes a message template and a keyword template. The message template is an initialization channel message template named after the channel name and the channel transaction type. The keyword template includes corresponding standardized request keywords and response keywords.

[0042] The role of keyword templates is to set the corresponding request and response standard templates according to the actual situation, find the corresponding response according to the request, and quickly respond to the corresponding request. Configure the request keyword and the response keyword in json-schema mode, and the two appear in pairs, so as to control multiple expected results to run in the expected way after matching.

[0043] The function of the message template is to restructure the response message according to the response keyword to obtain the response message of the required format, which is the initialization data structure returned by the channel to the payment system. Specifically, the message templates are request message templates and response message templates. When the payment system initiates a request, it is assembled into a standard message that can be parsed by the channel according to the request message template; after the channel accepts the request, it feeds back the response message of the payment channel, and the payment system parses the response message template into a standard response template that can be parsed by the payment system.

[0044] The configuration management module provides standardized configuration templates to get rid of the dependence on specific message formats. To achieve configuration, you only need to arrange the main parameters that affect the business into a JSON data structure, which is divided into request keywords and response keywords. It can support the arrangement of multiple business scenarios with a high degree of freedom. After configuration, it can be used all the time. The design mode of separating the actual message transmission process from the configuration template helps to reduce maintenance costs and makes testing more convenient and efficient.

[0045] S2. Run automated test cases through the test end tool, assemble payment request messages, call the payment system, and initiate channel requests;

[0046] S3. Through the channel MOCK service module, after the signature verification is passed, respond to the channel request, parse the payment request message, and obtain the channel name, channel transaction type and payment request keywords in a static or dynamic manner;

[0047] S4, such as Figure 2 As shown, the channel template is matched according to the channel name and channel transaction type;

[0048] If the payment request keyword matches the corresponding keyword template, the corresponding response keyword is obtained, and the response keyword is reconstructed through the corresponding message template to obtain a response message;

[0049] If the payment request keyword does not match the keyword template, it returns to generate a response message through the initialization channel message template;

[0050] That is, the parameters in the unique request keyword under the keyword template list are matched according to the parameters of the payment request keyword, and the corresponding response keyword parameters are obtained, and then the response message in the expected format is generated using the message template.

[0051] The advantage of pre-configured channel templates is that you only need to configure an initialization channel response template, and then use important parameters as keywords to obtain the expected response in an easy-to-maintain data structure such as JSON, eliminating the need to repeatedly configure the expected message steps of the original channel, thereby speeding up the overall testing efficiency.

[0052] In addition to statically configuring keyword templates in advance, you can also change the response keywords by calling the dynamic MOCK interface to dynamically assign keywords. This is mainly suitable for scenarios where request keywords are variable, making MOCK more flexible and easy to access automation.

[0053] S5. Send the response message to the payment system, respond to the accounting request issued by the payment system through the core MOCK service module, perform core accounting according to the response message, and simulate the accounting results.

[0054] In the core MOCK service module, if the accounting result is successful, the core accounting will be performed directly; if the accounting result is failed and there is a compensation mechanism, the supplementary accounting operation will be performed, otherwise it will be treated as a deduction failure; if the accounting result is a timeout, the verification operation will be triggered.

[0055] The core MOCK is integrated, which can trigger verification callbacks when simulating accounting exceptions, forming a closed loop of business logic. It can flexibly respond to various exceptions and non-standard scenarios, helping testers to efficiently complete the output of automated use cases and improve the coverage of automated use cases.

[0056] As an embodiment of the present invention, Figure 3 As shown, the payment system pre-uploads the payment public key to the channel MOCK service module, and the channel MOCK service module pre-uploads the channel public key to the payment system;

[0057] When initiating a channel request, the payment system uses the payment private key to request the signature parameter, encrypts the payment request message, and sends it to the channel MOCK service module;

[0058] When processing the channel request sent by the payment system, the channel MOCK service module verifies and decrypts the payment request message through the payment public key, obtains the channel request content, and processes the specific request content;

[0059] After generating the response message, the channel MOCK service module uses the channel private key to sign and encrypt the response message before sending it back to the payment system;

[0060] When receiving the response message, the payment system verifies the signature and decrypts the response message using the channel public key to obtain the content of the response message.

[0061] There are two pairs of keys in total, one pair is generated by the payment system, and the other pair is generated by the channel MOCK service module. Through key interaction structuring, when the certificate is generated, signing and verification can be completed through simple configuration.

[0062] The above scheme realizes the structured key interaction. During the message transmission process, it needs to be encrypted first and then signed. After the message is returned, it needs to be signed first and then decrypted. With the help of the method in the channel demo, the certificate can be directly generated, and then the structured and fast complete certificate adaptation is performed, that is, the channel party provides the payment system with an encryption interface and encryption algorithm to solve the signing and verification functions of multiple channels during the message transmission process; through the key interaction structured and fast complete certificate adaptation, the key interaction is completed through simple configuration after the certificate is generated, the ease of use of MOCK is enhanced, the signing and verification functions of multiple channels during the message transmission process are solved, and recognizable data results are returned to complete the self-test of each use case scenario.

[0063] As an embodiment of the present invention, the channel MOCK service module is provided with a dynamic MOCK interface, which not only supports changing the response keyword by presetting the keyword in the configuration template in advance, but also facilitates changing the response keyword by passing the API parameter when the automated use case is output. The dynamic MOCK interface is used to dynamically modify the keyword assignment in the keyword template in real time to obtain the expected result. Encapsulating the dynamic MOCK interface makes it easier to dynamically change the response keyword by passing the API parameter when the automated use case is output, which is suitable for scenarios where the request keyword is variable, making MOCK more flexible and easy to access automation.

[0064] As an embodiment of the present invention, the process of parsing and matching the actual payment request message and obtaining the response message is as follows:

[0065] First, obtain the channel name, channel transaction type and actual payment request message, and match the unique message template and keyword template;

[0066] The code of the payment request message is:

[0067] <?xml version=“1.0 ”encoding=“GB2312” standalone=“yes”?>

[0068] <tx>

[0069] <REQUEST_SN> 1220240523124819< / REQUEST_SN>

[0070] <CUST_ID> GD44000009345479301< / CUST_ID>

[0071] <USER_ID> WLPT01< / USER_ID>

[0072] <password> smb123456< / password>

[0073] <TX_CODE> 6W1303< / TX_CODE>

[0074] <language> CN< / language>

[0075] <TX_INFO>

[0076] <ACC_NO1> 44050164004509200009< / ACC_NO1>

[0077] <BILL_CODE> 4402690550< / BILL_CODE>

[0078] <ACC_NO2> 6217001370040728888< / ACC_NO2>

[0079] <OTHER_NAME> CCB Test Card< / OTHER_NAME>

[0080] <amount> 0.66< / amount>

[0081] <USEOF_CODE> 00001105< / USEOF_CODE>

[0082] < / TX_INFO>

[0083] < / tx>

[0084] Secondly, match the unique REQ (request) parameter under the keyword template LIST according to the request parameter, and obtain the REP (response) parameter:

[0085] The code of the keyword template is:

[0086] "gdccbprotpay":{

[0087] "TX_CODE": "6W1303",

[0088] "REQ_REP":[

[0089] {

[0090] "REQ": {

[0091] "AMOUNT": "0.66"

[0092] },

[0093] "REP":{

[0094] "RETURN_CODE":"YBLA0341146",

[0095] "ETURN_MSG":"Customer not signed"

[0096] }

[0097] },

[0098] {

[0099] "REQ": {

[0100] "AMOUNT": "0.66"

[0101] },

[0102] "REP":{

[0103] "RETURN_CODE":"0130Z0100001",

[0104] "ETURN_MSG": "System busy, communication timed out"

[0105] }

[0106] } ]

[0108] }

[0109] Next, after obtaining the REP parameters, the channel message template is reconstructed to return the expected response.

[0110] The code of the response message is as follows:

[0111] <?xml version=“1.0” encoding=“GB2312” standalone=“yes” ?>

[0112] <tx>

[0113] <REQUEST_SN>1220240523124819< / REQUEST_SN>

[0114] <CUST_ID>GD44000009345479301< / CUST_ID>

[0115] <TX_CODE>6W1303< / TX_CODE>

[0116] <RETURN_CODE>YBLA0341146< / RETURN_CODE>

[0117] <RETURN_MSG>Customer not signed< / RETURN_MSG>

[0118] <language> CN< / language>

[0119] <TX_INFO>

[0120] <CREDIT_NO>280250671963< / CREDIT_NO>

[0121] <INDIVIDUAL_NAME1>< / INDIVIDUAL_NAME1>

[0122] <individual1>< / individual1>

[0123] <INDIVIDUAL_NAME2>< / INDIVIDUAL_NAME2>

[0124] <individual2>< / individual2>

[0125] <rem1>< / rem1>

[0126] <rem2>< / rem2>

[0127] < / TX_INFO>

[0128] < / tx>

[0129] Finally, the response result will be obtained and sent to the core accounting processing.

[0130] Corresponding to the above method and system, the present invention also provides a payment channel automatic testing device based on JS MOCK, including: a processor and a memory, the memory stores a computer program executable by the processor, and the processor implements the above S1-S5 methods when executing the computer program.

[0131] The advantage of the present invention is that the parsing and judgment process of the channel configuration template mainly matches the parameters in the actual request (JSON or XML format) with the request and response keywords in the configuration keyword template, and then obtains the configuration result through the matching result, and finally returns the desired data of the configuration and combines it with different formats and returns it to the caller.

[0132] It can achieve comprehensive test case coverage, ensure that each code change can be strictly verified, improve test efficiency, and quickly respond to version iterations. It has higher flexibility and scalability, and can adapt to customized scheduling methods and internal RPC frameworks. When some non-standard capabilities are required, external tools are often difficult to quickly meet actual needs, and may not even be able to provide the required functions. The design scheme adopted by the present invention has strong scalability and readability, that is, the background configuration is convenient, the request keywords and the response keywords correspond to each other to facilitate the reading of configuration, and are integrated with the core MOCK service module. When the simulated accounting is abnormal, the verification callback is triggered to form a business logic closed loop, which can flexibly respond to various abnormal and non-standard scenarios.

[0133] It can also reduce the cost of joint debugging. The payment system provides payment settlement services in economic activities and often cooperates with multiple parties for joint debugging. In order to reduce the burden of joint debugging for testers, the solution of the present invention can be extended to provide a simple and easy-to-use operation interface, introduce intelligent auxiliary functions such as mature components, and help testers respond quickly. The method of the present invention has higher testing efficiency, more comprehensive coverage of use case scenarios, significantly reduced external risks, and ensures the smooth change of background services, providing more reliable quality assurance for the development team.

[0134] The solution of the present invention solves the various risk problems caused by the difficulty in simulating the channel environment and high dependence, and solves the barriers that make it difficult to automate the payment channel. It can not only support the entire project activities of R&D, joint debugging, and testing, but also adapt to the high-efficiency and fast-paced version iteration cycle by improving the coverage of automated use cases.

[0135] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A payment channel automated testing method based on JS MOCK, characterized by: The steps include: S1. Configure a channel template for the payment channel, wherein the channel template includes a message template and a keyword template, wherein the message template is an initialization channel message template named after the channel name and the channel transaction type, and the keyword template includes corresponding request keywords and response keywords; S2. Run automated test cases, assemble payment request messages, call the payment system, and initiate channel requests; S3. In response to the channel request, parse the payment request message to obtain the channel name, channel transaction type and payment request keyword; S4. Match the channel template according to the channel name and channel transaction type; If the payment request keyword matches the corresponding keyword template, the corresponding response keyword is obtained, and the response keyword is reconstructed through the corresponding message template to obtain a response message; If the payment request keyword does not match the keyword template, a response message generated by the initialization channel message template is returned; S5. Send a response message to the payment system, and respond to the accounting request issued by the payment system, perform core accounting according to the response message, and simulate the accounting result. If the accounting result is successful, perform core accounting directly; if the accounting result is failed and there is a compensation mechanism, perform supplementary accounting operation, otherwise it will be treated as a failed deduction; if the accounting result is a timeout, trigger a verification operation.

2. The payment channel automated testing method based on JS MOCK according to claim 1 is characterized in that: In S2, when the payment system initiates a channel request, the payment request message is encrypted; In S3, before parsing the payment request message, the payment request message is decrypted; In S4, after the response message is generated, the response message is encrypted; In S5, when the payment system receives the response message, it decrypts the response message.

3. A payment channel automated testing system based on JS MOCK, characterized by: include: A configuration management module, used to configure a channel template for a payment channel, wherein the channel template includes a message template and a keyword template, wherein the message template is an initialization channel message template named after the channel name and the channel transaction type, and the keyword template includes a corresponding request keyword and a response keyword; Test-side tools are used to run automated test cases, assemble payment request messages, call the payment system, and initiate channel requests; Channel MOCK service module, used to respond to channel requests, parse payment request messages, obtain channel names, channel transaction types, and payment request keywords; Match the channel template according to the channel name and channel transaction type; If the payment request keyword matches the corresponding keyword template, the corresponding response keyword is obtained, and the response keyword is reconstructed through the corresponding message template to obtain a response message; If the payment request keyword does not match the keyword template, it returns to generate a response message through the initialization channel message template; It is also used to send the response message to the payment system; The core MOCK service module is used to respond to the accounting request issued by the payment system, perform core accounting according to the response message, and simulate the accounting result. If the accounting result is successful, the core accounting is performed directly; if the accounting result is failed and there is a compensation mechanism, the supplementary accounting operation is performed, otherwise it is treated as a deduction failure; if the accounting result is a timeout, the verification operation is triggered.

4. A payment channel automatic testing system based on JS MOCK according to claim 3, characterized in that: The channel MOCK service module is provided with a dynamic MOCK interface, and the dynamic MOCK interface is used to dynamically modify the keyword assignment in the keyword template in real time to obtain the expected result.

5. A payment channel automatic testing system based on JS MOCK according to claim 4, characterized in that: The payment system pre-uploads the payment public key to the channel MOCK service module, and the channel MOCK service module pre-uploads the channel public key to the payment system; When initiating a channel request, the payment system uses the payment private key to encrypt the payment request message and sends it to the channel MOCK service module; When processing the channel request issued by the payment system, the channel MOCK service module decrypts the payment request message through the payment public key to obtain the channel request content; After generating the response message, the channel MOCK service module encrypts the response message using the channel private key and then sends it back to the payment system; When receiving the response message, the payment system decrypts the response message using the channel public key to obtain the response message content.

6. A payment channel automatic testing device based on JS MOCK, characterized by: include: A processor and a memory, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the method according to any one of claims 1 to 2 is implemented.

Citation Information

Patent Citations

  • Transaction access joint debugging test method and device, equipment and storage medium

    CN117370207A

  • Payment system test method and device, electronic equipment and readable storage medium

    CN117493156A