A payment QR code management method and system
By using WebSocket and Redis cache technology, short links are generated and signatures are verified to establish persistent connections, solving the problem of QR codes being too dense or too scattered, and improving the user experience and security of the payment system.
Patent Information
- Application Number
- CN202410537885.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-04-30
AI Technical Summary
In the existing payment system, QR codes are too dense or too scattered, resulting in poor user experience, network delays and misoperations leading to unnecessary payments, and untimely payment status inquiries, affecting user security and system performance.
It uses the WebSocket protocol and Redis cache technology to generate a random string as a short link identifier, store the third-party payment address and system order number, use the WebSocket handshake to verify the signature consistency, establish a persistent connection, and provide timely feedback on the payment status.
It effectively solves the problem of QR codes being too dense or too scattered, improves the user experience of scanning and paying, enhances the security and timeliness of payments, and reduces server load.
Smart Images

Figure CN118313833B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer communication technology, and in particular to a payment QR code management method and system. Background Art
[0002] In the current technological landscape, aggregated payment systems need to connect to various third-party payment channels and utilize their payment interfaces to generate payment QR code addresses for users. However, due to network delays or misoperation, users may repeatedly scan and pay, resulting in unnecessary payments. Furthermore, the lengths of payment addresses generated by different payment channels vary, which can result in QR codes that are too dense or too scattered, impacting the user experience. Furthermore, users may not receive payment results promptly during the payment process, lacking immediate payment feedback and creating a sense of insecurity. In the past, QR code pages typically used polling to query payment status, but this approach increased server load, reduced system performance, and delayed payment status queries, impacting the user experience. Therefore, a new solution is needed to address these issues and enhance both the user payment experience and system reliability.
[0003] WebSocket is a communication protocol that establishes a persistent connection between a web browser and a server, enabling real-time data transmission. Summary of the Invention
[0004] To overcome the above problems, the purpose of the present invention is to provide a method for managing payment QR codes, which effectively solves the problem of QR codes being too dense or too scattered, and improves the user experience of scanning and paying.
[0005] The present invention is implemented by the following scheme: a payment QR code management method, the management method comprising the following steps:
[0006] Step 1: The user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address. A random string greater than 5 characters is generated as a short link identifier code. The code is used as the key, and the third-party payment address and system order number are stored as values in the Redis cache. The payment QR code address of the user system is then returned.
[0007] Step 2: The user accesses the payment QR code address and uses the code as the key to read the Redis cache to query the system order number. If the code does not exist, a failure is returned. If the code does exist, the signature of the websocket handshake address is organized, the signature key is combined with the order number and MD5 encrypted, and the websocket handshake address of the payment QR code address page is returned.
[0008] Step 3. The payment QR code address page displays the QR code image of the short address and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier;
[0009] Step 4: The user scans the QR code image to access the short address. The payment system uses the code as the key to read the Redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation;
[0010] Step 5: The payment system receives the payment notification from the third-party payment system, obtains the websocket link with the system order number as the key from the websocket link pool, sends a payment message to the payment QR code address page, and removes this websocket link from the link pool.
[0011] Furthermore, the third-party payment address and system order number in step 1 are stored as values in the redis cache, and the expiration time of the key-value pair stored in the redis cache is set.
[0012] Furthermore, in step 3, a global variable websocket link pool is pre-set, and the websocket link pool is used to store all handshake-passed WebSocket links.
[0013] The present invention also provides a payment QR code management system, which includes: a redis cache storage module, a websocket handshake address encryption module, a websocket handshake verification module, a payment module, and a websocket link processing module;
[0014] The Redis cache storage module, the user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address, generates a random string greater than 5 as a short link identification code, uses the code as the key, and stores the third-party payment address and system order number as values in the Redis cache, and returns the payment QR code address of the user system;
[0015] The websocket handshake address encryption module, when the user accesses the payment QR code address, uses code as the key to read the redis cache query system order number. If it does not exist, it returns failure. If it does exist, it organizes the signature sign of the websocket handshake address to be the order number and the signature key for MD5 encryption, and returns the websocket handshake address of the payment QR code address page;
[0016] The websocket handshake verification module displays a QR code image of the short address on the payment QR code address page, and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature sign. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier;
[0017] In the payment module, when the user scans the QR code image to access the short address, the payment system uses the code as the key to read the redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation;
[0018] The websocket link processing module receives a payment notification from a third-party payment system in the payment system, obtains a websocket link with the system order number as the key from the websocket link pool, sends a paid message to the payment QR code address page, and removes this websocket link from the link pool.
[0019] Furthermore, the third-party payment address and the system order number in the redis cache storage module are stored as values in the redis cache, and the expiration time of the key-value pair stored in the redis cache is set.
[0020] Furthermore, a global variable websocket link pool is pre-set in the websocket handshake verification module, and the websocket link pool is used to store all WebSocket links that have passed the handshake.
[0021] The beneficial effects of the present invention are as follows: the present invention uses code as a key, the third-party payment address and the system order number as values to store in the Redis cache, returns the payment QR code address of the user system, combines the signature sign of the user's websocket handshake address with the order number and the signature key for MD5, returns the websocket handshake address of the page, and after a successful handshake, stores the websocket link with the order number as an identifier in the websocket link pool. When the user pays, the present invention matches whether there is a corresponding websocket link in the websocket link pool, thereby effectively solving the problem of overly dense or scattered QR codes and improving the user's scan code payment experience. Furthermore, the present invention can provide timely feedback on the payment status to the user, enhancing the user's payment experience and sense of security. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic flow chart of the method of the present invention.
[0023] Figure 2 It is a schematic diagram of the system framework of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described below with reference to the accompanying drawings.
[0025] See also Figure 1 As shown, a payment QR code management method of the present invention includes the following steps:
[0026] Step 1: The user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address. A random string greater than 5 characters is generated as a short link identifier code. The code is used as the key, and the third-party payment address and system order number are stored as values in the Redis cache. The payment QR code address of the user system is then returned.
[0027] Step 2: The user accesses the payment QR code address and uses the code as the key to read the Redis cache to query the system order number. If the code does not exist, a failure is returned. If the code does exist, the signature of the websocket handshake address is organized, the signature key is combined with the order number and MD5 encrypted, and the websocket handshake address of the payment QR code address page is returned.
[0028] Step 3. The payment QR code address page displays the QR code image of the short address and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier;
[0029] Step 4: The user scans the QR code image to access the short address. The payment system uses the code as the key to read the Redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation;
[0030] Step 5: The payment system receives the payment notification from the third-party payment system, obtains the websocket link with the system order number as the key from the websocket link pool, sends a payment message to the payment QR code address page, and removes this websocket link from the link pool.
[0031] The present invention will be further described below with reference to a specific embodiment:
[0032] A method for managing payment QR codes includes the following steps: Step 1: A user selects a payment channel and clicks the payment button. The payment system generates a system order number (order_no), then requests a third-party payment channel interface to obtain the third-party payment address (pay_url). A random string of 5 characters is generated as a short link identifier (code). This code is used as the key, and the third-party payment address (pay_url) and system order number (order_no) are stored in a Redis cache. An expiration time is set for the key-value pair stored in the Redis cache. The payment QR code address / qrcode / {code} is returned to the user's system.
[0033] For example, after a user selects a payment channel and clicks the pay button, the payment system generates a system order number (order_no=17134454860612552c7dc) and then requests the payment address (pay_url=https: / / pay.xxx.com / pay / xxxxx) from the third-party payment channel interface. The payment system then generates a random string of 5 characters as a short link identifier (code=29f59). This identifier, along with the third-party payment address and the system order number, is stored in a Redis cache as a key-value pair, with an expiration time of 10 minutes. Finally, the system returns the user's payment QR code address ( / qrcode / 29f59).
[0034] Step 2: The user accesses the payment QR code address. The payment system uses the code as the key to read the redis cache to query the system order number order_no. If it does not exist, it returns failure. If it does exist, it organizes the signature sign of the websocket handshake address to be the order number and the signature key for MD5. The real-time communication protocol websocket handshake address = wss: / / my.com / ws / {order_no} / {sign} is returned to the page.
[0035] For example, when a user accesses a payment QR code, the aggregate payment system retrieves the corresponding system order number (order_no = 17134454860612552c7dc) from the Redis cache based on the short address. If the code does not exist, the system returns a message stating "QR code does not exist or has expired." If the code does exist, the system concatenates the order number and the signature key using the MD5 algorithm to create a signature (sign = f561aaf6ef0bf14d4208bb46a4ccb3ad). The system then returns the WebSocket handshake address for the page (wss: / / my.com / ws / 17134454860612552c7dc / f561aaf6ef0bf14d4208bb46a4ccb3ad).
[0036] Step 3. The payment QR code address page displays a QR code image with the short address / surl / {code} and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature sign. If they are inconsistent, the handshake failure is returned. If they are consistent, the current websocket link is stored in the websocket link pool with the order number order_no as the identifier.
[0037] For example, the payment QR code page with the address / qrcode / 29f59 will display the corresponding QR code image with the short address / surl / 29f59. A handshake is initiated with the system using the WebSocket handshake address wss: / / my.com / ws / 17134454860612552c7dc / f561aaf6ef0bf14d4208bb46a4ccb3ad. Upon receiving the handshake request, the system verifies the signature (sign=f561aaf6ef0bf14d4208bb46a4ccb3ad). If the signatures do not match, the handshake fails. If they do match, the current WebSocket connection is stored in the WebSocket connection pool with the order number 17134454860612552c7dc as its identifier. The system also creates a global variable dictionary to store all successful WebSocket connections.
[0038] Step 4: The user scans the QR code image to access the short address / surl / {code}. The system uses code as the key to read the Redis cache to obtain the third-party payment address pay_url, jumps to the third-party payment address, and the user performs the payment operation.
[0039] For example, after a user scans a QR code image and accesses the corresponding short URL / surl / 29f59, the payment system retrieves the third-party payment URL pay_url = https: / / pay.xxx.com / pay / xxxxx from the Redis cache based on the code = 29f59 in the short URL, and redirects the user to the third-party payment page for payment.
[0040] Step 5: After receiving the payment notification from the third-party payment system, the system retrieves a websocket link from the websocket link pool, using the order number (order_no) as the key. It then sends a payment completion message to the payment QR code page and removes the websocket link from the link pool. The payment QR code page then removes the displayed QR code and displays a "Recharge Successful" message.
[0041] For example, when the system receives a payment notification from a third-party payment system, it retrieves a WebSocket link from the WebSocket connection pool with the order number 17134454860612552c7dc as the key. The system then sends a paid message (data={status:1}) to the payment QR code page and removes the WebSocket link from the connection pool. The payment QR code page ( / qrcode / 29f59) removes the displayed QR code and displays "Top-up Successful."
[0042] See also Figure 2 As shown, the present invention also provides a payment QR code management system, which includes: a redis cache storage module, a websocket handshake address encryption module, a websocket handshake verification module, a payment module, and a websocket link processing module;
[0043] The Redis cache storage module, the user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address, generates a random string greater than 5 as a short link identification code, uses the code as the key, and stores the third-party payment address and system order number as values in the Redis cache, and returns the payment QR code address of the user system;
[0044] The websocket handshake address encryption module, when the user accesses the payment QR code address, uses code as the key to read the redis cache query system order number. If it does not exist, it returns failure. If it does exist, it organizes the signature sign of the websocket handshake address to be the order number and the signature key for MD5 encryption, and returns the websocket handshake address of the payment QR code address page;
[0045] The websocket handshake verification module displays a QR code image of the short address on the payment QR code address page, and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature sign. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier;
[0046] In the payment module, when the user scans the QR code image to access the short address, the payment system uses the code as the key to read the redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation;
[0047] The websocket link processing module receives a payment notification from a third-party payment system in the payment system, obtains a websocket link with the system order number as the key from the websocket link pool, sends a paid message to the payment QR code address page, and removes this websocket link from the link pool.
[0048] The third-party payment address and system order number in the redis cache storage module are stored as values in the redis cache, and the expiration time of the key-value pair stored in the redis cache is set.
[0049] A global variable websocket link pool is pre-set in the websocket handshake verification module, and the websocket link pool is used to store all WebSocket links that have passed the handshake.
[0050] In summary, the present invention uses the code as the key, the third-party payment address and the system order number as the value to store them in the redis cache, returns the payment QR code address of the user system, and uses the signature sign of the user organization websocket handshake address as the order number to splice the signature key for MD5, and returns the page websocket handshake address. After the handshake is successful, the websocket link is stored in the websocket link pool with the order number as the identifier. When the user pays, it matches whether there is a corresponding websocket link in the websocket link pool. This not only improves payment security, but also improves the payment experience.
[0051] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for managing payment QR codes, characterized by: The management method comprises the following steps: Step 1: The user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address. A random string greater than 5 characters is generated as a short link identifier code. The code is used as the key, and the third-party payment address and system order number are stored as values in the Redis cache. The payment QR code address of the user system is then returned. Step 2: The user accesses the payment QR code address and uses the code as the key to read the Redis cache to query the system order number. If the code does not exist, a failure is returned. If the code does exist, the signature of the websocket handshake address is organized, the signature key is combined with the order number and MD5 encrypted, and the websocket handshake address of the payment QR code address page is returned. Step 3. The payment QR code address page displays the QR code image of the short address and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier; Step 4: The user scans the QR code image to access the short address. The payment system uses the code as the key to read the Redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation; Step 5: The payment system receives the payment notification from the third-party payment system, obtains the websocket link with the system order number as the key from the websocket link pool, sends a payment message to the payment QR code address page, and removes this websocket link from the link pool.
2. A payment QR code management method according to claim 1, characterized in that: In step 1, the third-party payment address and the system order number are stored as values in the redis cache, and the expiration time of the key-value pair stored in the redis cache is set.
3. A payment QR code management method according to claim 1, characterized in that: In step 3, a global variable websocket link pool is pre-set, and the websocket link pool is used to store all handshake-passed WebSocket links.
4. A payment QR code management system, characterized by: The management system includes: a redis cache storage module, a websocket handshake address encryption module, a websocket handshake verification module, a payment module, and a websocket link processing module; The Redis cache storage module, the user selects a payment channel and clicks the payment button. The payment system generates a system order number, then requests the third-party payment channel interface to obtain the third-party payment address, generates a random string greater than 5 as a short link identification code, uses the code as the key, and stores the third-party payment address and system order number as values in the Redis cache, and returns the payment QR code address of the user system; The websocket handshake address encryption module, when the user accesses the payment QR code address, uses code as the key to read the redis cache query system order number. If it does not exist, it returns failure. If it does exist, it organizes the signature sign of the websocket handshake address to be the order number and the signature key for MD5 encryption, and returns the websocket handshake address of the payment QR code address page; The websocket handshake verification module displays a QR code image of the short address on the payment QR code address page, and performs a handshake with the payment system through the websocket handshake address. After receiving the handshake request, the payment system verifies the consistency of the signature sign. If they are inconsistent, the handshake failure is returned. If they are consistent, the websocket link generated after the handshake is successful is stored in the websocket link pool with the system order number as the identifier; In the payment module, when the user scans the QR code image to access the short address, the payment system uses the code as the key to read the redis cache to obtain the third-party payment address, jumps to the third-party payment address, and the user performs the payment operation; The websocket link processing module receives a payment notification from a third-party payment system in the payment system, obtains a websocket link with the system order number as the key from the websocket link pool, sends a paid message to the payment QR code address page, and removes this websocket link from the link pool.
5. A payment QR code management system according to claim 4, characterized in that: The third-party payment address and system order number in the redis cache storage module are stored as values in the redis cache, and the expiration time of the key-value pair stored in the redis cache is set.
6. A payment QR code management system according to claim 4, characterized in that: A global variable websocket link pool is pre-set in the websocket handshake verification module, and the websocket link pool is used to store all WebSocket links that have passed the handshake.
Citation Information
Patent Citations
Financial receipt and payment method with two-dimension code being used as carrier
CN103679440A
Assisted third-party password authentication
US20210385217A1